Skip to content

Commit

Permalink
refactor: avoid encoding twice
Browse files Browse the repository at this point in the history
Co-authored-by: antazoey <yingthi@live.com>
  • Loading branch information
fubuloubu and antazoey committed Feb 2, 2024
1 parent 0363f7d commit a945ce8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ape_tokens/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ def __getitem__(self, symbol: str) -> ContractInstance:
except ValueError as err:
raise KeyError(f"Symbol '{symbol}' is not a known token symbol") from err

try:
return self.chain_manager.contracts.instance_at(to_checksum_address(token_info.address))
checksummed_address = to_checksum_address(token_info.address)
try:
return self.chain_manager.contracts.instance_at(address)
except ContractNotFoundError:
return self.chain_manager.contracts.instance_at(
to_checksum_address(token_info.address), contract_type=ERC20
)
return self.chain_manager.contracts.instance_at(address, contract_type=ERC20)

0 comments on commit a945ce8

Please sign in to comment.