Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion hathor/nanocontracts/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,19 @@ def copy(self) -> Context:

def to_json(self) -> dict[str, Any]:
"""Return a JSON representation of the context."""
caller_id: str
match self.caller_id:
case Address():
caller_id = get_address_b58_from_bytes(self.caller_id)
case ContractId():
caller_id = self.caller_id.hex()
case _:
assert_never(self.caller_id)

return {
'actions': [action.to_json() for action in self.__all_actions__],
'caller_id': get_address_b58_from_bytes(self.caller_id),
'caller_id': caller_id,
'timestamp': self.timestamp,
# XXX: Deprecated attribute
'address': caller_id,
}
Loading