UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

219 lines (216 loc) 5.74 kB
"use client"; import { getWalletConnectConnector } from "./chunk-23WIEY36.js"; import { getInjectedConnector, hasInjectedProvider } from "./chunk-DNSG5Q7V.js"; // src/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.ts import { isAndroid, isIOS } from "@funkit/utils"; function isMetaMask(ethereum) { if (!ethereum?.isMetaMask) { return false; } if (ethereum.isBraveWallet && !ethereum._events && !ethereum._state) { return false; } if (ethereum.isApexWallet) { return false; } if (ethereum.isAvalanche) { return false; } if (ethereum.isBackpack) { return false; } if (ethereum.isBifrost) { return false; } if (ethereum.isBitKeep) { return false; } if (ethereum.isBitski) { return false; } if (ethereum.isBlockWallet) { return false; } if (ethereum.isCoinbaseWallet) { return false; } if (ethereum.isDawn) { return false; } if (ethereum.isEnkrypt) { return false; } if (ethereum.isExodus) { return false; } if (ethereum.isFrame) { return false; } if (ethereum.isFrontier) { return false; } if (ethereum.isGamestop) { return false; } if (ethereum.isHyperPay) { return false; } if (ethereum.isImToken) { return false; } if (ethereum.isKuCoinWallet) { return false; } if (ethereum.isMathWallet) { return false; } if (ethereum.isNestWallet) { return false; } if (ethereum.isOkxWallet || ethereum.isOKExWallet) { return false; } if (ethereum.isOneInchIOSWallet || ethereum.isOneInchAndroidWallet) { return false; } if (ethereum.isOpera) { return false; } if (ethereum.isPhantom) { return false; } if (ethereum.isPortal) { return false; } if (ethereum.isRabby) { return false; } if (ethereum.isRainbow) { return false; } if (ethereum.isStatus) { return false; } if (ethereum.isTalisman) { return false; } if (ethereum.isTally) { return false; } if (ethereum.isTokenPocket) { return false; } if (ethereum.isTokenary) { return false; } if (ethereum.isTrust || ethereum.isTrustWallet) { return false; } if (ethereum.isXDEFI) { return false; } if (ethereum.isZeal) { return false; } if (ethereum.isZerion) { return false; } return true; } var metaMaskWallet = ({ projectId, walletConnectParameters }) => { const isMetaMaskInjected = hasInjectedProvider({ flag: "isMetaMask" }); const shouldUseWalletConnect = !isMetaMaskInjected; const getUri = (uri) => { return isAndroid() ? uri : isIOS() ? ( // currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457 `metamask://wc?uri=${encodeURIComponent(uri)}` ) : `https://metamask.app.link/wc?uri=${encodeURIComponent(uri)}`; }; return { id: "metaMask", name: "MetaMask", rdns: "io.metamask", iconUrl: async () => (await import("./metaMaskWallet-RMHEKBDR.js")).default, iconAccent: "#f6851a", iconBackground: "#fff", installed: !shouldUseWalletConnect ? isMetaMaskInjected : void 0, downloadUrls: { android: "https://play.google.com/store/apps/details?id=io.metamask", ios: "https://apps.apple.com/us/app/metamask/id1438144202", mobile: "https://metamask.io/download", qrCode: "https://metamask.io/download", chrome: "https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn", edge: "https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm", firefox: "https://addons.mozilla.org/firefox/addon/ether-metamask", opera: "https://addons.opera.com/extensions/details/metamask-10", browserExtension: "https://metamask.io/download" }, mobile: { getUri: shouldUseWalletConnect ? getUri : void 0 }, qrCode: shouldUseWalletConnect ? { getUri, instructions: { learnMoreUrl: "https://metamask.io/faqs/", steps: [ { description: "wallet_connectors.metamask.qr_code.step1.description", step: "install", title: "wallet_connectors.metamask.qr_code.step1.title" }, { description: "wallet_connectors.metamask.qr_code.step2.description", step: "create", title: "wallet_connectors.metamask.qr_code.step2.title" }, { description: "wallet_connectors.metamask.qr_code.step3.description", step: "refresh", title: "wallet_connectors.metamask.qr_code.step3.title" } ] } } : void 0, extension: { instructions: { learnMoreUrl: "https://metamask.io/faqs/", steps: [ { description: "wallet_connectors.metamask.extension.step1.description", step: "install", title: "wallet_connectors.metamask.extension.step1.title" }, { description: "wallet_connectors.metamask.extension.step2.description", step: "create", title: "wallet_connectors.metamask.extension.step2.title" }, { description: "wallet_connectors.metamask.extension.step3.description", step: "refresh", title: "wallet_connectors.metamask.extension.step3.title" } ] } }, createConnector: shouldUseWalletConnect ? getWalletConnectConnector({ projectId, walletConnectParameters }) : getInjectedConnector({ target: typeof window !== "undefined" ? window.ethereum?.providers?.find( isMetaMask ) ?? window.ethereum : void 0 }) }; }; export { metaMaskWallet };