zkverifyjs
Version:
Submit proofs to zkVerify and query proof state with ease using our npm package.
37 lines (36 loc) • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegisterKeyBuilder = void 0;
class RegisterKeyBuilder {
constructor(executeRegisterVerificationKey, proofOptions, accountAddress) {
this.executeRegisterVerificationKey = executeRegisterVerificationKey;
this.nonceSet = false;
this.options = { proofOptions, accountAddress };
}
/**
* Sets the nonce for the registration process.
* Can only be set once; subsequent calls will throw an error.
*
* @param {number} nonce - The nonce value to set.
* @returns {this} The builder instance for method chaining.
* @throws {Error} If the nonce is already set.
*/
nonce(nonce) {
if (this.nonceSet) {
throw new Error('Nonce can only be set once.');
}
this.nonceSet = true;
this.options.nonce = nonce;
return this;
}
/**
* Executes the registration process with the provided verification key.
*
* @param {unknown} verificationKey - The verification key to register.
* @returns {Promise<{ events: EventEmitter, transactionResult: Promise<VKRegistrationTransactionInfo> }>}
*/
async execute(verificationKey) {
return this.executeRegisterVerificationKey(this.options, verificationKey);
}
}
exports.RegisterKeyBuilder = RegisterKeyBuilder;