Skip to content

feat: WalletConnect support via Reown AppKit + wagmi#16

Merged
guibvieira merged 4 commits into
mainfrom
feat/walletconnect
Apr 28, 2026
Merged

feat: WalletConnect support via Reown AppKit + wagmi#16
guibvieira merged 4 commits into
mainfrom
feat/walletconnect

Conversation

@guibvieira
Copy link
Copy Markdown
Collaborator

Why

The current Connect Wallet flow uses raw EIP-6963 discovery, which only sees browser-extension wallets (MetaMask, Rabby). Mobile wallets like MetaMask Mobile, Trust Wallet, Rainbow, Coinbase Wallet were invisible to the tool — blocking signers whose authorised keys live only on a phone.

This came up concretely while approving an agent on a production multi-sig: a co-signer's authorised wallet sits on a mobile app, and the only fallback was "export your seed phrase to a desktop wallet" — insecure and high-friction.

Lessons learnt

  • Viem alone doesn't solve this — viem is just the signing library, it needs a connector layer above it to discover non-extension wallets.
  • The connector layer that ships in tradingstrategy-ai/frontend (AppKit + wagmi) covers both browser extensions and WalletConnect-bridged mobile wallets in a single UI, so adopting it here keeps us aligned with the wider stack and inherits any compat work that's already been done there.
  • WalletConnect needs a free project ID from cloud.reown.com baked into the static bundle at build time. For the Pages deploy this is wired through the new + 'WALLET_CONNECT_PROJECT_ID' + repo secret.
  • Keeping the public + 'getWallet()' + interface byte-identical means the migration is contained — no diff in + 'signing.ts' + , + 'l1signing.ts' + , + 'execute.ts' + , + 'WrongChainAlert.svelte' + , + 'SessionShare.svelte' + , + 'EIP712Preview.svelte' + , or routes.

Summary

  • Add + '@reown/appkit' + , + '@reown/appkit-adapter-wagmi' + , + '@wagmi/core' + , + '@wagmi/connectors' + to + 'package.json' + (versions pinned to match + 'tradingstrategy-ai/frontend' + ).
  • New + 'src/lib/wallet/client.ts' + : AppKit setup with chains + '[arbitrumSepolia, arbitrum]' + (Sepolia is mandatory because Hyperliquid hardcodes its chain ID 421614 in the EIP-712 signing domain).
  • Rewrite + 'src/lib/wallet.svelte.ts' + on top of wagmi's + 'getAccount' + / + 'watchAccount' + / + 'reconnect' + / + 'switchChain' + actions. Public + 'getWallet()' + interface unchanged (same getters, same methods); the + 'discoveredWallets' + / + 'showPicker' + / + 'connectProvider' + members tied to the bespoke EIP-6963 picker are dropped because AppKit owns the modal now.
  • + 'src/lib/components/ConnectWallet.svelte' + becomes a thin Connect/Disconnect button — picker UI lives in AppKit.
  • New + 'src/lib/config.ts' + reads + 'TS_PUBLIC_WALLET_CONNECT_PROJECT_ID' + from + '$env/dynamic/public' + and warns if unset.
  • + 'svelte.config.js' + sets + 'kit.env.publicPrefix: "TS_PUBLIC_"' + per project convention (CLAUDE.md).
  • + '.env.example' + documents the new env var; + '.gitignore' + already covers + '.env' + .
  • + '.github/workflows/deploy.yml' + wires the + 'WALLET_CONNECT_PROJECT_ID' + repo secret into the build step.
  • + 'README.md' + updated with one-line setup instruction.
  • + 'CHANGELOG.md' + created with the entry per project convention.

Notes for the reviewer

  • The + 'WALLET_CONNECT_PROJECT_ID' + repo secret has already been set on this repo (verified with + 'gh secret list' + ).
  • Lockfile is not updated in this PR — done from a sandbox without Node. Run + 'pnpm install' + locally before merging to refresh + 'pnpm-lock.yaml' + , then + 'pnpm run check' + and + 'pnpm run format' + .
  • Test plan after merge: regression-test MetaMask + Rabby (extension), then verify a fresh QR flow with MetaMask Mobile / Trust / Rainbow against the same + 'approveAgent' + session URL.

Ubuntu and others added 2 commits April 27, 2026 17:59
The previous Connect Wallet flow used raw EIP-6963 discovery, which only
sees browser-extension wallets (MetaMask, Rabby). Mobile wallets like
MetaMask Mobile, Trust, Rainbow, Coinbase Wallet were invisible to the
tool — blocking signers whose authorised keys live only on a phone.

Adopt the same wallet stack tradingstrategy-ai/frontend already uses
(@reown/appkit + @reown/appkit-adapter-wagmi + @wagmi/core + @wagmi/connectors)
on top of the existing viem dependency. AppKit's modal handles browser
extensions and WalletConnect-bridged mobile wallets in one UI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@guibvieira guibvieira self-assigned this Apr 27, 2026
@guibvieira guibvieira added the enhancement New feature or request label Apr 27, 2026
Ubuntu and others added 2 commits April 27, 2026 20:22
Why: prevent accidental secret commits from a single, well-known scanner
(gitleaks). Two layers — server-side via GitHub Action so nothing slips
past `git commit --no-verify`, and local via husky pre-commit hook so devs
get fast feedback before pushing.

Lessons learnt: husky's pre-commit hook gracefully no-ops with a warning if
gitleaks isn't installed locally; CI is still the source of truth. The
.gitleaks.toml allowlist covers .env.example, CHANGELOG.md, and
pnpm-lock.yaml to avoid false positives.

Summary:
- Add .github/workflows/secret-scan.yml running gitleaks/gitleaks-action@v2
  on every PR and push to main.
- Add .gitleaks.toml extending default rules with project-specific
  allowlist paths.
- Add husky as a devDependency, .husky/pre-commit running
  `gitleaks protect --staged`, and update prepare script.
- Document setup in README and CHANGELOG.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gitleaks/gitleaks-action@v2 requires a paid licence for repos owned by
organisations and fails with "missing gitleaks license" otherwise. The
gitleaks binary itself is MIT-licensed and free — install it from the
upstream release in the workflow and call it directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@guibvieira guibvieira merged commit 3938683 into main Apr 28, 2026
1 check passed
@guibvieira guibvieira deleted the feat/walletconnect branch May 5, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants