Add metadata.maps support - #67
Conversation
| "display": { | ||
| "formats": { | ||
| "wrap(address to, uint256 amount)": { | ||
| "$id": "wrap", |
There was a problem hiding this comment.
This key has a space after the comma. The ERC-7730 spec does not allow a space after a comma in a format key. The parser in this library removes the space, so the tests pass. But the registry lint tool will reject this key. Please change it to "wrap(address to,uint256 amount)". The same key is in calldata-ConfidentialWrapper.json.
Posted with Claude Code
| return { | ||
| warnings: [ | ||
| warn( | ||
| "DESCRIPTOR_NOT_APPLICABLE", |
There was a problem hiding this comment.
The PR description does not match the code. The description says: when a map lookup fails, the field falls back to raw with FORMAT_PARAM_RESOLUTION_ERROR. The code does something different. When a map lookup fails, the code emits DESCRIPTOR_NOT_APPLICABLE and drops the whole format. The test "abandons the whole format" checks this. I think the code is correct. The spec says the descriptor is invalid for that transaction. Please update the PR description to match the code.
Posted with Claude Code
There was a problem hiding this comment.
indeed, updated the PR description
|
Thank you. The implementation is clean. All map references are replaced in one pass in I added two small comments inline. One more request. About the Rust implementation: I agree. An ERC clarification is the way to make the two implementations agree. This PR follows the current spec text, and that is correct. Posted with Claude Code |
EIP-7730 defines
metadata.mapsbut this is currently not supported in the clear-signing sourcifyeth lib. This PR suggests to add this feature. Examples of its use can be seen in ethereum/clear-signing-erc7730-registry#2595, where a contract needs to display atokenAmountfrom an underlying tokenAdds ERC-7730
metadata.mapssupport: a descriptor can resolve a constant parameter (e.g. a token address) from a lookup table keyed on transaction context.params.token,params.chainIdand the other constant params the schema marks map-capable accept a{ map, keyPath }reference.tokenparam previously reachedisAddressString()and threws.startsWith is not a function.@.to.DESCRIPTOR_NOT_APPLICABLEwarning and the raw-calldata fallback — per ERC-7730 the descriptor does not describe the transaction. It does not degrade to a raw field.DescriptorMapReference/DescriptorMetadataMaptypes;metadata.mapsis no longerRecord<string, unknown>.Note on cross-implementation consistency: the Rust implementation
(https://github.com/llbartekll/clear-signing#) already has a
mapsimplementation, but of adifferent shape — it names the lookup bag
entriesrather than the spec'svalues, putskeyPathon the map definition (the pre-2026-04 spec form)rather than on the reference, and exposes a non-spec
params.mapReferencethat substitutes a field's display value instead of feeding constant params.
It also rejects the whole descriptor on the spec form, since
params.tokenis typed as a plain string. This PR follows the current
spec shape, but an ERC clarification would help both work to converge.
Open question: on a lookup miss this degrades to raw with
FORMAT_PARAM_RESOLUTION_ERROR, consistent with other unresolvable params.The spec says a wallet MUST treat the descriptor as invalid for the
transaction — should we follow it strictly ?