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.

146 lines (141 loc) 6.35 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/omniWallet/omniWallet.svg var require_omniWallet = __commonJS({ "src/wallets/walletConnectors/omniWallet/omniWallet.svg"(exports, module) { module.exports = 'data:image/svg+xml,<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<rect width="512" height="512" fill="black"/>%0A<path d="M67.8275 284.642C65.2758 277.745 64 270.6 64 263.193C64 254.255 65.2758 246.09 68.0826 238.428C90.5516 177.407 170.979 158 268.766 158C366.552 158 428.338 185.062 444.173 227.959C446.724 234.855 448 242 448 249.407C448 258.345 446.724 266.51 443.917 274.173C421.448 335.193 341.021 354.6 243.235 354.6C145.448 354.6 83.6622 327.531 67.8275 284.642ZM193.696 273.152C198.8 286.938 220.503 298.428 250.889 298.428C284.338 298.428 310.124 288.469 318.041 267.276C320.593 260.889 320.848 257.062 320.848 252.724C320.848 248.897 320.848 245.572 318.296 239.448C313.193 225.662 291.49 214.173 261.103 214.173C227.655 214.173 201.869 224.131 193.951 245.324C191.4 251.711 191.145 255.538 191.145 259.876C191.145 263.704 191.145 267.028 193.696 273.152Z" fill="white"/>%0A<path d="M229.477 263.47C231.65 269.339 240.887 274.231 253.827 274.231C268.066 274.231 279.045 269.995 282.413 260.969C283.499 258.25 283.609 256.624 283.609 254.773C283.609 253.139 283.609 251.732 282.522 249.122C280.35 243.254 271.113 238.362 258.173 238.362C243.934 238.362 232.955 242.598 229.587 251.623C228.501 254.342 228.391 255.968 228.391 257.82C228.391 259.453 228.391 260.86 229.477 263.47Z" fill="white"/>%0A</svg>%0A'; } }); // src/utils/isMobile.ts function isAndroid() { return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent); } // src/wallets/getWalletConnectConnector.ts import { createConnector } 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 createConnector((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/omniWallet/omniWallet.ts var omniWallet = ({ projectId, walletConnectParameters }) => ({ id: "omni", name: "Omni", iconUrl: async () => (await Promise.resolve().then(() => __toESM(require_omniWallet(), 1))).default, iconBackground: "#000", downloadUrls: { android: "https://play.google.com/store/apps/details?id=fi.steakwallet.app", ios: "https://itunes.apple.com/us/app/id1569375204", mobile: "https://omniwallet.app.link", qrCode: "https://omniwallet.app.link" }, mobile: { getUri: (uri) => { return isAndroid() ? uri : `omni://wc?uri=${encodeURIComponent(uri)}`; } }, qrCode: { getUri: (uri) => uri, instructions: { learnMoreUrl: "https://omni.app/support", steps: [ { description: "wallet_connectors.omni.qr_code.step1.description", step: "install", title: "wallet_connectors.omni.qr_code.step1.title" }, { description: "wallet_connectors.omni.qr_code.step2.description", step: "create", title: "wallet_connectors.omni.qr_code.step2.title" }, { description: "wallet_connectors.omni.qr_code.step3.description", step: "scan", title: "wallet_connectors.omni.qr_code.step3.title" } ] } }, createConnector: getWalletConnectConnector({ projectId, walletConnectParameters }) }); export { omniWallet };