Skip to content

Commit

Permalink
fix: catch wider range of explorer excs (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Jul 16, 2024
1 parent 00b50de commit 1b822c0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions y/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,11 @@ async def get_code(self, block: Optional[Block] = None) -> HexBytes:
_contract_queue = a_sync.SmartProcessingQueue(Contract._coroutine, num_workers=32)

@memory.cache()
# TODO: async this and put it into ydb for quicker startups
#yLazyLogger(logger)
def is_contract(address: AnyAddressType) -> bool:
'''
Checks to see if the input address is a contract. Returns `True` if:
Checks to see if the input address is a contract. Returns `False` if:
- The address is not and has never been a contract
- The address used to be a contract but has self-destructed
'''
Expand Down Expand Up @@ -485,7 +486,7 @@ def _extract_abi_data(address):
raise ContractNotFound(address) from e
raise
except ValueError as e:
if "Invalid API Key" in str(e):
if str(e).startswith("Failed to retrieve data from API") or "invalid api key" in str(e).lower():
raise exceptions.InvalidAPIKeyError from e
if exceptions.contract_not_verified(e):
raise exceptions.ContractNotVerified(f'{address} on {Network.printable()}') from e
Expand Down

0 comments on commit 1b822c0

Please sign in to comment.