zkverifyjs
Version:
Submit proofs to zkVerify and query proof state with ease using our npm package.
40 lines • 1.87 kB
JavaScript
import { getAggregateStatementPath, getVkHash } from "../../../api/rpc/index.js";
export class RpcManager {
/**
* Creates an instance of RpcManager.
* @param {ConnectionManager} connectionManager - The connection manager instance.
*/
constructor(connectionManager) {
this.connectionManager = connectionManager;
}
/**
* Retrieves the aggregate statement path from the blockchain via the custom RPC method.
*
* @async
* @function getAggregateStatementPath
* @param {string} at - The block hash at which to perform the query. Must be a non-empty string.
* @param {number} domainId - The domain ID for which the aggregation statement path is requested. Must be >= 0.
* @param {number} aggregationId - The aggregation ID associated with the requested statement path. Must be >= 0.
* @param {string} statement - The statement hash to query for. Must be a non-empty string.
* @returns {Promise<AggregateStatementPathResult>} A promise that resolves to the AggregateStatementPathResult.
* @throws {Error} If any of the inputs are invalid or if the RPC call fails.
*/
async getAggregateStatementPath(at, domainId, aggregationId, statement) {
const api = this.connectionManager.connectionDetails.api;
return getAggregateStatementPath(api, at, domainId, aggregationId, statement);
}
/**
* Retrieves the VK hash for the given proof type and verification key.
*
* @async
* @function getVkHash
* @param {ProofOptions} proofOptions - Proof specific options.
* @param {string} vk - The verification key string.
* @returns {Promise<string>} - The resulting VK hash.
* @throws {Error} If the proof type is unsupported or the RPC call fails.
*/
async getVkHash(proofOptions, vk) {
const api = this.connectionManager.connectionDetails.api;
return getVkHash(api, proofOptions, vk);
}
}