Пример #1
0
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)
Пример #2
0
 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),
     )
Пример #3
0
 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),
     )
Пример #4
0
 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)
     )
Пример #5
0
 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)
     )
Пример #6
0
 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)
     )
Пример #7
0
 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),
     )
Пример #8
0
 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),
     )
Пример #9
0
 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),
     )
Пример #10
0
 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),
     )
Пример #11
0
 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),
     )
Пример #12
0
 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),
     )