Skip to content

Commit

Permalink
fix: token not in tokenlist
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored May 23, 2024
1 parent da602a4 commit 13b583c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ape_tokens/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,16 @@ def __iter__(self) -> Iterator[ContractInstance]:
yield self[token.symbol]

def __getitem__(self, symbol: str) -> ContractInstance:
try:
token_info = self._manager.get_token_info(
symbol, chain_id=self.network_manager.network.chain_id
)

except ValueError as err:
token_info = None
for tokenlist in self._manager.available_tokenlists():
try:
token_info = self._manager.get_token_info(
symbol, chain_id=self.network_manager.network.chain_id, token_listname=tokenlist
)
except ValueError:
continue

if token_info is None:
raise KeyError(f"Symbol '{symbol}' is not a known token symbol") from err

checksummed_address = to_checksum_address(token_info.address)
Expand Down

0 comments on commit 13b583c

Please sign in to comment.