Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include encoded return data in transaction trace #1715

Merged
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
14 changes: 14 additions & 0 deletions brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,20 @@ def _expand_trace(self) -> None:
last["address"], trace[i]["stack"][-2][-40:], trace[i]["stack"][-3]
)

# If the function signature is not available for decoding return data attach
# the encoded data.
# If the function signature is available this will be overridden by setting
# `return_value` a few lines below.
if trace[i]["depth"] and opcode == "RETURN":
subcall: dict = next(
i for i in self._subcalls[::-1] if i["to"] == last["address"] # type: ignore
)

if opcode == "RETURN":
returndata = _get_memory(trace[i], -1)
if returndata.hex() not in ("", "0x"):
subcall["returndata"] = returndata.hex()

try:
pc = last["pc_map"][trace[i]["pc"]]
except (KeyError, TypeError):
Expand Down