Skip to content

feat(v2): update spec and add support for visibility rules and constraints - #335

Open
paoun-ledger wants to merge 1 commit into
mainfrom
fix/v2-visibility-mustmatch
Open

feat(v2): update spec and add support for visibility rules and constraints#335
paoun-ledger wants to merge 1 commit into
mainfrom
fix/v2-visibility-mustmatch

Conversation

@paoun-ledger

Copy link
Copy Markdown
Collaborator

Align spec with latest V2 from the registry.
Add support for visibility and constraints, already supported by the device and needed by LedgerHQ/internal-erc7730-registry#28

@paoun-ledger
paoun-ledger requested a review from a team as a code owner August 27, 2026 16:47
@paoun-ledger
paoun-ledger force-pushed the fix/v2-visibility-mustmatch branch from e3a029f to b50a462 Compare August 27, 2026 16:55
@paoun-ledger
paoun-ledger requested a lite review from Copilot August 27, 2026 16:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the repository’s ERC-7730 v2 implementation with the latest registry V2 spec by adding first-class support for visibility rules/constraints and tightening parts of the v2 input/resolved models to use explicit enums.

Changes:

  • Added v2 model-level enums for simple visibility rules and array iteration strategy, and applied them to input/resolved models.
  • Implemented calldata v1 conversion support for v2 visibility conditions by mapping them to FIELD VISIBLE/CONSTRAINT tags and validating constraint payloads.
  • Updated the v2 JSON schema and expanded test coverage to pin enum/constraint validation and conversion behavior.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/v2/model/test_enum_constraints.py Adds tests to enforce schema/model enum constraints (iteration strategy and address-name types).
tests/v2/model/init.py Test package marker (no behavioral change).
tests/v2/convert/resolved/test_convert_input_to_resolved.py Updates test case descriptions to reflect mustMatch naming.
tests/v2/convert/resolved/data/field_with_visibility_conditions_resolved.json Renames visibility condition key to mustMatch in resolved fixture.
tests/v2/convert/resolved/data/field_with_visibility_conditions_input.json Renames visibility condition key to mustMatch in input fixture.
tests/v2/convert/resolved/data/definition_no_label_visible_must_be_resolved.json Renames visibility condition key to mustMatch in resolved fixture.
tests/v2/convert/resolved/data/definition_no_label_visible_must_be_input.json Renames visibility condition key to mustMatch in input fixture.
tests/v2/convert/calldata/test_convert_fields.py Adds conversion/serialization tests for visibility conditions and constraints in calldata output.
src/erc7730/model/resolved/v2/display.py Types visibility/iteration and address-name types with explicit enums; renames mustBemustMatch.
src/erc7730/model/input/v2/unions.py Updates discriminator to detect mustMatch condition objects.
src/erc7730/model/input/v2/format.py Introduces VisibilityRule and IterationStrategy enums for v2.
src/erc7730/model/input/v2/display.py Applies new enums to v2 input models and renames mustBemustMatch.
src/erc7730/model/calldata/v1/instruction.py Adds FIELD visibility/constraint modeling and validation (max constraints, required constraints, size checks).
src/erc7730/convert/resolved/v2/references.py Updates hidden-field detection and visibility resolution for mustMatch.
src/erc7730/convert/resolved/v2/convert_erc7730_input_to_resolved.py Updates visibility resolution to emit mustMatch.
src/erc7730/convert/calldata/v1/tlv.py Adds TLV tags for FIELD visibility/constraint emission in FIELD serialization.
src/erc7730/convert/calldata/convert_erc7730_v2_input_to_calldata.py Maps v2 visibility conditions into calldata FIELD visibility/constraints and encodes constraint values.
specs/erc7730-v2.schema.json Updates schema draft/version and adds/adjusts visibility + reference override capabilities.
pyproject.toml Excludes schema JSONs from codespell scanning.
Suppressed comments (1)

specs/erc7730-v2.schema.json:325

  • "unresolvedProperties" is not a JSON Schema keyword (draft 2020-12). Validators will ignore it, so extra keys inside a map entry will be accepted unintentionally.
                        "additionalProperties": {
                            "type": ["string", "integer", "number", "boolean", "null"]
                        }
                    },
                    "unresolvedProperties": false
                }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread specs/erc7730-v2.schema.json
Comment thread specs/erc7730-v2.schema.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants