From 456887b111e15866aa536e8147c9c27d03390f5d Mon Sep 17 00:00:00 2001 From: banteg <4562643+banteg@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:56:26 +0400 Subject: [PATCH] refactor: rename deploy_block to block --- src/ape/api/query.py | 4 ++-- src/ape/contracts/base.py | 2 +- src/ape/managers/chain.py | 2 +- src/ape/managers/query.py | 10 ++++------ src/ape_geth/query.py | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ape/api/query.py b/src/ape/api/query.py index 639bc490b2..f6016b0fbc 100644 --- a/src/ape/api/query.py +++ b/src/ape/api/query.py @@ -158,7 +158,7 @@ def check_start_nonce_before_stop_nonce(cls, values: Dict) -> Dict: class ContractCreationQuery(_BaseQuery): """ A ``QueryType`` that obtains information about contract deployment. - Returns ``ContractCreation(txn_hash, deploy_block, deployer, factory)``. + Returns ``ContractCreation(txn_hash, block, deployer, factory)``. """ contract: AddressType @@ -166,7 +166,7 @@ class ContractCreationQuery(_BaseQuery): class ContractCreation(BaseModel): txn_hash: str - deploy_block: int + block: int deployer: AddressType factory: Optional[AddressType] = None diff --git a/src/ape/contracts/base.py b/src/ape/contracts/base.py index f44234ed61..8019a83c6a 100644 --- a/src/ape/contracts/base.py +++ b/src/ape/contracts/base.py @@ -907,7 +907,7 @@ def receipt(self) -> ReceiptAPI: @cached_property def creation(self) -> ContractCreation: """ - Contract creation details: txn_hash, deployer, factory, deploy_block. + Contract creation details: txn_hash, block, deployer, factory. """ data = self.chain_manager.contracts.get_creation_metadata(self.address) if data is not None: diff --git a/src/ape/managers/chain.py b/src/ape/managers/chain.py index a7f4df28a7..f967c7f308 100644 --- a/src/ape/managers/chain.py +++ b/src/ape/managers/chain.py @@ -843,7 +843,7 @@ def get_proxy_info(self, address: AddressType) -> Optional[ProxyInfoAPI]: def get_creation_metadata(self, address: AddressType) -> Optional[ContractCreation]: """ - Get contract creation metadata containing txn_hash, deployer, factory, deploy_block. + Get contract creation metadata containing txn_hash, deployer, factory, block. Args: address (AddressType): The address of the contract. diff --git a/src/ape/managers/query.py b/src/ape/managers/query.py index d3c4956b33..6d82b6b231 100644 --- a/src/ape/managers/query.py +++ b/src/ape/managers/query.py @@ -99,14 +99,12 @@ def find_creation_block(lo, hi): if not self.provider.get_code(query.contract): return None - deploy_block = find_creation_block(0, self.chain_manager.blocks.height) - deploy_block_traces = self.provider._make_request( - "trace_replayBlockTransactions", [deploy_block, ["trace"]] - ) + block = find_creation_block(0, self.chain_manager.blocks.height) + traces = self.provider._make_request("trace_replayBlockTransactions", [block, ["trace"]]) # iterate over transaction traces in a block to find the deploy transaction # this method also supports contract factories - for tx in deploy_block_traces: + for tx in traces: for trace in tx["trace"]: if ( "error" not in trace @@ -117,9 +115,9 @@ def find_creation_block(lo, hi): creator = self.conversion_manager.convert(trace["action"]["from"], AddressType) yield ContractCreation( txn_hash=tx["transactionHash"], + block=block, deployer=receipt.sender, factory=creator if creator != receipt.sender else None, - deploy_block=deploy_block, ) @perform_query.register diff --git a/src/ape_geth/query.py b/src/ape_geth/query.py index 984e8d91d2..fcd72d1f09 100644 --- a/src/ape_geth/query.py +++ b/src/ape_geth/query.py @@ -36,7 +36,7 @@ def get_contract_creation_receipt( receipt = self.provider.get_receipt(ots["hash"]) yield ContractCreation( txn_hash=ots["hash"], + block=receipt.block_number, deployer=receipt.sender, factory=creator if creator != receipt.sender else None, - deploy_block=receipt.block_number, )