@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.15 kB
JavaScript
"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/oktoWallet/oktoWallet.svg
var require_oktoWallet = __commonJS({
"src/wallets/walletConnectors/oktoWallet/oktoWallet.svg"(exports, module) {
module.exports = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path fill="url(%23a)" d="M0 0h28v28H0z"/><path fill="%23fff" fill-rule="evenodd" d="M14 7.52a6.48 6.48 0 0 0-6.398 7.512c.035.23.17.727.421.882.314.193.67.027.961-.11h.002l1.23-.573a.526.526 0 0 1 .445.01.53.53 0 0 1 .284.504.517.517 0 0 1-.287.426l-1.522.709a.714.714 0 0 0-.386.43.705.705 0 0 0 .44.874.695.695 0 0 0 .514-.021l3.34-1.557a.514.514 0 0 1 .439.016.52.52 0 0 1 .284.488c-.012.14-.09.347-.28.436l-2.265 1.055a.696.696 0 0 0-.384.585.697.697 0 0 0 .984.683l4.068-1.897a.542.542 0 0 1 .45 0 .52.52 0 0 1 .3.461c0 .149-.006.258-.242.469-.206.184-.508.366-1.537.805-.353.15-.593.26-.554.45.03.143.134.197.479.181.345-.015 1.897-.137 3.452-1.436A6.466 6.466 0 0 0 20.48 14c0-.722-.118-1.416-.336-2.064a.624.624 0 0 1-.51-1.139A6.478 6.478 0 0 0 14 7.52Zm2.4 4.08a.624.624 0 1 1-1.247 0 .624.624 0 0 1 1.247 0Z" clip-rule="evenodd"/><defs><linearGradient id="a" x1="14" x2="14" y1="0" y2="28" gradientUnits="userSpaceOnUse"><stop stop-color="%236246F5"/><stop offset=".493" stop-color="%235166EE"/><stop offset="1" stop-color="%2356B9F9"/></linearGradient></defs></svg>';
}
});
// 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/oktoWallet/oktoWallet.ts
var oktoWallet = ({ projectId, walletConnectParameters }) => ({
id: "Okto",
name: "Okto",
iconUrl: async () => (await Promise.resolve().then(() => __toESM(require_oktoWallet(), 1))).default,
iconBackground: "#fff",
downloadUrls: {
android: "https://play.google.com/store/apps/details?id=im.okto.contractwalletclient",
ios: "https://apps.apple.com/in/app/okto-wallet/id6450688229",
mobile: "https://okto.tech/",
qrCode: "https://okto.tech/"
},
mobile: {
getUri: (uri) => {
return isAndroid() ? uri : `okto://wc?uri=${encodeURIComponent(uri)}`;
}
},
qrCode: {
getUri: (uri) => uri,
instructions: {
learnMoreUrl: "https://okto.tech/",
steps: [
{
description: "wallet_connectors.okto.qr_code.step1.description",
step: "install",
title: "wallet_connectors.okto.qr_code.step1.title"
},
{
description: "wallet_connectors.okto.qr_code.step2.description",
step: "create",
title: "wallet_connectors.okto.qr_code.step2.title"
},
{
description: "wallet_connectors.okto.qr_code.step3.description",
step: "scan",
title: "wallet_connectors.okto.qr_code.step3.title"
}
]
}
},
createConnector: getWalletConnectConnector({
projectId,
walletConnectParameters
})
});
export {
oktoWallet
};