#!/usr/bin/env pyston3 import argparse import logging import os import sys sys.path.insert(0, os.path.abspath( os.path.join(os.path.dirname(__file__), '..'))) import mango # nopep8 parser = argparse.ArgumentParser(description="Shows all Wrapped SOL accounts for the wallet.") mango.Context.add_context_command_line_parameters(parser) parser.add_argument("--id-file", type=str, default="id.json", help="file containing the JSON-formatted wallet private key") parser.add_argument("--log-level", default=logging.WARNING, type=lambda level: getattr(logging, level), help="level of verbosity to log (possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL)") parser.add_argument("--overwrite", action="store_true", default=False, help="overwrite the ID file, if it exists (use with care!)") args = parser.parse_args() logging.getLogger().setLevel(args.log_level) logging.warning(mango.WARNING_DISCLAIMER_TEXT) id_filename = args.id_file if not os.path.isfile(id_filename): logging.error(f"Wallet file '{id_filename}' is not present.") sys.exit(1) wallet = mango.Wallet.load(id_filename) context = mango.Context.from_context_command_line_parameters(args) lookups = mango.TokenLookup.default_lookups() wrapped_sol = lookups.find_by_symbol("SOL") token_accounts = mango.TokenAccount.fetch_all_for_owner_and_token(context, wallet.address, wrapped_sol) if len(token_accounts) == 0: print("No wrapped SOL accounts.") else: print(f"{wrapped_sol.name}:") for account in token_accounts: print(f" {account.address}: {account.value}")