@opendatalabs/vana-sdk
Version:
A TypeScript library for interacting with Vana Network smart contracts.
70 lines • 2.37 kB
JavaScript
;
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, {
createClient: () => createClient,
createWalletClient: () => createWalletClient,
defaultFromBlocks: () => defaultFromBlocks,
getDefaultFromBlock: () => getDefaultFromBlock
});
module.exports = __toCommonJS(client_exports);
var import_viem = require("viem");
var import_chains = require("../config/chains");
const defaultFromBlocks = {
14800: 732312n,
// Moksha Testnet - earliest contract deployment
1480: 758584n
// Vana Mainnet - earliest contract deployment
};
function getDefaultFromBlock(chainId) {
return defaultFromBlocks[chainId] || 0n;
}
let cachedClient;
const createClient = (chainId = import_chains.mokshaTestnet.id) => {
if (!cachedClient || cachedClient.chain?.id !== chainId) {
const chain = import_chains.chains[chainId];
if (!chain) {
throw new Error(`Chain ${chainId} not found`);
}
cachedClient = (0, import_viem.createPublicClient)({
chain,
transport: (0, import_viem.http)()
});
}
return cachedClient;
};
const createWalletClient = (chainId = import_chains.mokshaTestnet.id, account) => {
const chain = import_chains.chains[chainId];
if (!chain) {
throw new Error(`Chain ${chainId} not found`);
}
return (0, import_viem.createWalletClient)({
chain,
transport: (0, import_viem.http)(),
account
});
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createClient,
createWalletClient,
defaultFromBlocks,
getDefaultFromBlock
});
//# sourceMappingURL=client.cjs.map