Skip to content

Fix five registry bugs: nested interpolatedIntent, chain names, wide chain IDs, byte slices, map references - #27

Merged
llbartekll merged 6 commits into
llbartekll:mainfrom
manuelwedler:claude/clear-signing-sdk-bugs-0b8b60
Oct 29, 2026
Merged

llbartekll merged 6 commits into
llbartekll:mainfrom
manuelwedler:claude/clear-signing-sdk-bugs-0b8b60

Conversation

@manuelwedler

Copy link
Copy Markdown
Contributor

Fixes five bugs in the SDK and the cs-test runner that the ERC-7730 registry hits with the runner pinned at 65af228. Each fix is its own commit with a test, so the PR can be reviewed one commit at a time. I can split it into five PRs if you prefer.

All checks pass: cargo fmt --check, cargo clippy --workspace --all-targets [--features uniffi,github-registry] -D warnings, cargo test --workspace (480 tests).

Registry check: I ran this branch and 65af228 on every testsv2 file of manuelwedler/clear-signing-erc7730-registry@21a929d (2988 cases, with --registry). Two cases go from fail to pass (blast L1BlastBridge, bug 4). No case regresses. The one case that still fails (rarible Meta Transaction, EIP-712 owner) also fails on 65af228 and is not part of this PR.

1. Nested interpolatedIntent (c6dd9bd)

The test schema allows interpolatedIntent in a nested rendered output (definitions.renderedOutput). cs-test rejected such a test file (NestedExpected has deny_unknown_fields), and the engine did not render the string for a nested call.

  • DisplayEntry::Nested has a new interpolated_intent field. Calldata and EIP-712 containers render the inner format's interpolatedIntent with the same rules as the top level.
  • NestedExpected accepts interpolatedIntent. compare.rs compares it when the expected output has it, and the mismatch names the nested path. results.json emits it. (owner was already in NestedExpected and compared.)
  • FFI change: the Nested variant has one more field. I regenerated bindings/swift/clear_signing.swift, updated the React Native TS bindings in the generator's own style (no npm ci here, so please let the release drift guard confirm), and updated the three .nested(...) patterns in the wallet app.

Test: the 23 cases of docs/top-contracts/nested-tests/ from the registry commit above, with their descriptors, are vendored as cs-test regressions (base, blast, pendle). There is also a spec-compliance parity test.

2. Chain names (f11ff3c)

chain_name() had 16 chains. The table is now generated from the name fields of https://chainid.network/chains.json by scripts/generate_chain_names.py, in the same way as the native currency table. An unknown chain ID still renders as Chain <id>.

Test: 999 → Wanchain Testnet, 81457 → Blast, 59144 → Linea.

3. Chain IDs above 64 bits (b495ff3)

  • chainId format: the value is parsed as an unsigned 256-bit integer. An ID above u64 renders as Chain <decimal> (it was Chain 0).
  • tokenAmount / tokenTicker with a chainIdPath that holds such an ID: the token is not looked up on the signing chain any more. The raw value is shown and token_metadata_not_found / token_ticker_not_found is emitted.
  • EIP-712 failed the whole render on the same input ("does not fit into u64"). It now follows the calldata rules. A parity test covers both.

4. Byte slice past the end of the data (9f5c075)

"_extraData.[0:32]" rendered <unresolved> when the bytes were empty or shorter than the slice. The spec does not define this case. This PR uses the Sourcify runner's behavior. Proposed rule for the spec:

A byte slice [start:end] clamps to the available bytes. A negative bound counts from the end of the bytes. Each bound is limited to 0..=len. If start >= end, the result is empty bytes. Empty bytes decode as 0 for integer formats.

An index out of range, and array slices, still resolve to nothing. Calldata and EIP-712 paths use the same rule (path::apply_byte_access).

Test: registry/blast/calldata-L1BlastBridge.json with its testsv2 file. "bridgeERC20 - chain 1" and "bridgeERC20-steth - chain 1" render 0 DAI. There is also a parity test.

5. Spec map references (bf5f6ab)

The spec form is now supported: a parameter {"map": "$.metadata.maps.<name>", "keyPath": "<path>"} and a map {"$keyType": ..., "values": {...}}.

  • It works for every parameter that takes a constant in the v2 schema: token, chainId, callee, selector, amount, spender, collection. This covers calldata and EIP-712 rendering, nested calldata, interpolatedIntent, and the nested-descriptor resolver.
  • A key that is not in the map is an invalid-descriptor error (FormatFailure::InvalidDescriptor), because the spec says "the wallet MUST consider the 7730 file invalid for the transaction".
  • FormatParams keeps its field types. A map reference goes into a new map_refs field, through a manual serde impl (remote = "Self"). The old entries / mapReference value maps still work (entries is an alias of values).

The spec is ambiguous here. These forms are all accepted:

  • The ERC example files write key where the spec text writes keyPath.
  • The inline example in the spec text writes "token": "$.metadata.maps.underlyingToken" and puts keyPath on the map itself.
  • A key matches exactly first, then case-insensitively (hex), then by equal integer value ("1" = "0x01").

Test: assets/erc-7730/example-maps.json and example-maps-pools.json of the ERC, vendored verbatim, on chains 1, 137 and 42161. A key that is not in the map gives an invalid-descriptor error. There are also a parity test for token / chainId / nested callee, a resolver test and parser tests.

Other

  • dfb01d5: clippy 1.95 reports collapsible_match in tests/safe_integration.rs on main. This commit fixes it so that -D warnings passes.
  • Not changed (adjacent, out of scope): a nested-calldata chainIdPath above u64 still falls back to the signing chain in resolve_nested_chain_id and in the resolver.

🤖 Generated with Claude Code

Clippy 1.95 reports collapsible_match in safe_integration.rs on main, so
cargo clippy -D warnings fails before any other change.
The v2 test schema allows interpolatedIntent in a nested rendered output
(definitions.renderedOutput), and the Sourcify runner requires it. The
engine did not render it for a nested call, and cs-test rejected a test
file that had it (NestedExpected has deny_unknown_fields).

- DisplayEntry::Nested has a new interpolated_intent field. Calldata and
  EIP-712 containers render the inner format's interpolatedIntent with the
  same rules as the top level.
- NestedExpected accepts interpolatedIntent. compare.rs compares it when
  the expected output has it, and the mismatch names the nested path.
- results.json emits the nested interpolatedIntent.
- Swift bindings, React Native TS bindings and the wallet app follow the
  new enum field.

Tests: the 23 cases of docs/top-contracts/nested-tests/ in
manuelwedler/clear-signing-erc7730-registry@21a929d (base, blast, pendle,
with their descriptors) are vendored as cs-test registry regressions.
chain_name() had a hand-written table of 16 chains, so every other chain
rendered as "Chain <id>". The spec converts the value "to a Blockchain
name using EIP-155 reference values". Generate the full table from the
name fields of https://chainid.network/chains.json with
scripts/generate_chain_names.py (same pattern as the native currency
table). An unknown chain ID still renders as "Chain <id>".

Test: 999 renders "Wanchain Testnet", 81457 "Blast", 59144 "Linea".
A chainId value above u64 rendered as "Chain 0", and a tokenAmount or
tokenTicker whose chainIdPath held such a value looked up the token on
the signing chain, so a wrong token could be shown.

- chainId format: parse the value as an unsigned 256-bit integer. An ID
  above u64 is not in the EIP-155 list and renders as "Chain <decimal>".
- tokenAmount / tokenTicker: when chainIdPath holds an ID above u64, do
  not resolve the token. Show the raw value and emit
  token_metadata_not_found / token_ticker_not_found.

EIP-712 had the same input fail the whole render ("does not fit into
u64"); it now follows the calldata rules. A spec-compliance parity test
covers both.
A field path with a byte slice, for example "_extraData.[0:32]", rendered
"<unresolved>" when the bytes were empty or shorter than the slice. The
Sourcify runner renders the empty slice as 0 for a tokenAmount.

The spec does not define this case. Proposed rule (aligned with the
Sourcify runner and Python slicing), for byte slices only:
- A negative bound counts from the end of the bytes.
- Each bound is limited to 0..=len.
- start >= end gives empty bytes.
- Empty bytes decode as 0 for integer formats.
An index out of range, and array slices, still resolve to nothing.

Calldata and EIP-712 paths use the same rule.

Test: registry/blast/calldata-L1BlastBridge.json with its testsv2 file
from manuelwedler/clear-signing-erc7730-registry@21a929d; the cases
"bridgeERC20 - chain 1" and "bridgeERC20-steth - chain 1" render "0 DAI".
The spec (metadata.maps) lets a parameter that takes a constant be a map
reference {"map": "$.metadata.maps.<name>", "keyPath": "<path>"}, where
a map is {"$keyType": ..., "values": {...}}. The SDK expected a string
in FormatParams.token and had its own map model ("entries" +
"mapReference"), so the spec form did not parse.

- MapDefinition reads $keyType and values. "entries" stays an alias, so
  the old mapReference value maps keep working.
- FormatParams moves a map reference given for token, chainId, callee,
  selector, amount, spender or collection into map_refs. Rendering
  (calldata and EIP-712, also nested calldata and interpolatedIntent)
  and the nested-descriptor resolver replace it with the map value for
  the key read at keyPath.
- A key that is not in the map is an invalid-descriptor error, as the
  spec requires ("the wallet MUST consider the 7730 file invalid for the
  transaction").

Spec ambiguities, handled leniently:
- The ERC example files write "key" in place of "keyPath"; both work.
- The inline example in the spec text writes the map path as a plain
  string and puts keyPath on the map; that form works too.
- Key match: exact, then case-insensitive (hex), then equal integer.

Tests: assets/erc-7730/example-maps.json and example-maps-pools.json of
the ERC (vendored verbatim), a calldata/EIP-712 parity test, a resolver
test and parser tests.
@llbartekll
llbartekll merged commit 8bfe6b4 into llbartekll:main Oct 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants