Skip to content

Commit

Permalink
Merge pull request #1715 from sparrowDom/sparrowDom/fixReturnData
Browse files Browse the repository at this point in the history
Include encoded return data in transaction trace
  • Loading branch information
iamdefinitelyahuman authored Jan 29, 2024
2 parents 209b78a + 0714237 commit 6879c9a
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit 6879c9a

Please sign in to comment.