From 8eed8d4f9033d1f3d4d671a050289f999a0c1ee9 Mon Sep 17 00:00:00 2001 From: sainathr19 Date: Wed, 19 Aug 2026 16:10:03 +0530 Subject: [PATCH] fix: only ever select a Ready-named wallet in resolvePrivacyWallet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get-starknet-discovery finds every wallet-standard-compatible extension on the page, not just Starknet-native ones — on a profile with MetaMask's Starknet snap installed, the previous wallets[0] fallback picked it up and repeatedly called requestAccounts/supportedWalletApi against it, each call rejected with no useful signal, for as long as the page stayed open. Require a Ready-named match or return null instead of guessing. --- ui/src/wallet-account-v6.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/src/wallet-account-v6.js b/ui/src/wallet-account-v6.js index 47fa6a9..cef91ab 100644 --- a/ui/src/wallet-account-v6.js +++ b/ui/src/wallet-account-v6.js @@ -60,18 +60,22 @@ async function discoverWallets(timeoutMs = 2000) { /// Resolves a connected WalletAccountV6 plus whether it's STRK20-capable. /// `provider` is an RpcProvider (e.g. from iceberg.js's makeProvider) — the /// wallet still does its own proving/discovery, this is only for reading -/// chain state the account interface needs. Returns null if no wallet -/// extension is found at all (distinct from "found but not privacy-capable", -/// which callers should surface directly). +/// chain state the account interface needs. Returns null if no Ready wallet +/// is found (distinct from "found Ready but not privacy-capable", which +/// callers should surface directly). +/// +/// Only ever selects a wallet whose name matches "ready" — never falls back +/// to "whatever extension answered first". get-starknet-discovery finds +/// every wallet-standard-compatible extension on the page (MetaMask's +/// Starknet snap included), and calling requestAccounts/supportedWalletApi +/// against a non-Ready wallet just gets rejected repeatedly with no useful +/// signal, on a loop, for as long as the page is open. export async function resolvePrivacyWallet(provider) { if (typeof window === "undefined") return null; const wallets = await discoverWallets(); - if (wallets.length === 0) return null; - - const selected = - wallets.find((w) => `${w.name ?? ""}`.toLowerCase().includes("ready")) ?? - wallets[0]; + const selected = wallets.find((w) => `${w.name ?? ""}`.toLowerCase().includes("ready")); + if (!selected) return null; try { await walletV6.requestAccounts(selected);