Repository navigation
Conversation
A group with an explicit "sequential" was displayed in bundled order when all its fields iterate over arrays. The descriptor model could not tell an absent `iteration` key from an explicit "sequential", and the special case for a group whose path ends with `.[]` applied to both. - `FieldGroup.iteration` and `DisplayField::Scope.iteration` are now `Option<Iteration>`; `None` means the key is absent. - Explicit "sequential": each array is displayed in full, in field order. - Absent key: if every field of the group iterates over an array, the elements are paired by index, as before. Arrays of different lengths are now an error, as in bundled mode. Every other group keeps its output. - Explicit "bundled": unchanged. Fixes llbartekll#28 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Why
A group with
"iteration": "sequential"gives the same lines as a group with"iteration": "bundled", if all the fields of the group are arrays. ERC-7730 says that sequential mode shows each array fully, one after the other.Fixes #28 (a group with
"iteration": "sequential"is displayed in bundled order).Example
The function is
disperseToken(address token, address[] recipients, uint256[] values). Alice gets 100 USDC and Bob gets 50 USDC.{ "iteration": "sequential", "fields": [ { "path": "recipients.[]", "label": "To" }, { "path": "values.[]", "label": "Amount" } ] }iterationbundledsequentialOnly the last row changes.
Cause
The type
FieldGroupgave an absent key the default valueSequential. So the code could not tell an absent key from an explicit"sequential".The
Sequentialbranch ofrender_group_kindhas a special case that shows each element fully before the next element. This special case is necessary for a group whosepathends with.[]and that has no key, for example"path": "allowances.[]"with the fieldsassetandamount. It also applied to an explicit"sequential".The change
1. The model keeps the absent key. In
types/display.rs, the fielditerationofFieldGroupand ofDisplayField::Scopeis now anOption:2. The two render functions have three cases.
render_group_kindinengine.rsandrender_typed_group_kindineip712.rsget the same change:The rule for each case:
sequentialbundledWhy a group with no arrays keeps its output. The
Bundledbranch returns the errorbundled groups cannot mix array-expanded and scalar fieldsfor a field that is not an array. Groups with no arrays and no key exist in the registry. Two examples are the group on#._settingsinregistry/flare/calldata-PollingFoundation-Flare.jsonand the group with the label "Access" inregistry/slice/eip712-erc8128-delegation.json. So an absent key does not go to theBundledbranch. It keeps the code of the oldSequentialbranch.The one change for an absent key. If all fields are arrays and the arrays have different lengths, the result is now the error
bundled groups require all array-expanded fields to have the same length. Before, the code showed the elements that exist and gave no error. The elements cannot be paired in that case, and bundled mode already returns this error. Tell me if you prefer the old behaviour, and I remove this check.Relation to the specification
The draft pull request ethereum/ERCs#2165 (require
iterationfor two or more array fields, default tobundled) proposes that an absent key meansbundled. It is a draft and it is not merged.This pull request does not depend on that draft. The fix for an explicit
"sequential"follows the specification of today. The behaviour for an absent key stays as it is in this library, and it agrees with the draft.Effect on library users
FieldGroup.iterationand ofDisplayField::Scope { iteration }changes fromIterationtoOption<Iteration>. Code that builds or reads these values directly must change. Descriptor JSON is read as before.DisplayEntry::Group { label, iteration: GroupIteration, items }does not change. A group with no key and no label still gives flatDisplayEntry::Itementries.FieldGroup.pathends with.[]and that writes an explicit"sequential"now shows field by field, because the path joins the fields first. The only registry descriptor with this shape isregistry/pendle/calldata-PendleRouterV4.json. All fields of its 32 groups have"visible": "never", so no line changes. A registry pull request, ethereum/clear-signing-erc7730-registry#3211 (remove the unused iteration key from the Router V4 limit order groups), removes that key.Tests
Seven new tests in
crates/clear-signing/tests/spec_compliance.rs. Six of them run the calldata path and the EIP-712 path with the same expected lines.maintest_group_explicit_sequential_displays_each_array_in_fulltest_group_explicit_sequential_allows_unequal_array_lengthstest_group_without_iteration_unequal_array_lengths_errorstest_group_explicit_bundled_pairs_array_items_by_indextest_group_without_iteration_pairs_array_items_by_indextest_array_path_group_without_iteration_displays_element_by_elementtest_group_without_iteration_mixed_scalar_field_keeps_field_orderNo existing test changed.
cargo fmt --checkcargo clippy -p clear-signing --all-targets --features uniffi,github-registry -- -D warningscargo test -p clear-signing --features uniffi,github-registrycargo testRegression check on the registry
I built
cs-testfrommainat8bfe6b4and from this branch. I ran both on alltestsv2files ofethereum/clear-signing-erc7730-registryand compared the status and the rendered fields of each case.mainsequentialkey on its 32 groupsThe 2 failures are the same cases on both builds.
The Disperse descriptor, test
disperseToken - chain 1with five recipients, with the key of its group changed:iterationmainbundledsequential🤖 Generated with Claude Code