Added more detail about keys/accounts to instruction reporters.
This commit is contained in:
parent
615e2abb71
commit
76530318bb
|
@ -61,7 +61,17 @@ class SerumInstructionReporter(InstructionReporter):
|
|||
def report(self, instruction: TransactionInstruction) -> str:
|
||||
initial = layouts.SERUM_INSTRUCTION_VARIANT_FINDER.parse(instruction.data)
|
||||
instruction_type = PySerumInstructionType(initial.variant)
|
||||
return f"« Serum Instruction: {instruction_type.name}: " + "".join("{:02x}".format(x) for x in instruction.data) + "»"
|
||||
data = "".join("{:02x}".format(x) for x in instruction.data)
|
||||
keys: typing.List[str] = []
|
||||
for index, key in enumerate(instruction.keys):
|
||||
is_writable: str = "Writable " if key.is_writable else "Read-Only"
|
||||
is_signer: str = "Signer" if key.is_signer else " "
|
||||
pubkey: str = str(key.pubkey)
|
||||
keys += [f"\tKey[{index: >2}]: {pubkey: <45} {is_writable} {is_signer}"]
|
||||
key_details: str = "\n".join(keys)
|
||||
return f"""« Serum Instruction: {instruction_type.name}: {data}
|
||||
{key_details}
|
||||
»"""
|
||||
|
||||
|
||||
# # 🥭 MangoInstructionReporter class
|
||||
|
|
|
@ -291,7 +291,14 @@ class MangoInstruction:
|
|||
|
||||
def __str__(self) -> str:
|
||||
parameters = self.describe_parameters() or "None"
|
||||
return f"« {self.instruction_type.name}: {parameters} »"
|
||||
keys: typing.List[str] = []
|
||||
for index, key in enumerate(self.accounts):
|
||||
pubkey: str = str(key)
|
||||
keys += [f"\tKey[{index: >2}]: {pubkey}"]
|
||||
key_details: str = "\n".join(keys)
|
||||
return f"""« {self.instruction_type.name}: {parameters}
|
||||
{key_details}
|
||||
»"""
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"{self}"
|
||||
|
|
Loading…
Reference in New Issue