def input_block_identifier_formatter(block_identifier): if is_predefined_block_number(block_identifier): return block_identifier elif is_integer(block_identifier): return hex(block_identifier) else: return block_identifier
def is_primitive_type(value): return any(( value is None, is_boolean(value), is_string(value), is_integer(value), isinstance(value, float), ))
def getBlockTransactionCount(self, block_identifier): """ `eth_getBlockTransactionCountByHash` `eth_getBlockTransactionCountByNumber` """ if is_integer(block_identifier): method = 'eth_getBlockTransactionCountByNumber' else: method = 'eth_getBlockTransactionCountByHash' return self.request_manager.request_blocking(method, [block_identifier])
def getBlockTransactionCount(self, block_identifier): """ `eth_getBlockTransactionCountByHash` `eth_getBlockTransactionCountByNumber` """ if is_predefined_block_number(block_identifier) or is_integer(block_identifier): method = 'eth_getBlockTransactionCountByNumber' else: method = 'eth_getBlockTransactionCountByHash' return self.web3._requestManager.request_blocking( method, [formatters.input_block_identifier_formatter(block_identifier)], )
def getTransactionFromBlock(self, block_identifier, txn_index): """ `eth_getTransactionByBlockHashAndIndex` `eth_getTransactionByBlockNumberAndIndex` """ if is_integer(block_identifier): method = 'eth_getTransactionByBlockNumberAndIndex' else: method = 'eth_getTransactionByBlockHashAndIndex' return self.request_manager.request_blocking( method, [block_identifier, txn_index], )
def getBlockTransactionCount(self, block_identifier): """ `eth_getBlockTransactionCountByHash` `eth_getBlockTransactionCountByNumber` """ if is_predefined_block_number(block_identifier) or is_integer( block_identifier): method = 'eth_getBlockTransactionCountByNumber' else: method = 'eth_getBlockTransactionCountByHash' return self.web3._requestManager.request_blocking( method, [formatters.input_block_identifier_formatter(block_identifier)], )
def getBlock(self, block_identifier, full_txns=False): """ `eth_getBlockByHash` `eth_getBlockByNumber` """ if is_integer(block_identifier): method = 'eth_getBlockByNumber' else: method = 'eth_getBlockByHash' return self.request_manager.request_blocking( method, [block_identifier, full_txns], )
def getTransactionFromBlock(self, block_identifier, transaction_index): """ `eth_getTransactionByBlockHashAndIndex` `eth_getTransactionByBlockNumberAndIndex` """ if is_predefined_block_number(block_identifier) or is_integer(block_identifier): method = 'eth_getTransactionByBlockNumberAndIndex' else: method = 'eth_getTransactionByBlockHashAndIndex' return self.web3._requestManager.request_blocking( method, [ formatters.input_block_identifier_formatter(block_identifier), transaction_index, ], )
def getTransactionFromBlock(self, block_identifier, transaction_index): """ `eth_getTransactionByBlockHashAndIndex` `eth_getTransactionByBlockNumberAndIndex` """ if is_predefined_block_number(block_identifier) or is_integer( block_identifier): method = 'eth_getTransactionByBlockNumberAndIndex' else: method = 'eth_getTransactionByBlockHashAndIndex' return self.web3._requestManager.request_blocking( method, [ formatters.input_block_identifier_formatter(block_identifier), transaction_index, ], )
def getBlock(self, block_identifier, full_transactions=False): """ `eth_getBlockByHash` `eth_getBlockByNumber` """ if is_predefined_block_number(block_identifier) or is_integer( block_identifier): method = 'eth_getBlockByNumber' else: method = 'eth_getBlockByHash' return self.request_manager.request_blocking( method, [ formatters.input_block_identifier_formatter(block_identifier), full_transactions, ], )
def test_eth_blockNumber(web3): block_number = web3.eth.blockNumber assert is_integer(block_number)
def test_is_integer(value, expected): assert is_integer(value) == expected