UNPKG

zkverifyjs

Version:

Submit proofs to zkVerify and query proof state with ease using our npm package.

51 lines (50 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NetworkBuilder = void 0; const config_1 = require("../../../config"); class NetworkBuilder { constructor(startSession, config) { this.startSession = startSession; this.options = {}; this.options.networkConfig = config; } /** * Sets a single seed phrase for a non-browser based session. * @param {string} seedPhrase - The seed phrase to use. * @returns {Promise<zkVerifySession>} A promise resolving to the session instance. */ withAccount(seedPhrase) { this.options.seedPhrases = [seedPhrase]; return this.startSession(this.options); } /** * Sets multiple seed phrases for a non-browser based session. * @param {string[]} seedPhrases - An array of seed phrases. * @returns {Promise<zkVerifySession>} A promise resolving to the session instance. * @throws Will throw an error if fewer than two seed phrases are provided. */ withAccounts(seedPhrases) { if (!Array.isArray(seedPhrases) || seedPhrases.length < 2) { throw new Error('withAccounts() requires at least two seed phrases. Use withAccount() for a single account.'); } this.options.seedPhrases = seedPhrases; return this.startSession(this.options); } /** * Sets a wallet connection for a browser based session. * @param {WalletOptions} wallet - The wallet options to use. * @returns {Promise<zkVerifySession>} A promise resolving to the session instance. */ withWallet(wallet) { this.options.wallet = wallet; return this.startSession(this.options); } /** * Initializes the session in read-only mode. * @returns {Promise<zkVerifySession>} A promise resolving to the session instance. */ readOnly() { return this.startSession(this.options); } } exports.NetworkBuilder = NetworkBuilder;