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

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(deployment: ~erc7730.model.resolved.v2.context.ResolvedDeployment, 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)])[source]View on GitHub

Bases: object

Device side maps of a calldata descriptor (bound to a single deployment and selector).

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, abi: Annotated[ABIStruct | ABIStaticArray | ABIDynamicArray | ABIStaticLeaf | ABIDynamicLeaf, FieldInfo(annotation=NoneType, required=True, discriminator='type')], 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

  • abi – function ABI tree

  • out – error handler

Returns:

MAP_REF value, or None on error

erc7730.convert.calldata.v1.map.encode_map_keys(value_map: ResolvedValueMap, abi: Annotated[ABIStruct | ABIStaticArray | ABIDynamicArray | ABIStaticLeaf | ABIDynamicLeaf, FieldInfo(annotation=NoneType, required=True, discriminator='type')], 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

  • abi – function ABI tree

  • out – error handler

Returns:

value the device reads the key from, and encoded keys indexed by source key, or None on error