From a994546b7544a3a38b4093e64ed210a74154aec3 Mon Sep 17 00:00:00 2001 From: jnicoulaud-ledger <102984500+jnicoulaud-ledger@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:45:36 +0200 Subject: [PATCH] chore: update following spec changes (#59) * chore: update following spec changes see: - https://github.com/LedgerHQ/clear-signing-erc7730-registry/pull/32 - https://ledger.slack.com/archives/C07D03LRKHQ/p1728389147928859 * chore: update linter --- src/erc7730/lint/common/paths.py | 8 ++++++-- src/erc7730/model/display.py | 13 ++++++++----- src/erc7730/model/path.py | 5 ++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/erc7730/lint/common/paths.py b/src/erc7730/lint/common/paths.py index 884e4be..857e57e 100644 --- a/src/erc7730/lint/common/paths.py +++ b/src/erc7730/lint/common/paths.py @@ -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)) diff --git a/src/erc7730/model/display.py b/src/erc7730/model/display.py index 45b7280..97337d2 100644 --- a/src/erc7730/model/display.py +++ b/src/erc7730/model/display.py @@ -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( diff --git a/src/erc7730/model/path.py b/src/erc7730/model/path.py index fd8ca03..b0d6756 100644 --- a/src/erc7730/model/path.py +++ b/src/erc7730/model/path.py @@ -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.""" @@ -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)*