Skip to content

Commit

Permalink
refactor: simplify assert
Browse files Browse the repository at this point in the history
  • Loading branch information
banteg committed Apr 13, 2024
1 parent 4fde0f4 commit d18cd6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ape/contracts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,9 @@ def __call__(self, *args, **kwargs) -> ReceiptAPI:

@classmethod
def from_receipt(cls, receipt: ReceiptAPI, contract_type: ContractType) -> "ContractInstance":
"""
Create a contract instance from the contract deployment receipt.
"""
address = receipt.contract_address
if not address:
raise ChainError(
Expand All @@ -883,9 +886,8 @@ def creation(self) -> ContractCreation:
Contract creation details: txn_hash, block, deployer, factory, receipt.
"""
data = self.chain_manager.contracts.get_creation_metadata(self.address)
if data is not None:
return data
raise AssertionError("unreachable")
assert data, "unreachable"
return data

@log_instead_of_fail(default="<ContractInstance>")
def __repr__(self) -> str:
Expand Down

0 comments on commit d18cd6e

Please sign in to comment.