erc7730.convert.calldata.v1.eip712_schema module

Reconstruction of EIP-712 schema (EIP712_SCHEMA struct) from ERC-7730 v2 display.formats keys.

In ERC-7730 v2, the display.formats keys are EIP-712 encodeType strings (e.g. Order(address owner,Bridge bridge)Bridge(bytes4 sel,uint256 chainId)) from which the whole schema can be rebuilt. The EIP712Domain type is reconstructed separately from the descriptor domain / deployment information.

Referred to as “EIP712 v2” in the Ethereum app specifications (https://github.com/LedgerHQ/app-ethereum).

class erc7730.convert.calldata.v1.eip712_schema.EIP712DomainBinding(chain_id: int | None, address: str | None)[source]View on GitHub

Bases: object

Chain id and verifying contract of the domain of the messages, either of which may be unknown.

address: str | None
chain_id: int | None
class erc7730.convert.calldata.v1.eip712_schema.ParsedSolidityType(sol_type: CalldataDescriptorEIP712SolType, type_size: int | None, array_dimensions: list[int | None], struct_name: str | None)[source]View on GitHub

Bases: object

A Solidity type parsed into its base type, size and array dimensions.

array_dimensions: list[int | None]
sol_type: CalldataDescriptorEIP712SolType
struct_name: str | None
type_size: int | None
class erc7730.convert.calldata.v1.eip712_schema.ReconstructedSchema(primary_type: str, 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)], types: dict[str, list[tuple[str, str]]] = <factory>, structs: list[~erc7730.model.calldata.v1.eip712.CalldataDescriptorEIP712StructV1] = <factory>)[source]View on GitHub

Bases: object

A reconstructed EIP-712 schema for a single message primary type.

primary_type: str
primary_type_hash: validate, json_schema_input_type=PydanticUndefined)]
structs: list[CalldataDescriptorEIP712StructV1]
types: dict[str, list[tuple[str, str]]]
erc7730.convert.calldata.v1.eip712_schema.bind_domain(domain: ResolvedDomain | None, deployment: ResolvedDeployment | None, out: OutputAdder) → EIP712DomainBinding | None[source]View on GitHub

Resolve the chain id and verifying contract of the domain of the messages of a deployment.

The deployment provides them when the domain does not declare them, which is also the only source for a descriptor without deployment. A domain declaring a chain id or a verifying contract the deployment is not on is rejected, as no message of the deployment can have this domain.

Parameters:
  • domain – the resolved EIP-712 domain

  • deployment – the deployment the descriptor is generated for, if any

  • out – error handler

Returns:

the binding, or None on error

erc7730.convert.calldata.v1.eip712_schema.compute_domain_separator(domain_fields: list[tuple[str, str]], domain: ResolvedDomain | None, binding: EIP712DomainBinding, out: OutputAdder) → validate, json_schema_input_type=PydanticUndefined)] | None[source]View on GitHub

Compute the domain separator, hashStruct(domain), of the messages of one deployment.

Parameters:
  • domain_fields – the fields of the type of the domain (see reconstruct_domain_fields)

  • domain – the resolved EIP-712 domain, which holds the values of its name, version and salt

  • binding – chain id and verifying contract of the domain

  • out – error handler

Returns:

the domain separator, or None on error

erc7730.convert.calldata.v1.eip712_schema.parse_solidity_type(type_str: str) → ParsedSolidityType[source]View on GitHub

Parse a Solidity type string into base type, size and array dimensions.

Parameters:

type_str – a Solidity type (e.g. uint256, bytes32, address[3][], Person)

Returns:

the parsed type

erc7730.convert.calldata.v1.eip712_schema.reconstruct_domain_fields(domain: ResolvedDomain | None, has_deployments: bool) → list[tuple[str, str]][source]View on GitHub

Reconstruct the EIP712Domain type fields, in canonical EIP-712 order.

Parameters:
  • domain – the resolved domain, or None

  • has_deployments – whether the descriptor declares deployments (implying chainId + verifyingContract)

Returns:

ordered list of (type string, field name)

erc7730.convert.calldata.v1.eip712_schema.reconstruct_schema(encode_type_key: str, domain: ResolvedDomain | None, has_deployments: bool, out: OutputAdder) → ReconstructedSchema | None[source]View on GitHub

Reconstruct an EIP-712 schema from an encodeType format key and the descriptor domain / deployment info.

Parameters:
  • encode_type_key – an encodeType string from display.formats

  • domain – the resolved EIP-712 domain

  • has_deployments – whether the descriptor declares deployments

  • out – error handler

Returns:

the reconstructed schema, or None on error