Add specify info item

This commit is contained in:
lash 2022-02-19 20:41:47 +00:00
parent 8dbab82445
commit 988858e3ae
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -42,6 +42,7 @@ logg = logging.getLogger()
arg_flags = chainlib.eth.cli.argflag_std_read | chainlib.eth.cli.Flag.EXEC arg_flags = chainlib.eth.cli.argflag_std_read | chainlib.eth.cli.Flag.EXEC
argparser = chainlib.eth.cli.ArgumentParser(arg_flags) argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
argparser.add_positional('item', required=False)
args = argparser.parse_args() args = argparser.parse_args()
config = chainlib.eth.cli.Config.from_args(args, arg_flags) config = chainlib.eth.cli.Config.from_args(args, arg_flags)
@ -56,25 +57,53 @@ token_address = config.get('_EXEC_ADDRESS')
def main(): def main():
g = ERC20(chain_spec=chain_spec, gas_oracle=rpc.get_gas_oracle()) g = ERC20(chain_spec=chain_spec, gas_oracle=rpc.get_gas_oracle())
name_o = g.name(token_address) if not args.item or args.item == 'name':
r = conn.do(name_o) name_o = g.name(token_address)
token_name = g.parse_name(r) r = conn.do(name_o)
print('Name: {}'.format(token_name)) token_name = g.parse_name(r)
s = ''
if not args.item or not args.raw:
s = 'Name: '
s += token_name
print(s)
if args.item == 'name':
sys.exit(0)
symbol_o = g.symbol(token_address) if not args.item or args.item == 'symbol':
r = conn.do(symbol_o) symbol_o = g.symbol(token_address)
token_symbol = g.parse_symbol(r) r = conn.do(symbol_o)
print('Symbol: {}'.format(token_symbol)) token_symbol = g.parse_symbol(r)
s = ''
if not args.item or not args.raw:
s = 'Symbol: '
s += token_symbol
print(s)
if args.item == 'symbol':
sys.exit(0)
decimals_o = g.decimals(token_address) if not args.item or args.item == 'decimals':
r = conn.do(decimals_o) decimals_o = g.decimals(token_address)
decimals = int(strip_0x(r), 16) r = conn.do(decimals_o)
print('Decimals: {}'.format(decimals)) decimals = int(strip_0x(r), 16)
s = ''
if not args.item or not args.raw:
s = 'Decimals: '
s += str(decimals)
print(s)
if args.item == 'decimals':
sys.exit(0)
supply_o = g.total_supply(token_address) if not args.item or args.item == 'supply':
r = conn.do(supply_o) supply_o = g.total_supply(token_address)
supply = int(strip_0x(r), 16) r = conn.do(supply_o)
print('Total supply: {}'.format(supply)) supply = int(strip_0x(r), 16)
s = ''
if not args.item or not args.raw:
s = 'Supply: '
s += str(supply)
print(s)
if args.item == 'supply':
sys.exit(0)
if __name__ == '__main__': if __name__ == '__main__':