diff --git a/eth_portfolio/_ydb/token_transfers.py b/eth_portfolio/_ydb/token_transfers.py index b30f04a5..44ab4544 100644 --- a/eth_portfolio/_ydb/token_transfers.py +++ b/eth_portfolio/_ydb/token_transfers.py @@ -6,11 +6,6 @@ import a_sync from brownie import chain -try: - # this is only available in 4.0.0+ - from eth_abi import encode -except ImportError: - from eth_abi import encode_single as encode from eth_utils import encode_hex from web3.types import LogReceipt from y.datatypes import Address @@ -20,6 +15,14 @@ from eth_portfolio.constants import TRANSFER_SIGS from eth_portfolio.structs import TokenTransfer +try: + # this is only available in 4.0.0+ + from eth_abi import encode + encode_address = lambda address: encode_hex(encode(["address"], str(address))) +except ImportError: + from eth_abi import encode_single + encode_address = lambda address: encode_hex(encode_single("address", str(address))) + logger = logging.getLogger(__name__) class _TokenTransfers(ProcessedEvents["asyncio.Task[TokenTransfer]"]): @@ -63,13 +66,13 @@ class InboundTokenTransfers(_TokenTransfers): """A container that fetches and iterates over all inbound token transfers for a particular wallet address""" @property def _topics(self) -> List: - return [TRANSFER_SIGS, None, [encode_hex(encode(['address'], str(self.address)))]] + return [TRANSFER_SIGS, None, [encode_address(self.address)]] class OutboundTokenTransfers(_TokenTransfers): """A container that fetches and iterates over all outbound token transfers for a particular wallet address""" @property def _topics(self) -> List: - return [TRANSFER_SIGS, [encode_hex(encode(['address'], str(self.address)))]] + return [TRANSFER_SIGS, [encode_address(self.address)]] class TokenTransfers(a_sync.ASyncIterable[TokenTransfer]): """