erc7730.convert.calldata.v1.enum module

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

erc7730.convert.calldata.v1.enum.convert_enums(deployment: ~erc7730.model.resolved.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)], 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) → list[CalldataDescriptorInstructionEnumValueV1][source]View on GitHub

Convert descriptor enum definitions to calldata descriptor enum value instructions.

@param enums: descriptor enum definitions @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