UNPKG

zkverifyjs

Version:

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

84 lines 4.16 kB
import { zkVerifySessionOptions } from '../../types'; import { AccountConnection, EstablishedConnection, WalletConnection } from '../../../api/connection/types'; import { ApiPromise, WsProvider } from '@polkadot/api'; import { KeyringPair } from '@polkadot/keyring/types'; import { AccountInfo, NetworkConfig } from '../../../types'; export declare class ConnectionManager { private accountMutex; private connection; customNetwork: boolean; readOnly: boolean; constructor(connection: AccountConnection | WalletConnection | EstablishedConnection, config: NetworkConfig); /** * Creates a new session with a connection to the specified network. * Supports multiple accounts for startSession if provided in options. * @param {zkVerifySessionOptions} options - The session configuration options. * @returns {Promise<ConnectionManager>} A promise resolving to a ConnectionManager instance. */ static createSession(options: zkVerifySessionOptions): Promise<ConnectionManager>; /** * Closes the current session, disconnecting from the provider and cleaning up resources. * @returns {Promise<void>} A promise that resolves when the session is closed. */ close(): Promise<void>; /** * Retrieves account information for a specified address or all accounts. * If no address is provided, returns an array of all account info objects. * * @param {string} [accountAddress] - The address of the account to fetch info for. If undefined, returns all accounts. * @returns {Promise<AccountInfo[]>} A promise resolving to an array of account info objects. * @throws Will throw an error if the account is not found. */ getAccountInfo(accountAddress?: string): Promise<AccountInfo[]>; /** * Adds a single account to the session in a thread-safe manner. * * @param {string} seedPhrase - The seed phrase used to generate the account. * @returns {Promise<string>} A promise resolving to the account address. * @throws {Error} If the account is already added. */ addAccount(seedPhrase: string): Promise<string>; /** * Adds multiple accounts to the session in a thread-safe manner. * * @param {string[]} seedPhrases - An array of seed phrases to generate accounts. * @returns {Promise<string[]>} A promise resolving to an array of added account addresses. * @throws {Error} If any of the accounts are already active. */ addAccounts(seedPhrases: string[]): Promise<string[]>; /** * Removes an account from the session in a thread-safe manner. * * @param {string} [address] - (Optional) The account address to remove. * If omitted and only one account exists, that account will be removed. * If omitted and no accounts exist, the method does nothing. * @throws {Error} If a specified account is not found or the connection type does not support accounts. */ removeAccount(address?: string): Promise<void>; /** * Getter for the API instance. * @returns {ApiPromise} The Polkadot.js API instance. */ get api(): ApiPromise; /** * Getter for the provider. * @returns {WsProvider} The WebSocket provider. */ get provider(): WsProvider; /** * Retrieves the account associated with the given address. * If no address is provided, it returns the first available account. * * @param {string} [accountAddress] - The address of the account to retrieve. If not provided, the first account is returned. * @returns {KeyringPair} The associated KeyringPair. * @throws {Error} If no accounts exist in the session or the specified account is not found. */ getAccount(accountAddress?: string): KeyringPair; /** * Retrieves the current connection details. * * @returns {AccountConnection | WalletConnection | EstablishedConnection} The current connection instance. */ get connectionDetails(): AccountConnection | WalletConnection | EstablishedConnection; } //# sourceMappingURL=index.d.ts.map