@molecularlabs/nucleus-frontend
Version:
Nucleus BoringVault Frontend SDK
25 lines • 699 B
JavaScript
import { createPublicClient, http } from "viem";
import { getChainFromConfig } from "../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 getChainFromConfig(chainId);
const client2 = createPublicClient({
chain,
transport: 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;
};
export {
getClient
};
//# sourceMappingURL=client.mjs.map