feat(web): wallet picker for the implemented adapters (Freighter, LOBSTR) - #627
Open
Mamavee001 wants to merge 1 commit into
Open
feat(web): wallet picker for the implemented adapters (Freighter, LOBSTR)#627Mamavee001 wants to merge 1 commit into
Mamavee001 wants to merge 1 commit into
Conversation
…STR) wallet.ts hardcoded a single FreighterWallet instance, so LobstrWallet (drydocs#537) was fully implemented and tested but unreachable from the UI, and XBullWallet (drydocs#598) would land in the same state. - wallet.ts: replaces the single `wallet` export's implicit Freighter-only assumption with a WALLETS registry (id, name, installUrl, adapter) and getSelectedWalletId/setSelectedWalletId, persisted via a dedicated localStorage key (kept out of the Zustand store to avoid a circular import, since store/wallet.ts already imports from wallet.ts). `wallet` itself becomes a dispatcher that resolves to whichever wallet is currently selected, so useSignAndSubmit's sign() and the store's revalidate() automatically follow the user's choice with no changes. - useWalletConnect.ts: handleConnect now takes an optional walletId, defaulting to the persisted selection. The choice is only persisted on a successful connect, so a failed/cancelled attempt never silently switches which wallet later calls go through. Returns attemptedWalletId so the no-extension fallback can link to the right wallet. - WalletConnect.tsx: adds a picker dropdown (a caret beside the existing button) listing every implemented wallet with an "Installed" badge; the plain "Connect Wallet" click is unchanged, still connecting through the default/selected wallet with one click. The no-extension fallback is now wallet-aware instead of hardcoded to freighter.app. - VaultPanel.tsx's own connect button/fallback made wallet-aware too, for consistency with the header. Tests added/updated across lib/wallet, useWalletConnect, and a new WalletConnect component test; existing suites (including e2e-relevant selectors) still pass.
|
@Mamavee001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@Mamavee001 is attempting to deploy a commit to the Collins' projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
closes #611
Summary
wallet.tshardcoded a singlewallet: WalletAdapterinstance toFreighterWallet, soLobstrWallet(merged in #537) was fully implemented and tested but never actually reachable from the app. This adds a wallet picker so users can choose between every implemented adapter and reconnect through the same one automatically next time.Changes
apps/web/src/lib/wallet.tsWALLETS: WalletMeta[]registry —{ id, name, installUrl, adapter }for each implemented wallet (Freighter, LOBSTR). Adding xBull once feat(wallet): add XBullWallet adapter (#488) #598 merges is one new entry here, nothing else.getSelectedWalletId()/setSelectedWalletId(), backed by a dedicatedlocalStoragekey (meridian-selected-wallet), default to Freighter. Kept inwallet.tsitself rather than the Zustand wallet store, sincestore/wallet.tsalready imports fromwallet.tsand putting it the other way round would create a circular import.wallet: WalletAdaptersingleton is now a dispatcher that resolves togetWalletAdapter(getSelectedWalletId())on every call, instead of being pinned toFreighterWallet. This meansuseSignAndSubmit'ssign()and the store'srevalidate()/isAuthorized()check automatically follow whichever wallet the user actually connected through — zero changes needed to those files or their tests.apps/web/src/hooks/useWalletConnect.tshandleConnect(walletId?)now accepts an explicit wallet, defaulting to the persisted selection when omitted (this is what keeps the plain "Connect Wallet" click unaffected — see acceptance criteria below).setSelectedWalletId) on a successful connect, so a failed or cancelled attempt never silently switches which wallet later sign/reconnect calls dispatch to.attemptedWalletIdso the no-extension fallback UI knows which wallet's install link to show.apps/web/src/components/onboarding/WalletConnect.tsxisInstalled()on open, so it reflects the extension state even without a reload).Install {name}→ that wallet's owninstallUrl) instead of hardcoded tofreighter.app.apps/web/src/components/dashboard/VaultPanel.tsxonClick={handleConnect}would have passed the raw click event ashandleConnect's newwalletIdparameter.Acceptance criteria
localStorage, only on a successful connect)WalletConnect.tsx's no-extension fallback is wallet-aware, not hardcoded to freighter.appgetByRole("button", { name: "Connect Wallet" })scoped to<main>) still resolve to the same element with the same text, and the "Install Freighter" e2e assertion still passes because the interpolated string (Install {{name}}→ "Install Freighter") renders identically for the default wallet.Test plan
apps/webunit tests: 108 passing (11 new/updated acrosslib/wallet.test.ts,useWalletConnect.test.ts, and a newWalletConnect.test.tsx).eslintandtsc && vite buildboth clean.freighter.app/lobstr.co), and confirmed the selection is not persisted tolocalStorageafter a failed connect attempt (no extension present in the sandbox).webServerconfig invokes a barepnpmbinary not onPATHhere, unrelated to this change), so verified by inspection that everygetByRole("button", { name: "Connect Wallet" })in the e2e specs is scoped to.locator("main"), which targetsVaultPanel's own button — untouched in shape/behavior by this PR.Caveats
WALLETS.installUrlpoints athttps://lobstr.co(its general site), matching howfreighter.appwas already used here — there's no official Chrome Web Store deep link in the LOBSTR package metadata to use instead.