diff --git a/src/components/wallet-connection/WalletConnectorButton.tsx b/src/components/wallet-connection/WalletConnectorButton.tsx
index db36f9820..1ea8d60d9 100644
--- a/src/components/wallet-connection/WalletConnectorButton.tsx
+++ b/src/components/wallet-connection/WalletConnectorButton.tsx
@@ -6,23 +6,14 @@ interface WalletConnectorButtonProps {
connector?: Connector;
walletName: string;
walletIcon: string;
- isInstalled: boolean;
- onConnect: () => void;
- disabled?: boolean;
+ onConnect?: () => void;
}
/**
* Single wallet connector button with icon and loading state
* Handles connection to a specific wallet connector
*/
-export function WalletConnectorButton({
- connector,
- walletName,
- walletIcon,
- isInstalled,
- onConnect,
- disabled,
-}: WalletConnectorButtonProps) {
+export function WalletConnectorButton({ connector, walletName, walletIcon, onConnect }: WalletConnectorButtonProps) {
const { connect, isPending, connectingWalletId } = useWalletConnection({
onSuccess: onConnect,
});
@@ -30,11 +21,7 @@ export function WalletConnectorButton({
const isConnecting = connector && isPending && connectingWalletId === connector.id;
const handleClick = () => {
- // Only connect if wallet is installed and connector exists
- if (!isInstalled || !connector) {
- return;
- }
- connect(connector.id);
+ if (connector) connect(connector.id);
};
return (
@@ -42,11 +29,9 @@ export function WalletConnectorButton({
variant="outline"
size="xl"
width="full"
- className={`flex flex-row items-center justify-start gap-3 h-14 text-pinto-gray-5 hover:text-pinto-gray-5 disabled:opacity-50 disabled:cursor-not-allowed ${
- !isInstalled ? "opacity-50 cursor-not-allowed" : ""
- }`}
+ className="flex flex-row items-center justify-start gap-3 h-14 text-pinto-gray-5 hover:text-pinto-gray-5 disabled:opacity-50 disabled:cursor-not-allowed"
onClick={handleClick}
- disabled={disabled || (isPending && !isConnecting)}
+ disabled={!connector || (isPending && !isConnecting)}
>
![]()
void;
}
-interface WalletConfig {
- id: string;
- name: string;
- icon: string;
- checkInstalled?: () => boolean;
-}
-
-const WALLET_ORDER: WalletConfig[] = [
+const WALLET_ORDER = [
{
- id: "rabby",
+ id: "io.rabby",
name: "Rabby Wallet",
icon: rabbyIcon,
- checkInstalled: () => typeof window !== "undefined" && window.ethereum?.isRabby === true,
},
{
- id: "metamask",
+ id: "io.metamask",
+ fallbackId: "io.metamask.flask",
name: "MetaMask",
icon: metamaskIcon,
- checkInstalled: () => typeof window !== "undefined" && window.ethereum?.isMetaMask === true,
},
{
- id: "walletconnect",
+ id: "walletConnect",
name: "WalletConnect",
icon: walletconnectIcon,
- checkInstalled: () => true, // WalletConnect is always available (QR code)
},
{
- id: "coinbase",
+ id: "coinbaseWalletSDK",
name: "Coinbase Wallet",
icon: coinbaseIcon,
- checkInstalled: () => true, // Coinbase Wallet can use QR code if extension not installed
},
];
@@ -51,44 +39,20 @@ const WALLET_ORDER: WalletConfig[] = [
* Shows: Rabby, MetaMask, WalletConnect, Coinbase Wallet
*/
export function WalletConnectorList({ onConnect }: WalletConnectorListProps) {
- const { connectors } = useConnect();
-
- const orderedWallets = useMemo(() => {
- return WALLET_ORDER.map((walletConfig) => {
- // Find matching connector
- const connector = connectors.find((c) => {
- const idLower = c.id.toLowerCase();
- const nameLower = c.name.toLowerCase();
- const configIdLower = walletConfig.id.toLowerCase();
-
- return (
- idLower.includes(configIdLower) ||
- nameLower.includes(configIdLower) ||
- (configIdLower === "walletconnect" && (c.type === "walletConnect" || c.type === "wallet_connect"))
- );
- });
-
- const isInstalled = walletConfig.checkInstalled?.() ?? false;
-
- return {
- config: walletConfig,
- connector,
- isInstalled,
- icon: walletConfig.icon,
- };
- });
- }, [connectors]);
+ const connectors = useConnectors();
return (
<>
- {orderedWallets.map(({ config, connector, isInstalled, icon }) => (
+ {WALLET_ORDER.map(({ id, fallbackId, name, icon }) => (
connector.id === id) ??
+ connectors.find((connector) => connector.id === fallbackId)
+ }
+ walletName={name}
walletIcon={icon}
- isInstalled={isInstalled}
- onConnect={() => onConnect?.()}
+ onConnect={onConnect}
/>
))}
>
diff --git a/src/components/wallet-connection/__tests__/WalletConnectorList.test.tsx b/src/components/wallet-connection/__tests__/WalletConnectorList.test.tsx
new file mode 100644
index 000000000..e4ced481e
--- /dev/null
+++ b/src/components/wallet-connection/__tests__/WalletConnectorList.test.tsx
@@ -0,0 +1,74 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { renderToStaticMarkup } from "react-dom/server";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { http, WagmiProvider, createConfig } from "wagmi";
+import { base } from "wagmi/chains";
+import { injected } from "wagmi/connectors";
+import { WalletConnectorList } from "../WalletConnectorList";
+
+vi.hoisted(() => {
+ vi.stubEnv("VITE_CHAINS", "8453");
+});
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+function renderWalletButtons(announcedWallets: { rdns: string; name: string }[], isMetaMask = false) {
+ const browser = Object.assign(new EventTarget(), {
+ ethereum: { isBraveWallet: true, isMetaMask },
+ });
+ vi.stubGlobal("window", browser);
+
+ browser.addEventListener("eip6963:requestProvider", () => {
+ for (const wallet of announcedWallets) {
+ browser.dispatchEvent(
+ new CustomEvent("eip6963:announceProvider", {
+ detail: { info: { ...wallet, uuid: crypto.randomUUID() }, provider: {} },
+ }),
+ );
+ }
+ });
+
+ const config = createConfig({
+ chains: [base],
+ transports: { [base.id]: http() },
+ connectors: [injected()],
+ storage: null,
+ });
+
+ const html = renderToStaticMarkup(
+
+
+
+
+ ,
+ );
+
+ return html.match(/