Example #1
0
transaction_formatter = apply_formatters_to_dict(TRANSACTION_FORMATTERS)

RECEIPT_FORMATTERS = {
    'logs': apply_formatter_to_array(log_key_remapper),
}

receipt_formatter = apply_formatters_to_dict(RECEIPT_FORMATTERS)

transaction_params_transformer = compose(transaction_params_remapper,
                                         transaction_params_formatter)

ethereum_tester_middleware = construct_formatting_middleware(
    request_formatters={
        # Eth
        RPCEndpoint('eth_getBlockByNumber'):
        apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex), ),
        RPCEndpoint('eth_getFilterChanges'):
        apply_formatters_to_args(hex_to_integer),
        RPCEndpoint('eth_getFilterLogs'):
        apply_formatters_to_args(hex_to_integer),
        RPCEndpoint('eth_getBlockTransactionCountByNumber'):
        apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex), ),
        RPCEndpoint('eth_getUncleCountByBlockNumber'):
        apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex), ),
        RPCEndpoint('eth_getTransactionByBlockHashAndIndex'):
        apply_formatters_to_args(
            identity,
            to_integer_if_hex,
        ),
Example #2
0
    'base_fee_per_gas': 'baseFeePerGas',
}
block_result_remapper = apply_key_map(BLOCK_RESULT_KEY_MAPPING)


RECEIPT_RESULT_FORMATTERS = {
    'logs': apply_formatter_to_array(log_result_remapper),
}
receipt_result_formatter = apply_formatters_to_dict(RECEIPT_RESULT_FORMATTERS)


ethereum_tester_middleware = construct_formatting_middleware(
    request_formatters={
        # Eth
        RPCEndpoint('eth_getBlockByNumber'): apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex),
        ),
        RPCEndpoint('eth_getFilterChanges'): apply_formatters_to_args(hex_to_integer),
        RPCEndpoint('eth_getFilterLogs'): apply_formatters_to_args(hex_to_integer),
        RPCEndpoint('eth_getBlockTransactionCountByNumber'): apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex),
        ),
        RPCEndpoint('eth_getUncleCountByBlockNumber'): apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex),
        ),
        RPCEndpoint('eth_getTransactionByBlockHashAndIndex'): apply_formatters_to_args(
            identity,
            to_integer_if_hex,
        ),
        RPCEndpoint('eth_getTransactionByBlockNumberAndIndex'): apply_formatters_to_args(
            apply_formatter_if(is_not_named_block, to_integer_if_hex),
Example #3
0
RECEIPT_FORMATTERS = {
    'logs': apply_formatter_to_array(log_key_remapper),
}

receipt_formatter = apply_formatters_to_dict(RECEIPT_FORMATTERS)

transaction_params_transformer = compose(transaction_params_remapper,
                                         transaction_params_formatter)

ethereum_tester_middleware = construct_formatting_middleware(
    request_formatters={
        # Eth
        RPCEndpoint('eth_getBlockByNumber'):
        apply_formatters_to_args(
            # type ignored for apply_formatter_if b/c
            # https://github.com/ethereum/eth-utils/issues/156
            apply_formatter_if(is_not_named_block,
                               to_integer_if_hex),  # type: ignore
        ),
        RPCEndpoint('eth_getFilterChanges'):
        apply_formatters_to_args(hex_to_integer),
        RPCEndpoint('eth_getFilterLogs'):
        apply_formatters_to_args(hex_to_integer),
        RPCEndpoint('eth_getBlockTransactionCountByNumber'):
        apply_formatters_to_args(
            apply_formatter_if(is_not_named_block,
                               to_integer_if_hex),  # type: ignore
        ),
        RPCEndpoint('eth_getUncleCountByBlockNumber'):
        apply_formatters_to_args(
            apply_formatter_if(is_not_named_block,
                               to_integer_if_hex),  # type: ignore