#!/usr/bin/env python3

import argparse
import os
import os.path
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import entropy  # nopep8

parser = argparse.ArgumentParser(
    description="Shows the on-chain data of a particular transaction."
)
entropy.ContextBuilder.add_command_line_parameters(parser)
parser.add_argument(
    "--signature", type=str, required=True, help="signature of the transaction"
)
args: argparse.Namespace = entropy.parse_args(parser)

with entropy.ContextBuilder.from_command_line_parameters(args) as context:
    transaction = context.client.get_confirmed_transaction(args.signature)
    if transaction is None:
        entropy.output(
            f"Transaction with signature {args.signature} could not be found."
        )
    else:
        scout = entropy.TransactionScout.from_transaction_response(context, transaction)
        entropy.output(scout)
