Skip to content

feat: EIP-712 signature requests (WALLET-1251)#1342

Merged
Comp0te merged 22 commits into
developfrom
WALLET-1251-cw-eip-712-signature-requests
Jun 17, 2026
Merged

feat: EIP-712 signature requests (WALLET-1251)#1342
Comp0te merged 22 commits into
developfrom
WALLET-1251-cw-eip-712-signature-requests

Conversation

@ost-ptk

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

Copy link
Copy Markdown
Member

WALLET-1251 — EIP-712 signature requests

Jira: https://make-software.atlassian.net/browse/WALLET-1251 (epic WALLET-1250, release CW 2.5.0)

Adds the EIP-712 typed-data signing flow: a dapp calls provider.signTypedData(params, publicKey), the user sees a window with Domain/Message blocks and signs with a software key, and the dapp receives the signature. All domain logic lives in casper-wallet-core (eip712Repository); the wallet renders the prepared domainRows/messageRows and signs.

How it works

dapp.signTypedData(params, pubKey)
  → content sdk.ts → signTypedDataRequest
  → background: dispatch typedData into redux (vault slice) + openWindow(SignatureRequestEip712)
  → SignEip712Page: reads typedData from redux → useFetchDataForEip712Request → eip712Repository.prepareSignatureRequest
  → renders Domain/Message rows; handleSign → eip712Repository.signTypedData → signTypedDataResponse
  → content/index.ts proxies the response to the page → dapp receives SignTypedDataResult

Changes

Dependencies / compilation

  • casper-js-sdk 5.0.10 → 5.0.12 (deduplicates with the core copy), date-fns 2.30 → ^4 (fixes the enUS import in core)
  • Deep type imports casper-js-sdk/dist/... moved to the package root (5.0.12 no longer ships .js at those paths)

SDK / protocol (src/content/)

  • sdk.ts: signTypedData(params, signingPublicKeyHex) method
  • sdk-method.ts: signTypedDataRequest/Response/Error actions
  • sdk-types.ts: SignTypedDataParams, SignTypedDataResult, EIP712HashArtifacts (contract aligned with the playground)
  • index.ts: whitelist response/error in the content proxy (otherwise the call hangs)

Background / redux

  • vault slice: eip712ById field + eip712PayloadReceived + selectEip712JsonById (follows the deploy jsonById pattern)
  • WindowApp.SignatureRequestEip712 + RouterPath.SignEip712
  • signTypedDataRequest handler in background/index.ts

UI (src/apps/signature-request/pages/sign-eip712/)

  • useFetchDataForEip712Request hook
  • Eip712DisplayRow — presentation → component mapper (AccountInfoRow / ContractInfoRow / Hash / text), all rows lay out label↔value via SpaceBetweenFlexRow
  • Eip712NetworkRow — Network with icon (reuses NetworkIconColor + the resolver from sign-transaction)
  • SignEip712Content — Domain + Message blocks
  • SignEip712Page — fetch + sign + cancel, route wired up

Ledger guard

  • Ledger accounts are rejected on the EIP-712 signing page (mirrors the existing decrypt-message pattern): an early signingAccount.hardware === HardwareWalletType.Ledger check sends signTypedDataError back to the dapp and throws, so the user sees the ErrorBoundary screen. New ErrorMessages.signTypedData.LEDGER_NOT_SUPPORTED constant.

Testing

  • npm run ci-check — green (format + lint + tsc + test)
  • npm run build:chrome — successful
  • Manual e2e via the Casper Wallet playground: sign/cancel, Domain/Message rendering, ContractInfoRow for a real package hash, and the Ledger-account rejection path

Notes

  • Ledger: EIP-712 typed-data signing is intentionally not supported on Ledger hardware wallets (confirmed with the feature owner). Software-key signing only; Ledger accounts are rejected before reaching the signing step.
  • Package hash when the package is unresolved: when core cannot resolve a contract package, the row arrives as presentation: 'string' and the hash is shown in full. Recommendation for core — force presentation: 'hash' for contract_package_hash. With a real package hash the row renders as ContractInfoRow correctly.

🤖 Generated with Claude Code

@ost-ptk ost-ptk self-assigned this Jun 12, 2026
@ost-ptk ost-ptk requested a review from Comp0te June 12, 2026 08:26
Comment thread src/background/redux/vault/actions.ts
Comment thread src/apps/signature-request/pages/sign-eip712/index.tsx Outdated
Comment thread src/apps/signature-request/pages/sign-eip712/index.tsx Outdated
Comment thread src/content/sdk.ts
Comment thread src/apps/signature-request/pages/sign-eip712/index.tsx Outdated
Comment thread src/apps/signature-request/pages/sign-eip712/index.tsx
Comment thread src/libs/ui/utils/formatters.ts Outdated
ost-ptk and others added 4 commits June 16, 2026 10:46
# Conflicts:
#	package-lock.json
#	package.json
- persist eip712 payload by adding eip712PayloadReceived to updateVaultCipher
  trigger list, preventing a hung request after a service-worker restart
- wrap handleSign key reconstruction + signing in try/catch, sending
  signTypedDataError on failure instead of leaving the dapp promise hanging
- guard the eip712 payload JSON.parse and send signTypedDataError on
  malformed data instead of throwing during render
- advertise signTypedData in CasperWalletSupports and getActiveAccountSupports
  (software accounts only) so dapps can feature-detect EIP-712
- reject watch-only accounts (no secret key) before signing
- harden optional chaining when reading the signing account balance
- import FormatDistanceToken from the date-fns package root

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The SDK bump 5.0.10 -> 5.0.12 changed the HTTP error format: a 500
response now throws HttpError(status, Error(statusText)), so the
transfer error screen renders 'Internal Server Error' instead of
'failed to send http request, details: Code: 500, err: Internal Server Error'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ost-ptk ost-ptk requested a review from Comp0te June 16, 2026 09:28
Comment thread src/utils.ts

@Comp0te Comp0te left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Comp0te Comp0te merged commit 0eb2851 into develop Jun 17, 2026
6 checks passed
@Comp0te Comp0te deleted the WALLET-1251-cw-eip-712-signature-requests branch June 17, 2026 11:11
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