EIP-712 & Passkey wallets#96
Draft
frol wants to merge 345 commits into
Draft
Conversation
feat: update intear wallet manifest
Fix manifest link
Enable `signDelegateActions` in NEARMobile manifest
Add Privy Wallet connector manifest and provide manifest to sandbox wallet on ready()
Export EventMap, EventType, and Account types
Ship Agent Skills (near-connect-quickstart, near-connect-transactions) via TanStack Intent so AI coding agents can auto-discover correct @hot-labs/near-connect usage patterns. Updates package.json files array, adds tanstack-intent keyword, and adds README section for consumers.
srcdoc iframes inherit the parent's Content Security Policy, so inline scripts inside the sandbox are blocked when the parent uses nonce-based CSP (script-src 'nonce-X'). Add a cspNonce option that propagates the parent's nonce to both <script> tags in the srcdoc iframe, allowing them to execute while preserving CSP enforcement.
feat: add TanStack Intent skills for AI agent discoverability
feat: add cspNonce option for nonce-based CSP compliance
…etConnect) and Passkeys [wip]
…he wallet implementation
…nnect-eip712 wallet
Three related bugs caused the NEP-641 sign flow to abort right after
Connect on mobile and Ledger Live, before the user could sign:
1) Open-handler echo loop in SandboxedWallet/executor.ts
The sandbox "open" RPC registered a window message forwarder that
relays cross-window messages back into the iframe when the panel's
origin matches `ev.origin`. For wallet deeplinks (`ledgerlive://`,
`metamask://`, etc.) `window.open` returns `null` and
`new URL(deeplink).origin === "null"` — the same string the
sandboxed iframe uses for its own outgoing messages. Every
selector.call message the iframe sent was therefore echoed back to
itself, resolving the call promise with `event.data.result === undefined`
long before WalletConnect could deliver the real response.
Fix: only attach the forwarder when `window.open` actually returned a
popup, ignore self-messages (`ev.source === iframe.contentWindow`),
and skip when the parsed URL origin is `"null"`.
2) wcConnect raced its own cancellation in eip712-wallet.ts
`modal.subscribeModal({ open: false }) → reject("User cancelled
pairing")` fired on every modal close — including when the wallet
app auto-closes the modal after the user approves pairing on mobile
and Ledger Live. Drop the subscribeModal cancel; rely on the
"Use a different wallet" button + indefinite getSession polling.
3) Stale persisted WC session shadowed the new pairing
WC v2 stores sessions in localStorage. On the next sign-in attempt
getSession returned the dead topic, the poll resolved early, and
eth_signTypedData_v4 was routed to a session no wallet was actually
bound to. Disconnect the persisted session before pairing and
snapshot/skip the stale topic in the poll for belt-and-suspenders.
Also tightened a few small spots:
- example/src/App.tsx: hoist SignClient.init to a module-level singleton
so React StrictMode's double-mount doesn't create two SignClient
instances (the "Pending session not found for topic" log).
- resolveAuth now throws a clear "Wallet returned no signature" error
instead of crashing on `sigHex.replace` when the wallet returns
undefined.
- IframeExecutor: expose a `contentWindow` getter so the new
self-message check doesn't have to reach into a private field.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a draft version of WalletConnect support through Wallet Contracts on NEAR taking EIP-712 signed message payload as "NEAR transaction".
It is based on DefuseLabs' WalletContract which also implements NEP-641 (signMessage for contracts)
There are still a few unresolved design items, which is why I will keep it as draft, but we have actually launched it in https://trezu.org (and will have to migrate users after we address the pending issues)