Skip to content

feat(react-dapp-v2): auto-connect and wallet fee when opened from a wallet (H2b) - #1053

Draft
ignaciosantise wants to merge 8 commits into
mainfrom
wcp4-185-react-app-host-auto-connect
Draft

ignaciosantise wants to merge 8 commits into
mainfrom
wcp4-185-react-app-host-auto-connect

Conversation

@ignaciosantise

@ignaciosantise ignaciosantise commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Part of WCP4-185 (H2b in-wallet flow, parent WCP4-181).

What

When a wallet opens the React App from its Explore section, it injects window.walletConnectHost before the page loads. On that host launch the app:

  1. Connects automatically, with no QR or modal. Once startup finishes, the app calls connect() if no session was restored. Universal Provider sends the pairing URI to the wallet (wc_session_offer) instead of emitting display_uri, and the wallet auto-approves it with its wallet_guide_id. A toast says "Connecting to your wallet…" and then "Connected to {wallet}".
  2. Shows the wallet's fee. Universal Provider loads the fee config for this wallet and app from the WalletConnect API. The "Opened from your wallet" card shows the Wallet Guide ID, plus the fee for the active chain: bps, recipient and referral code.
  3. Applies the fee in the demo transaction. eth_sendTransaction makes its chain active, then asks for the fee. If there is one, it sends 0.001 ETH × feeBps / 10000 to the recipient.

Opened in a normal browser, nothing changes: same modal, same QR, and authentication as before.

Changes

  • Versions: every @walletconnect/* package goes from 2.23.10 to 2.25.1-canary-1, in the dependencies and in pnpm.overrides. That's the canary of walletconnect-monorepo#7361 plus WCP4-183, which bring isHostLaunch(), the bridge hand-off, getWalletFee(), wallet_fee_changed and walletFeeApiUrl.
  • Fee API URL: NEXT_PUBLIC_WALLET_FEE_API_URL is passed as walletFeeApiUrl. It defaults to production, which doesn't have the endpoint yet; set it to the staging or a local API for testing.
  • No AppKit on a host launch: the app only uses AppKit as the QR modal, and it opens itself on startup.
  • Auto-connect runs once, on the first load, so a Disconnect doesn't trigger it again.
  • No authentication on a host launch: the canary only sends pair() to the wallet, not authenticate() (WCP4-186).
  • Chains: with none selected, a host launch requests Ethereum, Optimism and Arbitrum, which both this app and the RN sample wallet support. This app's RPC map has no Base or OP Sepolia.
  • Result modal fix:
    • the overlay is fixed to the viewport, so the card is centered on screen on long pages
    • next.config.js enables the styled-components compiler, so class names match between server and client; they didn't, which left the modal card unstyled after hydration

Testing

Local end to end, with:

  • the RN sample wallet in the iOS simulator (react-native-examples#611)
  • the fee API from walletconnect-apps#551
  • a local database seeded with a 50 bps config for the wallet and this app

What we checked:

  • Auto-connect: tapping the Explore tile connects with no modal and no approval screen, and the session carries wallet_guide_id.
  • The fee:
    • On Ethereum, which has no recipient, the card says "No wallet fee for this chain", and eth_sendTransaction sends 0 ETH.
    • On Optimism, the card shows 0.5% (50 bps), and the wallet's signing screen shows Amount 0.000005 ETH (value: 0x48c27395000) to the configured recipient.
  • Disconnect doesn't reconnect by itself; reopening the tile connects again. Going back and forth restores the session and the fee.
  • The result modal (e.g. "User rejected") is centered on screen.
  • Checks: tsc --noEmit passes.

Known CI failure: the pr_checks lint/prettier job fails on every recent PR. It runs yarn install --immutable in an app with no yarn.lock, and next lint no longer exists in Next.js 16. Not caused by this PR.

🤖 Generated with Claude Code

When a wallet opens the React App from its Explore section, it injects
window.walletConnectHost. On that host launch the app now connects once on
load with no QR or modal: Universal Provider hands the pairing URI to the
wallet, which auto-approves it. A card above Accounts shows the session's
wallet_guide_id.

- Bump @walletconnect/* to 2.25.1-canary-0 (deps and pnpm.overrides) for
  UniversalProvider.isHostLaunch().
- Skip authentication on a host launch: the canary only routes pair() to the
  wallet, not authenticate() (WCP4-186).
- Request Sepolia, Ethereum and Base when no chains are selected.

Part of WCP4-185.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
appkit-react-wagmi-example Error Error Oct 7, 2026 6:38pm UTC
malicious-dapp-verify-simulation Ready Ready Preview Oct 7, 2026 6:38pm UTC
pos-dapp Ready Ready Preview Oct 7, 2026 6:38pm UTC
react-dapp-v2 Ready Ready Preview Oct 7, 2026 6:38pm UTC
wdk-wallet-example Ready Ready Preview Oct 7, 2026 6:38pm UTC
5 Skipped Deployments
Project Deployment Actions Updated
appkit-solana Ignored Ignored Oct 7, 2026 6:38pm UTC
chain-abstraction-demo Ignored Ignored Preview Oct 7, 2026 6:38pm UTC
decentralized-relay-wallet Ignored Ignored Preview Oct 7, 2026 6:38pm UTC
react-wallet-v2 Ignored Ignored Preview Oct 7, 2026 6:38pm UTC
smart-sessions-demo Ignored Ignored Preview Oct 7, 2026 6:38pm UTC

Request Review

@linear

linear Bot commented Oct 2, 2026

Copy link
Copy Markdown

WCP4-185

A loading toast at the top says "Connecting to your wallet…" during the host-launch auto-connect, then turns into "Connected to <wallet>". On failure it's dismissed, since connect() already shows the error toast.

Part of WCP4-185.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…launch

- Don't create the AppKit modal on a host launch; it can open itself on
  startup and the app only uses it as the QR modal.
- Mark host auto-connect as done once startup finishes, so a restored
  session followed by Disconnect doesn't auto-connect again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bump @walletconnect/* to 2.25.1-canary-1, which adds getWalletFee(),
wallet_fee_changed and the walletFeeApiUrl option to Universal Provider.

- Pass NEXT_PUBLIC_WALLET_FEE_API_URL as walletFeeApiUrl (defaults to production).
- Keep the fee for the active chain in state and show it in the "Opened from
  your wallet" card: bps, recipient, referral code, and what the demo
  transaction pays.
- eth_sendTransaction makes its chain active, then pays the wallet fee on a
  0.001 ETH demo amount (amount x feeBps / 10000) to the recipient.
- On a host launch, request Ethereum, Optimism and Arbitrum, which both this
  app and the sample wallet support.
- Fix the result modal on long pages: the overlay is fixed to the viewport, so
  the card is centered on screen, and next.config enables the styled-components
  compiler so class names match between server and client (they didn't, which
  left the modal card unstyled after hydration).
- Card title at 18px; only IDs and addresses wrap anywhere.

Part of WCP4-185.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch had an error being deployed

1 failed and 4 active deployments
Preview – react-dapp-v2 — ad055f01 Deployed Oct 7, 2026 by vercel[bot]
Preview – malicious-dapp-verify-simulation — ad055f01 Deployed Oct 7, 2026 by vercel[bot]
Preview – pos-dapp — ad055f01 Deployed Oct 7, 2026 by vercel[bot]
Preview – wdk-wallet-example — ad055f01 Deployed Oct 7, 2026 by vercel[bot]
Preview – appkit-react-wagmi-example — ad055f01 Deployed Oct 7, 2026 by vercel[bot]
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