Skip to content

Commit

Permalink
include return data in transaction trace even when the function signa…
Browse files Browse the repository at this point in the history
…ture is not available
  • Loading branch information
sparrowDom committed Dec 19, 2023
1 parent bc7b511 commit 0714237
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 0714237

Please sign in to comment.