erc7730.convert.calldata.v1.map module
Conversion of map lookups to device side maps: a MAP_REF value, looked up by the device in MAP_ENTRY structs.
The device reads the key from the transaction, then looks up the MAP_ENTRY provided by the wallet whose key matches it byte for byte, so each map key is encoded exactly as the device reads the key value:
a static calldata value is a whole calldata chunk (ABI encoding on 32 bytes)
a dynamic calldata value (bytes, string) is its raw content
a sliced calldata value is the slice of the above
the chain id is a 64 bits big endian integer, the sender / target addresses are 20 bytes, the native value is a 256 bits big endian integer
In a typed message, the key is the leaf as the host sends it (see “Leaf encoding” in doc/eip712.md): an integer in its
minimal big-endian form (7 is 0x07), a bytesN on exactly N bytes, an address on 20 bytes.
See doc/tlv_structs.md#map_entry in https://github.com/LedgerHQ/app-ethereum for specifications of these structs.
- class erc7730.convert.calldata.v1.map.MapEntries(chain_id: int | None, address: str | None, selector: ~typing.Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Selector', description='An Ethereum contract function identifier, in 4 bytes, hex encoded form.', metadata=[MinLen(min_length=10), MaxLen(max_length=10), _PydanticGeneralMetadata(pattern='^0x[a-z0-9]+$')]), ~erc7730.common.pydantic.ErrorTypeLabel(func=~erc7730.common.pydantic.ErrorTypeLabel._validator.<locals>.validate, json_schema_input_type=PydanticUndefined)] | None = None, domain_separator: ~typing.Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Hexadecimal string', description='A byte array encoded as an hexadecimal string.', metadata=[_PydanticGeneralMetadata(pattern='^0x[a-f0-9]+$')]), ~pydantic.functional_validators.BeforeValidator(func=~erc7730.model.types.<lambda>, json_schema_input_type=PydanticUndefined), ~erc7730.common.pydantic.ErrorTypeLabel(func=~erc7730.common.pydantic.ErrorTypeLabel._validator.<locals>.validate, json_schema_input_type=PydanticUndefined)] | None = None, primary_type_hash: ~typing.Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Hexadecimal string', description='A byte array encoded as an hexadecimal string.', metadata=[_PydanticGeneralMetadata(pattern='^0x[a-f0-9]+$')]), ~pydantic.functional_validators.BeforeValidator(func=~erc7730.model.types.<lambda>, json_schema_input_type=PydanticUndefined), ~erc7730.common.pydantic.ErrorTypeLabel(func=~erc7730.common.pydantic.ErrorTypeLabel._validator.<locals>.validate, json_schema_input_type=PydanticUndefined)] | None = None)[source]View on GitHub
Bases:
objectDevice side maps of a calldata descriptor, bound to a single chain and contract and either a selector (transaction), or the domain separator and primary type hash of the message (EIP-712 message).
Map ids are allocated per descriptor: a map looked up several times with the same key and value encodings shares its id and MAP_ENTRY structs, a map looked up with different encodings (for instance its values read as addresses in one field and as strings in another) gets one id per encoding.
- map_ref(value_map: ResolvedValueMap, abi_type: ABIDataType, convert_path: Callable[[DataPath, OutputAdder], CalldataDescriptorValuePathV1 | None], out: OutputAdder) CalldataDescriptorValueMapRefV1 | None[source]View on GitHub
Convert a map lookup to a MAP_REF value, and register the MAP_ENTRY structs of the map.
- Parameters:
value_map – resolved map lookup
abi_type – data type the map values are encoded with
convert_path – strategy converting the key data path to a calldata value
out – error handler
- Returns:
MAP_REF value, or None on error
- erc7730.convert.calldata.v1.map.encode_map_keys(value_map: ResolvedValueMap, convert_path: Callable[[DataPath, OutputAdder], CalldataDescriptorValuePathV1 | None], out: OutputAdder) tuple[CalldataDescriptorValuePathV1, dict[str, bytes]] | None[source]View on GitHub
Convert the key path of a map lookup to the value the device reads the key from, and encode the map keys the way the device reads that value.
- Parameters:
value_map – resolved map lookup
convert_path – strategy converting the key data path to a calldata value
out – error handler
- Returns:
value the device reads the key from, and encoded keys indexed by source key, or None on error