Skip to content

Commit

Permalink
fix: eth tester ret fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 26, 2024
1 parent 4d7fb56 commit 0553d98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/ape/api/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ def return_value(self) -> Any:
Obtain the final return value of the call. Requires tracing to function,
since this is not available from the receipt object.
"""

if trace := self.trace:
ret_val = trace.return_value
return ret_val[0] if isinstance(ret_val, tuple) and len(ret_val) == 1 else ret_val
Expand Down
19 changes: 18 additions & 1 deletion src/ape_test/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,21 @@ class EthTesterTransactionTrace(TransactionTrace):
def return_value(self) -> Any:
# perf: skip trying anything else, because eth-tester doesn't
# yet implement any tracing RPCs.
return self._return_value_from_enriched_calltree
init_kwargs = self._get_tx_calltree_kwargs()
receipt = self.chain_manager.get_receipt(self.transaction_hash)
init_kwargs["gas_cost"] = receipt.gas_used

if not (abi := self.root_method_abi):
return (None,)

num_return = len(self.root_method_abi.outputs)

# Figure out the 'returndata' using 'eth_call' RPC.
tx = receipt.transaction.model_copy(update={"nonce": None})
try:
returndata = self.provider.send_call(tx, block_id=receipt.block_number)
except ContractLogicError:
# Unable to get the return value because even as a call, it fails.
return tuple([None for _ in range(num_return)])

return self._ecosystem.decode_returndata(abi, returndata)

0 comments on commit 0553d98

Please sign in to comment.