示例#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
示例#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
示例#3
0
文件: types.py 项目: 4gn3s/populus
def is_primitive_type(value):
    return any((
        value is None,
        is_boolean(value),
        is_string(value),
        is_integer(value),
        isinstance(value, float),
    ))
示例#4
0
def is_primitive_type(value):
    return any((
        value is None,
        is_boolean(value),
        is_string(value),
        is_integer(value),
        isinstance(value, float),
    ))
示例#5
0
文件: eth.py 项目: XertroV/web3.py
 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])
示例#6
0
文件: eth.py 项目: euri10/web3.py
 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)],
     )
示例#7
0
文件: eth.py 项目: XertroV/web3.py
 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],
     )
示例#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)],
     )
示例#9
0
文件: eth.py 项目: XertroV/web3.py
    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],
        )
示例#10
0
文件: eth.py 项目: euri10/web3.py
 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,
         ],
     )
示例#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,
         ],
     )
示例#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,
            ],
        )
示例#13
0
def test_eth_blockNumber(web3):
    block_number = web3.eth.blockNumber
    assert is_integer(block_number)
示例#14
0
def test_is_integer(value, expected):
    assert is_integer(value) == expected
示例#15
0
def test_eth_blockNumber(web3):
    block_number = web3.eth.blockNumber
    assert is_integer(block_number)
示例#16
0
def test_is_integer(value, expected):
    assert is_integer(value) == expected