erc7730.convert.calldata.v1.enum module

Conversion of ERC-7730 enum definitions to calldata descriptor instructions.

erc7730.convert.calldata.v1.enum.convert_enums(chain_id: int | None, address: str | None, enums: dict[~typing.Annotated[str, FieldInfo(annotation=NoneType, required=True, title='Id', description='An internal identifier that can be used either for clarity specifying what the element is or as a reference in device specific sections.', examples=['some_identifier'], metadata=[MinLen(min_length=1)]), ~erc7730.common.pydantic.ErrorTypeLabel(func=~erc7730.common.pydantic.ErrorTypeLabel._validator.<locals>.validate, json_schema_input_type=PydanticUndefined)], ~typing.Annotated[dict[str, str], FieldInfo(annotation=NoneType, required=True, title='Enum Definition', description='A mapping of enum values to human readable strings.', examples=[{'1': 'stable', '2': 'variable'}], metadata=[MinLen(min_length=1), MaxLen(max_length=32)])]] | 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) → list[CalldataDescriptorInstructionEnumValueV1][source]View on GitHub

Convert descriptor enum definitions to calldata descriptor enum value instructions.

@param chain_id: chain id the enums are bound to @param address: contract address the enums are bound to @param enums: descriptor enum definitions @param selector: function selector the enums are bound to (transactions) @param domain_separator: domain separator the enums are bound to (EIP-712 messages) @param primary_type_hash: primary type hash the enums are bound to (EIP-712 messages) @return: instructions for each enum entry

erc7730.convert.calldata.v1.enum.enum_ordinal(ordinal: str) → int[source]View on GitHub

Value the device compares an enum entry against.

Parameters:

ordinal – enum key, as written in the descriptor

Returns:

the numeric field value it stands for

Raises:

ValueError – if the key is neither decimal nor a boolean literal