UNPKG

@kryptogo/kryptogokit-sdk-react

Version:

KryptogoKit offers a comprehensive web3 wallet solution with seamless KryptoGO Auth integration and multi-wallet connection support. Designed for users. Built for developers.

248 lines (243 loc) 9.61 kB
"use client"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // src/wallets/walletConnectors/kaikasWallet/kaikasWallet.svg var require_kaikasWallet = __commonJS({ "src/wallets/walletConnectors/kaikasWallet/kaikasWallet.svg"(exports, module) { module.exports = 'data:image/svg+xml,<svg width="26" height="26" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="%23fff" d="M0 0h26v26H0z"/><mask id="a" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="26" height="26"><path d="M26 0H0v25.95h26V0Z" fill="%23fff"/></mask><g mask="url(%23a)"><path d="m17.828 13.081-1.206 2.581c-.605 1.296-1.834 2.114-3.176 2.114H5.423C4.088 17.771 3 18.951 3 20.386 3 21.82 4.088 23 5.423 23h16.368c.97 0 1.543-1.17.998-2.034l-4.959-7.885h-.002Z" fill="%2399B3FF"/><path d="M20.574 3H6.654C4.637 3 3 4.765 3 6.944v13.442c0-1.435 1.088-2.615 2.423-2.615h8.025c1.342 0 2.572-.818 3.177-2.114L21.65 4.884C22.055 4.02 21.473 3 20.574 3Z" fill="%2336F"/><path d="M13.836 11.122c.813 0 1.473-.555 1.473-1.241 0-.687-.66-1.242-1.473-1.242-.814 0-1.474.555-1.474 1.242 0 .686.66 1.241 1.474 1.241Z" fill="%23DAFF86"/></g></svg>'; } }); // src/wallets/getInjectedConnector.ts import { createConnector } from "wagmi"; import { injected } from "wagmi/connectors"; function getExplicitInjectedProvider(flag) { const _window = typeof window !== "undefined" ? window : void 0; if (typeof _window === "undefined" || typeof _window.ethereum === "undefined") return; const providers = _window.ethereum.providers; return providers ? providers.find((provider) => provider[flag]) : _window.ethereum[flag] ? _window.ethereum : void 0; } function getWindowProviderNamespace(namespace) { const providerSearch = (provider, namespace2) => { const [property, ...path] = namespace2.split("."); const _provider = provider[property]; if (_provider) { if (path.length === 0) return _provider; return providerSearch(_provider, path.join(".")); } }; if (typeof window !== "undefined") return providerSearch(window, namespace); } function hasInjectedProvider({ flag, namespace }) { if (namespace && typeof getWindowProviderNamespace(namespace) !== "undefined") return true; if (flag && typeof getExplicitInjectedProvider(flag) !== "undefined") return true; return false; } function getInjectedProvider({ flag, namespace }) { const _window = typeof window !== "undefined" ? window : void 0; if (typeof _window === "undefined") return; if (namespace) { const windowProvider = getWindowProviderNamespace(namespace); if (windowProvider) return windowProvider; } const providers = _window.ethereum?.providers; if (flag) { const provider = getExplicitInjectedProvider(flag); if (provider) return provider; } if (typeof providers !== "undefined" && providers.length > 0) return providers[0]; return _window.ethereum; } function createInjectedConnector(provider) { return (walletDetails) => { const injectedConfig = provider ? { shimDisconnect: false, target: () => ({ id: walletDetails.rkDetails.id, name: walletDetails.rkDetails.name, provider }) } : { shimDisconnect: false }; return createConnector((config) => ({ // Spread the injectedConfig object, which may be empty or contain the target function ...injected(injectedConfig)(config), ...walletDetails })); }; } function getInjectedConnector({ flag, namespace, target }) { const provider = target ? target : getInjectedProvider({ flag, namespace }); return createInjectedConnector(provider); } // src/wallets/getWalletConnectConnector.ts import { createConnector as createConnector2 } from "wagmi"; import { walletConnect } from "wagmi/connectors"; var walletConnectInstances = /* @__PURE__ */ new Map(); var getOrCreateWalletConnectInstance = ({ projectId, walletConnectParameters, rkDetailsShowQrModal }) => { let config = { ...walletConnectParameters ? walletConnectParameters : {}, projectId, showQrModal: false // Required. Otherwise WalletConnect modal (Web3Modal) will popup during time of connection for a wallet }; if (rkDetailsShowQrModal) { config = { ...config, showQrModal: true }; } const serializedConfig = JSON.stringify(config); const sharedWalletConnector = walletConnectInstances.get(serializedConfig); if (sharedWalletConnector) { return sharedWalletConnector; } const newWalletConnectInstance = walletConnect(config); walletConnectInstances.set(serializedConfig, newWalletConnectInstance); return newWalletConnectInstance; }; function createWalletConnectConnector({ projectId, walletDetails, walletConnectParameters }) { return createConnector2((config) => ({ ...getOrCreateWalletConnectInstance({ projectId, walletConnectParameters, // Used in `connectorsForWallets` to add another // walletConnect wallet into kryptogokit with modal popup option rkDetailsShowQrModal: walletDetails.rkDetails.showQrModal })(config), ...walletDetails })); } function getWalletConnectConnector({ projectId, walletConnectParameters }) { const exampleProjectId = "04b90987df7d8e1e08a7d7ce0df821a6"; if (!projectId || projectId === "" || projectId === "YOUR_PROJECT_ID") { projectId = exampleProjectId; } return (walletDetails) => createWalletConnectConnector({ projectId, walletDetails, walletConnectParameters }); } // src/wallets/walletConnectors/kaikasWallet/kaikasWallet.ts var kaikasWallet = ({ projectId, walletConnectParameters }) => { const isKaikasWalletInjected = hasInjectedProvider({ namespace: "klaytn" }); const shouldUseWalletConnect = !isKaikasWalletInjected; const getUri = (uri) => { return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`; }; return { id: "kaikas", name: "Kaikas Wallet", iconUrl: async () => (await Promise.resolve().then(() => __toESM(require_kaikasWallet(), 1))).default, installed: isKaikasWalletInjected || void 0, iconBackground: "#fff", downloadUrls: { chrome: "https://chromewebstore.google.com/detail/kaikas/jblndlipeogpafnldhgmapagcccfchpi", browserExtension: "https://app.kaikas.io", qrCode: "https://app.kaikas.io", ios: "https://apps.apple.com/us/app/kaikas-mobile-crypto-wallet/id1626107061", android: "https://play.google.com/store/apps/details?id=io.klutch.wallet", mobile: "https://app.kaikas.io" }, mobile: { getUri: shouldUseWalletConnect ? getUri : void 0 }, qrCode: shouldUseWalletConnect ? { getUri: (uri) => uri, instructions: { learnMoreUrl: "https://kaikas.io", steps: [ { description: "wallet_connectors.kaikas.qr_code.step1.description", step: "install", title: "wallet_connectors.kaikas.qr_code.step1.title" }, { description: "wallet_connectors.kaikas.qr_code.step2.description", step: "create", title: "wallet_connectors.kaikas.qr_code.step2.title" }, { description: "wallet_connectors.kaikas.qr_code.step3.description", step: "refresh", title: "wallet_connectors.kaikas.qr_code.step3.title" } ] } } : void 0, extension: { instructions: { learnMoreUrl: "https://kaikas.io", steps: [ { description: "wallet_connectors.kaikas.extension.step1.description", step: "install", title: "wallet_connectors.kaikas.extension.step1.title" }, { description: "wallet_connectors.kaikas.extension.step2.description", step: "create", title: "wallet_connectors.kaikas.extension.step2.title" }, { description: "wallet_connectors.kaikas.extension.step3.description", step: "refresh", title: "wallet_connectors.kaikas.extension.step3.title" } ] } }, createConnector: shouldUseWalletConnect ? getWalletConnectConnector({ projectId, walletConnectParameters }) : getInjectedConnector({ namespace: "klaytn" }) }; }; export { kaikasWallet };