def name_to_address_middleware(w3): normalizers = [ abi_ens_resolver(w3), ] return construct_formatting_middleware( request_formatters=abi_request_formatters(normalizers, RPC_ABIS) )
from web3._utils.normalizers import ( abi_address_to_hex, abi_bytes_to_hex, abi_int_to_hex, abi_string_to_hex, ) from web3._utils.rpc_abi import ( abi_request_formatters, ) from helios_web3.utils.rpc_abi import RPC_ABIS from web3.middleware.formatting import ( construct_formatting_middleware, ) STANDARD_NORMALIZERS = [ abi_bytes_to_hex, abi_int_to_hex, abi_string_to_hex, abi_address_to_hex, ] RPC_ABIS['personal_importRawKey'] = ['bytes', None] abi_middleware = construct_formatting_middleware( request_formatters=abi_request_formatters(STANDARD_NORMALIZERS, RPC_ABIS))
'*': apply_formatter_if(is_dict and not_attrdict, AttributeDict.recursive) } METHOD_NORMALIZERS: Dict[RPCEndpoint, Callable[..., Any]] = { RPC.eth_getLogs: apply_formatter_at_index(FILTER_PARAM_NORMALIZERS, 0), RPC.eth_newFilter: apply_formatter_at_index(FILTER_PARAM_NORMALIZERS, 0) } STANDARD_NORMALIZERS = [ abi_bytes_to_hex, abi_int_to_hex, abi_string_to_hex, abi_address_to_hex, ] ABI_REQUEST_FORMATTERS = abi_request_formatters(STANDARD_NORMALIZERS, RPC_ABIS) def raise_solidity_error_on_revert(response: RPCResponse) -> RPCResponse: """ Reverts contain a `data` attribute with the following layout: "Reverted " Function selector for Error(string): 08c379a (4 bytes) Data offset: 32 (32 bytes) String length (32 bytes) Reason string (padded, use string length from above to get meaningful part) See also https://solidity.readthedocs.io/en/v0.6.3/control-structures.html#revert """ if not isinstance(response['error'], dict): raise ValueError('Error expected to be a dict')
from web3._utils.normalizers import ( abi_address_to_hex, abi_bytes_to_hex, abi_int_to_hex, abi_string_to_hex, ) from web3._utils.rpc_abi import ( RPC_ABIS, abi_request_formatters, ) from .formatting import ( construct_formatting_middleware, ) STANDARD_NORMALIZERS = [ abi_bytes_to_hex, abi_int_to_hex, abi_string_to_hex, abi_address_to_hex, ] abi_middleware = construct_formatting_middleware( request_formatters=abi_request_formatters(STANDARD_NORMALIZERS, RPC_ABIS) )