Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
feat: support CREATE [APE-1107] (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jul 17, 2023
1 parent 87d3480 commit 3b4eae4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ape_ganache/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,23 @@ def get_call_tree(self, txn_hash: str) -> CallTreeNode:
data_gas = sum([4 if x == 0 else 16 for x in receipt.data])
method_gas_cost = receipt.gas_used - 21_000 - data_gas

if receipt.contract_address:
# Deploy txn
address = receipt.contract_address
call_type = CallType.CREATE
else:
# Invoke txn
address = receipt.receiver
call_type = CallType.CALL

evm_call = get_calltree_from_geth_trace(
self._get_transaction_trace(txn_hash),
gas_cost=method_gas_cost,
gas_limit=receipt.gas_limit,
address=receipt.receiver,
address=address,
calldata=receipt.data,
value=receipt.value,
call_type=CallType.CALL,
call_type=call_type,
failed=receipt.failed,
)
# Strange bug in Ganache where sub-calls REVERT trickles to the top-level
Expand Down
5 changes: 4 additions & 1 deletion tests/test_gas_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Method +Times called +Min. +Max. +Mean +Median
─+
__init__ +\d +\d+ + \d+ + \d+ + \d+
balanceOf +\d +\d+ + \d+ + \d+ + \d+
transfer +\d +\d+ + \d+ + \d+ + \d+
"""
Expand All @@ -21,14 +22,16 @@
Method +Times called +Min. +Max. +Mean +Median
─+
__init__ +\d +\d+ + \d+ + \d+ + \d+
fooAndBar +\d +\d+ + \d+ + \d+ + \d+
myNumber +\d +\d+ + \d+ + \d+ + \d+
setNumber +\d +\d+ + \d+ + \d+ + \d+
fooAndBar +\d +\d+ + \d+ + \d+ + \d+
+TokenA Gas
Method +Times called +Min. +Max. +Mean +Median
─+
__init__ +\d +\d+ + \d+ + \d+ + \d+
balanceOf +\d +\d+ + \d+ + \d+ + \d+
transfer +\d +\d+ + \d+ + \d+ + \d+
{TOKEN_B_GAS_REPORT}
Expand Down

0 comments on commit 3b4eae4

Please sign in to comment.