Skip to content

Add Reown existing-wallet login alongside Web3Auth - #72

Draft
sirpy wants to merge 3 commits into
mainfrom
feat-connect-wallet-reown
Draft

sirpy wants to merge 3 commits into
mainfrom
feat-connect-wallet-reown

Conversation

@sirpy

@sirpy sirpy commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add an optional Connect Wallet login path using Reown AppKit + an ethers browser provider; keep Google, Facebook and SMS/Web3Auth login unchanged.
  • Persist and restore Reown EVM sessions, disconnect on logout, expose EVM message/transaction/typed-data signing, and adjust the GoodID claim link to handle a missing username.
  • Add a login feature flag and EN/DA label. Pin AppKit and its Ethers adapter to matching 1.8.23 versions to avoid incompatible duplicate appkit-common types.

Draft: keep NEXT_PUBLIC_LOGIN_EXISTING_WALLET_ENABLED off in production until QA below passes.

Follow-ups addressed in 1fee3b6 (not reviewed)

  1. EVM-only scope. Connected-wallet sessions only expose chains the session has an address for (getAvailableChainIds). Balances, history, token lists (Home/Send/Swap pickers), Receive, profile copy-address and WalletConnect proposal chains are filtered. An EVM-only notice is shown under the Connect Wallet button and on Receive. BTC/SVM send dialogs no longer throw when the signer is missing.
  2. Account/network changes. AppKit account is watched; switching accounts or disconnecting in the external wallet ends the session, disconnects dApp WalletConnect sessions and shows a reconnect prompt on the login screen. Signing/sending switches the wallet to the target chain first (ensureChain); typed data uses domain.chainId.
  3. Transaction compatibility. External wallets submit via eth_sendTransaction (EVMSigner.submitTransaction); the wallet chooses nonce/fees and broadcasts once. Wired into sendTx/sendTxWaitForMining (receipt + Divvi tracking preserved), the widget EIP-1193 provider, WalletConnect eth_sendTransaction, and LI.FI (viem wallet client over the Reown EIP-1193 provider). signTransaction throws a clear error for connected wallets.
  4. Login feedback. Connect button shows a loading state; cancel (modal closed) and failures show localized toasts; retry works. getAppKit init is retryable.
  5. WalletConnect relay. Namespaces are built from available signers: eip155 always, Solana/bip122 only when the session has those signers. Proposals requiring other chains are rejected with "Connected wallets support EVM networks only." eth_signTransaction/eth_sendRawTransaction and EIP-5792 are not advertised for external wallets.
  6. Restore/logout. Restore failure for a stored Reown session shows a "reconnect your wallet" message and defaults to Connect Wallet. Logout disconnects Reown and dApp sessions.
  7. GoodID. Reown sessions pass an empty firstname to the GoodID link; needs verification (QA step 4). Private-key copy in Options is restricted to private-key sessions.

Human QA guide

Setup: use a test deployment and test-only wallet with small balances. Set NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID to a valid Reown project ID and NEXT_PUBLIC_LOGIN_EXISTING_WALLET_ENABLED=true; restart/redeploy. Have MetaMask (or another injected EVM wallet), optionally a mobile wallet for QR, and a second account. Do not use production funds. Use DevTools Console/Network and watch for rejected promises and failed RPCs.

  1. Login entry: Connect Wallet appears among login choices with the EVM-only notice; Reown lists injected and QR wallets. ?login=existing_wallet (and ?login=existing-wallet) makes it the default. With the flag false the option disappears. Google/SMS login unchanged.
  2. Connect/cancel/errors: connect account A; home shows A and only EVM balances/address. Close the modal without connecting → "cancelled" toast, button usable again. Deny the wallet request; test a missing/invalid project ID → "failed" toast, retry works.
  3. Restore/exit: reload while connected → A restores without a prompt. Logout and reload → stays logged out, wallet disconnected. Disconnect in the external wallet, then reload → login screen with "reconnect" message and Connect Wallet preselected. While the app is open, switch to account B in the wallet → session ends, "account changed" message, any dApp WalletConnect sessions are disconnected.
  4. EVM signing (wallet-submitted): sign a message and typed data; send a small EVM transfer; claim on GoodDollar (including the whitelist/GoodID path — confirm GoodID accepts the empty first name); run an EVM swap. While the wallet is on a different network, start each action and confirm the wallet is asked to switch. Verify the tx hash appears, the activity updates and balances refresh after mining. Test MetaMask and one mobile wallet.
  5. Unsupported chain UX: Home, Send, Swap pickers, Receive, Activity filter and profile copy-address drawer show no BTC/DOGE/SOLANA/XRP. Receive shows the EVM-only notice. No cross-chain route to a non-EVM chain is offered.
  6. WalletConnect-in-Wallet: pair an EVM-only dApp → proposal lists only EVM chains and requests (personal_sign, eth_signTypedData_v4, eth_sendTransaction) resolve via the external wallet. Pair a dApp requiring Solana/Bitcoin → rejected with the EVM-only message, no uncaught exceptions.
  7. Locales and platform: repeat login, toasts and reconnect messages in English and Danish; check mobile layout/QR handoff.

Automated verification

  • yarn tsc --noEmit: clean (excluding stale .next types).
  • Biome: passes.
  • yarn test: 14 files / 127 tests pass. New tests: wallet-submit branch of sendTx/sendTxWaitForMining, widget provider submit path, WalletWrapper.sendTransactionHash.
  • yarn build: succeeds.

This branch has not been deployed

No deployments
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