예제 #1
0
def test_apply_key_map(formatter, value, expected):
    assert eth_utils.apply_key_map(formatter, value) == expected

    mapper = apply_key_map(formatter)
    assert mapper(value) == expected
예제 #2
0
from eth_utils.curried import (
    apply_formatters_to_dict,
    apply_key_map,
)
from hexbytes import (
    HexBytes, )

from vns_web3.middleware.formatting import (
    construct_formatting_middleware, )
from vns_web3.utils.toolz import (
    compose, )

remap_geth_poa_fields = apply_key_map({
    'extraData': 'proofOfAuthorityData',
})

pythonic_geth_poa = apply_formatters_to_dict({
    'proofOfAuthorityData': HexBytes,
})

geth_poa_cleanup = compose(pythonic_geth_poa, remap_geth_poa_fields)

geth_poa_middleware = construct_formatting_middleware(result_formatters={
    'eth_getBlockByHash':
    geth_poa_cleanup,
    'eth_getBlockByNumber':
    geth_poa_cleanup,
}, )
예제 #3
0
    apply_formatters_to_dict,
    apply_key_map,
)
from hexbytes import (
    HexBytes,
)

from web3._utils.toolz import (
    compose,
)
from web3.middleware.formatting import (
    construct_formatting_middleware,
)

remap_geth_poa_fields = apply_key_map({
    'extraData': 'proofOfAuthorityData',
})

pythonic_geth_poa = apply_formatters_to_dict({
    'proofOfAuthorityData': HexBytes,
})

geth_poa_cleanup = compose(pythonic_geth_poa, remap_geth_poa_fields)

geth_poa_middleware = construct_formatting_middleware(
    result_formatters={
        'eth_getBlockByHash': geth_poa_cleanup,
        'eth_getBlockByNumber': geth_poa_cleanup,
    },
)