Exemple #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
Exemple #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
Exemple #3
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)],
     )
Exemple #4
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)],
     )
Exemple #5
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.manager.request_blocking(
         method,
         [block_identifier, transaction_index],
     )
Exemple #6
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.web3.manager.request_blocking(
            method,
            [block_identifier, full_transactions],
        )
Exemple #7
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,
         ],
     )
Exemple #8
0
def test_is_predefined_block_number(block_identifier, expected):
    actual = is_predefined_block_number(block_identifier)
    assert actual is expected