def _prepare_selector_collision_msg(duplicates): dup_sel = valmap(apply_formatter_to_array(abi_to_signature), duplicates) joined_funcs = valmap(lambda funcs: ', '.join(funcs), dup_sel) func_sel_msg_list = [ funcs + ' have selector ' + sel for sel, funcs in joined_funcs.items() ] return ' and\n'.join(func_sel_msg_list)
'maxFeePerGas': 'max_fee_per_gas', 'maxPriorityFeePerGas': 'max_priority_fee_per_gas', 'accessList': 'access_list', } transaction_request_remapper = apply_key_map(TRANSACTION_REQUEST_KEY_MAPPING) TRANSACTION_REQUEST_FORMATTERS = { 'gas': to_integer_if_hex, 'gasPrice': to_integer_if_hex, 'value': to_integer_if_hex, 'nonce': to_integer_if_hex, 'maxFeePerGas': to_integer_if_hex, 'maxPriorityFeePerGas': to_integer_if_hex, 'accessList': apply_formatter_to_array( apply_key_map({'storageKeys': 'storage_keys'}) ), } transaction_request_formatter = apply_formatters_to_dict(TRANSACTION_REQUEST_FORMATTERS) transaction_request_transformer = compose( transaction_request_remapper, transaction_request_formatter, ) FILTER_REQUEST_KEY_MAPPING = { 'fromBlock': 'from_block', 'toBlock': 'to_block', } filter_request_remapper = apply_key_map(FILTER_REQUEST_KEY_MAPPING)
'toBlock': to_integer_if_hex, } filter_params_formatter = apply_formatters_to_dict(FILTER_PARAMS_FORMATTERS) filter_params_transformer = compose(filter_params_remapper, filter_params_formatter) TRANSACTION_FORMATTERS = { 'to': apply_formatter_if(partial(operator.eq, ''), static_return(None)), } 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),
def apply_list_to_array_formatter(formatter): return to_list(apply_formatter_to_array(formatter))
'hash': to_hexbytes(64), 'recipientPublicKey': apply_formatter_if(is_not_null, to_hexbytes(130)), } whisper_log_formatter = apply_formatters_to_dict(WHISPER_LOG_FORMATTERS) LOG_ENTRY_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'logIndex': to_integer_if_hex, 'address': to_checksum_address, 'topics': apply_formatter_to_array(to_hexbytes(32)), 'data': to_ascii_if_bytes, } log_entry_formatter = apply_formatters_to_dict(LOG_ENTRY_FORMATTERS) RECEIPT_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': to_hexbytes(32), 'cumulativeGasUsed': to_integer_if_hex, 'status': to_integer_if_hex, 'gasUsed': to_integer_if_hex,
'hash': to_hexbytes(64), 'recipientPublicKey': apply_formatter_if(is_not_null, to_hexbytes(130)), } whisper_log_formatter = apply_formatters_to_dict(WHISPER_LOG_FORMATTERS) LOG_ENTRY_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'logIndex': to_integer_if_hex, 'address': to_checksum_address, 'topics': apply_formatter_to_array(to_hexbytes(32)), 'data': to_ascii_if_bytes, } log_entry_formatter = apply_formatters_to_dict(LOG_ENTRY_FORMATTERS) RECEIPT_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': to_hexbytes(32), 'cumulativeGasUsed': to_integer_if_hex, 'status': to_integer_if_hex, 'gasUsed': to_integer_if_hex,
'payload': HexBytes, 'padding': apply_formatter_if(is_not_null, HexBytes), 'hash': to_hexbytes(64), 'recipientPublicKey': apply_formatter_if(is_not_null, to_hexbytes(130)), } whisper_log_formatter = apply_formatters_to_dict(WHISPER_LOG_FORMATTERS) LOG_ENTRY_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'logIndex': to_integer_if_hex, 'address': to_checksum_address, 'topics': apply_formatter_to_array(to_hexbytes(32)), 'data': to_ascii_if_bytes, } log_entry_formatter = apply_formatters_to_dict(LOG_ENTRY_FORMATTERS) RECEIPT_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': to_hexbytes(32), 'cumulativeGasUsed': to_integer_if_hex, 'status': to_integer_if_hex, 'gasUsed': to_integer_if_hex, 'contractAddress': apply_formatter_if(is_not_null, to_checksum_address), 'logs': apply_formatter_to_array(log_entry_formatter),
'payload': HexBytes, 'padding': apply_formatter_if(is_not_null, HexBytes), 'hash': to_hexbytes(64), 'recipientPublicKey': apply_formatter_if(is_not_null, to_hexbytes(130)), } whisper_log_formatter = apply_formatters_to_dict(WHISPER_LOG_FORMATTERS) LOG_ENTRY_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'logIndex': to_integer_if_hex, 'address': to_checksum_address, 'topics': apply_formatter_to_array(to_hexbytes(32)), 'data': to_ascii_if_bytes, } log_entry_formatter = apply_formatters_to_dict(LOG_ENTRY_FORMATTERS) RECEIPT_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': to_hexbytes(32), 'cumulativeGasUsed': to_integer_if_hex, 'status': to_integer_if_hex, 'gasUsed': to_integer_if_hex, 'contractAddress': apply_formatter_if(is_not_null, to_checksum_address), 'logs': apply_formatter_to_array(log_entry_formatter),
def _prepare_selector_collision_msg(duplicates): dup_sel = valmap(apply_formatter_to_array(abi_to_signature), duplicates) joined_funcs = valmap(lambda funcs: ', '.join(funcs), dup_sel) func_sel_msg_list = [funcs + ' have selector ' + sel for sel, funcs in joined_funcs.items()] return ' and\n'.join(func_sel_msg_list)
filter_params_formatter = apply_formatters_to_dict(FILTER_PARAMS_FORMATTERS) filter_params_transformer = compose(filter_params_remapper, filter_params_formatter) TRANSACTION_FORMATTERS = { 'to': apply_formatter_if(partial(operator.eq, ''), static_return(None)), } 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 'eth_getBlockByNumber': apply_formatters_to_args( apply_formatter_if(is_not_named_block, to_integer_if_hex), ), 'eth_getFilterChanges': apply_formatters_to_args(hex_to_integer), 'eth_getFilterLogs': apply_formatters_to_args(hex_to_integer),
'payload': HexBytes, 'padding': apply_formatter_if(is_not_null, HexBytes), 'hash': to_hexbytes(64), 'recipientPublicKey': apply_formatter_if(is_not_null, to_hexbytes(130)), } whisper_log_formatter = apply_formatters_to_dict(WHISPER_LOG_FORMATTERS) LOG_ENTRY_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'logIndex': to_integer_if_hex, 'address': to_checksum_address, 'topics': apply_formatter_to_array(to_hexbytes(32)), 'data': to_ascii_if_bytes, } log_entry_formatter = apply_formatters_to_dict(LOG_ENTRY_FORMATTERS) RECEIPT_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': to_hexbytes(32), 'cumulativeGasUsed': to_integer_if_hex, 'status': to_integer_if_hex, 'gasUsed': to_integer_if_hex, 'contractAddress': apply_formatter_if(is_not_null, to_checksum_address), 'logs': apply_formatter_to_array(log_entry_formatter),
'hash': to_hexbytes(64), 'recipientPublicKey': apply_formatter_if(is_not_null, to_hexbytes(130)), } whisper_log_formatter = apply_formatters_to_dict(WHISPER_LOG_FORMATTERS) LOG_ENTRY_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'logIndex': to_integer_if_hex, 'address': to_checksum_address, 'topics': apply_formatter_to_array(to_hexbytes(32)), 'data': to_ascii_if_bytes, } log_entry_formatter = apply_formatters_to_dict(LOG_ENTRY_FORMATTERS) RECEIPT_FORMATTERS = { 'blockHash': apply_formatter_if(is_not_null, to_hexbytes(32)), 'blockNumber': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionIndex': apply_formatter_if(is_not_null, to_integer_if_hex), 'transactionHash': to_hexbytes(32), 'cumulativeGasUsed': to_integer_if_hex, 'status': to_integer_if_hex, 'gasUsed': to_integer_if_hex,