Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message to show oracle contract for chainId on start #713

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/telliot_feeds/utils/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from chained_accounts import ChainedAccount
from chained_accounts import find_accounts
from simple_term_menu import TerminalMenu
from telliot_core.apps.core import Tellor360OracleContract
from telliot_core.apps.telliot_config import TelliotConfig
from telliot_core.model.endpoints import RPCEndpoint

Expand Down Expand Up @@ -64,7 +65,8 @@ def setup_config(

"""
)
click.echo(f"Your current settings...\nYour chain id: {cfg.main.chain_id}\n")
click.echo(f"Your current settings...\nYour chain id: {cfg.main.chain_id}")
click.echo(f"Oracle contract address: {check_oracle_address(cfg, account_name)}\n")

if endpoint is not None:
click.echo(
Expand Down Expand Up @@ -150,6 +152,16 @@ def check_accounts(cfg: TelliotConfig, account_name: str) -> List[ChainedAccount
return find_accounts(chain_id=cfg.main.chain_id, name=account_name) # type: ignore


def check_oracle_address(cfg: TelliotConfig, account_name: str) -> Optional[str]:
"""Check oracle contract for the account's chain ID"""

try:
return str(Tellor360OracleContract(node=check_endpoint(cfg), account=account_name).address)
except Exception as e:
logger.warning(f"No oracle contract found on chain id{cfg.main.chain_id}: " + str(e))
return None


def prompt_for_endpoint(chain_id: int) -> Optional[RPCEndpoint]:
"""Take user input to create a new RPCEndpoint"""
rpc_url = click.prompt("Enter RPC URL", type=str)
Expand Down
Loading