47 lines
1.6 KiB
Plaintext
Executable File
47 lines
1.6 KiB
Plaintext
Executable File
#!/usr/bin/env pyston3
|
|
|
|
import argparse
|
|
import logging
|
|
import os
|
|
import os.path
|
|
import sys
|
|
import traceback
|
|
|
|
from solana.publickey import PublicKey
|
|
|
|
sys.path.insert(0, os.path.abspath(
|
|
os.path.join(os.path.dirname(__file__), "..")))
|
|
import mango # nopep8
|
|
|
|
# We explicitly want argument parsing to be outside the main try-except block because some arguments
|
|
# (like --help) will cause an exit, which our except: block traps.
|
|
parser = argparse.ArgumentParser(description="Display the balances of all grop tokens in the current wallet.")
|
|
mango.Context.add_command_line_parameters(parser)
|
|
mango.Wallet.add_command_line_parameters(parser)
|
|
parser.add_argument("--address", type=PublicKey,
|
|
help="Root address to check (if not provided, the wallet address is used)")
|
|
args = parser.parse_args()
|
|
|
|
logging.getLogger().setLevel(args.log_level)
|
|
logging.warning(mango.WARNING_DISCLAIMER_TEXT)
|
|
|
|
try:
|
|
context = mango.Context.from_command_line_parameters(args)
|
|
|
|
address = args.address
|
|
if address is None:
|
|
wallet = mango.Wallet.from_command_line_parameters_or_raise(args)
|
|
address = wallet.address
|
|
|
|
logging.info(f"Context: {context}")
|
|
logging.info(f"Address: {address}")
|
|
|
|
group = mango.Group.load(context)
|
|
balances = group.fetch_balances(context, address)
|
|
print("Balances:")
|
|
mango.TokenValue.report(balances)
|
|
except Exception as exception:
|
|
logging.critical(f"group-balances stopped because of exception: {exception} - {traceback.format_exc()}")
|
|
except:
|
|
logging.critical(f"group-balances stopped because of uncatchable error: {traceback.format_exc()}")
|