Skip to content

feat: align v2 with spec (@.chainId path and metadata.contractName) - #320

Merged
fsamier merged 3 commits into
mainfrom
feat/v2-spec-align
Aug 6, 2026
Merged

feat: align v2 with spec (@.chainId path and metadata.contractName)#320
fsamier merged 3 commits into
mainfrom
feat/v2-spec-align

Conversation

@fsamier

@fsamier fsamier commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Aligns the v2 implementation with the ERC-7730 spec on two points.

1. Implement @.chainId container path

The spec lists @.chainId as a canonical container field (for both EVM transaction and EIP-712 containers), notably used as a map keyPath (e.g. underlyingToken keyed by chain id). This adds full support for it:

  • Added CHAIN_ID = "chainId" to ContainerField.
  • Added chainId to the path parser grammar.
  • Added CHAIN_ID = 0x3 to the calldata binary value enum and handled it in convert_container_path (encoded as a 32-byte UINT).
  • Added parsing tests for @.chainId.

2. Use metadata.contractName for the contract name

Prefer the explicit metadata.contractName field where a contract name is set, falling back to the previous value when not available:

  • Calldata v2 conversion: metadata.contractName or context.id.
  • Legacy EIP-712 v2 conversion: InputEIP712Contract.contractName prefers metadata.contractName, falling back to metadata.owner (dapp name keeps its owner-based fallback).
  • v2 max-length lint validates the effective contract name (metadata.contractName or context.id).

v1 paths are left untouched since v1 metadata has no contractName field.

Testing

  • pdm run pytest tests/model tests/convert tests/v2 tests/lint — all passing.
  • Pre-commit hooks (ruff, mypy, bandit, etc.) pass.

@fsamier
fsamier requested a review from a team as a code owner August 6, 2026 11:27
@fsamier
fsamier enabled auto-merge (squash) August 6, 2026 11:54
@fsamier
fsamier merged commit c074293 into main Aug 6, 2026
13 checks passed
@fsamier
fsamier deleted the feat/v2-spec-align branch August 6, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants