feat(schema): add --v2, so the v2 model's schema can be printed - #347
Open
venugopalanvip wants to merge 1 commit into
Open
venugopalanvip wants to merge 1 commit into
venugopalanvip wants to merge 1 commit into
Conversation
`erc7730 schema` was the only command with no way to reach the v2 models. `lint`, `resolve`, `calldata` and `convert` all take --v2 or detect it from $schema; `schema` printed the v1 model either way, so the schema that `erc7730 lint --v2` actually enforces could not be obtained from the tool. That is the schema worth having. A descriptor is validated twice by the clear-signing registry: against `specs/erc7730-v2.schema.json`, which is maintained by hand, and against these models, by `erc7730 lint`. When the two disagree the descriptor passes one check and fails the other, which is what issue LedgerHQ#338 is. Printing the model's schema is how that comparison gets made. The flag switches both forms, so `schema resolved --v2` works too. Tests cover all four combinations and assert the flag reaches the v2 model rather than only that a schema was printed: `mustMatch` is a v2 visibility rule and `excluded` a v1 field, so each name appears in exactly one of the two schemas. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gap
schemais the only command with no way to reach the v2 models:lint--v2, or detected from$schemaresolve--v2, or detectedcalldata--v2, or detectedconvert erc7730-to-eip712schemaSo
erc7730 lint --v2validates against the v2 models, but the schema it enforces could not be obtained from the tool at all.Why that schema is the one worth printing
A descriptor in the clear-signing registry is validated twice, against two independently maintained things:
specs/erc7730-v2.schema.json, written by hand, in thevalidate JSON schemasjob;erc7730 lint, in thevalidate descriptorsjob.When the two disagree, a descriptor passes one check and fails the other. That is exactly #338:
erc7730 generateemitsmetadata.info.legalName,lintaccepts it, and the registry's schema rejects it. Printing the model's schema is how a comparison like that gets made in the first place.The change
A
--v2flag, matching howlintdeclares its own, and switching both forms —schema input --v2andschema resolved --v2. The v2 imports are local to the branch, as in the other commands.Tests
All four combinations, plus one that checks the flag actually reaches the v2 model rather than only that a schema was printed — exit code 0 would not have caught a wiring mistake here, since both models are named
InputERC7730Descriptor:mustMatchis a v2 visibility rule andexcludeda v1 field, so each name appears in exactly one of the two schemas.One thing worth knowing
Both models carry the same
title(InputERC7730Descriptor), so the two schemas are not self-identifying — only their contents differ. Anyone diffing them has to track which is which. Renaming a model's title is a wider change than this flag, so I have left it; worth a follow-up if you would rather the output named its version.