Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions ui/src/wallet-account-v6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading