Example #1
0
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
Example #2
0
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
Example #3
0
def is_primitive_type(value):
    return any((
        value is None,
        is_boolean(value),
        is_string(value),
        is_integer(value),
        isinstance(value, float),
    ))
Example #4
0
def is_primitive_type(value):
    return any((
        value is None,
        is_boolean(value),
        is_string(value),
        is_integer(value),
        isinstance(value, float),
    ))
Example #5
0
 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])
Example #6
0
 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)],
     )
Example #7
0
 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],
     )
Example #8
0
 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)],
     )
Example #9
0
    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],
        )
Example #10
0
 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,
         ],
     )
Example #11
0
 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,
         ],
     )
Example #12
0
    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,
            ],
        )
Example #13
0
def test_eth_blockNumber(web3):
    block_number = web3.eth.blockNumber
    assert is_integer(block_number)
Example #14
0
def test_is_integer(value, expected):
    assert is_integer(value) == expected
Example #15
0
def test_eth_blockNumber(web3):
    block_number = web3.eth.blockNumber
    assert is_integer(block_number)
Example #16
0
def test_is_integer(value, expected):
    assert is_integer(value) == expected