@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.
178 lines (173 loc) • 6.69 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/ledgerWallet/ledgerWallet.svg
var require_ledgerWallet = __commonJS({
"src/wallets/walletConnectors/ledgerWallet/ledgerWallet.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="%23000" d="M0 0h28v28H0z"/><path fill="%23fff" fill-rule="evenodd" d="M11.65 4.4H4.4V9h1.1V5.5l6.15-.04V4.4Zm.05 5.95v7.25h4.6v-1.1h-3.5l-.04-6.15H11.7ZM4.4 23.6h7.25v-1.06L5.5 22.5V19H4.4v4.6ZM16.35 4.4h7.25V9h-1.1V5.5l-6.15-.04V4.4Zm7.25 19.2h-7.25v-1.06l6.15-.04V19h1.1v4.6Z" clip-rule="evenodd"/></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/ledgerWallet/ledgerWallet.ts
var ledgerWallet = ({ projectId, walletConnectParameters }) => ({
id: "ledger",
iconBackground: "#000",
iconAccent: "#000",
name: "Ledger",
iconUrl: async () => (await Promise.resolve().then(() => __toESM(require_ledgerWallet(), 1))).default,
downloadUrls: {
android: "https://play.google.com/store/apps/details?id=com.ledger.live",
ios: "https://apps.apple.com/us/app/ledger-live-web3-wallet/id1361671700",
mobile: "https://www.ledger.com/ledger-live",
qrCode: "https://r354.adj.st/?adj_t=t2esmlk",
windows: "https://www.ledger.com/ledger-live/download",
macos: "https://www.ledger.com/ledger-live/download",
linux: "https://www.ledger.com/ledger-live/download",
desktop: "https://www.ledger.com/ledger-live"
},
mobile: {
getUri: (uri) => {
return isAndroid() ? uri : `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
}
},
desktop: {
getUri: (uri) => {
return `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
},
instructions: {
learnMoreUrl: "https://support.ledger.com/hc/en-us/articles/4404389503889-Getting-started-with-Ledger-Live",
steps: [
{
description: "wallet_connectors.ledger.desktop.step1.description",
step: "install",
title: "wallet_connectors.ledger.desktop.step1.title"
},
{
description: "wallet_connectors.ledger.desktop.step2.description",
step: "create",
title: "wallet_connectors.ledger.desktop.step2.title"
},
{
description: "wallet_connectors.ledger.desktop.step3.description",
step: "connect",
title: "wallet_connectors.ledger.desktop.step3.title"
}
]
}
},
qrCode: {
getUri: (uri) => {
return `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
},
instructions: {
learnMoreUrl: "https://support.ledger.com/hc/en-us/articles/4404389503889-Getting-started-with-Ledger-Live",
steps: [
{
description: "wallet_connectors.ledger.qr_code.step1.description",
step: "install",
title: "wallet_connectors.ledger.qr_code.step1.title"
},
{
description: "wallet_connectors.ledger.qr_code.step2.description",
step: "create",
title: "wallet_connectors.ledger.qr_code.step2.title"
},
{
description: "wallet_connectors.ledger.qr_code.step3.description",
step: "scan",
title: "wallet_connectors.ledger.qr_code.step3.title"
}
]
}
},
createConnector: getWalletConnectConnector({
projectId,
walletConnectParameters
})
});
export {
ledgerWallet
};