mango-explorer/bin/transaction-scout

44 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import logging
import os
import os.path
import sys
import traceback
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="Run the Transaction Scout to display information about a specific transaction."
)
mango.ContextBuilder.add_command_line_parameters(parser)
parser.add_argument(
"--signature",
type=str,
required=True,
help="The signature of the transaction to look up",
)
args: argparse.Namespace = mango.parse_args(parser)
try:
signature = args.signature
context = mango.ContextBuilder.from_command_line_parameters(args)
logging.info(f"Signature: {signature}")
report = mango.TransactionScout.load(context, signature)
mango.output(report)
except Exception as exception:
logging.critical(
f"transaction-scout stopped because of exception: {exception} - {traceback.format_exc()}"
)
except:
logging.critical(
f"transaction-scout stopped because of uncatchable error: {traceback.format_exc()}"
)