Skip to content

Commit

Permalink
feat(connect-kit/wallets): add Browser Wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
runjuu committed Sep 7, 2023
1 parent eda2c5a commit 3e49350
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/connect-kit/src/wallets/wallets/browser-wallet/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { InjectedConnector } from "wagmi/connectors/injected";
import React from "react";

import { WalletIcon } from "../../../components";
import { Wallet } from "../../types";
import styles from "../coinbase-wallet/index.module.css";

export const browserWallet = (connector?: InjectedConnector): Wallet | null => {
if (!connector) return null;

const installed =
typeof window !== "undefined" && typeof window.ethereum !== "undefined";

return installed
? {
id: "injected",
name: "Browser Wallet",
installed: installed,
createConnector: () => {
return { connector };
},
icon: <WalletIcon className={styles.icon} />,
}
: null;
};
2 changes: 2 additions & 0 deletions packages/connect-kit/src/wallets/wallets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { metaMaskWallet } from "./meta-mask-wallet";
import { coinbaseWallet } from "./coinbase-wallet";
import { braveWallet } from "./brave-wallet";
import { okxWallet } from "./okx-wallet";
import { browserWallet } from "./browser-wallet";

enum KnownConnector {
metaMask = "metaMask",
Expand Down Expand Up @@ -43,6 +44,7 @@ export function useWalletConnectors() {
metaMaskWallet(connectorMap.metaMask, connectorMap.walletConnect),
coinbaseWallet(connectorMap.coinbaseWallet),
braveWallet(connectorMap.injected),
browserWallet(connectorMap.injected),
]),
[connectors],
);
Expand Down

0 comments on commit 3e49350

Please sign in to comment.