diff --git a/openbb_terminal/cryptocurrency/onchain/onchain_controller.py b/openbb_terminal/cryptocurrency/onchain/onchain_controller.py index 158333c2edfd..4df778870809 100644 --- a/openbb_terminal/cryptocurrency/onchain/onchain_controller.py +++ b/openbb_terminal/cryptocurrency/onchain/onchain_controller.py @@ -91,6 +91,7 @@ class OnchainController(BaseController): ] PATH = "/crypto/onchain/" + CHOICES_GENERATION = True def __init__(self, queue: List[str] = None): """Constructor""" @@ -275,9 +276,12 @@ def __init__(self, queue: List[str] = None): "--address": None, } choices["info"]["--social"] = {} + choices: dict = self.choices_default - choices["support"] = self.SUPPORT_CHOICES - choices["about"] = self.ABOUT_CHOICES + choices["hr"].update({c: {} for c in GLASSNODE_SUPPORTED_HASHRATE_ASSETS}) + choices["ds"].update( + {c: None for c in shroom_model.DAPP_STATS_PLATFORM_CHOICES} + ) self.completer = NestedCompleter.from_nested_dict(choices) @@ -798,16 +802,17 @@ def call_balance(self, other_args: List[str]): ns_parser = self.parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_address_info( - limit=ns_parser.limit, - sortby=ns_parser.sortby, - ascend=ns_parser.reverse, - address=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_address_info( + limit=ns_parser.limit, + sortby=ns_parser.sortby, + ascend=ns_parser.reverse, + address=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_hist(self, other_args: List[str]): @@ -854,16 +859,17 @@ def call_hist(self, other_args: List[str]): ns_parser = self.parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_address_history( - limit=ns_parser.limit, - sortby=ns_parser.sortby, - ascend=ns_parser.reverse, - address=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_address_history( + limit=ns_parser.limit, + sortby=ns_parser.sortby, + ascend=ns_parser.reverse, + address=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_holders(self, other_args: List[str]): @@ -909,16 +915,17 @@ def call_holders(self, other_args: List[str]): ns_parser = self.parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_top_token_holders( - limit=ns_parser.limit, - sortby=ns_parser.sortby, - ascend=ns_parser.reverse, - address=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_top_token_holders( + limit=ns_parser.limit, + sortby=ns_parser.sortby, + ascend=ns_parser.reverse, + address=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_top(self, other_args: List[str]): @@ -998,14 +1005,15 @@ def call_info(self, other_args: List[str]): parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_token_info( - social=ns_parser.social, - address=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_token_info( + social=ns_parser.social, + address=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_th(self, other_args: List[str]): @@ -1060,17 +1068,18 @@ def call_th(self, other_args: List[str]): parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_token_history( - limit=ns_parser.limit, - hash_=ns_parser.hash, - sortby=ns_parser.sortby, - ascend=ns_parser.reverse, - address=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_token_history( + limit=ns_parser.limit, + hash_=ns_parser.hash, + sortby=ns_parser.sortby, + ascend=ns_parser.reverse, + address=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_tx(self, other_args: List[str]): @@ -1090,13 +1099,14 @@ def call_tx(self, other_args: List[str]): parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_tx_info( - tx_hash=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_tx_info( + tx_hash=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_prices(self, other_args: List[str]): @@ -1142,16 +1152,17 @@ def call_prices(self, other_args: List[str]): ns_parser = self.parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) - if ns_parser and self.address: - ethplorer_view.display_token_historical_prices( - limit=ns_parser.limit, - sortby=ns_parser.sortby, - ascend=ns_parser.reverse, - address=self.address, - export=ns_parser.export, - ) - else: - console.print("You need to set an ethereum address\n") + if ns_parser: + if self.address: + ethplorer_view.display_token_historical_prices( + limit=ns_parser.limit, + sortby=ns_parser.sortby, + ascend=ns_parser.reverse, + address=self.address, + export=ns_parser.export, + ) + else: + console.print("You need to set an ethereum address\n") @log_start_end(log=logger) def call_lt(self, other_args: List[str]): @@ -1198,6 +1209,8 @@ def call_lt(self, other_args: List[str]): type=check_positive, help="Number of days to display data for.", default=90, + choices=range(1, 360), + metavar="DAYS", ) parser.add_argument( "-s", @@ -1255,7 +1268,13 @@ def call_dvcp(self, other_args: List[str]): required="-h" not in other_args, ) parser.add_argument( - "-vs", "--vs", dest="vs", type=str, help="Quote currency", default="USDT" + "-vs", + "--vs", + dest="vs", + type=str, + help="Quote currency", + default="USDT", + choices=bitquery_model.CURRENCIES, ) parser.add_argument( "-d", @@ -1264,6 +1283,8 @@ def call_dvcp(self, other_args: List[str]): type=check_positive, help="Number of days to display data for.", default=10, + choices=range(1, 100), + metavar="DAYS", ) parser.add_argument( "-s", @@ -1400,6 +1421,8 @@ def call_ueat(self, other_args: List[str]): "For interval: month, and number: 10, period of calculation equals to 300, " "but because of max days limit: 90, it will only return last 3 months (3 records). ", default=10, + choices=range(1, 90), + metavar="LIMIT", ) parser.add_argument( "-s", @@ -1433,7 +1456,9 @@ def call_ueat(self, other_args: List[str]): ), ) ns_parser = self.parse_known_args_and_warn( - parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED + parser, + other_args, + EXPORT_ONLY_RAW_DATA_ALLOWED, ) if ns_parser: @@ -1480,6 +1505,8 @@ def call_ttcp(self, other_args: List[str]): type=check_positive, help="Number of days to display data for.", default=30, + choices=range(1, 100), + metavar="DAYS", ) parser.add_argument( "-s", @@ -1571,9 +1598,17 @@ def call_baas(self, other_args: List[str]): dest="coin", type=str, help="ERC20 token symbol or address.", + choices=bitquery_model.POSSIBLE_CRYPTOS, + metavar="COIN", ) parser.add_argument( - "-vs", "--vs", dest="vs", type=str, help="Quote currency", default="USDT" + "-vs", + "--vs", + dest="vs", + type=str, + help="Quote currency", + default="USDT", + choices=bitquery_model.CURRENCIES, ) parser.add_argument( "-l",