Skip to content

Commit

Permalink
Show unbonding and leasing balance. Fixes #49
Browse files Browse the repository at this point in the history
  • Loading branch information
jasny committed Apr 25, 2023
1 parent 940b390 commit 9a8fee2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
10 changes: 6 additions & 4 deletions src/lto_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ def main():
parser_balance.add_argument('--account', type=str, nargs=1, required=False, help="The account can be identified by address or name. In addition, an address of an account not stored locally can also be used")
parser_balance.add_argument('--network', type=str, nargs=1, required=False, help ='Optional network parameter, if not specified default is L')
parser_balance.add_argument('--testnet', '-T', action='store_const', dest='network', const='T', required=False, help='Short for --network=T')
parser_balance.add_argument('--regular', action='store_true', required=False, help="Use this option to show the regular balance")
parser_balance.add_argument('--generating', action='store_true', required=False, help="Use this option to show the generating balance")
parser_balance.add_argument('--available', action='store_true', required=False, help="Use this option to show the available balance")
parser_balance.add_argument('--effective', action='store_true', required=False, help="Use this option to to show the effective balance")
parser_balance.add_argument('--regular', action='append_const', dest='types', const='regular', required=False, help="Use this option to show the regular balance")
parser_balance.add_argument('--available', action='append_const', dest='types', const='available', required=False, help="Use this option to show the available balance")
parser_balance.add_argument('--leasing', action='append_const', dest='types', const='leasing', required=False, help="Use this option to show the available balance")
parser_balance.add_argument('--unbonding', action='append_const', dest='types', const='unbonding', required=False, help="Use this option to show the available balance")
parser_balance.add_argument('--generating', action='append_const', dest='types', const='generating', required=False, help="Use this option to show the generating balance")
parser_balance.add_argument('--effective', action='append_const', dest='types', const='effective', required=False, help="Use this option to to show the effective balance")

# --------------------------------------------------------------
parser_anchor = subparsers.add_parser(name='anchor', help="Create an Anchor Transaction, type 'lto anchor --help' for more information")
Expand Down
31 changes: 14 additions & 17 deletions src/lto_cli/commands/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@


def print_balance(name_space, balances):
if vars(name_space)['regular'] is False and \
vars(name_space)['available'] is False and \
vars(name_space)['generating'] is False and \
vars(name_space)['effective'] is False:
print('Regular: ', balances['regular'] / 100000000,
'\nGenerating: ', balances['generating'] / 100000000,
'\nAvailable: ', balances['available'] / 100000000,
'\nEffective: ', balances['effective']/ 100000000,)
else:
if vars(name_space)['regular'] is True:
print('Regular: ', balances['regular'] / 100000000)
if vars(name_space)['generating'] is True:
print('Generating: ', balances['generating'] / 100000000)
if vars(name_space)['available'] is True:
print('Available: ', balances['available'] / 100000000)
if vars(name_space)['effective'] is True:
print('Effective: ', balances['effective'] / 100000000)
types = vars(name_space)['types']

if types is None or 'regular' in types:
print('Regular: ', balances['regular'] / 100000000)
if types is None or 'available' in types:
print('Available: ', balances['available'] / 100000000)
if types is None or 'leasing' in types:
print('Leasing: ', balances['leasing'] / 100000000)
if types is None or 'unbonding' in types:
print('Unbonding: ', balances['unbonding'] / 100000000)
if types is None or 'effective' in types:
print('Effective: ', balances['effective'] / 100000000)
if types is None or 'generating' in types:
print('Generating:', balances['generating'] / 100000000)


def validate_address(address, node):
Expand Down

0 comments on commit 9a8fee2

Please sign in to comment.