Skip to content

Commit

Permalink
Merge pull request #694 from tellor-io/unsafe-mode
Browse files Browse the repository at this point in the history
Add unsafe option to skip confirmation prompts
  • Loading branch information
0xSpuddy authored Jul 27, 2023
2 parents 4246941 + 8d4fd79 commit af8c54e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/telliot_feeds/cli/commands/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ async def report(
gas_multiplier: int,
max_priority_fee_range: int,
ignore_tbr: bool,
unsafe: bool,
) -> None:
"""Report values to Tellor oracle"""
ctx.obj["ACCOUNT_NAME"] = account_str
Expand All @@ -200,7 +201,7 @@ async def report(
# Initialize telliot core app using CLI context
async with reporter_cli_core(ctx) as core:

core._config, account = setup_config(core.config, account_name=account_str)
core._config, account = setup_config(core.config, account_name=account_str, unsafe=unsafe)

endpoint = check_endpoint(core._config)

Expand Down Expand Up @@ -262,7 +263,8 @@ async def report(
min_native_token_balance=min_native_token_balance,
)

_ = input("Press [ENTER] to confirm settings.")
if not unsafe:
_ = input("Press [ENTER] to confirm settings.")

contracts = core.get_tellor360_contracts() if tellor_360 else core.get_tellorflex_contracts()

Expand Down
8 changes: 8 additions & 0 deletions src/telliot_feeds/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ def common_options(f: Callable[..., Any]) -> Callable[..., Any]:
nargs=1,
type=str,
)
@click.option(
"--unsafe/--safe",
"-u/-sf",
"unsafe",
help="Disables config confirmation prompts",
required=False,
default=True,
)
@click.option(
"--query-tag",
"-qt",
Expand Down
14 changes: 11 additions & 3 deletions src/telliot_feeds/utils/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
logger = get_logger(__name__)


def setup_config(cfg: TelliotConfig, account_name: str) -> Tuple[TelliotConfig, Optional[ChainedAccount]]:
def setup_config(
cfg: TelliotConfig, account_name: str, unsafe: bool = False
) -> Tuple[TelliotConfig, Optional[ChainedAccount]]:
"""Setup TelliotConfig via CLI if not already configured
Inputs:
Expand Down Expand Up @@ -50,13 +52,19 @@ def setup_config(cfg: TelliotConfig, account_name: str) -> Tuple[TelliotConfig,
else:
click.echo("No accounts set.")

keep_settings = click.confirm("Proceed with current settings (y) or update (n)?", default=True)
if unsafe:
keep_settings = True
else:
keep_settings = click.confirm("Proceed with current settings (y) or update (n)?", default=True)

if keep_settings:
click.echo("Keeping current settings...")
return cfg, accounts[0] if accounts else None

want_to_update_chain_id = click.confirm(f"Chain_id is {cfg.main.chain_id}. Do you want to update it?")
if unsafe:
want_to_update_chain_id = False
else:
want_to_update_chain_id = click.confirm(f"Chain_id is {cfg.main.chain_id}. Do you want to update it?")

if want_to_update_chain_id: # noqa: F821
new_chain_id = click.prompt("Enter a new chain id", type=int)
Expand Down

0 comments on commit af8c54e

Please sign in to comment.