block_formatter = apply_formatters_to_dict(BLOCK_FORMATTERS) SYNCING_FORMATTERS = { 'startingBlock': to_integer_if_hex, 'currentBlock': to_integer_if_hex, 'highestBlock': to_integer_if_hex, 'knownStates': to_integer_if_hex, 'pulledStates': to_integer_if_hex, } syncing_formatter = apply_formatters_to_dict(SYNCING_FORMATTERS) TRANSACTION_POOL_CONTENT_FORMATTERS = { 'pending': compose( curried.keymap(to_ascii_if_bytes), curried.valmap(transaction_result_formatter), ), 'queued': compose( curried.keymap(to_ascii_if_bytes), curried.valmap(transaction_result_formatter), ), } transaction_pool_content_formatter = apply_formatters_to_dict( TRANSACTION_POOL_CONTENT_FORMATTERS) TRANSACTION_POOL_INSPECT_FORMATTERS = { 'pending': curried.keymap(to_ascii_if_bytes), 'queued': curried.keymap(to_ascii_if_bytes),
state_dict = deep_merge(*state_dicts) else: assert TypeError("State definition must either be a mapping or a sequence") seen_keys = set(concat(d.keys() for d in state_dict.values())) bad_keys = seen_keys - {"balance", "nonce", "storage", "code"} if bad_keys: raise ValidationError( f"State definition contains the following invalid account fields: {', '.join(bad_keys)}" ) return state_dict normalize_storage = compose( curried.keymap(normalize_int), curried.valmap(normalize_int), ) normalize_state = compose( curried.keymap(to_canonical_address), curried.valmap(dict_normalizer({ "balance": normalize_int, "code": normalize_bytes, "nonce": normalize_int, "storage": normalize_storage }, required=[])), apply_formatter_if( lambda s: isinstance(s, Iterable) and not isinstance(s, Mapping), state_definition_to_dict