Skip to content

feat(eip712): populate signature requests with additional data (WALLET-1318)#42

Open
ost-ptk wants to merge 5 commits into
WALLET-1255-cw-core-eip-712-signature-requests-parsing-and-validationfrom
WALLET-1318-cw-core-eip-712-signature-requests-populate-with-additional-data
Open

feat(eip712): populate signature requests with additional data (WALLET-1318)#42
ost-ptk wants to merge 5 commits into
WALLET-1255-cw-core-eip-712-signature-requests-parsing-and-validationfrom
WALLET-1318-cw-core-eip-712-signature-requests-populate-with-additional-data

Conversation

@ost-ptk

@ost-ptk ost-ptk commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

Implements WALLET-1318 — populate EIP-712 signature requests with additional data.

Follow-up to WALLET-1255 (base eip712 module). Where WALLET-1255 added validate → digest → display model → sign → recover/verify, this PR adds enrichment: core now prepares fully-populated, ready-to-render typed-data, the same way TxSignatureRequestRepository does for deploys — so consumer apps (extension, mobile) render the entity without doing their own lookups.

Stacked PR: base is the WALLET-1255 branch, not master. Review/merge WALLET-1255 first.

Closes WALLET-1318.

What's added

  • EIP712Repository.prepareSignatureRequest(...) (async) → returns a fully-populated IEIP712SignatureRequest:
    • every field classified by presentation type (bytes*hash, uint*/int*number, addressaccount, else→string);
    • address fields resolved to account info (name, logo, CSPR.name, explorer link);
    • domain contract_package_hash resolved to contract package data;
    • chain_name mapped to CasperNetwork;
    • plus signing key/account info, digest, hash artifacts, rawJson.
  • The synchronous WALLET-1255 methods (computeDigest, buildDisplayModel, signDigest, signTypedData, recoverSigner, verifySignature) are unchanged.
  • IEIP712DisplayRow.isAddresspresentation enum, plus optional accountInfo / contractPackage.
  • Repository now takes injected accountInfoRepository + contractPackageRepository (wired in setup.ts).

Design notes

  • Best-effort enrichment: each network lookup is isolated in its own try/catch (mirrors TxSignatureRequestRepository), so a flaky API never breaks the request. Only invalid typed data throws EIP712Error.
  • Network source: domain.chain_name via getCasperNetworkByChainName, with an optional network param fallback; if unresolved, the entity is returned without network-dependent enrichment (rows still classified).
  • address value format is heuristic. The casper-eip-712 address encoder accepts a 20-byte Ethereum address or a 33-byte Casper public key (not a 32-byte account hash), while the ticket pseudo-code calls these "account hash" — the sources disagree. resolveEip712AddressToAccountHash therefore auto-detects: strips an optional 0x, treats 01/02-prefixed 66/68-hex values as public keys (→ account hash), otherwise treats the value as an account hash. The same resolver is used both when collecting hashes to fetch and when looking them up, so keys always match. ETH-style 20-byte addresses won't map to a Casper account (classification only). This will be revisited against real payloads once the wallet exercises it.
  • rawJson uses a bigintstring JSON replacer (EIP-712 message values can be bigint).

Testing

  • yarn code:check — tsc (strict) + eslint + prettier clean.
  • yarn test435/435 pass (44 suites). New/updated coverage: presentation classification, account-hash collection, address resolver (public key / account hash / 0x), DTO assembly (incl. bigint rawJson), and the repository's happy path + degraded lookups + unmappable network + invalid-typed-data error.

Developed via spec → plan → subagent-driven execution; design/plan in docs/superpowers/.

ost-ptk and others added 4 commits June 8, 2026 12:01
…esentation and enrichment support

- Introduced `getPresentationForType` to classify types into `account`, `hash`, `number`, or `string`.
- Updated display model rows to include additional metadata: `presentation`, `accountInfo`, and `contractPackage`.
- Added `IEIP712DisplayEnrichment` for optional domain/message row enrichment.
- Expanded unit tests to validate type classification, presentation logic, and enrichment capabilities.
…ests

- Implemented `getAccountHashesFromTypedData` to extract and deduplicate account hashes from typed data, including signing key-derived hashes.
- Added comprehensive test cases for address-based field collection, deduplication, and edge cases handling.
- Updated exports to include the new utility in the `eip712` module.
- Introduced `EIP712SignatureRequestDto` for encapsulating EIP-712 signature request details.
- Implemented support for account info resolution, contract package enrichment, and hash artifacts forwarding.
- Added comprehensive unit tests to validate field mappings, enrichment logic, and fallback behavior.
- Updated exports to include the new DTO in the `eip712` module.
… enrichment

Adds EIP712Repository.prepareSignatureRequest, which returns a fully
populated IEIP712SignatureRequest: fields classified by presentation
type, address fields resolved to account info, contract_package_hash
resolved to contract package, and chain_name mapped to CasperNetwork.
Enrichment is best-effort (each lookup isolated); only invalid typed
data throws EIP712Error. Wires the repository constructor in setup.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: ost-ptk <ostap@make.services>
@ost-ptk ost-ptk marked this pull request as ready for review June 9, 2026 10:02
@ost-ptk ost-ptk requested a review from Comp0te June 9, 2026 10:02
…n domain rows

- Updated `buildTypedDataDisplayModel` to force `hash` presentation for `contract_package_hash`, even if undeclared in `types.EIP712Domain` or specified as `string`.
- Added test case to validate shortened display and full value copyability for undeclared `contract_package_hash`.
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.

1 participant