Skip to content

Commit

Permalink
fix: im just dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jan 27, 2025
1 parent 9c88e37 commit 0b23dcb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,11 +969,15 @@ def get_receipt(self, transaction_hash: str) -> ReceiptAPI:

def get_code(self, address: "AddressType") -> "ContractCode":
network = self.provider.network
if not network.is_local:
self._code.setdefault(network.ecosystem.name, {})
self._code[network.ecosystem.name].setdefault(network.name, {})
if address in self._code[network.ecosystem.name][network.name]:
return self._code[network.ecosystem.name][network.name][address]
if network.is_dev:
# Avoid caching when dev, as you can manipulate the chain more
# (and there is isolation).
return self.provider.get_code(address)

self._code.setdefault(network.ecosystem.name, {})
self._code[network.ecosystem.name].setdefault(network.name, {})
if address in self._code[network.ecosystem.name][network.name]:
return self._code[network.ecosystem.name][network.name][address]

# Get from RPC for the first time.
code = self.provider.get_code(address)
Expand Down

0 comments on commit 0b23dcb

Please sign in to comment.