UNPKG

@molecularlabs/nucleus-frontend

Version:
45 lines 1.65 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var client_exports = {}; __export(client_exports, { getClient: () => getClient }); module.exports = __toCommonJS(client_exports); var import_viem = require("viem"); var import_chain_utils = require("../utils/chain-utils"); const clients = /* @__PURE__ */ new Map(); const getClient = async (chainId) => { if (!chainId) { throw new Error("Chain ID is required"); } if (!clients.has(chainId)) { const chain = await (0, import_chain_utils.getChainFromConfig)(chainId); const client2 = (0, import_viem.createPublicClient)({ chain, transport: (0, import_viem.http)(chain.rpcUrls.default.http[0]) }); clients.set(chainId, client2); } const client = clients.get(chainId); if (!client) { throw new Error(`Client not found for chain ID ${chainId}`); } return client; }; //# sourceMappingURL=client.js.map