def test_check_tag(): assert check_tag('latest') == 'latest' assert check_tag('earliest') == 'earliest' assert check_tag('pending') == 'pending' with patch('aioetherscan.common.check_hex', new=Mock()) as mock: check_tag(123) mock.assert_called_once_with(123)
async def block_tx_count_by_number(self, tag: Union[int, str] = 'latest') -> str: """Returns the number of transactions in a block from a block matching the given block number.""" return await self._get( action='eth_getBlockTransactionCountByNumber', tag=check_tag(tag), )
async def code(self, address: str, tag: Union[int, str] = 'latest') -> str: """Returns code at a given address.""" return await self._get( action='eth_getCode', address=address, tag=check_tag(tag), )
async def balances(self, addresses: Iterable[str], tag: str = 'latest') -> List[Dict]: """Get Ether Balance for multiple Addresses in a single call.""" return await self._get( action='balancemulti', address=','.join(addresses), tag=check_tag(tag) )
async def balance(self, address: str, tag: str = 'latest') -> str: """Get Ether Balance for a single Address.""" return await self._get( action='balance', address=address, tag=check_tag(tag) )
async def token_balance(self, address: str, contract_address: str, tag: str = 'latest') -> str: """Get ERC20-Token Account Balance for TokenContractAddress.""" return await self._get( action='tokenbalance', address=address, contractaddress=contract_address, tag=check_tag(tag) )
async def tx_count(self, address: str, tag: Union[int, str] = 'latest') -> str: """Returns the number of transactions sent from an address.""" return await self._get( action='eth_getTransactionCount', address=address, tag=check_tag(tag), )
async def tx_by_number_and_index(self, index: Union[int, str], tag: Union[int, str] = 'latest') -> Dict: """Returns information about a transaction by block number and transaction index position.""" return await self._get( action='eth_getTransactionByBlockNumberAndIndex', index=check_hex(index), tag=check_tag(tag), )
async def block_by_number(self, full: bool, tag: Union[int, str] = 'latest') -> Dict: """Returns information about a block by block number.""" return await self._get( action='eth_getBlockByNumber', boolean=full, tag=check_tag(tag), )
async def uncle_block_by_number_and_index( self, index: Union[int, str], tag: Union[int, str] = 'latest') -> Dict: """Returns information about a uncle by block number.""" return await self._get( action='eth_getUncleByBlockNumberAndIndex', index=check_hex(index), tag=check_tag(tag), )
async def call(self, to: str, data: str, tag: Union[int, str] = 'latest') -> str: """Executes a new message call immediately without creating a transaction on the block chain.""" return await self._get( action='eth_call', to=check_hex(to), data=check_hex(data), tag=check_tag(tag), )
async def storage_at(self, address: str, position: str, tag: Union[int, str] = 'latest') -> str: """Returns the value from a storage position at a given address.""" return await self._get( action='eth_getStorageAt', address=address, position=position, tag=check_tag(tag), )