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.

138 lines (133 loc) 6.91 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/dawnWallet/dawnWallet.svg var require_dawnWallet = __commonJS({ "src/wallets/walletConnectors/dawnWallet/dawnWallet.svg"(exports, module) { module.exports = 'data:image/svg+xml,<?xml version="1.0" encoding="UTF-8"?>%0A<svg width="28px" height="28px" viewBox="0 0 192 192" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">%0A <defs>%0A <linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">%0A <stop stop-color="%23151515" offset="0%"></stop>%0A <stop stop-color="%23232323" offset="100%"></stop>%0A </linearGradient>%0A <rect id="path-2" x="0" y="0" width="192" height="192"></rect>%0A <linearGradient x1="50%" y1="0%" x2="50%" y2="99.7051532%" id="linearGradient-3">%0A <stop stop-color="%23F3DC83" offset="0%"></stop>%0A <stop stop-color="%23F9EEC8" offset="100%"></stop>%0A </linearGradient>%0A </defs>%0A <g id="Icons---Pixel-Fitted" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">%0A <g id="Group">%0A <g id="Rectangle">%0A <use fill="%23232323" xlink:href="%23path-2"></use>%0A <use fill="url(%23linearGradient-1)" xlink:href="%23path-2"></use>%0A </g>%0A <path d="M123.748399,157.001808 C115.293464,160.853955 105.89735,163 96,163 C86.1026503,163 76.7065363,160.853955 68.2516012,157.001808 Z M146.526595,140.002206 C144.677242,142.123986 142.696426,144.128189 140.59684,146.002121 L51.4031598,146.002121 C49.3035743,144.128189 47.3227581,142.123986 45.4734054,140.002206 Z M157.337411,122.999613 C155.955969,126.133404 154.34141,129.141319 152.515704,132.001388 L39.484296,132.001388 C37.6585895,129.141319 36.0440306,126.133404 34.662589,122.999613 Z M96,29 C133.003078,29 163,58.9969218 163,96 C163,103.706309 161.69895,111.108742 159.304524,117.999626 L32.6954763,117.999626 C30.3010496,111.108742 29,103.706309 29,96 C29,58.9969218 58.9969218,29 96,29 Z" id="Combined-Shape" fill="url(%23linearGradient-3)"></path>%0A </g>%0A </g>%0A</svg>'; } }); // src/utils/isMobile.ts function isSmallIOS() { return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent); } function isLargeIOS() { return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1); } function isIOS() { return isSmallIOS() || isLargeIOS(); } // 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/walletConnectors/dawnWallet/dawnWallet.ts var dawnWallet = () => ({ id: "dawn", name: "Dawn", iconUrl: async () => (await Promise.resolve().then(() => __toESM(require_dawnWallet(), 1))).default, iconBackground: "#000000", installed: hasInjectedProvider({ flag: "isDawn" }), hidden: () => !isIOS(), downloadUrls: { ios: "https://apps.apple.com/us/app/dawn-ethereum-wallet/id1673143782", mobile: "https://dawnwallet.xyz" }, createConnector: getInjectedConnector({ flag: "isDawn" }) }); export { dawnWallet };