From 8fa3ed3e422da4679b0c2a689e4483cb3d23dae0 Mon Sep 17 00:00:00 2001 From: Maroutis <118286466+Maroutis@users.noreply.github.com> Date: Thu, 26 Mar 2026 16:01:47 +0100 Subject: [PATCH] fix: accept scalar v2 visibility conditions Align the v2 visibility models with the schema so mustBe/ifNotIn accept numbers and booleans instead of rejecting valid descriptors during lint resolution. Made-with: Cursor --- src/erc7730/model/input/v2/display.py | 4 ++-- src/erc7730/model/resolved/v2/display.py | 4 ++-- ...field_with_visibility_conditions_input.json | 18 ++++++++++++++++++ ...ld_with_visibility_conditions_resolved.json | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/erc7730/model/input/v2/display.py b/src/erc7730/model/input/v2/display.py index e9ecda91..f6672c95 100644 --- a/src/erc7730/model/input/v2/display.py +++ b/src/erc7730/model/input/v2/display.py @@ -31,13 +31,13 @@ class InputVisibilityConditions(Model): Complex visibility conditions for field display rules. """ - ifNotIn: list[str] | None = Field( + ifNotIn: list[ScalarType | None] | None = Field( None, title="If Not In", description="Display this field only if its value is NOT in this list.", ) - mustBe: list[str] | None = Field( + mustBe: list[ScalarType | None] | None = Field( None, title="Must Be", description="Skip displaying this field but its value MUST match one of these values.", diff --git a/src/erc7730/model/resolved/v2/display.py b/src/erc7730/model/resolved/v2/display.py index f0db295e..d959f391 100644 --- a/src/erc7730/model/resolved/v2/display.py +++ b/src/erc7730/model/resolved/v2/display.py @@ -32,13 +32,13 @@ class ResolvedVisibilityConditions(Model): Complex visibility conditions for field display rules (resolved). """ - ifNotIn: list[str] | None = Field( + ifNotIn: list[ScalarType | None] | None = Field( None, title="If Not In", description="Display this field only if its value is NOT in this list.", ) - mustBe: list[str] | None = Field( + mustBe: list[ScalarType | None] | None = Field( None, title="Must Be", description="Skip displaying this field but its value MUST match one of these values.", diff --git a/tests/v2/convert/resolved/data/field_with_visibility_conditions_input.json b/tests/v2/convert/resolved/data/field_with_visibility_conditions_input.json index 9f240906..ec452fea 100644 --- a/tests/v2/convert/resolved/data/field_with_visibility_conditions_input.json +++ b/tests/v2/convert/resolved/data/field_with_visibility_conditions_input.json @@ -27,6 +27,24 @@ "0x0000000000000000000000000000000000000000" ] } + }, + { + "path": "destinationChainId", + "label": "Destination Chain", + "visible": { + "mustBe": [ + 100 + ] + } + }, + { + "path": "hasSourceSwaps", + "label": "Has Source Swaps", + "visible": { + "mustBe": [ + true + ] + } } ] } diff --git a/tests/v2/convert/resolved/data/field_with_visibility_conditions_resolved.json b/tests/v2/convert/resolved/data/field_with_visibility_conditions_resolved.json index e14ff398..859c6256 100644 --- a/tests/v2/convert/resolved/data/field_with_visibility_conditions_resolved.json +++ b/tests/v2/convert/resolved/data/field_with_visibility_conditions_resolved.json @@ -27,6 +27,24 @@ "0x0000000000000000000000000000000000000000" ] } + }, + { + "label": "Destination Chain", + "path": "#.destinationChainId", + "visible": { + "mustBe": [ + 100 + ] + } + }, + { + "label": "Has Source Swaps", + "path": "#.hasSourceSwaps", + "visible": { + "mustBe": [ + true + ] + } } ] }