Skip to content

Commit

Permalink
works better
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSpuddy committed Nov 14, 2024
1 parent 14c3b9b commit bf81e1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
27 changes: 11 additions & 16 deletions src/disputable_values_monitor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from disputable_values_monitor.utils import format_values
from disputable_values_monitor.utils import get_logger
from disputable_values_monitor.utils import get_tx_explorer_url
from disputable_values_monitor.utils import select_account
from disputable_values_monitor.utils import Topics
from disputable_values_monitor.utils import select_account

warnings.simplefilter("ignore", UserWarning)
price_aggregator_logger = logging.getLogger("telliot_feeds.sources.price_aggregator")
Expand All @@ -38,7 +38,7 @@

def print_title_info() -> None:
"""Prints the title info."""
click.echo("Disputable Values Monitor 📒🔎📲")
click.echo("Disputable Values Monitor Starting... 📒🔎📲")


@click.command()
Expand All @@ -63,7 +63,6 @@ def print_title_info() -> None:
default=0,
)
@click.option("-sc", "skip_confirmations", help="skip confirm configuration (unsafe start)", is_flag=True)

@async_run
async def main(
all_values: bool,
Expand Down Expand Up @@ -107,25 +106,21 @@ async def start(
print_title_info()

if not disp_cfg.monitored_feeds:
logger.error("No feeds set for monitoring, please add feeds to ./disputer-config.yaml")
click.echo("No feeds set for monitoring, please add feeds to ./disputer-config.yaml")
logger.error("No feeds set for monitoring, please check ./disputer-config.yaml")
return

account = None
account: ChainedAccount = select_account(cfg, account_name, password)

if is_disputing and not account:
logger.error("A telliot account is required for auto-disputing (see --help)")
if not account_name and is_disputing:
click.echo("An account is required for auto-disputing (see --help)")
logger.error("auto-disputing enabled, but no account provided (see --help)")
return

if account and is_disputing and not skip_confirmations:
click.echo("DVM started successfully...")

if account and is_disputing and skip_confirmations and not password:
logger.error("Use pwd flag to provide account password if skipping confirmations")
if account_name and not is_disputing:
click.echo("Telliot account provided but not disputing? (see --help)")
logger.error("Telliot account provided, but not disputing? (see --help)")
return

if account and is_disputing and skip_confirmations and password:
click.echo("DVM starting now with auto-disputer...")
account: ChainedAccount = select_account(cfg, account_name, password, skip_confirmations)

display_rows = []
displayed_events = set()
Expand Down
5 changes: 3 additions & 2 deletions src/disputable_values_monitor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ def clear_console() -> None:
_ = os.system("clear")


def select_account(cfg: TelliotConfig, account: Optional[str], password: Optional[str]) -> Optional[ChainedAccount]:
def select_account(cfg: TelliotConfig, account: Optional[str], password: Optional[str], skip_confirmations: Optional[bool]) -> Optional[ChainedAccount]:
"""Select an account for disputing, allow no account to be chosen."""

if account is not None:
accounts = find_accounts(name=account)
click.echo(f"Your account name: {accounts[0].name if accounts else None}")
if skip_confirmations:
return None
else:
run_alerts_only = click.confirm("Missing an account to send disputes. Run alerts only?")
if not run_alerts_only:
Expand Down

0 comments on commit bf81e1a

Please sign in to comment.