UNPKG

vana-sdk

Version:

A TypeScript library for interacting with Vana Network smart contracts

45 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VanaProvider = void 0; const viem_1 = require("viem"); const addresses_1 = require("../config/addresses"); const client_1 = require("./client"); const contractController_1 = require("../contracts/contractController"); class VanaProvider { provider; signer; chainId; addresses; client; contracts; constructor(config) { this.provider = (0, viem_1.createPublicClient)({ transport: (0, viem_1.http)(config.rpcUrl), }); this.signer = config.signer; this.chainId = config.chainId; this.addresses = addresses_1.CONTRACT_ADDRESSES[config.chainId] || {}; this.client = (0, client_1.createClient)(config.chainId); // Initialize contracts this.contracts = { dataRegistry: (0, contractController_1.getContractController)("DataRegistry", this.client), teePool: (0, contractController_1.getContractController)("TeePool", this.client), computeEngine: (0, contractController_1.getContractController)("ComputeEngine", this.client), dataLiquidityPool: (0, contractController_1.getContractController)("DataLiquidityPool", this.client), }; } getContractAddress(name) { const addr = this.addresses[name]; if (!addr) throw new Error(`No address for ${name} on chain ${this.chainId}`); return addr; } async signerAddress() { if (!this.signer) { throw new Error("No signer configured"); } return this.signer.address; } } exports.VanaProvider = VanaProvider; //# sourceMappingURL=provider.js.map