Skip to content

Commit

Permalink
refactor: create and use disk-cache utilities for contracts-cache ite…
Browse files Browse the repository at this point in the history
…ms (#2416)
  • Loading branch information
antazoey authored Dec 16, 2024
1 parent 48cfcaa commit 9dc7098
Show file tree
Hide file tree
Showing 24 changed files with 1,285 additions and 966 deletions.
3 changes: 2 additions & 1 deletion docs/userguides/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ or
```python
from ape import project


def main():
my_contract = project.MyContract.deployments[-1]
my_contract = project.MyContract.deployments[-1]
```

`my_contract` will be of type `ContractInstance`.
Expand Down
4 changes: 2 additions & 2 deletions src/ape/api/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, *args, **kwargs):
@classmethod
def validate_gas_limit(cls, value):
if value is None:
if not cls.network_manager.active_provider:
if not cls.network_manager.connected:
raise NetworkError("Must be connected to use default gas config.")

value = cls.network_manager.active_provider.network.gas_limit
Expand All @@ -82,7 +82,7 @@ def validate_gas_limit(cls, value):
return None # Delegate to `ProviderAPI.estimate_gas_cost`

elif value == "max":
if not cls.network_manager.active_provider:
if not cls.network_manager.connected:
raise NetworkError("Must be connected to use 'max'.")

return cls.network_manager.active_provider.max_gas
Expand Down
2 changes: 1 addition & 1 deletion src/ape/contracts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ def from_receipt(

# Cache creation.
creation = ContractCreation.from_receipt(receipt)
cls.chain_manager.contracts._local_contract_creation[address] = creation
cls.chain_manager.contracts.contract_creations[address] = creation

return instance

Expand Down
Loading

0 comments on commit 9dc7098

Please sign in to comment.