Skip to content

Commit

Permalink
chore: update following spec changes (#59)
Browse files Browse the repository at this point in the history
* chore: update following spec changes

see:
- LedgerHQ/clear-signing-erc7730-registry#32
- https://ledger.slack.com/archives/C07D03LRKHQ/p1728389147928859

* chore: update linter
  • Loading branch information
jnicoulaud-ledger authored Oct 8, 2024
1 parent a8d0f9d commit a994546
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/erc7730/lint/common/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ def append_paths(path: str, field: ResolvedField | None) -> None:
match field:
case ResolvedFieldDescription():
add_path(path, field.path)
if field.params and isinstance(field.params, TokenAmountParameters):
add_path(path, _remove_slicing(field.params.tokenPath).strip("."))
if (
(params := field.params)
and isinstance(params, TokenAmountParameters)
and (token_path := params.tokenPath) is not None
):
add_path(path, _remove_slicing(token_path).strip("."))
case ResolvedNestedFields():
for nested_field in field.fields:
append_paths(_append_path(path, field.path), cast(ResolvedField, nested_field))
Expand Down
13 changes: 8 additions & 5 deletions src/erc7730/model/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,18 @@ class TokenAmountParameters(Model):
Token Amount Formatting Parameters.
"""

tokenPath: str = Field(
title="Token Path", description="The path to the token address in the structured data, or in the ERC 7730 file."
tokenPath: str | None = Field(
title="Token Path",
description="Path reference to the address of the token contract. Used to associate correct ticker. If ticker"
"is not found or tokenPath is not set, the wallet SHOULD display the raw value instead with an"
'"Unknown token" warning.',
)

nativeCurrencyAddress: str | None = Field(
nativeCurrencyAddress: str | list[str] | None = Field(
default=None,
title="Native Currency Address",
description="An address equal to this value is interpreted as an amount in native currency rather than a"
"token.",
description="An address or array of addresses, any of which are interpreted as an amount in native currency"
"rather than a token.",
)

threshold: str | None = Field(
Expand Down
5 changes: 4 additions & 1 deletion src/erc7730/model/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class ContainerField(StrEnum):
VALUE = auto()
"""The native currency value of the transaction containing the structured data."""

FROM = auto()
"""The address of the sender of the transaction / signer of the message."""

TO = auto()
"""The destination address of the containing transaction, ie the target smart contract address."""

Expand Down Expand Up @@ -228,7 +231,7 @@ def __str__(self) -> str:
?descriptor_path_component: field | array_element
container_path: "@." container_field
!container_field: "to" | "value"
!container_field: "from" | "to" | "value"
?data_path: absolute_data_path | relative_data_path
absolute_data_path: "#." data_path_component ("." data_path_component)*
Expand Down

0 comments on commit a994546

Please sign in to comment.