Skip to content

Commit

Permalink
fix: dont cache none
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Feb 18, 2025
1 parent 2e9c7df commit e17fa60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ape/managers/_contractscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,18 @@ def get(
if fetch_from_explorer
else None
)
contract_type_to_cache = None

if proxy_contract_type:
contract_type_to_cache = _get_combined_contract_type(
proxy_contract_type, proxy_info, implementation_contract_type
)
else:
elif implementation_contract_type is not None:
contract_type_to_cache = implementation_contract_type

self.contract_types[address_key] = contract_type_to_cache
return contract_type_to_cache
if contract_type_to_cache is not None:
self.contract_types[address_key] = contract_type_to_cache
return contract_type_to_cache

# Also gets cached to disk for faster lookup next time.
if fetch_from_explorer:
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/test_contracts_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ def test_get_pass_along_proxy_info(chain, owner, minimal_proxy_container, ethere
actual = chain.contracts.get(minimal_proxy.address, proxy_info=info)
assert actual is None # It can't find the contact anymore.

# Ensure it does store 'None' (was a bug where it did).
assert minimal_proxy.address not in chain.contracts.contract_types


def test_get_creation_metadata(chain, vyper_contract_instance, owner):
address = vyper_contract_instance.address
Expand Down

0 comments on commit e17fa60

Please sign in to comment.