UNPKG

zkverifyjs

Version:

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

115 lines 5.4 kB
import { ApiPromise } from '@polkadot/api'; import { EventEmitter } from 'events'; import { Delivery, DomainOptions, ProofProcessor } from '../../types'; import { Groth16Config, Plonky2Config, ProofOptions, ProofType, Risc0Config, UltraplonkConfig } from '../../config'; import { Extrinsic } from '@polkadot/types/interfaces'; import { AccountConnection, EstablishedConnection, WalletConnection } from '../../api/connection/types'; import { KeyringPair } from '@polkadot/keyring/types'; import { SubmittableExtrinsic } from '@polkadot/api/types'; /** * Waits for the zkVerify node to sync. * @param api - The ApiPromise instance. * @returns A promise that resolves when the node is synced. */ export declare function waitForNodeToSync(api: ApiPromise): Promise<void>; export declare function getProofProcessor(proofType: ProofType): ProofProcessor; export declare function getProofPallet(proofType: ProofType): string; export declare function checkReadOnly(connection: AccountConnection | WalletConnection | EstablishedConnection): void; /** * Interprets a dry run response and returns whether it was successful and any error message. * @param api - The Polkadot.js API instance. * @param resultHex - The hex-encoded response from a dry run. * @returns An object containing `success` (boolean) and `message` (string). */ export declare const interpretDryRunResponse: (api: ApiPromise, resultHex: string) => Promise<{ success: boolean; message: string; }>; /** * Binds all methods from the source object to the target object, * preserving the original `this` context. * * Throws an error if a method with the same name already exists on the target. * * @param target - The object to bind methods to. * @param source - The object containing the methods to bind. * * @throws {Error} If a method with the same name already exists on the target. */ export declare function bindMethods<T extends object>(target: T, source: object): void; /** * Retrieves the selected account from the connection based on the provided account address. * If no account address is provided, it defaults to the first available account. * * @param {AccountConnection} connection - The connection containing account information. * @param {string | undefined} accountAddress - The optional account address to retrieve. * @returns {KeyringPair} - The selected account. * @throws {Error} If the account is not found. */ export declare const getSelectedAccount: (connection: AccountConnection, accountAddress?: string) => KeyringPair; /** * Retrieves the selected `KeyringPair` from the given connection if it is an `AccountConnection`. * * - If the connection has local `accounts` (i.e., it's an `AccountConnection`), it uses the provided `accountAddress` * to select the appropriate account via `getSelectedAccount`. * - If the connection is a `WalletConnection`, returns `undefined`. * * @param {AccountConnection | WalletConnection} connection - The connection object which may contain accounts. * @param {string} [accountAddress] - Optional address of the account to select. * @returns {KeyringPair | undefined} - The selected `KeyringPair` if available, otherwise `undefined`. */ export declare function getKeyringAccountIfAvailable(connection: AccountConnection | WalletConnection, accountAddress?: string): KeyringPair | undefined; /** * Converts a `DeliveryInput` into a properly formatted `Delivery` object. * Supports either a `None` variant or a `Hyperbridge` delivery configuration. * * @returns A `Delivery` object formatted for on-chain use. * @throws {Error} If required fields for Hyperbridge delivery are missing or invalid. * @param options */ export declare function normalizeDeliveryFromOptions(options: DomainOptions): Delivery; /** * Extracts a human-readable error message from various error types. * * @param err - The error object to extract a message from. * @returns A string message describing the error. */ export declare const extractErrorMessage: (err: unknown) => string; /** * Safe wrapper for emitting events without crashing. */ export declare const safeEmit: (emitter: EventEmitter, event: string, data: unknown) => void; /** * Type guard for Groth16Config */ export declare function isGroth16Config(options: ProofOptions): options is ProofOptions & { config: Groth16Config; }; /** * Type guard for Plonky2Config */ export declare function isPlonky2Config(options: ProofOptions): options is ProofOptions & { config: Plonky2Config; }; /** * Type guard for Risc0Config */ export declare function isRisc0Config(options: ProofOptions): options is ProofOptions & { config: Risc0Config; }; /** * Type guard for Ultraplonk Config */ export declare function isUltraplonkConfig(options: ProofOptions): options is ProofOptions & { config: UltraplonkConfig; }; /** * Ensures the provided extrinsic is a SubmittableExtrinsic. * Converts a raw Extrinsic to Submittable if needed using the given API instance. * * @param extrinsic - A SubmittableExtrinsic or raw Extrinsic. * @param api - An instance of ApiPromise used to convert the extrinsic. * @returns A SubmittableExtrinsic<'promise'> ready to be signed and submitted. */ export declare function toSubmittableExtrinsic(extrinsic: SubmittableExtrinsic<'promise'> | Extrinsic, api: ApiPromise): SubmittableExtrinsic<'promise'>; //# sourceMappingURL=index.d.ts.map