erc7730.model.path module

pydantic model erc7730.model.path.Array[source]View on GitHub

Bases: Model

A path component designating all elements of an array (in which case, the path targets multiple values).

Fields:
field type: Literal['array'] = 'array'

The path component type identifier (discriminator for path components discriminated union).

pydantic model erc7730.model.path.ArrayElement[source]View on GitHub

Bases: Model

A path component designating a single element of an array.

Fields:
field index: Annotated[int, FieldInfo(annotation=NoneType, required=True, title='Array index', description='Index of an element in an array. An index can be negative to count from the end of the array.', metadata=[Ge(ge=-32767), Le(le=32768)])] [Required]

The index of the element in the array. It can be negative to count from the end of the array.

Constraints:
  • ge = -32767

  • le = 32768

field type: Literal['array_element'] = 'array_element'

The path component type identifier (discriminator for path components discriminated union).

pydantic model erc7730.model.path.ArraySlice[source]View on GitHub

Bases: Model

A path component designating an element range of an array (in which case, the path targets multiple values).

Fields:
Validators:
  • _validate » all fields

field end: Annotated[int, FieldInfo(annotation=NoneType, required=True, title='Array index', description='Index of an element in an array. An index can be negative to count from the end of the array.', metadata=[Ge(ge=-32767), Le(le=32768)])] [Required]

The end index of the slice. Must be positive and greater than the start index.

Constraints:
  • ge = 0

  • le = 32768

Validated by:
  • _validate

field start: Annotated[int, FieldInfo(annotation=NoneType, required=True, title='Array index', description='Index of an element in an array. An index can be negative to count from the end of the array.', metadata=[Ge(ge=-32767), Le(le=32768)])] [Required]

The start index of the slice. Must be positive and lower than the end index.

Constraints:
  • ge = 0

  • le = 32768

Validated by:
  • _validate

field type: Literal['array_slice'] = 'array_slice'

The path component type identifier (discriminator for path components discriminated union).

Validated by:
  • _validate

class erc7730.model.path.ContainerField(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]View on GitHub

Bases: StrEnum

Path applying to the container of the structured data to be signed.

Such paths are prefixed with “@”.

FROM = 'from'

The address of the sender of the transaction / signer of the message.

TO = 'to'

The destination address of the containing transaction, ie the target smart contract address.

VALUE = 'value'

The native currency value of the transaction containing the structured data.

pydantic model erc7730.model.path.ContainerPath[source]View on GitHub

Bases: Model

Path applying to the container of the structured data to be signed.

Such paths are prefixed with “@”.

Fields:
field field: ContainerField [Required]

The referenced field in the container, only some well-known values are allowed.

field type: Literal['container'] = 'container'

The path type identifier (discriminator for paths discriminated union).

pydantic model erc7730.model.path.DataPath[source]View on GitHub

Bases: Model

Path applying to the structured data schema (ABI path for contracts, path in the message types itself for EIP-712).

A data path can reference multiple values if it contains array elements or slices.

Such paths are prefixed with “#”.

Fields:
field absolute: bool [Required]

Whether the path is absolute (starting from the structured data root) or relative (starting fromthe current field).

field elements: list[Annotated[Field | ArrayElement | ArraySlice | Array, FieldInfo(annotation=NoneType, required=True, title='Data Path Element', description='An element of a data path, applying to the structured data schema (ABI path for contracts, pathin the message types itself for EIP-712)', discriminator='type')]] [Required]

The path elements, as a list of references to be interpreted left to right from the structureddata root to reach the referenced value(s).

Constraints:
  • min_length = 1

field type: Literal['data'] = 'data'

The path type identifier (discriminator for paths discriminated union).

pydantic model erc7730.model.path.DescriptorPath[source]View on GitHub

Bases: Model

Path applying to the current file describing the structured data formatting, after merging with includes.

A descriptor path can only reference a single value in the document.

Such paths are prefixed with “$”.

Fields:
field elements: list[Annotated[Field | ArrayElement, FieldInfo(annotation=NoneType, required=True, title='Descriptor Path Element', description='An element of a descriptor path, applying to the current file describing the structured dataformatting, after merging with includes.', discriminator='type')]] [Required]

The path elements, as a list of references to be interpreted left to right from the current fileroot to reach the referenced value.

Constraints:
  • min_length = 1

field type: Literal['descriptor'] = 'descriptor'

The path type identifier (discriminator for paths discriminated union).

pydantic model erc7730.model.path.Field[source]View on GitHub

Bases: Model

A path component designating a field in a structured data schema.

Fields:
field identifier: str [Required]

The identifier of the referenced field in the structured data schema.

Constraints:
field type: Literal['field'] = 'field'

The path component type identifier (discriminator for path components discriminated union).

class erc7730.model.path.PathTransformer(visit_tokens: bool = True)[source]View on GitHub

Bases: Transformer_InPlaceRecursive

Visitor to transform the parsed path AST into path domain model objects.

absolute_data_path(ast: Any) DataPath[source]View on GitHub
array(ast: Any) Array[source]View on GitHub
array_element(ast: Any) ArrayElement[source]View on GitHub
array_index(ast: Any) Annotated[int, FieldInfo(annotation=NoneType, required=True, title='Array index', description='Index of an element in an array. An index can be negative to count from the end of the array.', metadata=[Ge(ge=-32767), Le(le=32768)])][source]View on GitHub
array_slice(ast: Any) ArraySlice[source]View on GitHub
container_field(ast: Any) ContainerField[source]View on GitHub
container_path(ast: Any) ContainerPath[source]View on GitHub
descriptor_path(ast: Any) DescriptorPath[source]View on GitHub
field(ast: Any) Field[source]View on GitHub
relative_data_path(ast: Any) DataPath[source]View on GitHub
erc7730.model.path.parse_path(path: str) ContainerPath | DataPath | DescriptorPath[source]View on GitHub

Parse a path string into a domain model object.

Parameters:

path – the path input string

Returns:

an union of all possible path types

Raises:
  • ValueError – if the input string is not a valid path

  • Exception – if the path parsing fails for an unexpected reason