@provablehq/sdk 0.9.15-enc → 0.9.15-experimental

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sources":["../../src/account.ts","../../src/utils.ts","../../src/models/provingResponse.ts","../../src/security.ts","../../src/constants.ts","../../src/network-client.ts","../../src/function-key-provider.ts","../../src/offline-key-provider.ts","../../src/record-provider.ts","../../src/models/record-scanner/registrationResult.ts","../../src/record-scanner.ts","../../src/integrations/sealance/merkle-tree.ts","../../src/program-manager.ts","../../src/browser.ts"],"sourcesContent":["import {\n Address,\n ComputeKey,\n EncryptionToolkit,\n Field,\n Group,\n PrivateKey,\n Transition,\n Signature,\n ViewKey,\n PrivateKeyCiphertext,\n RecordCiphertext,\n RecordPlaintext,\n} from \"./wasm.js\";\n\ninterface AccountParam {\n privateKey?: string;\n seed?: Uint8Array;\n}\n\n/**\n * Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\n * an existing private key or seed, and message signing and verification functionality. An Aleo Account is generated\n * from a randomly generated seed (number) from which an account private key, view key, and a public account address are\n * derived. The private key lies at the root of an Aleo account. It is a highly sensitive secret and should be protected\n * as it allows for creation of Aleo Program executions and arbitrary value transfers. The View Key allows for decryption\n * of a user's activity on the blockchain. The Address is the public address to which other users of Aleo can send Aleo\n * credits and other records to. This class should only be used in environments where the safety of the underlying key\n * material can be assured.\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a new account\n * const myRandomAccount = new Account();\n *\n * // Create an account from a randomly generated seed\n * const seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);\n * const mySeededAccount = new Account({seed: seed});\n *\n * // Create an account from an existing private key\n * const myExistingAccount = new Account({privateKey: process.env.privateKey});\n *\n * // Sign a message\n * const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100]);\n * const signature = myRandomAccount.sign(hello_world);\n *\n * // Verify a signature\n * assert(myRandomAccount.verify(hello_world, signature));\n */\nexport class Account {\n _privateKey: PrivateKey;\n _viewKey: ViewKey;\n _computeKey: ComputeKey;\n _address: Address;\n\n constructor(params: AccountParam = {}) {\n try {\n this._privateKey = this.privateKeyFromParams(params);\n } catch (e) {\n console.error(\"Wrong parameter\", e);\n throw new Error(\"Wrong Parameter\");\n }\n this._viewKey = ViewKey.from_private_key(this._privateKey);\n this._computeKey = ComputeKey.from_private_key(this._privateKey);\n this._address = Address.from_private_key(this._privateKey);\n }\n\n /**\n * Attempts to create an account from a private key ciphertext\n * @param {PrivateKeyCiphertext | string} ciphertext The encrypted private key ciphertext or its string representation\n * @param {string} password The password used to decrypt the private key ciphertext\n * @returns {Account} A new Account instance created from the decrypted private key\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create an account object from a previously encrypted ciphertext and password.\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n */\n public static fromCiphertext(ciphertext: PrivateKeyCiphertext | string, password: string): Account {\n try {\n ciphertext = (typeof ciphertext === \"string\") ? PrivateKeyCiphertext.fromString(ciphertext) : ciphertext;\n const _privateKey = PrivateKey.fromPrivateKeyCiphertext(ciphertext, password);\n return new Account({ privateKey: _privateKey.to_string() });\n } catch(e) {\n throw new Error(\"Wrong password or invalid ciphertext\");\n }\n }\n\n /**\n * Validates whether the given input is a valid Aleo address.\n * @param {string | Uint8Array} address The address to validate, either as a string or bytes\n * @returns {boolean} True if the address is valid, false otherwise\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const isValid = Account.isValidAddress(\"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\");\n * console.log(isValid); // true\n *\n * const isInvalid = Account.isValidAddress(\"invalid_address\");\n * console.log(isInvalid); // false\n */\n public static isValidAddress(address: string | Uint8Array): boolean {\n return Address.isValid(address);\n }\n\n /**\n * Creates a PrivateKey from the provided parameters.\n * @param {AccountParam} params The parameters containing either a private key string or a seed\n * @returns {PrivateKey} A PrivateKey instance derived from the provided parameters\n */\n private privateKeyFromParams(params: AccountParam): PrivateKey {\n if (params.seed) {\n return PrivateKey.from_seed_unchecked(params.seed);\n }\n if (params.privateKey) {\n return PrivateKey.from_string(params.privateKey);\n }\n return new PrivateKey();\n }\n\n /**\n * Returns the PrivateKey associated with the account.\n * @returns {PrivateKey} The private key of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const privateKey = account.privateKey();\n */\n privateKey(): PrivateKey {\n return this._privateKey;\n }\n\n /**\n * Returns the ViewKey associated with the account.\n * @returns {ViewKey} The view key of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const viewKey = account.viewKey();\n */\n viewKey(): ViewKey {\n return this._viewKey;\n }\n\n /**\n * Returns the ComputeKey associated with the account.\n * @returns {ComputeKey} The compute key of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const computeKey = account.computeKey();\n */\n computeKey(): ComputeKey {\n return this._computeKey;\n }\n\n /**\n * Returns the Aleo address associated with the account.\n * @returns {Address} The public address of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const address = account.address();\n */\n address(): Address {\n return this._address;\n }\n\n /**\n * Deep clones the Account.\n * @returns {Account} A new Account instance with the same private key\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const clonedAccount = account.clone();\n */\n clone(): Account {\n return new Account({ privateKey: this._privateKey.to_string() });\n }\n\n /**\n * Returns the address of the account in a string representation.\n *\n * @returns {string} The string representation of the account address\n */\n toString(): string {\n return this.address().to_string()\n }\n\n /**\n * Encrypts the account's private key with a password.\n *\n * @param {string} password Password to encrypt the private key.\n * @returns {PrivateKeyCiphertext} The encrypted private key ciphertext\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const ciphertext = account.encryptAccount(\"password\");\n * process.env.ciphertext = ciphertext.toString();\n */\n encryptAccount(password: string): PrivateKeyCiphertext {\n return this._privateKey.toCiphertext(password);\n }\n\n /**\n * Decrypts an encrypted record string into a plaintext record object.\n *\n * @param {string} ciphertext A string representing the ciphertext of a record.\n * @returns {RecordPlaintext} The decrypted record plaintext\n *\n * @example\n * // Import the AleoNetworkClient and Account classes\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n *\n * // Get the record ciphertexts from a transaction.\n * const transaction = await networkClient.getTransactionObject(\"at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd\");\n * const records = transaction.records();\n *\n * // Decrypt any records the account owns.\n * const decryptedRecords = [];\n * for (const record of records) {\n * if (account.decryptRecord(record)) {\n * decryptedRecords.push(record);\n * }\n * }\n */\n decryptRecord(ciphertext: string): RecordPlaintext {\n return this._viewKey.decrypt(ciphertext);\n }\n\n /**\n * Decrypts an array of Record ciphertext strings into an array of record plaintext objects.\n *\n * @param {string[]} ciphertexts An array of strings representing the ciphertexts of records.\n * @returns {RecordPlaintext[]} An array of decrypted record plaintexts\n *\n * @example\n * // Import the AleoNetworkClient and Account classes\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n *\n * // Get the record ciphertexts from a transaction.\n * const transaction = await networkClient.getTransactionObject(\"at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd\");\n * const records = transaction.records();\n *\n * // Decrypt any records the account owns. If the account owns no records, the array will be empty.\n * const decryptedRecords = account.decryptRecords(records);\n */\n decryptRecords(ciphertexts: string[]): RecordPlaintext[] {\n return ciphertexts.map((ciphertext) => this._viewKey.decrypt(ciphertext));\n }\n\n /**\n * Generates a record view key from the account owner's view key and the record ciphertext.\n * This key can be used to decrypt the record without revealing the account's view key.\n * @param {RecordCiphertext | string} recordCiphertext The record ciphertext to generate the view key for\n * @returns {Field} The record view key\n * \n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n * \n * // Create an account object from a previously encrypted ciphertext and password.\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n * \n * // Generate a record view key from the account's view key and a record ciphertext\n * const recordCiphertext = RecordCiphertext.fromString(\"your_record_ciphertext_here\");\n * const recordViewKey = account.generateRecordViewKey(recordCiphertext);\n */\n generateRecordViewKey(recordCiphertext: RecordCiphertext | string): Field {\n if (typeof recordCiphertext === 'string') {\n recordCiphertext = RecordCiphertext.fromString(recordCiphertext);\n }\n if (!(recordCiphertext.isOwner(this._viewKey))) {\n throw new Error(\"The record ciphertext does not belong to this account\");\n }\n return EncryptionToolkit.generateRecordViewKey(this._viewKey, recordCiphertext);\n }\n\n /**\n * Generates a transition view key from the account owner's view key and the transition public key.\n * This key can be used to decrypt the private inputs and outputs of a the transition without \n * revealing the account's view key.\n * @param {string | Group} tpk The transition public key\n * @returns {Field} The transition view key\n * \n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n * \n * // Generate a transition view key from the account's view key and a transition public key\n * const tpk = Group.fromString(\"your_transition_public_key_here\");\n * \n * const transitionViewKey = account.generateTransitionViewKey(tpk);\n */\n generateTransitionViewKey(tpk: string | Group): Field {\n if (typeof tpk === 'string') {\n tpk = Group.fromString(tpk);\n }\n return EncryptionToolkit.generateTvk(this._viewKey, tpk);\n }\n\n /**\n * Determines whether the account owns a ciphertext record.\n * @param {RecordCiphertext | string} ciphertext The record ciphertext to check ownership of\n * @returns {boolean} True if the account owns the record, false otherwise\n *\n * @example\n * // Import the AleoNetworkClient and Account classes\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n *\n * // Get the record ciphertexts from a transaction and check ownership of them.\n * const transaction = await networkClient.getTransactionObject(\"at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd\");\n * const records = transaction.records();\n *\n * // Check if the account owns any of the record ciphertexts present in the transaction.\n * const ownedRecords = [];\n * for (const record of records) {\n * if (account.ownsRecordCiphertext(record)) {\n * ownedRecords.push(record);\n * }\n * }\n */\n ownsRecordCiphertext(ciphertext: RecordCiphertext | string): boolean {\n if (typeof ciphertext === 'string') {\n try {\n const ciphertextObject = RecordCiphertext.fromString(ciphertext);\n return ciphertextObject.isOwner(this._viewKey);\n }\n catch (e) {\n return false;\n }\n }\n else {\n return ciphertext.isOwner(this._viewKey);\n }\n }\n\n /**\n * Signs a message with the account's private key.\n * Returns a Signature.\n *\n * @param {Uint8Array} message Message to be signed.\n * @returns {Signature} Signature over the message in bytes.\n *\n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Create an account and a message to sign.\n * const account = new Account();\n * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])\n * const signature = account.sign(message);\n *\n * // Verify the signature.\n * assert(account.verify(message, signature));\n */\n sign(message: Uint8Array): Signature {\n return this._privateKey.sign(message);\n }\n\n /**\n * Verifies the Signature on a message.\n *\n * @param {Uint8Array} message Message in bytes to be signed.\n * @param {Signature} signature Signature to be verified.\n * @returns {boolean} True if the signature is valid, false otherwise.\n *\n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Sign a message.\n * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])\n * const signature = account.sign(message);\n *\n * // Verify the signature.\n * assert(account.verify(message, signature));\n */\n verify(message: Uint8Array, signature: Signature): boolean {\n return this._address.verify(message, signature);\n }\n}\n","function detectBrowser() {\n const userAgent = navigator.userAgent;\n\n if (/chrome|crios|crmo/i.test(userAgent) && !/edge|edg|opr/i.test(userAgent)) {\n return \"chrome\";\n } else if (/firefox|fxios/i.test(userAgent)) {\n return \"firefox\";\n } else if (/safari/i.test(userAgent) && !/chrome|crios|crmo|android/i.test(userAgent)) {\n return \"safari\";\n } else if (/edg/i.test(userAgent)) {\n return \"edge\";\n } else if (/opr\\//i.test(userAgent)) {\n return \"opera\";\n } else {\n return \"browser\";\n }\n}\n\nexport function environment() {\n if ((typeof process !== 'undefined') &&\n (process.release?.name === 'node')) {\n return 'node';\n } else if (typeof window !== 'undefined') {\n return detectBrowser();\n } else {\n return 'unknown';\n }\n}\n\nexport function logAndThrow(message: string): never {\n console.error(message);\n throw new Error(message);\n}\n\nexport function parseJSON(json: string): any {\n function revive(key: string, value: any, context: any) {\n if (Number.isInteger(value)) {\n return BigInt(context.source);\n } else {\n return value;\n }\n }\n\n return JSON.parse(json, revive as any);\n}\n\nexport async function get(url: URL | string, options?: RequestInit) {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(response.status + \" could not get URL \" + url);\n }\n\n return response;\n}\n\nexport async function post(url: URL | string, options: RequestInit) {\n options.method = \"POST\";\n\n const response = await fetch(url, options);\n\n if (!response.ok) {\n const error = await response.text();\n let message = `${response.status} error received from ${url}`;\n if (error) {\n message = `${error}`\n }\n throw new Error(message);\n }\n\n return response;\n}\n\ntype RetryOptions = {\n maxAttempts?: number;\n baseDelay?: number;\n jitter?: number;\n retryOnStatus?: number[]; // e.g. [500, 502, 503]\n shouldRetry?: (err: any) => boolean;\n};\n\nexport async function retryWithBackoff<T>(\n fn: () => Promise<T>,\n {\n maxAttempts = 5,\n baseDelay = 100,\n jitter,\n retryOnStatus = [],\n shouldRetry,\n }: RetryOptions = {},\n): Promise<T> {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (err: any) {\n const isLast = attempt === maxAttempts;\n const error = err as Error & { code?: string; status?: number };\n\n let retryable = false;\n\n if (typeof error.status === \"number\") {\n if (error.status >= 500) {\n retryable = true;\n } else if (error.status >= 400 && shouldRetry) {\n retryable = shouldRetry(error);\n }\n } else if (shouldRetry) {\n retryable = shouldRetry(error);\n }\n\n if (!retryable || isLast) throw error;\n\n const jitterAmount = jitter ?? baseDelay;\n const actualJitter = Math.floor(Math.random() * jitterAmount);\n const delay = baseDelay * 2 ** (attempt - 1) + actualJitter;\n console.warn(\n `Retry ${attempt}/${maxAttempts} failed. Retrying in ${delay}ms...`,\n );\n\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n\n throw new Error(\"retryWithBackoff: unreachable\");\n}\n","import { TransactionJSON } from \"./transaction/transactionJSON.js\";\n\n/** HTTP status and optional message from snarkOS broadcast (Accepted/Rejected variants). */\nexport interface BroadcastResponse {\n status_code: bigint | number;\n message?: string;\n}\n\n/** Result of the optional broadcast step. Discriminated by `status`. */\nexport type BroadcastResult =\n | { status: \"Accepted\"; status_code: bigint | number; message?: string }\n | { status: \"Rejected\"; status_code: bigint | number; message?: string }\n | { status: \"Failed\"; message: string }\n | { status: \"Skipped\" };\n\n/** Success response body for POST /prove (HTTP 200). */\nexport interface ProvingResponse {\n transaction: TransactionJSON;\n broadcast_result: BroadcastResult;\n}\n\n/** Error response body for POST /prove (HTTP 400, 500, 503). Same shape for all error cases. */\nexport interface ProveApiErrorBody {\n message: string;\n}\n\n/** Error thrown on prove API failure; `status` is set for retry logic (e.g. retryWithBackoff checks error.status >= 500). */\nexport interface ProvingRequestError extends Error {\n status?: bigint | number;\n}\n\n/** Success variant of a proving request result. */\nexport interface ProvingSuccess {\n ok: true;\n data: ProvingResponse;\n}\n\n/** Failure variant of a proving request result (HTTP 400, 500, 503). */\nexport interface ProvingFailure {\n ok: false;\n status: bigint | number;\n error: ProveApiErrorBody;\n}\n\n/** Result of a proving request. Type used to give callers the ability to self-handle errors. */\nexport type ProvingResult = ProvingSuccess | ProvingFailure;\n\n/** Type guard: value is a ProvingResponse. */\nexport function isProvingResponse(value: unknown): value is ProvingResponse {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"transaction\" in value &&\n \"broadcast_result\" in value &&\n typeof (value as ProvingResponse).broadcast_result === \"object\"\n );\n}\n\n/** Type guard: value is a ProveApiErrorBody. */\nexport function isProveApiErrorBody(value: unknown): value is ProveApiErrorBody {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"message\" in value\n );\n}","import sodium from \"libsodium-wrappers\";\nimport { ViewKey, Authorization, ProvingRequest } from \"@provablehq/wasm\";\nawait sodium.ready;\n\n/**\n * Encrypt an authorization with a libsodium cryptobox public key.\n *\n * @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).\n * @param {Authorization} authorization the authorization to encrypt.\n *\n * @returns {string} the encrypted authorization in RFC 4648 standard Base64.\n */\nexport function encryptAuthorization(publicKey: string, authorization: Authorization): string {\n // Ready the cryptobox lib.\n return encryptMessage(publicKey, authorization.toBytesLe());\n}\n\n/**\n * Encrypt a ProvingRequest with a libsodium cryptobox public key.\n *\n * @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).\n * @param {Authorization} provingRequest the ProvingRequest to encrypt.\n *\n * @returns {string} the encrypted ProvingRequest in RFC 4648 standard Base64.\n */\nexport function encryptProvingRequest(publicKey: string, provingRequest: ProvingRequest): string {\n return encryptMessage(publicKey, provingRequest.toBytesLe());\n}\n\n/**\n * Encrypt a view key with a libsodium cryptobox public key.\n *\n * @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).\n * @param {ViewKey} viewKey the view key to encrypt.\n *\n * @returns {string} the encrypted view key in RFC 4648 standard Base64.\n */\nexport function encryptViewKey(publicKey: string, viewKey: ViewKey): string {\n return encryptMessage(publicKey, viewKey.toBytesLe());\n}\n\n/**\n * Encrypt a record scanner registration request.\n *\n * @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).\n * @param {ViewKey} viewKey the view key to encrypt.\n * @param {number} start the start height of the registration request.\n *\n * @returns {string} the encrypted view key in RFC 4648 standard Base64.\n */\nexport function encryptRegistrationRequest(publicKey: string, viewKey: ViewKey, start: number): string {\n // Turn the view key into a Uint8Array.\n const vk_bytes: Uint8Array = viewKey.toBytesLe();\n // Create a new array to hold the original bytes and the 4-byte start height.\n const bytes = new Uint8Array(vk_bytes.length + 4);\n\n // Copy existing bytes.\n bytes.set(vk_bytes, 0);\n\n // Write the 4-byte number in LE format at the end of the array.\n const view = new DataView(bytes.buffer);\n view.setUint32(vk_bytes.length, start, true);\n\n // Encrypt the encoded bytes.\n return encryptMessage(publicKey, bytes);\n}\n\n/**\n * Encrypt arbitrary bytes with a libsodium cryptobox public key.\n *\n * @param {string} publicKey The cryptobox X25519 public key to encrypt with (encoded in RFC 4648 standard Base64).\n * @param {Uint8Array} message the bytes to encrypt.\n *\n * @returns {string} the encrypted bytes in RFC 4648 standard Base64.\n */\nfunction encryptMessage(publicKey: string, message: Uint8Array): string {\n const publicKeyBytes = sodium.from_base64(publicKey, sodium.base64_variants.ORIGINAL);\n return sodium.to_base64(sodium.crypto_box_seal(message, publicKeyBytes), sodium.base64_variants.ORIGINAL);\n}\n","import {VerifyingKey, Metadata} from \"./wasm.js\";\n\nexport const KEY_STORE = Metadata.baseUrl();\n\nexport interface Key {\n name: string,\n locator: string,\n prover: string,\n verifier: string,\n verifyingKey: () => VerifyingKey,\n}\n\nfunction convert(metadata: Metadata): Key {\n // This looks up the method name in VerifyingKey\n const verifyingKey = (VerifyingKey as any)[metadata.verifyingKey];\n\n if (!verifyingKey) {\n throw new Error(\"Invalid method name: \" + metadata.verifyingKey);\n }\n\n return {\n name: metadata.name,\n locator: metadata.locator,\n prover: metadata.prover,\n verifier: metadata.verifier,\n verifyingKey,\n };\n}\n\nexport const CREDITS_PROGRAM_KEYS = {\n bond_public: convert(Metadata.bond_public()),\n bond_validator: convert(Metadata.bond_validator()),\n claim_unbond_public: convert(Metadata.claim_unbond_public()),\n fee_private: convert(Metadata.fee_private()),\n fee_public: convert(Metadata.fee_public()),\n inclusion: convert(Metadata.inclusion()),\n join: convert(Metadata.join()),\n set_validator_state: convert(Metadata.set_validator_state()),\n split: convert(Metadata.split()),\n transfer_private: convert(Metadata.transfer_private()),\n transfer_private_to_public: convert(Metadata.transfer_private_to_public()),\n transfer_public: convert(Metadata.transfer_public()),\n transfer_public_as_signer: convert(Metadata.transfer_public_as_signer()),\n transfer_public_to_private: convert(Metadata.transfer_public_to_private()),\n unbond_public: convert(Metadata.unbond_public()),\n getKey: function(key: string): Key {\n if (this.hasOwnProperty(key)) {\n return (this as any)[key] as Key;\n } else {\n throw new Error(`Key \"${key}\" not found.`);\n }\n }\n};\n\nexport const PRIVATE_TRANSFER_TYPES = new Set([\n \"transfer_private\",\n \"private\",\n \"transferPrivate\",\n \"transfer_private_to_public\",\n \"privateToPublic\",\n \"transferPrivateToPublic\",\n]);\n\nexport const VALID_TRANSFER_TYPES = new Set([\n \"transfer_private\",\n \"private\",\n \"transferPrivate\",\n \"transfer_private_to_public\",\n \"privateToPublic\",\n \"transferPrivateToPublic\",\n \"transfer_public\",\n \"transfer_public_as_signer\",\n \"public\",\n \"public_as_signer\",\n \"transferPublic\",\n \"transferPublicAsSigner\",\n \"transfer_public_to_private\",\n \"publicToPrivate\",\n \"publicAsSigner\",\n \"transferPublicToPrivate\",\n]);\n\nexport const PRIVATE_TRANSFER = new Set([\n \"private\",\n \"transfer_private\",\n \"transferPrivate\",\n]);\n\nexport const PRIVATE_TO_PUBLIC_TRANSFER = new Set([\n \"private_to_public\",\n \"privateToPublic\",\n \"transfer_private_to_public\",\n \"transferPrivateToPublic\",\n]);\n\nexport const PUBLIC_TRANSFER = new Set([\n \"public\",\n \"transfer_public\",\n \"transferPublic\",\n]);\n\nexport const PUBLIC_TRANSFER_AS_SIGNER = new Set([\n \"public_as_signer\",\n \"transfer_public_as_signer\",\n \"transferPublicAsSigner\",\n]);\n\nexport const PUBLIC_TO_PRIVATE_TRANSFER = new Set([\n \"public_to_private\",\n \"publicToPrivate\",\n \"transfer_public_to_private\",\n \"transferPublicToPrivate\",\n]);\n\nexport const RECORD_DOMAIN = \"RecordScannerV0\";\n\n/**\n * Zero address on Aleo blockchain that corresponds to field element 0. Used as padding in Merkle trees and as a sentinel value.\n */\nexport const ZERO_ADDRESS = \"aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc\";\nexport const FIVE_MINUTES = 5 * 60 * 1000; // 5 minutes in milliseconds\n\n","import { get, post, parseJSON, logAndThrow, retryWithBackoff, environment } from \"./utils.js\";\nimport { Account } from \"./account.js\";\nimport { BlockJSON } from \"./models/blockJSON.js\";\nimport { TransactionJSON } from \"./models/transaction/transactionJSON.js\";\nimport {\n Address,\n Plaintext,\n RecordCiphertext,\n Program,\n ProvingRequest,\n RecordPlaintext,\n PrivateKey,\n Transaction,\n} from \"./wasm.js\";\nimport { ConfirmedTransactionJSON } from \"./models/confirmed_transaction.js\";\nimport {\n ProveApiErrorBody,\n ProvingResponse,\n ProvingResult,\n ProvingRequestError,\n isProvingResponse,\n isProveApiErrorBody,\n} from \"./models/provingResponse.js\";\nimport { CryptoBoxPubKey } from \"./models/cryptoBoxPubkey.js\";\nimport { EncryptedProvingRequest } from \"./models/encryptedProvingRequest.js\";\nimport { encryptProvingRequest } from \"./security.js\"\nimport { FIVE_MINUTES } from \"./constants\";\n\ntype ProgramImports = { [key: string]: string | Program };\n\ninterface AleoNetworkClientOptions {\n headers?: { [key: string]: string };\n proverUri?: string;\n recordScannerUri?: string;\n}\n\n/**\n * Interface for the JWT data.\n * \n * @property jwt {string} The JWT token string.\n * @property expiration {number} The expiration time of the JWT token in UNIX timestamp format.\n */\ninterface JWTData {\n jwt: string;\n expiration: number;\n}\n\n/**\n * Options for submitting a proving request.\n *\n * @property provingRequest {ProvingRequest | string} The proving request being submitted to the network.\n * @property url {string} The URL of the delegated proving service.\n * @property apiKey {string} The API key used for generating a JWT.\n * @property consumerId {string} The consumer ID associated with the API key.\n * @property jwt {string} An optional JWT token used for authenticating with the proving service.\n */\ninterface DelegatedProvingParams {\n provingRequest: ProvingRequest | string;\n url?: string;\n apiKey?: string;\n consumerId?: string;\n jwtData?: JWTData;\n dpsPrivacy?: boolean;\n}\n\n/**\n * Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this\n * allow users to query public information from the Aleo blockchain and submit transactions to the network.\n *\n * @param {string} host\n * @example\n * // Connection to a local node.\n * const localNetworkClient = new AleoNetworkClient(\"http://0.0.0.0:3030\", undefined, account);\n *\n * // Connection to a public beacon node\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n * const apiKey = process.env.apiKey;\n * const consumerId = process.env.consumerId;\n * const publicNetworkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined, account);\n */\nclass AleoNetworkClient {\n host: string;\n headers: { [key: string]: string };\n account: Account | undefined;\n ctx: { [key: string]: string };\n verboseErrors: boolean;\n readonly network: string;\n apiKey?: string;\n consumerId?: string;\n jwtData?: JWTData;\n proverUri?: string;\n recordScannerUri?: string;\n\n constructor(host: string, options?: AleoNetworkClientOptions) {\n this.host = host + \"/%%NETWORK%%\";\n this.network = \"%%NETWORK%%\";\n this.ctx = {};\n this.verboseErrors = true;\n\n if (options) {\n if (options.headers) {\n this.headers = options.headers;\n } else {\n this.headers = {\n // This is replaced by the actual version by a Rollup plugin\n \"X-Aleo-SDK-Version\": \"%%VERSION%%\",\n \"X-Aleo-environment\": environment(),\n };\n }\n\n // If a prover uri was specified, set the prover uri.\n if (options.proverUri) {\n this.proverUri = options.proverUri + \"/%%NETWORK%%\";\n }\n\n // If a record scanner uri was specified, set the record scanner uri.\n if (options.recordScannerUri) {\n this.recordScannerUri = options.recordScannerUri + \"/%%NETWORK%%\";\n }\n } else {\n this.headers = {\n // This is replaced by the actual version by a Rollup plugin\n \"X-Aleo-SDK-Version\": \"%%VERSION%%\",\n \"X-Aleo-environment\": environment(),\n };\n }\n }\n\n /**\n * Set an account to use in networkClient calls\n *\n * @param {Account} account Set an account to use for record scanning functions.\n * @example\n * import { Account, AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\");\n * const account = new Account();\n * networkClient.setAccount(account);\n */\n setAccount(account: Account) {\n this.account = account;\n }\n\n /**\n * Return the Aleo account used in the networkClient\n *\n * @example\n * const account = networkClient.getAccount();\n */\n getAccount(): Account | undefined {\n return this.account;\n }\n\n /**\n * Set a new host for the networkClient\n *\n * @param {string} host The address of a node hosting the Aleo API\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient that connects to a local node.\n * const networkClient = new AleoNetworkClient(\"http://0.0.0.0:3030\", undefined);\n *\n * // Set the host to a public node.\n * networkClient.setHost(\"http://api.explorer.provable.com/v1\");\n */\n setHost(host: string) {\n this.host = host + \"/%%NETWORK%%\";\n }\n\n /**\n * Set a new uri for a remote prover.\n *\n * @param {string} proverUri The uri of the remote prover.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient that connects to the provable explorer api.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Set the prover uri.\n * networkClient.setProverUri(\"https://prover.provable.prove\");\n */\n setProverUri(proverUri: string) {\n this.proverUri = proverUri + \"/%%NETWORK%%\";\n }\n\n /**\n * Set a new uri for a remote record scanner.\n *\n * @param {string} recordScannerUri The uri of the remote record scanner.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient that connects to the provable explorer api.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Set the record scanner uri.\n * networkClient.setRecordScannerUri(\"https://scanner.provable.scan\");\n */\n setRecordScannerUri(recordScannerUri: string) {\n this.recordScannerUri = recordScannerUri + \"/%%NETWORK%%\";\n }\n\n /**\n * Set verbose errors to true or false for the `AleoNetworkClient`. When set to true, if `submitTransaction` fails, the failure responses will report descriptive information as to why the transaction failed.\n *\n * @param {boolean} verboseErrors Set verbose error mode to true or false for the AleoNetworkClient.\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient\n * const networkClient = new AleoNetworkClient();\n *\n * // Set debug mode to true\n * networkClient.setVerboseTransactionErrors(true);\n **/\n setVerboseErrors(verboseErrors: boolean) {\n this.verboseErrors = verboseErrors;\n }\n\n /**\n * Set a header in the `AleoNetworkClient`s header map\n *\n * @param {string} headerName The name of the header to set\n * @param {string} value The header value\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient\n * const networkClient = new AleoNetworkClient();\n *\n * // Set the value of the `Accept-Language` header to `en-US`\n * networkClient.setHeader('Accept-Language', 'en-US');\n */\n setHeader(headerName: string, value: string) {\n this.headers[headerName] = value;\n }\n\n removeHeader(headerName: string) {\n delete this.headers[headerName];\n }\n\n /**\n * Fetches data from the Aleo network and returns it as a JSON object.\n *\n * @param url The URL to fetch data from.\n */\n async fetchData<Type>(url = \"/\"): Promise<Type> {\n try {\n const raw = await this.fetchRaw(url);\n return parseJSON(raw);\n } catch (error) {\n throw new Error(`Error fetching data: ${error}`);\n }\n }\n\n /**\n * Fetches data from the Aleo network and returns it as an unparsed string.\n *\n * This method should be used when it is desired to reconstitute data returned\n * from the network into a WASM object.\n *\n * @param url\n */\n async fetchRaw(url = \"/\"): Promise<string> {\n try {\n const ctx = {...this.ctx};\n return await retryWithBackoff(async () => {\n const response = await get(this.host + url, {\n headers: {\n ...this.headers,\n ...ctx,\n },\n });\n return await response.text();\n });\n } catch (error) {\n throw new Error(`Error fetching data: ${error}`);\n }\n }\n\n /**\n * Wrapper around the POST helper to allow mocking in tests. Not meant for use in production.\n *\n * @param url The URL to POST to.\n * @param options The RequestInit options for the POST request.\n * @returns The Response object from the POST request.\n */\n private async _sendPost(url: string, options: RequestInit) {\n return post(url, options);\n }\n\n /**\n * Attempt to find records in the Aleo blockchain.\n *\n * @param {number} startHeight - The height at which to start searching for unspent records\n * @param {number} endHeight - The height at which to stop searching for unspent records\n * @param {boolean} unspent - Whether to search for unspent records only\n * @param {string[]} programs - The program(s) to search for unspent records in\n * @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])\n * @param {number} maxMicrocredits - The maximum number of microcredits to search for\n * @param {string[]} nonces - The nonces of already found records to exclude from the search\n * @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.\n * @returns {Promise<Array<RecordPlaintext>>} An array of records belonging to the account configured in the network client.\n *\n * @example\n * import { Account, AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Import an account from a ciphertext and password.\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * networkClient.setAccount(account);\n *\n * // Find specific amounts\n * const startHeight = 500000;\n * const amounts = [600000, 1000000];\n * const records = networkClient.findRecords(startHeight, undefined, true, [\"credits.aleo\"] amounts);\n *\n * // Find specific amounts with a maximum number of cumulative microcredits\n * const maxMicrocredits = 100000;\n * const records = networkClient.findRecords(startHeight, undefined, true, [\"credits.aleo\"] undefined, maxMicrocredits);\n */\n async findRecords(\n startHeight: number,\n endHeight: number | undefined,\n unspent: boolean = false,\n programs?: string[],\n amounts?: number[] | undefined,\n maxMicrocredits?: number | undefined,\n nonces?: string[] | undefined,\n privateKey?: string | PrivateKey | undefined,\n ): Promise<Array<RecordPlaintext>> {\n nonces = nonces || [];\n // Ensure start height is not negative\n if (startHeight < 0) {\n throw new Error(\"Start height must be greater than or equal to 0\");\n }\n\n // Initialize search parameters\n const records = new Array<RecordPlaintext>();\n let start;\n let end;\n let resolvedPrivateKey: PrivateKey;\n let failures = 0;\n let totalRecordValue = BigInt(0);\n let latestHeight: number;\n\n // Ensure a private key is present to find owned records\n if (typeof privateKey === \"undefined\") {\n if (typeof this.account === \"undefined\") {\n throw new Error(\n \"Private key must be specified in an argument to findOwnedRecords or set in the AleoNetworkClient\",\n );\n } else {\n resolvedPrivateKey = this.account._privateKey;\n }\n } else {\n try {\n resolvedPrivateKey =\n privateKey instanceof PrivateKey\n ? privateKey\n : PrivateKey.from_string(privateKey);\n } catch (error) {\n throw new Error(\"Error parsing private key provided.\");\n }\n }\n const viewKey = resolvedPrivateKey.to_view_key();\n\n // Get the latest height to ensure the range being searched is valid\n try {\n const blockHeight = await this.getLatestHeight();\n if (typeof blockHeight === \"number\") {\n latestHeight = blockHeight;\n } else {\n throw new Error(\n `Error fetching latest block height: Expected type 'number' got '${typeof blockHeight}'`,\n );\n }\n } catch (error) {\n throw new Error(`Error fetching latest block height: ${error}`);\n }\n\n // If no end height is specified or is greater than the latest height, set the end height to the latest height\n if (typeof endHeight === \"number\" && endHeight <= latestHeight) {\n end = endHeight;\n } else {\n end = latestHeight;\n }\n\n // If the starting is greater than the ending height, return an error\n if (startHeight > end) {\n throw new Error(\n \"Start height must be less than or equal to end height.\",\n );\n }\n\n // Iterate through blocks in reverse order in chunks of 50\n while (end > startHeight) {\n start = end - 50;\n if (start < startHeight) {\n start = startHeight;\n }\n try {\n // Get 50 blocks (or the difference between the start and end if less than 50)\n const blocks = await this.getBlockRange(start, end);\n end = start;\n // Iterate through blocks to find unspent records\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n const transactions = block.transactions;\n if (!(typeof transactions === \"undefined\")) {\n for (let j = 0; j < transactions.length; j++) {\n const confirmedTransaction = transactions[j];\n // Search for unspent records in execute transactions of credits.aleo\n if (confirmedTransaction.type == \"execute\") {\n const transaction =\n confirmedTransaction.transaction;\n if (\n transaction.execution &&\n !(\n typeof transaction.execution\n .transitions == \"undefined\"\n )\n ) {\n for (\n let k = 0;\n k <\n transaction.execution.transitions\n .length;\n k++\n ) {\n const transition =\n transaction.execution.transitions[\n k\n ];\n // Only search for unspent records in the specified programs.\n if (\n !(typeof programs === \"undefined\")\n ) {\n if (\n !programs.includes(\n transition.program,\n )\n ) {\n continue;\n }\n }\n if (\n !(\n typeof transition.outputs ==\n \"undefined\"\n )\n ) {\n for (\n let l = 0;\n l < transition.outputs.length;\n l++\n ) {\n const output =\n transition.outputs[l];\n if (output.type === \"record\") {\n try {\n // Create a wasm record ciphertext object from the found output\n const record =\n RecordCiphertext.fromString(\n output.value,\n );\n // Determine if the record is owned by the specified view key\n if (\n record.isOwner(\n viewKey,\n )\n ) {\n // Decrypt the record and get the serial number\n const recordPlaintext =\n record.decrypt(\n viewKey,\n );\n\n // If the record has already been found, skip it\n const nonce =\n recordPlaintext.nonce();\n if (\n nonces.includes(\n nonce,\n )\n ) {\n continue;\n }\n\n if (unspent) {\n const recordViewKey = recordPlaintext.recordViewKey(viewKey).toString();\n // Otherwise record the nonce that has been found\n const serialNumber =\n recordPlaintext.serialNumberString(\n resolvedPrivateKey,\n \"credits.aleo\",\n \"credits\",\n recordViewKey\n );\n // Attempt to see if the serial number is spent\n try {\n await retryWithBackoff(\n () =>\n this.getTransitionId(\n serialNumber,\n ),\n );\n continue;\n } catch (error) {\n console.log(\n \"Found unspent record!\",\n );\n }\n }\n\n // Add the record to the list of records if the user did not specify amounts.\n if (!amounts) {\n records.push(\n recordPlaintext,\n );\n // If the user specified a maximum number of microcredits, check if the search has found enough\n if (\n typeof maxMicrocredits ===\n \"number\"\n ) {\n totalRecordValue +=\n recordPlaintext.microcredits();\n // Exit if the search has found the amount specified\n if (\n totalRecordValue >=\n BigInt(\n maxMicrocredits,\n )\n ) {\n return records;\n }\n }\n }\n\n // If the user specified a list of amounts, check if the search has found them\n if (\n !(\n typeof amounts ===\n \"undefined\"\n ) &&\n amounts.length >\n 0\n ) {\n let amounts_found = 0;\n if (\n recordPlaintext.microcredits() >\n amounts[\n amounts_found\n ]\n ) {\n amounts_found += 1;\n records.push(\n recordPlaintext,\n );\n // If the user specified a maximum number of microcredits, check if the search has found enough\n if (\n typeof maxMicrocredits ===\n \"number\"\n ) {\n totalRecordValue +=\n recordPlaintext.microcredits();\n // Exit if the search has found the amount specified\n if (\n totalRecordValue >=\n BigInt(\n maxMicrocredits,\n )\n ) {\n return records;\n }\n }\n if (\n records.length >=\n amounts.length\n ) {\n return records;\n }\n }\n }\n }\n } catch (error) {}\n }\n }\n }\n }\n }\n }\n }\n }\n }\n } catch (error) {\n // If there is an error fetching blocks, log it and keep searching\n console.warn(\n \"Error fetching blocks in range: \" +\n start.toString() +\n \"-\" +\n end.toString(),\n );\n console.warn(\"Error: \", error);\n failures += 1;\n if (failures > 10) {\n console.warn(\n \"10 failures fetching records reached. Returning records fetched so far\",\n );\n return records;\n }\n }\n }\n return records;\n }\n\n /**\n * Attempts to find unspent records in the Aleo blockchain.\n *\n * @param {number} startHeight - The height at which to start searching for unspent records\n * @param {number} endHeight - The height at which to stop searching for unspent records\n * @param {string[]} programs - The program(s) to search for unspent records in\n * @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])\n * @param {number} maxMicrocredits - The maximum number of microcredits to search for\n * @param {string[]} nonces - The nonces of already found records to exclude from the search\n * @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.\n * @returns {Promise<Array<RecordPlaintext>>} An array of unspent records belonging to the account configured in the network client.\n *\n * @example\n * import { Account, AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Create a network client and set an account to search for records with.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * networkClient.setAccount(account);\n *\n * // Find specific amounts\n * const startHeight = 500000;\n * const endHeight = 550000;\n * const amounts = [600000, 1000000];\n * const records = networkClient.findUnspentRecords(startHeight, endHeight, [\"credits.aleo\"], amounts);\n *\n * // Find specific amounts with a maximum number of cumulative microcredits\n * const maxMicrocredits = 100000;\n * const records = networkClient.findUnspentRecords(startHeight, undefined, [\"credits.aleo\"], undefined, maxMicrocredits);\n */\n async findUnspentRecords(\n startHeight: number,\n endHeight: number | undefined,\n programs?: string[],\n amounts?: number[] | undefined,\n maxMicrocredits?: number | undefined,\n nonces?: string[] | undefined,\n privateKey?: string | PrivateKey | undefined,\n ): Promise<Array<RecordPlaintext>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"findUnspentRecords\" };\n return await this.findRecords(\n startHeight,\n endHeight,\n true,\n programs,\n amounts,\n maxMicrocredits,\n nonces,\n privateKey,\n );\n } catch (error) {\n throw new Error(\"Error finding unspent records: \" + error);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the contents of the block at the specified block height.\n *\n * @param {number} blockHeight - The height of the block to fetch\n * @returns {Promise<BlockJSON>} A javascript object containing the block at the specified height\n *\n * @example\n * const block = networkClient.getBlock(1234);\n */\n async getBlock(blockHeight: number): Promise<BlockJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getBlock\" };\n const block = await this.fetchData<BlockJSON>(\n \"/block/\" + blockHeight,\n );\n return block;\n } catch (error) {\n throw new Error(`Error fetching block ${blockHeight}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the contents of the block with the specified hash.\n *\n * @param {string} blockHash The hash of the block to fetch.\n * @returns {Promise<BlockJSON>} A javascript object representation of the block matching the hash.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const block = networkClient.getBlockByHash(\"ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9\");\n */\n async getBlockByHash(blockHash: string): Promise<BlockJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getBlockByHash\" };\n const block = await this.fetchData<BlockJSON>(\n `/block/${blockHash}`,\n );\n return block;\n } catch (error) {\n throw new Error(`Error fetching block ${blockHash}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a range of blocks between the specified block heights. A maximum of 50 blocks can be fetched at a time.\n *\n * @param {number} start Starting block to fetch.\n * @param {number} end Ending block to fetch. This cannot be more than 50 blocks ahead of the start block.\n * @returns {Promise<Array<BlockJSON>>} An array of block objects\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Fetch 50 blocks.\n * const (start, end) = (2050, 2100);\n * const blockRange = networkClient.getBlockRange(start, end);\n *\n * let cursor = start;\n * blockRange.forEach((block) => {\n * assert(block.height == cursor);\n * cursor += 1;\n * }\n */\n async getBlockRange(start: number, end: number): Promise<Array<BlockJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getBlockRange\" };\n return await this.fetchData<Array<BlockJSON>>(\n \"/blocks?start=\" + start + \"&end=\" + end,\n );\n } catch (error) {\n throw new Error(\n `Error fetching blocks between ${start} and ${end}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the deployment transaction id associated with the specified program.\n *\n * @param {Program | string} program The name of the deployed program OR a wasm Program object.\n * @returns {Promise<string>} The transaction ID of the deployment transaction.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/testnet.js\";\n *\n * // Get the transaction ID of the deployment transaction for a program.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const transactionId = networkClient.getDeploymentTransactionIDForProgram(\"hello_hello.aleo\");\n *\n * // Get the transaction data for the deployment transaction.\n * const transaction = networkClient.getTransactionObject(transactionId);\n *\n * // Get the verifying keys for the functions in the deployed program.\n * const verifyingKeys = transaction.verifyingKeys();\n */\n async getDeploymentTransactionIDForProgram(\n program: Program | string,\n ): Promise<string> {\n this.ctx = { \"X-ALEO-METHOD\": \"getDeploymentTransactionIDForProgram\" };\n if (program instanceof Program) {\n program = program.id();\n }\n try {\n const id = await this.fetchData<string>(\n \"/find/transactionID/deployment/\" + program,\n );\n return id.replace('\"', \"\");\n } catch (error) {\n throw new Error(\n `Error fetching deployment transaction for program ${program}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the deployment transaction associated with a specified program as a JSON object.\n *\n * @param {Program | string} program The name of the deployed program OR a wasm Program object.\n * @returns {Promise<Transaction>} JSON representation of the deployment transaction.\n *\n * @example\n * import { AleoNetworkClient, DeploymentJSON } from \"@provablehq/sdk/testnet.js\";\n *\n * // Get the transaction ID of the deployment transaction for a program.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const transaction = networkClient.getDeploymentTransactionForProgram(\"hello_hello.aleo\");\n *\n * // Get the verifying keys for each function in the deployment.\n * const deployment = <DeploymentJSON>transaction.deployment;\n * const verifyingKeys = deployment.verifying_keys;\n */\n async getDeploymentTransactionForProgram(\n program: Program | string,\n ): Promise<TransactionJSON> {\n if (program instanceof Program) {\n program = program.id();\n }\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getDeploymentTransactionForProgram\" };\n const transaction_id = <string>(\n await this.getDeploymentTransactionIDForProgram(program)\n );\n return <TransactionJSON>await this.getTransaction(transaction_id);\n } catch (error) {\n throw new Error(\n `Error fetching deployment transaction for program ${program}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the deployment transaction associated with a specified program as a wasm object.\n *\n * @param {Program | string} program The name of the deployed program OR a wasm Program object.\n * @returns {Promise<Transaction>} Wasm object representation of the deployment transaction.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/testnet.js\";\n *\n * // Get the transaction ID of the deployment transaction for a program.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const transactionId = networkClient.getDeploymentTransactionIDForProgram(\"hello_hello.aleo\");\n *\n * // Get the transaction data for the deployment transaction.\n * const transaction = networkClient.getDeploymentTransactionObjectForProgram(transactionId);\n *\n * // Get the verifying keys for the functions in the deployed program.\n * const verifyingKeys = transaction.verifyingKeys();\n */\n async getDeploymentTransactionObjectForProgram(\n program: Program | string,\n ): Promise<Transaction> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getDeploymentTransactionObjectForProgram\" };\n const transaction_id = <string>(\n await this.getDeploymentTransactionIDForProgram(program)\n );\n return await this.getTransactionObject(transaction_id);\n } catch (error) {\n throw new Error(\n `Error fetching deployment transaction for program ${program}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the contents of the latest block as JSON.\n *\n * @returns {Promise<BlockJSON>} A javascript object containing the latest block\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const latestHeight = networkClient.getLatestBlock();\n */\n async getLatestBlock(): Promise<BlockJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestBlock\" };\n return (await this.fetchData<BlockJSON>(\n \"/block/latest\",\n )) as BlockJSON;\n } catch (error) {\n throw new Error(`Error fetching latest block: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest committee.\n *\n * @returns {Promise<object>} A javascript object containing the latest committee\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Create a network client and get the latest committee.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const latestCommittee = await networkClient.getLatestCommittee();\n */\n async getLatestCommittee(): Promise<object> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestCommittee\" };\n return await this.fetchData<object>(\"/committee/latest\");\n } catch (error) {\n throw new Error(`Error fetching latest committee: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the committee at the specified block height.\n *\n * @param {number} blockHeight - The height of the block to fetch the committee for\n * @returns {Promise<object>} A javascript object containing the committee\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Create a network client and get the committee for a specific block.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const committee = await networkClient.getCommitteeByBlockHeight(1234);\n */\n async getCommitteeByBlockHeight(blockHeight: number): Promise<object> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getCommitteeByBlockHeight\" };\n return await this.fetchData<object>(`/committee/${blockHeight}`);\n } catch (error) {\n throw new Error(\n `Error fetching committee at height ${blockHeight}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest block height.\n *\n * @returns {Promise<number>} The latest block height.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const latestHeight = networkClient.getLatestHeight();\n */\n async getLatestHeight(): Promise<number> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestHeight\" };\n return Number(await this.fetchData<bigint>(\"/block/height/latest\"));\n } catch (error) {\n throw new Error(`Error fetching latest height: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest block hash.\n *\n * @returns {Promise<string>} The latest block hash.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the latest block hash.\n * const latestHash = networkClient.getLatestBlockHash();\n */\n async getLatestBlockHash(): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestBlockHash\" };\n return String(await this.fetchData<string>(\"/block/hash/latest\"));\n } catch (error) {\n throw new Error(`Error fetching latest hash: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the source code of a program given a program ID.\n *\n * @param {string} programId The program ID of a program deployed to the Aleo Network.\n * @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.\n * @returns {Promise<string>} The source code of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the source code of a program.)\n * @returns {Promise<string>} Source code of the program\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const program = networkClient.getProgram(\"hello_hello.aleo\");\n * const expectedSource = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\"\n * assert.equal(program, expectedSource);\n */\n async getProgram(programId: string, edition?: number): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramVersion\" };\n if (typeof edition === \"number\") {\n return await this.fetchData<string>(\n `/program/${programId}/${edition}`,\n );\n } else {\n return await this.fetchData<string>(\"/program/\" + programId);\n }\n } catch (error) {\n throw new Error(`Error fetching program ${programId}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the current program edition deployed on the Aleo network.\n *\n * @param {string} programId The program ID of a program deployed to the Aleo Network.\n * @returns {Promise<number>} The edition of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const programVersion = networkClient.getLatestProgramEdition(\"hello_hello.aleo\");\n * assert.equal(programVersion, 1);\n */\n async getLatestProgramEdition(programId: string): Promise<number> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestProgramEdition\" };\n const raw = await this.fetchRaw(\"/program/\" + programId + \"/latest_edition\");\n return JSON.parse(raw);\n } catch (error) {\n throw new Error(`Error fetching program ${programId}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a program object from a program ID or program source code.\n *\n * @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network.\n * @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.\n * @returns {Promise<Program>} Source code of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const programID = \"hello_hello.aleo\";\n * const programSource = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\"\n *\n * // Get program object from program ID or program source code\n * const programObjectFromID = await networkClient.getProgramObject(programID);\n * const programObjectFromSource = await networkClient.getProgramObject(programSource);\n *\n * // Both program objects should be equal\n * assert(programObjectFromID.to_string() === programObjectFromSource.to_string());\n */\n async getProgramObject(inputProgram: string, edition?: number): Promise<Program> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramObject\" };\n return Program.fromString(\n <string>await this.getProgram(inputProgram, edition),\n );\n } catch (error) {\n throw new Error(\n `${inputProgram} is neither a program name or a valid program: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns an object containing the source code of a program and the source code of all programs it imports\n *\n * @param {Program | string} inputProgram The program ID or program source code of a program deployed to the Aleo Network\n * @returns {Promise<ProgramImports>} Object of the form { \"program_id\": \"program_source\", .. } containing program id & source code for all program imports\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const double_test_source = \"import multiply_test.aleo;\\n\\nprogram double_test.aleo;\\n\\nfunction double_it:\\n input r0 as u32.private;\\n call multiply_test.aleo/multiply 2u32 r0 into r1;\\n output r1 as u32.private;\\n\"\n * const double_test = Program.fromString(double_test_source);\n * const expectedImports = {\n * \"multiply_test.aleo\": \"program multiply_test.aleo;\\n\\nfunction multiply:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n mul r0 r1 into r2;\\n output r2 as u32.private;\\n\"\n * }\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Imports can be fetched using the program ID, source code, or program object\n * let programImports = await networkClient.getProgramImports(\"double_test.aleo\");\n * assert.deepStrictEqual(programImports, expectedImports);\n *\n * // Using the program source code\n * programImports = await networkClient.getProgramImports(double_test_source);\n * assert.deepStrictEqual(programImports, expectedImports);\n *\n * // Using the program object\n * programImports = await networkClient.getProgramImports(double_test);\n * assert.deepStrictEqual(programImports, expectedImports);\n */\n async getProgramImports(inputProgram: Program | string, imports: ProgramImports = {}): Promise<ProgramImports> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramImports\" };\n\n // Normalize input to a Program object\n let program: Program;\n if (inputProgram instanceof Program) {\n program = inputProgram;\n } else {\n try {\n program = Program.fromString(inputProgram);\n } catch {\n try {\n program = await this.getProgramObject(inputProgram);\n } catch (error2) {\n throw new Error(\n `${inputProgram} is neither a program name nor a valid program: ${error2}`,\n );\n }\n }\n }\n\n // Get the list of programs that the program imports\n const importList = program.getImports();\n\n // Recursively get any imports that the imported programs have in a depth-first search\n for (let i = 0; i < importList.length; i++) {\n const import_id = importList[i];\n if (!imports.hasOwnProperty(import_id)) {\n const programSource = <string>await this.getProgram(import_id);\n const nestedImports = <ProgramImports>await this.getProgramImports(programSource, imports);\n\n for (const key in nestedImports) {\n if (!imports.hasOwnProperty(key)) {\n imports[key] = nestedImports[key];\n }\n }\n\n imports[import_id] = programSource;\n }\n }\n\n return imports;\n } catch (error: any) {\n logAndThrow(\"Error fetching program imports: \" + error.message);\n } finally {\n this.ctx = {};\n }\n }\n\n\n /**\n * Get a list of the program names that a program imports.\n *\n * @param {Program | string} inputProgram - The program id or program source code to get the imports of\n * @returns {string[]} - The list of program names that the program imports\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const programImportsNames = networkClient.getProgramImports(\"wrapped_credits.aleo\");\n * const expectedImportsNames = [\"credits.aleo\"];\n * assert.deepStrictEqual(programImportsNames, expectedImportsNames);\n */\n async getProgramImportNames(\n inputProgram: Program | string,\n ): Promise<string[]> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramImportNames\" };\n const program =\n inputProgram instanceof Program\n ? inputProgram\n : <Program>await this.getProgramObject(inputProgram);\n return program.getImports();\n } catch (error: any) {\n throw new Error(\n `Error fetching imports for program ${inputProgram instanceof Program ? inputProgram.id() : inputProgram}: ${error.message}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the names of the mappings of a program.\n *\n * @param {string} programId - The program ID to get the mappings of (e.g. \"credits.aleo\")\n * @returns {Promise<Array<string>>} - The names of the mappings of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const mappings = networkClient.getProgramMappingNames(\"credits.aleo\");\n * const expectedMappings = [\n * \"committee\",\n * \"delegated\",\n * \"metadata\",\n * \"bonded\",\n * \"unbonding\",\n * \"account\",\n * \"withdraw\"\n * ];\n * assert.deepStrictEqual(mappings, expectedMappings);\n */\n async getProgramMappingNames(programId: string): Promise<Array<string>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramMappingNames\" };\n return await this.fetchData<Array<string>>(\n `/program/${programId}/mappings`,\n );\n } catch (error) {\n throw new Error(\n `Error fetching mappings for program ${programId} - ensure the program exists on chain before trying again: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the value of a program's mapping for a specific key.\n *\n * @param {string} programId - The program ID to get the mapping value of (e.g. \"credits.aleo\")\n * @param {string} mappingName - The name of the mapping to get the value of (e.g. \"account\")\n * @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the \"account\" mapping)\n * @returns {Promise<string>} String representation of the value of the mapping\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get public balance of an account\n * const mappingValue = networkClient.getMappingValue(\"credits.aleo\", \"account\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\");\n * const expectedValue = \"0u64\";\n * assert(mappingValue === expectedValue);\n */\n async getProgramMappingValue(\n programId: string,\n mappingName: string,\n key: string | Plaintext,\n ): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramMappingValue\" };\n const keyString = key instanceof Plaintext ? key.toString() : key;\n return await this.fetchData<string>(\n `/program/${programId}/mapping/${mappingName}/${keyString}`,\n );\n } catch (error) {\n throw new Error(\n `Error fetching value for key '${key}' in mapping '${mappingName}' in program '${programId}' - ensure the mapping exists and the key is correct: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.\n *\n * @param {string} programId - The program ID to get the mapping value of (e.g. \"credits.aleo\")\n * @param {string} mappingName - The name of the mapping to get the value of (e.g. \"bonded\")\n * @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the \"bonded\" mapping)\n * @returns {Promise<Plaintext>} String representation of the value of the mapping\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the bond state as an account.\n * const unbondedState = networkClient.getMappingPlaintext(\"credits.aleo\", \"bonded\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\");\n *\n * // Get the two members of the object individually.\n * const validator = unbondedState.getMember(\"validator\");\n * const microcredits = unbondedState.getMember(\"microcredits\");\n *\n * // Ensure the expected values are correct.\n * assert.equal(validator, \"aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd\");\n * assert.equal(microcredits, BigInt(\"9007199254740991\"));\n *\n * // Get a JS object representation of the unbonded state.\n * const unbondedStateObject = unbondedState.toObject();\n *\n * const expectedState = {\n * validator: \"aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd\",\n * microcredits: BigInt(9007199254740991)\n * };\n * assert.equal(unbondedState, expectedState);\n */\n async getProgramMappingPlaintext(\n programId: string,\n mappingName: string,\n key: string | Plaintext,\n ): Promise<Plaintext> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramMappingPlaintext\" };\n const keyString = key instanceof Plaintext ? key.toString() : key;\n const value = await this.fetchRaw(\n `/program/${programId}/mapping/${mappingName}/${keyString}`,\n );\n return Plaintext.fromString(JSON.parse(value));\n } catch (error) {\n throw new Error(\"Failed to fetch mapping value.\" + error);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the public balance of an address from the account mapping in credits.aleo\n *\n * @param {Address | string} address A string or wasm object representing an address.\n * @returns {Promise<number>} The public balance of the address in microcredits.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the balance of an account from either an address object or address string.\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n * const publicBalance = await networkClient.getPublicBalance(account.address());\n * const publicBalanceFromString = await networkClient.getPublicBalance(account.address().to_string());\n * assert(publicBalance === publicBalanceFromString);\n */\n async getPublicBalance(address: Address | string): Promise<number> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getPublicBalance\" };\n const addressString =\n address instanceof Address ? address.to_string() : address;\n const balanceStr = await this.getProgramMappingValue(\n \"credits.aleo\",\n \"account\",\n addressString,\n );\n return balanceStr ? parseInt(balanceStr) : 0;\n } catch (error) {\n throw new Error(\n `Error fetching public balance for ${address}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest state/merkle root of the Aleo blockchain.\n *\n * @returns {Promise<string>} A string representing the latest state root of the Aleo blockchain.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the latest state root.\n * const stateRoot = networkClient.getStateRoot();\n */\n async getStateRoot(): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getStateRoot\" };\n return await this.fetchData<string>(\"/stateRoot/latest\");\n } catch (error) {\n throw new Error(`Error fetching latest state root: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a transaction by its unique identifier.\n *\n * @param {string} transactionId The transaction ID to fetch.\n * @returns {Promise<TransactionJSON>} A json representation of the transaction.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transaction = networkClient.getTransaction(\"at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj\");\n */\n async getTransaction(transactionId: string): Promise<TransactionJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransaction\" };\n return await this.fetchData<TransactionJSON>(\n \"/transaction/\" + transactionId,\n );\n } catch (error) {\n throw new Error(\n `Error fetching transaction ${transactionId}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a confirmed transaction by its unique identifier.\n *\n * @param {string} transactionId The transaction ID to fetch.\n * @returns {Promise<ConfirmedTransactionJSON>} A json object containing the confirmed transaction.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transaction = networkClient.getConfirmedTransaction(\"at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj\");\n * assert.equal(transaction.status, \"confirmed\");\n */\n async getConfirmedTransaction(\n transactionId: string,\n ): Promise<ConfirmedTransactionJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getConfirmedTransaction\" };\n return await this.fetchData<ConfirmedTransactionJSON>(\n `/transaction/confirmed/${transactionId}`,\n );\n } catch (error) {\n throw new Error(\n `Error fetching confirmed transaction ${transactionId}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,\n * outputs, and records to be searched for and displayed.\n *\n * @param {string} transactionId - The unique identifier of the transaction to fetch\n * @returns {Promise<Transaction>} A wasm object representation of the transaction.\n *\n * @example\n * const transactionObject = networkClient.getTransaction(\"at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj\");\n * // Get the transaction inputs as a JS array.\n * const transactionInputs = transactionObject.inputs(true);\n *\n * // Get the transaction outputs as a JS object.\n * const transactionOutputs = transactionObject.outputs(true);\n *\n * // Get any records generated in transitions in the transaction as a JS object.\n * const records = transactionObject.records();\n *\n * // Get the transaction type.\n * const transactionType = transactionObject.transactionType();\n * assert.equal(transactionType, \"Execute\");\n *\n * // Get a JS representation of all inputs, outputs, and transaction metadata.\n * const transactionSummary = transactionObject.summary();\n */\n async getTransactionObject(transactionId: string): Promise<Transaction> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactionObject\" };\n const transaction = await this.fetchRaw(\n \"/transaction/\" + transactionId,\n );\n return Transaction.fromString(transaction);\n } catch (error) {\n throw new Error(\n `Error fetching transaction object ${transactionId}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the transactions present at the specified block height.\n *\n * @param {number} blockHeight The block height to fetch the confirmed transactions at.\n * @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block height.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transactions = networkClient.getTransactions(654);\n */\n async getTransactions(\n blockHeight: number,\n ): Promise<Array<ConfirmedTransactionJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactions\" };\n return await this.fetchData<Array<ConfirmedTransactionJSON>>(\n \"/block/\" + blockHeight.toString() + \"/transactions\",\n );\n } catch (error) {\n throw new Error(`Error fetching transactions: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the confirmed transactions present in the block with the specified block hash.\n *\n * @param {string} blockHash The block hash to fetch the confirmed transactions at.\n * @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block hash.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transactions = networkClient.getTransactionsByBlockHash(\"ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9\");\n */\n async getTransactionsByBlockHash(\n blockHash: string,\n ): Promise<Array<ConfirmedTransactionJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactionsByBlockHash\" };\n const block = await this.fetchData<BlockJSON>(\n `/block/${blockHash}`,\n );\n const height = block.header.metadata.height;\n return await this.getTransactions(Number(height));\n } catch (error) {\n throw new Error(\n `Error fetching transactions for block ${blockHash}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the transactions in the memory pool. This method requires access to a validator's REST API.\n *\n * @returns {Promise<Array<TransactionJSON>>} An array of transactions (in JSON format) currently in the mempool.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the current transactions in the mempool.\n * const transactions = networkClient.getTransactionsInMempool();\n */\n async getTransactionsInMempool(): Promise<Array<TransactionJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactionsInMempool\" };\n return await this.fetchData<Array<TransactionJSON>>(\n \"/memoryPool/transactions\",\n );\n } catch (error) {\n throw new Error(\n `Error fetching transactions from mempool: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the transition ID of the transition corresponding to the ID of the input or output.\n * @param {string} inputOrOutputID - The unique identifier of the input or output to find the transition ID for\n * @returns {Promise<string>} - The transition ID of the input or output ID.\n *\n * @example\n * const transitionId = networkClient.getTransitionId(\"2429232855236830926144356377868449890830704336664550203176918782554219952323field\");\n */\n async getTransitionId(inputOrOutputID: string): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransitionId\" };\n return await this.fetchData<string>(\n \"/find/transitionID/\" + inputOrOutputID,\n );\n } catch (error) {\n throw new Error(\n `Error fetching transition ID for input/output ${inputOrOutputID}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Submit an execute or deployment transaction to the Aleo network.\n *\n * @param {Transaction | string} transaction - The transaction to submit, either as a Transaction object or string representation\n * @returns {Promise<string>} - The transaction id of the submitted transaction or the resulting error\n */\n async submitTransaction(\n transaction: Transaction | string,\n ): Promise<string> {\n const transactionString =\n transaction instanceof Transaction\n ? transaction.toString()\n : transaction;\n try {\n const endpoint = this.verboseErrors ? \"transaction/broadcast?check_transaction=true\" : \"transaction/broadcast\";\n const response = await retryWithBackoff(() =>\n this._sendPost(`${this.host}/${endpoint}`, {\n body: transactionString,\n headers: Object.assign({}, {...this.headers, \"X-ALEO-METHOD\" : \"submitTransaction\"}, {\n \"Content-Type\": \"application/json\",\n }),\n }),\n );\n\n try {\n const text = await response.text();\n return parseJSON(text);\n } catch (error: any) {\n throw new Error(\n `Error posting transaction. Aleo network response: ${error.message}`,\n );\n }\n } catch (error: any) {\n throw new Error(\n `Error posting transaction: ${error}`,\n );\n }\n }\n\n /**\n * Submit a solution to the Aleo network.\n *\n * @param {string} solution - The string representation of the solution to submit\n * @returns {Promise<string>} The solution id of the submitted solution or the resulting error.\n */\n async submitSolution(solution: string): Promise<string> {\n try {\n const response = await retryWithBackoff(() =>\n post(this.host + \"/solution/broadcast\", {\n body: solution,\n headers: Object.assign({}, {...this.headers, \"X-ALEO-METHOD\": \"submitSolution\"}, {\n \"Content-Type\": \"application/json\",\n }),\n }),\n );\n\n try {\n const text = await response.text();\n return parseJSON(text);\n } catch (error: any) {\n throw new Error(\n `Error posting solution. Aleo network response: ${error.message}`,\n );\n }\n } catch (error: any) {\n throw new Error(\n `Error posting solution: No response received: ${error.message}`,\n );\n }\n }\n\n /**\n * Refreshes the JWT by making a POST request to /jwts/{consumer_id}\n * \n * @param {string} apiKey - The API key for authentication.\n * @param {string} consumerId - The consumer ID associated with the API key.\n * @returns {Promise<JwtData>} The JWT token and expiration time\n */\n private async refreshJwt(apiKey: string, consumerId: string): Promise<JWTData> {\n if (!apiKey || !consumerId) {\n throw new Error('API key and consumer ID are required to refresh JWT');\n }\n const response = await post(\n `https://api.provable.com/jwts/${consumerId}`,\n {\n headers: {\n 'X-Provable-API-Key': apiKey\n }\n }\n );\n const authHeader = response.headers.get('authorization');\n if (!authHeader) {\n throw new Error('No authorization header in JWT refresh response');\n }\n const body = await response.json();\n \n return {\n jwt: authHeader,\n expiration: body.exp * 1000 // Convert to milliseconds\n };\n }\n\n\n /**\n * Parses a /prove or /prove/encrypted response. Returns a result object (never throws for 200/400/500/503).\n */\n private async handleProvingResponse(response: Response): Promise<ProvingResult> {\n // Get the proving response text.\n const text = await response.text();\n let body: unknown;\n\n // Parse the body.\n try {\n body = parseJSON(text);\n } catch {\n body = {};\n }\n\n // If the status is 200, attempt to parse the Proving Request along its expected structure.\n if (response.status === 200) {\n if (isProvingResponse(body)) {\n return { ok: true, data: body };\n }\n return {\n ok: false,\n status: response.status,\n error: { message: \"Invalid response from proving service\" },\n };\n }\n\n // If the response is non 200, return the information back to the caller so it can be handled.\n if (response.status === 400 || response.status === 500 || response.status === 503) {\n const error: ProveApiErrorBody = isProveApiErrorBody(body)\n ? body\n : { message: text || `${response.status} error` };\n return { ok: false, status: response.status, error };\n }\n return {\n ok: false,\n status: response.status,\n error: { message: text || `${response.status} error` },\n };\n }\n\n /**\n * Submit a `ProvingRequest` to a remote proving service for delegated proving. If the broadcast flag of the `ProvingRequest` is set to `true` the remote service will attempt to broadcast the result `Transaction` on behalf of the requestor. Throws on HTTP 400, 500, 503 (and retries on 500/503). Callers should {@link submitProvingRequestSafe} to handle proving request failures without throwing.\n *\n * @param {DelegatedProvingParams} options - The optional parameters required to submit a proving request.\n * @returns {Promise<ProvingResponse>} The ProvingResponse containing the transaction result and the result of the broadcast if the `broadcast` flag was set to `true`.\n */\n async submitProvingRequest(options: DelegatedProvingParams): Promise<ProvingResponse> {\n const result = await this.submitProvingRequestSafe(options);\n if (result.ok) {\n return result.data;\n }\n const err = new Error(result.error.message) as ProvingRequestError;\n err.status = result.status;\n throw err;\n }\n\n /**\n * Submit a proving request and return a result object instead of throwing. This method is usable when callers want to handle HTTP status (400, 500, 503) yourself. Retries on 500/503 and returns on 200 or 400.\n *\n * @param {DelegatedProvingParams} options - The optional parameters required to submit a proving request.\n * @returns {Promise<ProvingResult>} `{ ok: true, data }` on success (200), or `{ ok: false, status, error }` on 400/500/503. Check `result.ok` and then either `result.data` or `result.status` / `result.error.message`.\n */\n async submitProvingRequestSafe(options: DelegatedProvingParams): Promise<ProvingResult> {\n // Attempt to get the Prover URI first from the options, then from any configured globally, or third try the main configured host.\n const proverUri = (options.url ?? this.proverUri) ?? this.host;\n const provingRequestString = options.provingRequest instanceof ProvingRequest\n ? options.provingRequest.toString()\n : options.provingRequest;\n\n // Try to get JWT data to access the Provable API.\n const apiKey = options.apiKey ?? this.apiKey;\n const consumerId = options.consumerId ?? this.consumerId;\n let jwtData = options.jwtData ?? this.jwtData;\n\n // Check to see if the JWT needs refreshing.\n const isExpired = jwtData && Date.now() >= jwtData.expiration - FIVE_MINUTES;\n if (!jwtData || isExpired) {\n if (options.apiKey && options.consumerId) {\n jwtData = await this.refreshJwt(apiKey!, consumerId!);\n this.jwtData = jwtData;\n options.jwtData = jwtData;\n } else {\n console.warn('JWT or both apiKey and consumerId are required when using the Provable API');\n }\n }\n\n // Create the necessary headers to hit the provable api.\n const headers: Record<string, string> = {\n ...this.headers,\n \"X-ALEO-METHOD\": \"submitProvingRequest\",\n \"Content-Type\": \"application/json\",\n };\n if (jwtData?.jwt) {\n headers[\"Authorization\"] = jwtData.jwt;\n }\n\n // Encapsulate the requests in a locally scoped function that can be run with a retry closure.\n const runRequest = async (): Promise<ProvingResult> => {\n // If DPS privacy is set, call invoke the encrypted flow.\n if (options.dpsPrivacy) {\n // Get an ephemeral public key from a DPS service.\n const pubKeyResponse = await get(proverUri + \"/pubkey\", {\n headers,\n });\n\n // Encrypt the provingRequest.\n const pubkey: CryptoBoxPubKey = parseJSON(\n await pubKeyResponse.text(),\n );\n const ciphertext = encryptProvingRequest(\n pubkey.public_key,\n ProvingRequest.fromString(provingRequestString),\n );\n\n // Form the expected query a DPS service expects (including the key_id).\n const payload: EncryptedProvingRequest = {\n key_id: pubkey.key_id,\n ciphertext: ciphertext,\n };\n const res = await fetch(`${proverUri}/prove/encrypted`, {\n method: \"POST\",\n body: JSON.stringify(payload),\n headers,\n });\n\n // Properly handle the proving response.\n return this.handleProvingResponse(res);\n }\n\n // If encrypted usage is not specified use the unencrypted endpoint.\n const proveEndpoint = (<string>proverUri).endsWith(\"/prove\")\n ? proverUri\n : proverUri + \"/prove\";\n const res = await fetch(proveEndpoint, {\n method: \"POST\",\n body: provingRequestString,\n headers,\n });\n\n // Properly handle the proving response.\n return this.handleProvingResponse(res);\n };\n\n try {\n // Run the request with retries.\n return await retryWithBackoff(async () => {\n // Run the encrypted or non-encrypted flow as specified by the flags.\n const result = await runRequest();\n if (result.ok) {\n return result;\n }\n\n // If 500s are hit responses are returned, attempt retries.\n if (result.status === 500 || result.status === 503) {\n const err = new Error(result.error.message) as ProvingRequestError;\n err.status = result.status;\n throw err;\n }\n return result;\n });\n } catch (err) {\n // If an error is returned, provide usable information to the caller.\n const e = err as ProvingRequestError;\n return {\n ok: false,\n status: e.status ?? 500,\n error: { message: e.message },\n };\n }\n }\n\n /**\n * Await a submitted transaction to be confirmed or rejected on the Aleo network.\n *\n * @param {string} transactionId - The transaction ID to wait for confirmation\n * @param {number} checkInterval - The interval in milliseconds to check for confirmation (default: 2000)\n * @param {number} timeout - The maximum time in milliseconds to wait for confirmation (default: 45000)\n * @returns {Promise<Transaction>} The confirmed transaction object that returns if the transaction is confirmed.\n *\n * @example\n * import { AleoNetworkClient, Account, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client and program manager.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const programManager = new ProgramManager(networkClient);\n *\n * // Set the account for the program manager.\n * programManager.setAccount(Account.fromCiphertext(process.env.ciphertext, process.env.password));\n *\n * // Build a transfer transaction.\n * const tx = await programManager.buildTransferPublicTransaction(100, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", 0);\n *\n * // Submit the transaction to the network.\n * const transactionId = await networkClient.submitTransaction(tx);\n *\n * // Wait for the transaction to be confirmed.\n * const transaction = await networkClient.waitForTransactionConfirmation(transactionId);\n */\n async waitForTransactionConfirmation(\n transactionId: string,\n checkInterval: number = 2000,\n timeout: number = 45000,\n ): Promise<ConfirmedTransactionJSON> {\n const startTime = Date.now();\n\n return new Promise((resolve, reject) => {\n const interval = setInterval(async () => {\n const elapsed = Date.now() - startTime;\n\n if (elapsed > timeout) {\n clearInterval(interval);\n return reject(\n new Error(\n `Transaction ${transactionId} did not appear after the timeout period of ${interval}ms - consider resubmitting the transaction`,\n ),\n );\n }\n\n try {\n const res = await fetch(\n `${this.host}/transaction/confirmed/${transactionId}`,\n {\n headers: {\n ...this.headers,\n \"X-ALEO-METHOD\" : \"waitForTransactionConfirmation\",\n },\n },\n );\n if (!res.ok) {\n let text = \"\";\n try {\n text = await res.text();\n console.warn(\"Response text from server:\", text);\n } catch (err) {\n console.warn(\"Failed to read response text:\", err);\n }\n\n // If the transaction ID is malformed (e.g. invalid checksum, wrong length),\n // the API returns a 4XX with \"Invalid URL\" — we treat this as a fatal error and stop polling.\n if (\n res.status >= 400 &&\n res.status < 500 &&\n text.includes(\"Invalid URL\")\n ) {\n clearInterval(interval);\n return reject(\n new Error(`Malformed transaction ID: ${text}`),\n );\n }\n\n // Log and continue polling for 404s or 5XX errors in case a tx doesn't exist yet\n console.warn(\n \"Non-OK response (retrying):\",\n res.status,\n text,\n );\n return;\n }\n\n const data = parseJSON(await res.text());\n if (data?.status === \"accepted\") {\n clearInterval(interval);\n return resolve(data);\n }\n\n if (data?.status === \"rejected\") {\n clearInterval(interval);\n return reject(\n new Error(\n `Transaction ${transactionId} was rejected by the network. Ensure that the account paying the fee has enough credits and that the inputs to the on-chain function are valid.`,\n ),\n );\n }\n } catch (err) {\n console.error(\"Polling error:\", err);\n }\n }, checkInterval);\n });\n }\n}\n\nexport { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports };","import {\n CREDITS_PROGRAM_KEYS,\n KEY_STORE,\n Key,\n PRIVATE_TRANSFER,\n PRIVATE_TO_PUBLIC_TRANSFER,\n PUBLIC_TRANSFER,\n PUBLIC_TO_PRIVATE_TRANSFER,\n PUBLIC_TRANSFER_AS_SIGNER,\n} from \"./constants.js\";\n\nimport {\n ProvingKey,\n VerifyingKey,\n} from \"./wasm.js\";\n\nimport { get } from \"./utils.js\";\n\ntype FunctionKeyPair = [ProvingKey, VerifyingKey];\ntype CachedKeyPair = [Uint8Array, Uint8Array];\ntype AleoKeyProviderInitParams = {\n proverUri?: string;\n verifierUri?: string;\n cacheKey?: string;\n};\n\n/**\n * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider\n * implementations.\n */\ninterface KeySearchParams {\n [key: string]: any; // This allows for arbitrary keys with any type values\n}\n\n/**\n * AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and\n * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.\n */\nclass AleoKeyProviderParams implements KeySearchParams {\n name: string | undefined;\n proverUri: string | undefined;\n verifierUri: string | undefined;\n cacheKey: string | undefined;\n\n /**\n * Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally\n * specify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique\n * cacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must\n * be provided.\n *\n * @param { AleoKeyProviderInitParams } params - Optional search parameters\n */\n constructor(params: {proverUri?: string, verifierUri?: string, cacheKey?: string, name?: string}) {\n this.proverUri = params.proverUri;\n this.verifierUri = params.verifierUri;\n this.cacheKey = params.cacheKey;\n this.name = params.name;\n }\n}\n\n/**\n * KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs.\n */\ninterface FunctionKeyProvider {\n /**\n * Get bond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function\n */\n bondPublicKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get bond_validator function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_validator function\n */\n bondValidatorKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\n * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.\n *\n * @param {string} keyId access key for the cache\n * @param {FunctionKeyPair} keys keys to cache\n */\n cacheKeys(keyId: string, keys: FunctionKeyPair): void;\n\n /**\n * Get unbond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function\n */\n claimUnbondPublicKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get arbitrary function keys from a provider\n *\n * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * // Create a search object which implements the KeySearchParams interface\n * class IndexDbSearch implements KeySearchParams {\n * db: string\n * keyId: string\n * constructor(params: {db: string, keyId: string}) {\n * this.db = params.db;\n * this.keyId = params.keyId;\n * }\n * }\n *\n * // Create a new object which implements the KeyProvider interface\n * class IndexDbKeyProvider implements FunctionKeyProvider {\n * async functionKeys(params: KeySearchParams): Promise<FunctionKeyPair> {\n * return new Promise((resolve, reject) => {\n * const request = indexedDB.open(params.db, 1);\n *\n * request.onupgradeneeded = function(e) {\n * const db = e.target.result;\n * if (!db.objectStoreNames.contains('keys')) {\n * db.createObjectStore('keys', { keyPath: 'id' });\n * }\n * };\n *\n * request.onsuccess = function(e) {\n * const db = e.target.result;\n * const transaction = db.transaction([\"keys\"], \"readonly\");\n * const store = transaction.objectStore(\"keys\");\n * const request = store.get(params.keyId);\n * request.onsuccess = function(e) {\n * if (request.result) {\n * resolve(request.result as FunctionKeyPair);\n * } else {\n * reject(new Error(\"Key not found\"));\n * }\n * };\n * request.onerror = function(e) { reject(new Error(\"Error fetching key\")); };\n * };\n *\n * request.onerror = function(e) { reject(new Error(\"Error opening database\")); };\n * });\n * }\n *\n * // implement the other methods...\n * }\n *\n *\n * const keyProvider = new AleoKeyProvider();\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const searchParams = new IndexDbSearch({db: \"keys\", keyId: \"credits.aleo:transferPrivate\"});\n * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(searchParams);\n */\n functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;\n\n /**\n * Get fee_private function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePrivateKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get fee_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePublicKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get keys for the inclusion proof.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n inclusionKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get join function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n joinKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get split function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n splitKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get keys for a variant of the transfer function from the credits.aleo program\n *\n * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function\n *\n * @example\n * // Create a new object which implements the KeyProvider interface\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys(\"public\");\n */\n transferKeys(visibility: string): Promise<FunctionKeyPair>;\n\n /**\n * Get unbond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n unBondPublicKeys(): Promise<FunctionKeyPair>;\n\n}\n\n\n/**\n * AleoKeyProvider class. Implements the KeyProvider interface. Enables the retrieval of Aleo program proving and\n * verifying keys for the credits.aleo program over http from official Aleo sources and storing and retrieving function\n * keys from a local memory cache.\n */\nclass AleoKeyProvider implements FunctionKeyProvider {\n cache: Map<string, CachedKeyPair>;\n cacheOption: boolean;\n keyUris: string;\n\n async fetchBytes(\n url = \"/\",\n ): Promise<Uint8Array> {\n try {\n const response = await get(url);\n const data = await response.arrayBuffer();\n return new Uint8Array(data);\n } catch (error: any) {\n throw new Error(\"Error fetching data.\" + error.message);\n }\n }\n\n constructor() {\n this.keyUris = KEY_STORE;\n this.cache = new Map<string, CachedKeyPair>();\n this.cacheOption = false;\n }\n\n /**\n * Use local memory to store keys\n *\n * @param {boolean} useCache whether to store keys in local memory\n */\n useCache(useCache: boolean) {\n this.cacheOption = useCache;\n }\n\n /**\n * Clear the key cache\n */\n clearCache() {\n this.cache.clear();\n }\n\n /**\n * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\n * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.\n *\n * @param {string} keyId access key for the cache\n * @param {FunctionKeyPair} keys keys to cache\n */\n cacheKeys(keyId: string, keys: FunctionKeyPair) {\n const [provingKey, verifyingKey] = keys;\n this.cache.set(keyId, [provingKey.toBytes(), verifyingKey.toBytes()]);\n }\n\n /**\n * Determine if a keyId exists in the cache\n *\n * @param {string} keyId keyId of a proving and verifying key pair\n * @returns {boolean} true if the keyId exists in the cache, false otherwise\n */\n containsKeys(keyId: string): boolean {\n return this.cache.has(keyId)\n }\n\n /**\n * Delete a set of keys from the cache\n *\n * @param {string} keyId keyId of a proving and verifying key pair to delete from memory\n * @returns {boolean} true if the keyId exists in the cache and was deleted, false if the key did not exist\n */\n deleteKeys(keyId: string): boolean {\n return this.cache.delete(keyId)\n }\n\n /**\n * Get a set of keys from the cache\n * @param keyId keyId of a proving and verifying key pair\n *\n * @returns {FunctionKeyPair} Proving and verifying keys for the specified program\n */\n getKeys(keyId: string): FunctionKeyPair {\n console.debug(`Checking if key exists in cache. KeyId: ${keyId}`)\n if (this.cache.has(keyId)) {\n const [provingKeyBytes, verifyingKeyBytes] = <CachedKeyPair>this.cache.get(keyId);\n return [ProvingKey.fromBytes(provingKeyBytes), VerifyingKey.fromBytes(verifyingKeyBytes)];\n } else {\n throw new Error(\"Key not found in cache.\");\n }\n }\n\n /**\n * Get arbitrary function keys from a provider\n *\n * @param {KeySearchParams} params parameters for the key search in form of: {proverUri: string, verifierUri: string, cacheKey: string}\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * // Create a new object which implements the KeyProvider interface\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually using the key provider\n * const keySearchParams = { \"cacheKey\": \"myProgram:myFunction\" };\n * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(keySearchParams);\n */\n async functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair> {\n if (params) {\n let proverUrl;\n let verifierUrl;\n let cacheKey;\n if (\"name\" in params && typeof params[\"name\"] == \"string\") {\n let key = CREDITS_PROGRAM_KEYS.getKey(params[\"name\"]);\n return this.fetchCreditsKeys(key);\n }\n\n if (\"proverUri\" in params && typeof params[\"proverUri\"] == \"string\") {\n proverUrl = params[\"proverUri\"];\n }\n\n if (\"verifierUri\" in params && typeof params[\"verifierUri\"] == \"string\") {\n verifierUrl = params[\"verifierUri\"];\n }\n\n if (\"cacheKey\" in params && typeof params[\"cacheKey\"] == \"string\") {\n cacheKey = params[\"cacheKey\"];\n }\n\n if (proverUrl && verifierUrl) {\n return await this.fetchRemoteKeys(proverUrl, verifierUrl, cacheKey);\n }\n\n if (cacheKey) {\n return this.getKeys(cacheKey);\n }\n }\n throw new Error(\"Invalid parameters provided, must provide either a cacheKey and/or a proverUrl and a verifierUrl\");\n }\n\n /**\n * Returns the proving and verifying keys for a specified program from a specified url.\n *\n * @param {string} verifierUrl Url of the proving key\n * @param {string} proverUrl Url the verifying key\n * @param {string} cacheKey Key to store the keys in the cache\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * // Create a new AleoKeyProvider object\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.fetchKeys(\n * CREDITS_PROGRAM_KEYS.transfer_private.prover,\n * CREDITS_PROGRAM_KEYS.transfer_private.verifier,\n * );\n */\n async fetchRemoteKeys(proverUrl: string, verifierUrl: string, cacheKey?: string): Promise<FunctionKeyPair> {\n try {\n // If cache is enabled, check if the keys have already been fetched and return them if they have\n if (this.cacheOption) {\n if (!cacheKey) {\n cacheKey = proverUrl;\n }\n const value = this.cache.get(cacheKey);\n if (typeof value !== \"undefined\") {\n return [ProvingKey.fromBytes(value[0]), VerifyingKey.fromBytes(value[1])];\n } else {\n console.debug(\"Fetching proving keys from url \" + proverUrl);\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl))\n console.debug(\"Fetching verifying keys \" + verifierUrl);\n const verifyingKey = <VerifyingKey>(await this.getVerifyingKey(verifierUrl));\n this.cache.set(cacheKey, [provingKey.toBytes(), verifyingKey.toBytes()]);\n return [provingKey, verifyingKey];\n }\n }\n else {\n // If cache is disabled, fetch the keys and return them\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl))\n const verifyingKey = <VerifyingKey>(await this.getVerifyingKey(verifierUrl));\n return [provingKey, verifyingKey];\n }\n } catch (error: any) {\n throw new Error(`Error: ${error.message} fetching fee proving and verifying keys from ${proverUrl} and ${verifierUrl}.`);\n }\n }\n\n /***\n * Fetches the proving key from a remote source.\n *\n * @param proverUrl\n * @param cacheKey\n *\n * @returns {Promise<ProvingKey>} Proving key for the specified program\n */\n async fetchProvingKey(proverUrl: string, cacheKey?: string): Promise<ProvingKey> {\n try {\n // If cache is enabled, check if the keys have already been fetched and return them if they have\n if (this.cacheOption) {\n if (!cacheKey) {\n cacheKey = proverUrl;\n }\n const value = this.cache.get(cacheKey);\n if (typeof value !== \"undefined\") {\n return ProvingKey.fromBytes(value[0]);\n } else {\n console.debug(\"Fetching proving keys from url \" + proverUrl);\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl));\n return provingKey;\n }\n }\n else {\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl));\n return provingKey;\n }\n } catch (error: any) {\n throw new Error(`Error: ${error.message} fetching fee proving keys from ${proverUrl}`);\n }\n }\n\n async fetchCreditsKeys(key: Key): Promise<FunctionKeyPair> {\n try {\n if (!this.cache.has(key.locator) || !this.cacheOption) {\n const verifying_key = key.verifyingKey()\n const proving_key = <ProvingKey>await this.fetchProvingKey(key.prover, key.locator);\n if (this.cacheOption) {\n this.cache.set(CREDITS_PROGRAM_KEYS.getKey(key.name).locator, [proving_key.toBytes(), verifying_key.toBytes()]);\n }\n return [proving_key, verifying_key];\n } else {\n const keyPair = <CachedKeyPair>this.cache.get(key.locator);\n return [ProvingKey.fromBytes(keyPair[0]), VerifyingKey.fromBytes(keyPair[1])];\n }\n } catch (error: any) {\n throw new Error(`Error: fetching credits.aleo keys: ${error.message}`);\n }\n }\n\n async bondPublicKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_public);\n }\n\n bondValidatorKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_validator);\n }\n\n claimUnbondPublicKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public)\n }\n\n /**\n * Returns the proving and verifying keys for the transfer functions in the credits.aleo program\n * @param {string} visibility Visibility of the transfer function\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer functions\n *\n * @example\n * // Create a new AleoKeyProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys(\"public\");\n */\n async transferKeys(visibility: string): Promise<FunctionKeyPair> {\n if (PRIVATE_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private);\n } else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public);\n } else if (PUBLIC_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);\n } else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_as_signer);\n } else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private);\n } else {\n throw new Error(\"Invalid visibility type\");\n }\n }\n\n /**\n * Returns the proving and verifying keys for the transfer_public function.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function\n */\n async transferPublicKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);\n }\n\n /**\n * Returns the proving and verifying keys for the inclusion proof.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.\n */\n async inclusionKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.inclusion);\n }\n\n /**\n * Returns the proving and verifying keys for the join function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n async joinKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.join);\n }\n\n /**\n * Returns the proving and verifying keys for the split function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the split function\n * */\n async splitKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.split);\n }\n\n /**\n * Returns the proving and verifying keys for the fee_private function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function\n */\n async feePrivateKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_private);\n }\n\n /**\n * Returns the proving and verifying keys for the fee_public function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function\n */\n async feePublicKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public);\n }\n\n /**\n * Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise\n *\n * @returns {Promise<VerifyingKey>} Verifying key for the function\n */\n // attempt to fetch it from the network\n async getVerifyingKey(verifierUri: string): Promise<VerifyingKey> {\n switch (verifierUri) {\n case CREDITS_PROGRAM_KEYS.bond_public.verifier:\n return CREDITS_PROGRAM_KEYS.bond_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.bond_validator.verifier:\n return CREDITS_PROGRAM_KEYS.bond_validator.verifyingKey();\n case CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier:\n return CREDITS_PROGRAM_KEYS.claim_unbond_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.fee_private.verifier:\n return CREDITS_PROGRAM_KEYS.fee_private.verifyingKey();\n case CREDITS_PROGRAM_KEYS.fee_public.verifier:\n return CREDITS_PROGRAM_KEYS.fee_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.inclusion.verifier:\n return CREDITS_PROGRAM_KEYS.inclusion.verifyingKey();\n case CREDITS_PROGRAM_KEYS.join.verifier:\n return CREDITS_PROGRAM_KEYS.join.verifyingKey();\n case CREDITS_PROGRAM_KEYS.set_validator_state.verifier:\n return CREDITS_PROGRAM_KEYS.set_validator_state.verifyingKey();\n case CREDITS_PROGRAM_KEYS.split.verifier:\n return CREDITS_PROGRAM_KEYS.split.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_private.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_private.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_public.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifyingKey();\n case CREDITS_PROGRAM_KEYS.unbond_public.verifier:\n return CREDITS_PROGRAM_KEYS.unbond_public.verifyingKey();\n default:\n try {\n /// Try to fetch the verifying key from the network as a string\n const response = await get(verifierUri);\n const text = await response.text();\n return <VerifyingKey>VerifyingKey.fromString(text);\n } catch (e) {\n /// If that fails, try to fetch the verifying key from the network as bytes\n try {\n return <VerifyingKey>VerifyingKey.fromBytes(await this.fetchBytes(verifierUri));\n } catch (inner: any) {\n throw new Error(\"Invalid verifying key. Error: \" + inner.message);\n }\n }\n }\n }\n\n unBondPublicKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.unbond_public);\n }\n}\n\nexport {AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams}\n","import {\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider.js\";\n\nimport {\n ProvingKey,\n VerifyingKey,\n} from \"./wasm.js\";\n\nimport {\n CREDITS_PROGRAM_KEYS,\n PRIVATE_TRANSFER,\n PRIVATE_TO_PUBLIC_TRANSFER,\n PUBLIC_TRANSFER,\n PUBLIC_TO_PRIVATE_TRANSFER,\n PUBLIC_TRANSFER_AS_SIGNER,\n} from \"./constants.js\";\n\n/**\n * Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes\n * a convenience method for creating a new instance of this class for each function of the credits.aleo program.\n *\n * @example\n * // If storing a key for a custom program function\n * offlineSearchParams = new OfflineSearchParams(\"myprogram.aleo/myfunction\");\n *\n * // If storing a key for a credits.aleo program function\n * bondPublicKeyParams = OfflineSearchParams.bondPublicKeyParams();\n */\nclass OfflineSearchParams implements KeySearchParams {\n cacheKey: string | undefined;\n verifyCreditsKeys: boolean | undefined;\n\n /**\n * Create a new OfflineSearchParams instance.\n *\n * @param {string} cacheKey - Key used to store the local function proving & verifying keys. This should be stored\n * under the naming convention \"programName/functionName\" (i.e. \"myprogram.aleo/myfunction\")\n * @param {boolean} verifyCreditsKeys - Whether to verify the keys against the credits.aleo program,\n * defaults to false, but should be set to true if using keys from the credits.aleo program\n */\n constructor(cacheKey: string, verifyCreditsKeys = false) {\n this.cacheKey = cacheKey;\n this.verifyCreditsKeys = verifyCreditsKeys;\n }\n\n /**\n * Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program.\n */\n static bondPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.bond_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program.\n */\n static bondValidatorKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.bond_validator.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the claim_unbond_public function of the\n */\n static claimUnbondPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.claim_unbond_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program.\n */\n static feePrivateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.fee_private.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program.\n */\n static feePublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.fee_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the inclusion prover function.\n */\n static inclusionKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.inclusion.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the join function of the credits.aleo program.\n */\n static joinKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.join.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program.\n */\n static setValidatorStateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.set_validator_state.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the split function of the credits.aleo program.\n */\n static splitKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.split.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program.\n */\n static transferPrivateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_private.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program.\n */\n static transferPrivateToPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program.\n */\n static transferPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program.\n */\n static transferPublicAsSignerKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public_as_signer.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program.\n */\n static transferPublicToPrivateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program.\n */\n static unbondPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.unbond_public.locator, true);\n }\n}\n\n/**\n * A key provider meant for building transactions offline on devices such as hardware wallets. This key provider is not\n * able to contact the internet for key material and instead relies on the user to insert Aleo function proving &\n * verifying keys from local storage prior to usage.\n *\n * @example\n * // Create an offline program manager\n * const programManager = new ProgramManager();\n *\n * // Create a temporary account for the execution of the program\n * const account = new Account();\n * programManager.setAccount(account);\n *\n * // Create the proving keys from the key bytes on the offline machine\n * console.log(\"Creating proving keys from local key files\");\n * const program = \"program hello_hello.aleo; function hello: input r0 as u32.public; input r1 as u32.private; add r0 r1 into r2; output r2 as u32.private;\";\n * const myFunctionProver = await getLocalKey(\"/path/to/my/function/hello_hello.prover\");\n * const myFunctionVerifier = await getLocalKey(\"/path/to/my/function/hello_hello.verifier\");\n * const feePublicProvingKeyBytes = await getLocalKey(\"/path/to/credits.aleo/feePublic.prover\");\n *\n * myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProver);\n * myFunctionVerifyingKey = VerifyingKey.fromBytes(myFunctionVerifier);\n * const feePublicProvingKey = ProvingKey.fromBytes(feePublicKeyBytes);\n *\n * // Create an offline key provider\n * console.log(\"Creating offline key provider\");\n * const offlineKeyProvider = new OfflineKeyProvider();\n *\n * // Cache the keys\n * // Cache the proving and verifying keys for the custom hello function\n * OfflineKeyProvider.cacheKeys(\"hello_hello.aleo/hello\", myFunctionProvingKey, myFunctionVerifyingKey);\n *\n * // Cache the proving key for the fee_public function (the verifying key is automatically cached)\n * OfflineKeyProvider.insertFeePublicKey(feePublicProvingKey);\n *\n * // Create an offline query using the latest state root in order to create the inclusion proof\n * const offlineQuery = new OfflineQuery(\"latestStateRoot\");\n *\n * // Insert the key provider into the program manager\n * programManager.setKeyProvider(offlineKeyProvider);\n *\n * // Create the offline search params\n * const offlineSearchParams = new OfflineSearchParams(\"hello_hello.aleo/hello\");\n *\n * // Create the offline transaction\n * const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction(\"hello_hello.aleo\", \"hello\", 1, false, [\"5u32\", \"5u32\"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);\n *\n * // Broadcast the transaction later on a machine with internet access\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const txId = await networkClient.broadcastTransaction(offlineExecuteTx);\n */\nclass OfflineKeyProvider implements FunctionKeyProvider {\n cache: Map<string, CachedKeyPair>;\n\n constructor() {\n this.cache = new Map<string, CachedKeyPair>();\n }\n\n /**\n * Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function\n */\n bondPublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.bondPublicKeyParams());\n };\n\n /**\n * Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function\n */\n bondValidatorKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.bondValidatorKeyParams());\n };\n\n\n /**\n * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\n * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.\n *\n * @param {string} keyId access key for the cache\n * @param {FunctionKeyPair} keys keys to cache\n */\n cacheKeys(keyId: string, keys: FunctionKeyPair): void {\n const [provingKey, verifyingKey] = keys;\n this.cache.set(keyId, [provingKey.toBytes(), verifyingKey.toBytes()]);\n };\n\n /**\n * Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function\n */\n claimUnbondPublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.claimUnbondPublicKeyParams());\n };\n\n /**\n * Get arbitrary function key from the offline key provider cache.\n *\n * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * /// First cache the keys from local offline resources\n * const offlineKeyProvider = new OfflineKeyProvider();\n * const myFunctionVerifyingKey = VerifyingKey.fromString(\"verifier...\");\n * const myFunctionProvingKeyBytes = await readBinaryFile('./resources/myfunction.prover');\n * const myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProvingKeyBytes);\n *\n * /// Cache the keys for future use with a memorable locator\n * offlineKeyProvider.cacheKeys(\"myprogram.aleo/myfunction\", [myFunctionProvingKey, myFunctionVerifyingKey]);\n *\n * /// When they're needed, retrieve the keys from the cache\n *\n * /// First create a search parameter object with the same locator used to cache the keys\n * const keyParams = new OfflineSearchParams(\"myprogram.aleo/myfunction\");\n *\n * /// Then retrieve the keys\n * const [myFunctionProver, myFunctionVerifier] = await offlineKeyProvider.functionKeys(keyParams);\n */\n functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair> {\n return new Promise((resolve, reject) => {\n if (params === undefined) {\n reject(new Error(\"No search parameters provided, cannot retrieve keys\"));\n } else {\n const keyId = params.cacheKey;\n const verifyCreditsKeys = params.verifyCreditsKeys;\n if (this.cache.has(keyId)) {\n const [provingKeyBytes, verifyingKeyBytes] = this.cache.get(keyId) as CachedKeyPair;\n const provingKey = ProvingKey.fromBytes(provingKeyBytes);\n const verifyingKey = VerifyingKey.fromBytes(verifyingKeyBytes);\n if (verifyCreditsKeys) {\n const keysMatchExpected = this.verifyCreditsKeys(keyId, provingKey, verifyingKey)\n if (!keysMatchExpected) {\n reject (new Error(`Cached keys do not match expected keys for ${keyId}`));\n }\n }\n resolve([provingKey, verifyingKey]);\n } else {\n reject(new Error(\"Keys not found in cache for \" + keyId));\n }\n }\n });\n };\n\n /**\n * Determines if the keys for a given credits function match the expected keys.\n *\n * @returns {boolean} Whether the keys match the expected keys\n */\n verifyCreditsKeys(locator: string, provingKey: ProvingKey, verifyingKey: VerifyingKey): boolean {\n switch (locator) {\n case CREDITS_PROGRAM_KEYS.bond_public.locator:\n return provingKey.isBondPublicProver() && verifyingKey.isBondPublicVerifier();\n case CREDITS_PROGRAM_KEYS.claim_unbond_public.locator:\n return provingKey.isClaimUnbondPublicProver() && verifyingKey.isClaimUnbondPublicVerifier();\n case CREDITS_PROGRAM_KEYS.fee_private.locator:\n return provingKey.isFeePrivateProver() && verifyingKey.isFeePrivateVerifier();\n case CREDITS_PROGRAM_KEYS.fee_public.locator:\n return provingKey.isFeePublicProver() && verifyingKey.isFeePublicVerifier();\n case CREDITS_PROGRAM_KEYS.inclusion.locator:\n return provingKey.isInclusionProver() && verifyingKey.isInclusionVerifier();\n case CREDITS_PROGRAM_KEYS.join.locator:\n return provingKey.isJoinProver() && verifyingKey.isJoinVerifier();\n case CREDITS_PROGRAM_KEYS.set_validator_state.locator:\n return provingKey.isSetValidatorStateProver() && verifyingKey.isSetValidatorStateVerifier();\n case CREDITS_PROGRAM_KEYS.split.locator:\n return provingKey.isSplitProver() && verifyingKey.isSplitVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_private.locator:\n return provingKey.isTransferPrivateProver() && verifyingKey.isTransferPrivateVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator:\n return provingKey.isTransferPrivateToPublicProver() && verifyingKey.isTransferPrivateToPublicVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_public.locator:\n return provingKey.isTransferPublicProver() && verifyingKey.isTransferPublicVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator:\n return provingKey.isTransferPublicToPrivateProver() && verifyingKey.isTransferPublicToPrivateVerifier();\n case CREDITS_PROGRAM_KEYS.unbond_public.locator:\n return provingKey.isUnbondPublicProver() && verifyingKey.isUnbondPublicVerifier();\n default:\n return false;\n }\n }\n\n /**\n * Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePrivateKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.feePrivateKeyParams());\n };\n\n /**\n * Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.feePublicKeyParams());\n };\n\n /**\n * Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover\n */\n inclusionKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.inclusionKeyParams());\n };\n\n /**\n * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n joinKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.joinKeyParams());\n };\n\n /**\n * Get split function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n splitKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.splitKeyParams());\n };\n\n /**\n * Get keys for a variant of the transfer function from the credits.aleo program.\n *\n *\n * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function\n *\n * @example\n * // Create a new OfflineKeyProvider\n * const offlineKeyProvider = new OfflineKeyProvider();\n *\n * // Cache the keys for future use with the official locator\n * const transferPublicProvingKeyBytes = await readBinaryFile('./resources/transfer_public.prover.a74565e');\n * const transferPublicProvingKey = ProvingKey.fromBytes(transferPublicProvingKeyBytes);\n *\n * // Cache the transfer_public keys for future use with the OfflinKeyProvider's convenience method for\n * // transfer_public (the verifying key will be cached automatically)\n * offlineKeyProvider.insertTransferPublicKeys(transferPublicProvingKey);\n *\n * /// When they're needed, retrieve the keys from the cache\n * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys(\"public\");\n */\n transferKeys(visibility: string): Promise<FunctionKeyPair> {\n if (PRIVATE_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPrivateKeyParams());\n } else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPrivateToPublicKeyParams());\n } else if (PUBLIC_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPublicKeyParams());\n } else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPublicAsSignerKeyParams());\n } else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPublicToPrivateKeyParams());\n } else {\n throw new Error(\"Invalid visibility type\");\n }\n };\n\n /**\n * Get unbond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n async unBondPublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.unbondPublicKeyParams());\n };\n\n /**\n * Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for bond_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertBondPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isBondPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.bond_public.locator, [provingKey.toBytes(), VerifyingKey.bondPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for bond_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for claim_unbond_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertClaimUnbondPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isClaimUnbondPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.claim_unbond_public.locator, [provingKey.toBytes(), VerifyingKey.claimUnbondPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for claim_unbond_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for fee_private before inserting them into the cache.\n *\n * @param provingKey\n */\n insertFeePrivateKeys(provingKey: ProvingKey) {\n if (provingKey.isFeePrivateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.fee_private.locator, [provingKey.toBytes(), VerifyingKey.feePrivateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for fee_private\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for fee_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertFeePublicKeys(provingKey: ProvingKey) {\n if (provingKey.isFeePublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.fee_public.locator, [provingKey.toBytes(), VerifyingKey.feePublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for fee_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for the inclusion prover.\n *\n * @param provingKey\n */\n insertInclusionKeys(provingKey: ProvingKey) {\n if (provingKey.isInclusionProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.inclusion.locator, [provingKey.toBytes(), VerifyingKey.inclusionVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for the inclusion prover\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for join before inserting them into the cache.\n *\n * @param provingKey\n */\n insertJoinKeys(provingKey: ProvingKey) {\n if (provingKey.isJoinProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.join.locator, [provingKey.toBytes(), VerifyingKey.joinVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for join\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for set_validator_state before inserting them into the cache.\n *\n * @param provingKey\n */\n insertSetValidatorStateKeys(provingKey: ProvingKey) {\n if (provingKey.isSetValidatorStateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.set_validator_state.locator, [provingKey.toBytes(), VerifyingKey.setValidatorStateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for set_validator_state\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the split function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for split before inserting them into the cache.\n *\n * @param provingKey\n */\n insertSplitKeys(provingKey: ProvingKey) {\n if (provingKey.isSplitProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.split.locator, [provingKey.toBytes(), VerifyingKey.splitVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for split\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_private before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPrivateKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPrivateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_private.locator, [provingKey.toBytes(), VerifyingKey.transferPrivateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_private\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_private_to_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPrivateToPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPrivateToPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator, [provingKey.toBytes(), VerifyingKey.transferPrivateToPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_private_to_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_public.locator, [provingKey.toBytes(), VerifyingKey.transferPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_public_to_private before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPublicToPrivateKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPublicToPrivateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator, [provingKey.toBytes(), VerifyingKey.transferPublicToPrivateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_public_to_private\");\n }\n }\n\n insertUnbondPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isUnbondPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.unbond_public.locator, [provingKey.toBytes(), VerifyingKey.unbondPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for unbond_public\");\n }\n }\n}\n\n\nexport {OfflineKeyProvider, OfflineSearchParams}\n","import { Account } from \"./account.js\";\nimport { AleoNetworkClient } from \"./network-client.js\";\nimport { EncryptedRecord } from \"./models/record-provider/encryptedRecord.js\";\nimport { logAndThrow } from \"./utils.js\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord.js\";\nimport { RecordSearchParams } from \"./models/record-provider/recordSearchParams.js\";\nimport { RecordsResponseFilter } from \"./models/record-scanner/recordsResponseFilter.js\";\n\n/**\n * Interface for a record provider. A record provider is used to find records for use in deployment and execution\n * transactions on the Aleo Network. A default implementation is provided by the NetworkRecordProvider class. However,\n * a custom implementation can be provided (say if records are synced locally to a database from the network) by\n * implementing this interface.\n */\ninterface RecordProvider {\n /**\n * The account used to search for records.\n */\n account?: Account;\n\n /**\n * Find encrypted records from the chosen provider.\n *\n * @param {RecordSearchParams} recordsFilter The filter used to find the records.\n * @param {RecordsResponseFilter} responseFilter The filter used to filter the response.\n * @returns {Promise<EncryptedRecord[]>} The encrypted records.\n */\n encryptedRecords(recordsFilter: RecordSearchParams, responseFilter?: RecordsResponseFilter): Promise<EncryptedRecord[]>;\n\n /**\n * Check if a list of serial numbers exist in the chosen provider.\n *\n * @param {string[]} serialNumbers The serial numbers to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.\n */\n checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;\n\n /**\n * Check if a list of tags exist in the chosen provider.\n *\n * @param {string[]} tags The tags to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.\n */\n checkTags(tags: string[]): Promise<Record<string, boolean>>;\n\n /**\n * Find a credits.aleo record with a given number of microcredits from the chosen provider.\n *\n * @param {number} microcredits The number of microcredits to search for.\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord>} The record if one is found.\n *\n * @example\n * // A class implementing record provider can be used to find a record with a given number of microcredits\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, its nonce should be added to the nonces array so that it is not\n * // found again if a subsequent search is performed\n * const record2 = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [record.nonce()] });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n */\n findCreditsRecord(microcredits: number, searchParameters: RecordSearchParams): Promise<OwnedRecord>;\n\n /**\n * Find a list of credit.aleo records with a given number of microcredits from the chosen provider\n *\n * @param {number[]} microcreditAmounts A list of separate microcredit amounts to search for (e.g. [5000, 100000]).\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord[]>} A list of records with a value greater or equal to the amounts specified if such records exist, otherwise an error.\n *\n * @example\n * // A class implementing record provider can be used to find a record with a given number of microcredits\n * const records = await recordProvider.findCreditsRecords([5000, 5000], { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, it's nonce should be added to the nonces array so that it is not\n * // found again if a subsequent search is performed\n * const nonces = [];\n * records.forEach(record => { nonces.push(record.nonce()) });\n * const records2 = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n */\n findCreditsRecords(microcreditAmounts: number[], searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;\n\n /**\n * Find an arbitrary record\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord>} The record if found, otherwise an error.\n *\n * @example\n * // The RecordSearchParams interface can be used to create parameters for custom record searches which can then\n * // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown\n * // below.\n *\n * class CustomRecordSearch implements RecordSearchParams {\n * startHeight: number;\n * endHeight: number;\n * amount: number;\n * program: string;\n * recordName: string;\n * nonces: string[];\n * unspent: boolean;\n * constructor(\n * startHeight: number,\n * endHeight: number,\n * credits: number,\n * maxRecords: number,\n * programName: string,\n * recordName: string,\n * nonces: string[],\n * unspent: boolean\n * ) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.amount = amount;\n * this.program = programName;\n * this.recordName = recordName;\n * this.nonces = nonces;\n * this.unspent = unspent;\n * }\n * }\n *\n * const params = new CustomRecordSearch(0, 100, 5000, \"credits.aleo\", \"credits\", [], true);\n *\n * const record = await recordProvider.findRecord(params);\n */\n findRecord(searchParameters: RecordSearchParams): Promise<OwnedRecord>;\n\n /**\n * Find multiple records from arbitrary programs\n *\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.\n *\n * @example\n * // The RecordSearchParams interface can be used to create parameters for custom record searches which can then\n * // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown\n * // below.\n *\n * class CustomRecordSearch implements RecordSearchParams {\n * startHeight: number;\n * endHeight: number;\n * credits: number;\n * program: string;\n * recordName: string;\n * nonces: string[];\n * unspent: boolean;\n * constructor(\n * startHeight: number,\n * endHeight: number,\n * credits: number,\n * maxRecords: number,\n * programName: string,\n * recordName: string,\n * nonces: string[],\n * unspent: boolean\n * ) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.credits = credits;\n * this.program = programName;\n * this.recordName = recordName;\n * this.nonces = nonces;\n * this.unspent = unspent;\n * }\n * }\n *\n * const params = new CustomRecordSearch(0, 100, 5000, 2, \"credits.aleo\", \"credits\");\n * const records = await recordProvider.findRecord(true, [], params);\n */\n findRecords(searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;\n}\n\n/**\n * A record provider implementation that uses the official Aleo API to find records for usage in program execution and\n * deployment, wallet functionality, and other use cases.\n */\nclass NetworkRecordProvider implements RecordProvider {\n account: Account;\n networkClient: AleoNetworkClient;\n constructor(account: Account, networkClient: AleoNetworkClient) {\n this.account = account;\n this.networkClient = networkClient;\n }\n\n /**\n * Set the account used to search for records\n *\n * @param {Account} account The account used to use for searching for records.\n */\n setAccount(account: Account) {\n this.account = account;\n }\n\n /**\n * Find a list of credit records with a given number of microcredits by via the official Aleo API\n *\n * @param {number[]} microcredits The number of microcredits to search for.\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.\n *\n * @example\n * // Create a new NetworkRecordProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // The record provider can be used to find records with a given number of microcredits\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not\n * // found again if a subsequent search is performed\n * const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * */\n async findCreditsRecords(microcredits: number[], searchParameters: RecordSearchParams): Promise<OwnedRecord[]> {\n let startHeight = 0;\n let endHeight = 0;\n let maxAmount = undefined;\n\n if (searchParameters) {\n if (\"startHeight\" in searchParameters && typeof searchParameters[\"startHeight\"] == \"number\") {\n startHeight = searchParameters[\"startHeight\"];\n }\n\n if (\"endHeight\" in searchParameters && typeof searchParameters[\"endHeight\"] == \"number\") {\n endHeight = searchParameters[\"endHeight\"];\n }\n\n if (\"amounts\" in searchParameters && Array.isArray(searchParameters[\"amounts\"]) && searchParameters[\"amount\"].every((item: any) => typeof item === 'number')) {\n microcredits = searchParameters[\"amounts\"];\n }\n\n if (\"maxAmount\" in searchParameters && typeof searchParameters[\"maxAmount\"] == \"number\") {\n maxAmount = searchParameters[\"maxAmount\"];\n }\n }\n\n // If the end height is not specified, use the current block height\n if (endHeight == 0) {\n const end = await this.networkClient.getLatestHeight();\n endHeight = end;\n }\n\n // If the start height is greater than the end height, throw an error\n if (startHeight >= endHeight) {\n logAndThrow(\"Start height must be less than end height\");\n }\n\n const recordsPts = await this.networkClient.findRecords(startHeight, endHeight, searchParameters.unspent, [\"credits.aleo\"], microcredits, maxAmount, searchParameters.nonces, this.account.privateKey());\n return recordsPts.map((record) => ({\n owner: record.owner().toString(),\n programName: 'credits.aleo',\n recordName: 'credits',\n recordPlaintext: record.toString(),\n }));\n }\n\n /**\n * Find a credit record with a given number of microcredits by via the official Aleo API\n *\n * @param {number} microcredits The number of microcredits to search for.\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord>} The record if found, otherwise an error.\n *\n * @example\n * // Create a new NetworkRecordProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // The record provider can be used to find records with a given number of microcredits\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not\n * // found again if a subsequent search is performed\n * const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n */\n async findCreditsRecord(microcredits: number, searchParameters: RecordSearchParams): Promise<OwnedRecord> {\n let records = null;\n\n try {\n records = await this.findCreditsRecords([microcredits], searchParameters);\n } catch (e) {\n console.log(\"No records found with error:\", e);\n }\n\n if (records && records.length > 0) {\n return records[0];\n }\n\n console.error(\"Record not found with error:\", records);\n throw new Error(\"Record not found\");\n }\n\n /**\n * Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.\n */\n async findRecord(searchParameters: RecordSearchParams): Promise<OwnedRecord> {\n let records;\n\n try {\n records = await this.findRecords(searchParameters);\n } catch (e) {\n console.log(\"No records found with error:\", e);\n }\n\n if (records && records.length > 0) {\n return records[0];\n }\n\n console.error(\"Record not found with error:\", records);\n throw new Error(\"Record not found\");\n }\n\n /**\n * Find multiple records from a specified program.\n */\n async findRecords(searchParameters: RecordSearchParams): Promise<OwnedRecord[]> {\n let startHeight = 0;\n let endHeight = 0;\n let amounts = undefined;\n let maxAmount = undefined;\n let programs = undefined;\n\n if (searchParameters) {\n if (\"startHeight\" in searchParameters && typeof searchParameters[\"startHeight\"] == \"number\") {\n startHeight = searchParameters[\"startHeight\"];\n }\n\n if (\"endHeight\" in searchParameters && typeof searchParameters[\"endHeight\"] == \"number\") {\n endHeight = searchParameters[\"endHeight\"];\n }\n\n if (\"amounts\" in searchParameters && Array.isArray(searchParameters[\"amounts\"]) && searchParameters[\"amounts\"].every((item: any) => typeof item === 'number')) {\n amounts = searchParameters[\"amounts\"];\n }\n\n if (\"maxAmount\" in searchParameters && typeof searchParameters[\"maxAmount\"] == \"number\") {\n maxAmount = searchParameters[\"maxAmount\"];\n }\n\n if (\"program\" in searchParameters && typeof searchParameters[\"program\"] == \"string\") {\n programs = [searchParameters[\"program\"]];\n }\n\n if (\"programs\" in searchParameters && Array.isArray(searchParameters[\"programs\"]) && searchParameters[\"programs\"].every((item: any) => typeof item === \"string\")) {\n programs = searchParameters[\"programs\"];\n }\n }\n\n // If the end height is not specified, use the current block height.\n if (endHeight == 0) {\n const end = await this.networkClient.getLatestHeight();\n endHeight = end;\n }\n\n // If the start height is greater than the end height, throw an error.\n if (startHeight >= endHeight) {\n logAndThrow(\"Start height must be less than end height\");\n }\n\n const recordPts = await this.networkClient.findRecords(startHeight, endHeight, searchParameters.unspent, programs, amounts, maxAmount, searchParameters.nonces, this.account.privateKey());\n return recordPts.map((record) => ({\n record_plaintext: record.toString(),\n }));\n }\n\n async encryptedRecords(recordsFilter: RecordSearchParams, responseFilter?: RecordsResponseFilter): Promise<EncryptedRecord[]> {\n throw new Error(\"Not implemented\");\n }\n\n async checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>> {\n throw new Error(\"Not implemented\");\n }\n\n async checkTags(tags: string[]): Promise<Record<string, boolean>> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/**\n * BlockHeightSearch is a RecordSearchParams implementation that allows for searching for records within a given\n * block height range.\n *\n * @example\n * // Create a new BlockHeightSearch\n * const params = new BlockHeightSearch(89995, 99995);\n *\n * // Create a new NetworkRecordProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // The record provider can be used to find records with a given number of microcredits and the block height search\n * // can be used to find records within a given block height range\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [], ...params });\n *\n */\nclass BlockHeightSearch implements RecordSearchParams {\n startHeight: number;\n endHeight: number;\n unspent: boolean;\n constructor(startHeight: number, endHeight: number, unspent?: boolean) {\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n this.unspent = !!unspent;\n }\n}\n\nexport {\n BlockHeightSearch,\n NetworkRecordProvider,\n RecordProvider,\n};","import type { RegistrationResponse } from \"./registrationResponse.js\";\n\n/**\n * Error thrown when a record scanner request fails (e.g. /register, /register/encrypted).\n * Includes HTTP status so callers can handle 422 vs 500 etc.\n */\nexport class RecordScannerRequestError extends Error {\n readonly status: number;\n\n constructor(message: string, status: number) {\n super(message);\n this.name = \"RecordScannerRequestError\";\n this.status = status;\n Object.setPrototypeOf(this, RecordScannerRequestError.prototype);\n }\n}\n\n/** Error payload for registration failure result (/register and /register/encrypted). */\nexport interface RegistrationErrorBody {\n message: string;\n}\n\n/** Success variant of registration result. */\nexport interface RegisterSuccess {\n ok: true;\n data: RegistrationResponse;\n}\n\n/** Failure variant of registration result. */\nexport interface RegisterFailure {\n ok: false;\n status: number;\n error: RegistrationErrorBody;\n}\n\n/** Result of register() and registerEncrypted(); never throws on HTTP error. */\nexport type RegisterResult = RegisterSuccess | RegisterFailure;\n","import { parseJSON, post } from \"./utils.js\";\nimport { EncryptedRecord } from \"./models/record-provider/encryptedRecord\";\nimport { CryptoBoxPubKey } from \"./models/cryptoBoxPubkey.js\";\nimport { EncryptedRegistrationRequest } from \"./models/record-scanner/encryptedRegistrationRequest.js\";\nimport { OwnedFilter } from \"./models/record-scanner/ownedFilter\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord\";\nimport { RecordProvider } from \"./record-provider\";\nimport { Field, Poseidon4, RecordPlaintext, ViewKey } from \"./wasm\";\nimport { RecordsFilter } from \"./models/record-scanner/recordsFilter\";\nimport {\n RecordScannerRequestError,\n RegisterResult,\n} from \"./models/record-scanner/registrationResult.js\";\nimport { RegistrationRequest } from \"./models/record-scanner/registrationRequest\";\nimport { RegistrationResponse } from \"./models/record-scanner/registrationResponse\";\nimport { StatusResponse } from \"./models/record-scanner/statusResponse\";\nimport { RECORD_DOMAIN, FIVE_MINUTES } from \"./constants.js\";\nimport { encryptRegistrationRequest } from \"./security.js\";\n\n/**\n * JWT data for optional authentication with the record scanning service (e.g. Provable API).\n */\nexport interface RecordScannerJWTData {\n jwt: string;\n expiration: number;\n}\n\ntype RecordScannerOptions = {\n url: string;\n apiKey?: string | { header: string, value: string };\n /** Required for JWT refresh when using authenticated record scanner (e.g. Provable API). */\n consumerId?: string;\n /** Optional JWT for auth. If omitted and apiKey + consumerId are set, JWT is refreshed when needed. */\n jwtData?: RecordScannerJWTData;\n}\n\n/**\n * RecordScanner is a RecordProvider implementation that uses the record scanner service to find records.\n * \n * @example\n * const account = new Account({ privateKey: 'APrivateKey1...' });\n * \n * const recordScanner = new RecordScanner({ url: \"https://record-scanner.aleo.org\" });\n * recordScanner.setAccount(account);\n * recordScanner.setApiKey(\"your-api-key\");\n * const result = await recordScanner.register(viewKey, 0);\n * if (result.ok) { const uuid = result.data.uuid; }\n * \n * const filter = {\n * uuid,\n * filter: {\n * program: \"credits.aleo\",\n * records: [\"credits\"],\n * },\n * responseFilter: {\n * commitment: true,\n * owner: true,\n * tag: true,\n * tag?: boolean;\n * sender: true,\n * spent: true,\n * record_ciphertext: true,\n * block_height: true;\n * block_timestamp: true;\n * output_index: true;\n * record_name: true;\n * function_name: true;\n * program_name: true;\n * transition_id: true;\n * transaction_id: true;\n * transaction_index: true;\n * transition_index: true;\n * },\n * unspent: true,\n * };\n * \n * const records = await recordScanner.findRecords(filter);\n */\nclass RecordScanner implements RecordProvider {\n readonly url: string;\n private apiKey?: { header: string, value: string };\n private uuid?: Field;\n private consumerId?: string;\n private jwtData?: RecordScannerJWTData;\n\n constructor(options: RecordScannerOptions) {\n // Set the network by detecting which version of the SDK is being used.\n const network = \"/%%NETWORK%%\";\n\n // If the user has configured a network in their uri, throw\n if (options.url.endsWith(\"/mainnet\") || options.url.endsWith(\"/testnet\")) {\n throw new Error(\"The record scanning url should not include the specific network, this is automatically configured by the Provable SDK.\");\n }\n\n // Configure the url to use the network the SDK is using.\n this.url = options.url + network;\n\n // Configure authentication options/\n this.apiKey = typeof options.apiKey === \"string\" ? { header: \"X-Provable-API-Key\", value: options.apiKey } : options.apiKey;\n this.consumerId = options.consumerId;\n this.jwtData = options.jwtData;\n }\n\n /**\n * Set the API key to use for the record scanner.\n * \n * @param {string} apiKey The API key to use for the record scanner.\n */\n async setApiKey(apiKey: string | { header: string, value: string }): Promise<void> {\n this.apiKey = typeof apiKey === \"string\" ? { header: \"X-Provable-API-Key\", value: apiKey } : apiKey;\n }\n\n /**\n * Set the consumer ID used for JWT refresh when using authenticated record scanner (e.g. Provable API).\n */\n async setConsumerId(consumerId: string): Promise<void> {\n this.consumerId = consumerId;\n }\n\n /**\n * Set JWT data for authentication. Optional; when not set, JWT can be refreshed from apiKey + consumerId if provided.\n */\n async setJwtData(jwtData: RecordScannerJWTData | undefined): Promise<void> {\n this.jwtData = jwtData;\n }\n\n /**\n * Refreshes the JWT by making a POST request to /jwts/{consumer_id}. Used when authentication is required.\n */\n private async refreshJwt(apiKey: string, consumerId: string): Promise<RecordScannerJWTData> {\n const response = await post(\n `https://api.provable.com/jwts/${consumerId}`,\n {\n headers: {\n \"X-Provable-API-Key\": apiKey,\n },\n }\n );\n const authHeader = response.headers.get(\"authorization\");\n if (!authHeader) {\n throw new Error(\"No authorization header in JWT refresh response\");\n }\n const body = await response.json();\n return {\n jwt: authHeader,\n expiration: body.exp * 1000, // Convert to milliseconds\n };\n }\n\n /**\n * Returns auth headers (e.g. Authorization with JWT). Refreshes JWT if expired and apiKey + consumerId are set. Empty when auth is not configured.\n */\n private async getAuthHeaders(): Promise<Record<string, string>> {\n let jwtData = this.jwtData;\n const isExpired = jwtData && Date.now() >= jwtData.expiration - FIVE_MINUTES;\n if (!jwtData || isExpired) {\n const apiKey = this.apiKey?.value;\n if (apiKey && this.consumerId) {\n jwtData = await this.refreshJwt(apiKey, this.consumerId);\n this.jwtData = jwtData;\n } else if (jwtData?.jwt) {\n // Use existing JWT even if expired when we can't refresh\n return { Authorization: jwtData.jwt };\n } else {\n return {};\n }\n }\n return jwtData?.jwt ? { Authorization: jwtData.jwt } : {};\n }\n\n /**\n * Set the UUID to use for the record scanner.\n * \n * @param {Field} uuid The UUID to use for the record scanner.\n */\n async setUuid(uuidOrViewKey: Field | ViewKey): Promise<void> {\n this.uuid = uuidOrViewKey instanceof ViewKey ? this.computeUUID(uuidOrViewKey) : uuidOrViewKey;\n }\n\n /**\n * Register the account with the record scanner service (unencrypted POST /register). Does not throw if a valid error response from the record scanner is received; returns a result object instead.\n *\n * @param {ViewKey} viewKey The view key to register.\n * @param {number} startBlock The block height to start scanning from.\n * @returns {Promise<RegisterResult>} `{ ok: true, data }` on success, or `{ ok: false, status, error }` on failure.\n */\n async register(viewKey: ViewKey, startBlock: number): Promise<RegisterResult> {\n try {\n const request: RegistrationRequest = {\n view_key: viewKey.to_string(),\n start: startBlock,\n };\n const response = await this.request(\n new Request(`${this.url}/register`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(request),\n }),\n );\n const data = await response.json();\n this.uuid = data.uuid;\n return { ok: true, data };\n } catch (err) {\n if (err instanceof RecordScannerRequestError) {\n return {\n ok: false,\n status: err.status,\n error: { message: err.message },\n };\n }\n console.error(`Failed to register view key: ${err}`);\n throw err;\n }\n }\n\n /**\n * Fetches an ephemeral public key from the record scanner service for use with registerEncrypted.\n * Follows the same pattern as the delegated proving service /pubkey endpoint.\n *\n * @returns {Promise<CryptoBoxPubKey>} The service's ephemeral public key and key_id.\n */\n async getPubkey(): Promise<CryptoBoxPubKey> {\n const response = await this.request(\n new Request(`${this.url}/pubkey`, { method: \"GET\" })\n );\n return parseJSON(await response.text()) as CryptoBoxPubKey;\n }\n\n /**\n * Registers the account with the record scanner service using the encrypted flow: 1. fetches an ephemeral public key from /pubkey - 2. encrypts the registration request (view key + start block) - 3. POSTs to /register/encrypted. Does not HTTP error on a proper error response from the record scanner; returns a result object instead.\n *\n * @param {ViewKey} viewKey The view key to register.\n * @param {number} startBlock The block height to start scanning from.\n * @returns {Promise<RegisterResult>} `{ ok: true, data }` on success, or `{ ok: false, status, error }` on failure.\n */\n async registerEncrypted(\n viewKey: ViewKey,\n startBlock: number,\n ): Promise<RegisterResult> {\n try {\n const pubkey = await this.getPubkey();\n const ciphertext = encryptRegistrationRequest(pubkey.public_key, viewKey, startBlock);\n const payload: EncryptedRegistrationRequest = {\n key_id: pubkey.key_id,\n ciphertext,\n };\n const response = await this.request(\n new Request(`${this.url}/register/encrypted`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n }),\n );\n const data = await response.json();\n this.uuid = data.uuid;\n return { ok: true, data };\n } catch (err) {\n if (err instanceof RecordScannerRequestError) {\n return {\n ok: false,\n status: err.status,\n error: { message: err.message },\n };\n }\n throw err;\n }\n }\n\n /**\n * Get encrypted records from the record scanner service.\n * \n * @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.\n * @returns {Promise<EncryptedRecord[]>} The encrypted records.\n */\n async encryptedRecords(recordsFilter: RecordsFilter): Promise<EncryptedRecord[]> {\n try {\n const response = await this.request(\n new Request(`${this.url}/records/encrypted`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(recordsFilter),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to get encrypted records: ${error}`);\n throw error;\n }\n }\n\n /**\n * Check if a list of serial numbers exist in the record scanner service.\n * \n * @param {string[]} serialNumbers The serial numbers to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.\n */\n async checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>> {\n try {\n const response = await this.request(\n new Request(`${this.url}/records/sns`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(serialNumbers),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to check if serial numbers exist: ${error}`);\n throw error;\n }\n }\n\n /**\n * Check if a list of tags exist in the record scanner service.\n * \n * @param {string[]} tags The tags to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.\n */\n async checkTags(tags: string[]): Promise<Record<string, boolean>> {\n try {\n const response = await this.request(\n new Request(`${this.url}/records/tags`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(tags),\n }),\n );\n \n return await response.json();\n } catch (error) {\n console.error(`Failed to check if tags exist: ${error}`);\n throw error;\n }\n }\n\n /**\n * Check the status of a record scanner indexing job.\n * \n * @param {string} jobId The job id to check.\n * @returns {Promise<StatusResponse>} The status of the job.\n */\n async checkStatus(): Promise<StatusResponse> {\n try {\n const response = await this.request(\n new Request(`${this.url}/status`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(this.uuid?.toString()),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to check status of job: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find a record in the record scanner service.\n * \n * @param {OwnedFilter} searchParameters The filter to use to find the record.\n * @returns {Promise<OwnedRecord>} The record.\n */\n async findRecord(searchParameters: OwnedFilter): Promise<OwnedRecord> {\n try {\n const records = await this.findRecords(searchParameters);\n\n if (records.length > 0) {\n return records[0];\n }\n\n throw new Error(\"Record not found\");\n } catch (error) {\n console.error(`Failed to find record: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find records in the record scanner service.\n * \n * @param {OwnedFilter} filter The filter to use to find the records.\n * @returns {Promise<OwnedRecord[]>} The records.\n */\n async findRecords(filter: OwnedFilter): Promise<OwnedRecord[]> {\n if (!this.uuid) {\n throw new Error(\"You are using the RecordScanner implementation of the RecordProvider. No account has been registered with the RecordScanner which is required to use the findRecords method. Please set an with the setAccount method before calling the findRecords method again.\");\n }\n\n filter.uuid = this.uuid?.toString();\n\n try {\n const response = await this.request(\n new Request(`${this.url}/records/owned`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(filter),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to get owned records: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find a credits record in the record scanner service.\n * \n * @param {number} microcredits The amount of microcredits to find.\n * @param {OwnedFilter} searchParameters The filter to use to find the record.\n * @returns {Promise<OwnedRecord>} The record.\n */\n async findCreditsRecord(microcredits: number, searchParameters: OwnedFilter): Promise<OwnedRecord> {\n try {\n const records = await this.findRecords({\n decrypt: true,\n unspent: searchParameters.unspent,\n filter: {\n start: searchParameters.filter?.start ?? 0,\n program: \"credits.aleo\",\n record: \"credits\",\n },\n uuid: this.uuid?.toString(),\n });\n\n const record = records.find(record => {\n const plaintext = RecordPlaintext.fromString(record.record_plaintext ?? '');\n const amountStr = plaintext.getMember(\"microcredits\").toString();\n const amount = parseInt(amountStr.replace(\"u64\", \"\"));\n return amount >= microcredits;\n });\n\n if (!record) {\n throw new Error(`No records found matching the supplied search filter:\\n${JSON.stringify(searchParameters, null, 2)}`);\n }\n\n return record;\n } catch (error) {\n console.error(`Failed to find credits record: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find credits records using a record scanning service.\n * \n * @param {number[]} microcreditAmounts The amounts of microcredits to find.\n * @param {OwnedFilter} searchParameters The filter to use to find the records.\n * @returns {Promise<OwnedRecord[]>} The records\n */\n async findCreditsRecords(microcreditAmounts: number[], searchParameters: OwnedFilter): Promise<OwnedRecord[]> {\n try {\n const records = await this.findRecords({\n decrypt: true,\n unspent: searchParameters.unspent,\n filter: {\n start: searchParameters.filter?.start ?? 0,\n program: \"credits.aleo\",\n record: \"credits\",\n },\n uuid: this.uuid?.toString(),\n });\n return records.filter(record => {\n const plaintext = RecordPlaintext.fromString(record.record_plaintext ?? '');\n const amount = plaintext.getMember(\"microcredits\").toString();\n return microcreditAmounts.includes(parseInt(amount.replace(\"u64\", \"\")));\n });\n } catch (error) {\n console.error(`Failed to find credits records: ${error}`);\n throw error;\n }\n }\n\n /**\n * Wrapper function to make a request to the record scanner service and handle any errors.\n * Optionally adds JWT Authorization header when consumerId/jwtData (or apiKey+consumerId) are configured.\n *\n * @param {Request} req The request to make.\n * @returns {Promise<Response>} The response.\n */\n private async request(req: Request): Promise<Response> {\n try {\n const authHeaders = await this.getAuthHeaders();\n for (const [key, value] of Object.entries(authHeaders)) {\n req.headers.set(key, value);\n }\n if (this.apiKey) {\n req.headers.set(this.apiKey.header, this.apiKey.value);\n }\n const response = await fetch(req);\n\n if (!response.ok) {\n const text = await response.text();\n throw new RecordScannerRequestError(\n text || `Request to ${req.url} failed with status ${response.status}`,\n response.status,\n );\n }\n\n return response;\n } catch (error) {\n console.error(`Failed to make request to ${req.url}: ${error}`);\n throw error;\n }\n }\n\n computeUUID(vk: ViewKey): Field {\n // Construct the material needed for the Poseidon oracle.\n const inputs = [Field.newDomainSeparator(RECORD_DOMAIN), vk.toField(), Field.one()]\n // Calculate the uuid.\n const hasher = new Poseidon4();\n return hasher.hash(inputs);\n }\n}\n\nexport { RecordScanner };\n","import { Field, Plaintext, Poseidon4 } from \"../../wasm.js\";\nimport { bech32m } from \"@scure/base\";\nimport { ZERO_ADDRESS } from \"../../constants.js\";\n\n/**\n * Client library that encapsulates methods for constructing Merkle exclusion proofs for compliant stablecoin programs following the Sealance architecture.\n *\n\n * @example\n * Construct a Merkle exclusion proof.\n * ```typescript\n * const sealance = new SealanceMerkleTree();\n * const leaves = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const result = sealance.generateLeaves(leaves); \n * const tree = sealance.buildTree(result);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1kypwp5m7qtk9mwazgcpg0tq8aal23mnrvwfvug65qgcg9xvsrqgspyjm6n\");\n * const proof_left = sealance.getSiblingPath(tree, leftIdx, 15);\n * const proof_right = sealance.getSiblingPath(tree, rightIdx, 15);\n * const exclusion_proof = [proof_left, proof_right];\n * const formatted_proof = sealance.formatMerkleProof(exclusion_proof);\n * ```\n */\nclass SealanceMerkleTree {\n private static hasher = new Poseidon4();\n \n /**\n * Converts an Aleo blockchain address to a field element.\n *\n * This function decodes a bech32m-encoded Aleo address and converts it to a field element\n * represented as a BigInt. The address format follows the Aleo protocol specification,\n * starting with the prefix \"aleo1\" followed by encoded data.\n *\n * @param address - The Aleo blockchain address (e.g., \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\")\n * @returns A BigInt representing the field element.\n * @throws Error if the address is invalid or cannot be decoded.\n *\n * @example\n * ```typescript\n * const sealance = new SealanceMerkleTree();\n * const address = \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\";\n * const fieldValue = sealance.convertAddressToField(address);\n * console.log(fieldValue); // 123456789...n\n * ```\n */\n convertAddressToField(address: string): bigint {\n const { words } = bech32m.decode(address as `${string}1${string}`);\n const bytes = bech32m.fromWords(words);\n\n // Convert bytes to BigInt (little-endian)\n let fieldValue = BigInt(0);\n for (let i = 0; i < bytes.length; i++) {\n fieldValue |= BigInt(bytes[i]) << BigInt(i * 8);\n }\n\n return fieldValue;\n }\n\n /**\n * Hashes two elements using Poseidon4 hash function\n * @param prefix - Prefix for the hash (e.g., \"0field\" for nodes, \"1field\" for leaves)\n * @param el1 - First element to hash\n * @param el2 - Second element to hash\n * @returns The hash result as a Field\n * @throws {Error} If inputs are empty or invalid\n */\n hashTwoElements(prefix: string, el1: string, el2: string): Field {\n if (!el1 || !el2) {\n throw new Error(\"Invalid inputs: elements cannot be empty\");\n }\n const fields = [Field.fromString(prefix), Field.fromString(el1), Field.fromString(el2)];\n const arrayPlaintext = Plaintext.fromString(`[${fields.map(f => f.toString()).join(\",\")}]`);\n\n return SealanceMerkleTree.hasher.hash(arrayPlaintext.toFields());\n }\n\n /**\n * Builds a Merkle tree from given leaves. The tree is built bottom-up, hashing pairs of elements at each level.\n *\n * @param leaves - Array of leaf elements (must have even number of elements).\n * @returns Array representing the complete Merkle tree as BigInts.\n * @throws {Error} If leaves array is empty or has odd number of elements.\n *\n * @example\n * ```typescript\n * const sealance = new SealanceMerkleTree();\n * const leaves = [\"0field\", \"1field\", \"2field\", \"3field\"];\n * const tree = sealance.buildTree(leaves);\n * const root = tree[tree.length - 1]; // Get the Merkle root\n * ```\n */\n buildTree(leaves: string[]): bigint[] {\n if (leaves.length === 0) {\n throw new Error(\"Leaves array cannot be empty\");\n }\n if (leaves.length % 2 !== 0) {\n throw new Error(\"Leaves array must have even number of elements\");\n }\n let currentLevel = leaves;\n let tree = [...currentLevel];\n let levelSize = currentLevel.length;\n\n while (levelSize > 1) {\n const nextLevel = [];\n for (let i = 0; i < levelSize; i += 2) {\n const left = currentLevel[i];\n const right = currentLevel[i + 1];\n const prefix = leaves.length === levelSize ? \"1field\" : \"0field\";\n const hash = this.hashTwoElements(prefix, left, right);\n nextLevel.push(hash.toString());\n }\n tree = [...tree, ...nextLevel];\n currentLevel = nextLevel;\n levelSize = currentLevel.length;\n }\n return tree.map(element => BigInt(element.slice(0, element.length - \"field\".length)));\n }\n\n /** \n * Converts an array of decimal string representations of U256 numbers to an array of BigInts.\n *\n * @param tree - Array of decimal string representations of U256 numbers.\n * @returns Array of BigInts.\n * \n * @example\n * ```typescript\n * const treeStrings = [\"0\",\"4328470178059738374782465505490977516512210899136548187530607227309847251692\",\"1741259420362056497457198439964202806733137875365061915996980524089960046336\"];\n * const sealance = new SealanceMerkleTree();\n * const treeBigInts = sealance.convertTreeToBigInt(treeStrings);\n * console.log(treeBigInts); // [\n * 0, \n * 4328470178059738374782465505490977516512210899136548187530607227309847251692, \n * 1741259420362056497457198439964202806733137875365061915996980524089960046336\n * ]\n * ```\n */\n convertTreeToBigInt(tree: string[]): bigint[] {\n return tree.map((element) => {\n try {\n // decimal string → native bigint\n return BigInt(element);\n } catch {\n throw new Error(`Invalid decimal U256 string: ${element}`);\n }\n });\n }\n\n /**\n * Converts Aleo addresses to field elements, sorts them, pads with zero fields, and returns an array. This prepares addresses for Merkle tree construction.\n *\n * @param addresses - Array of Aleo addresses.\n * @param maxTreeDepth - Maximum depth of the Merkle tree (default: 15).\n * @returns Array of field elements ready for Merkle tree construction.\n * @throws {Error} If the number of addresses exceeds the maximum capacity.\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses, 15);\n * console.log(leaves); // [\n * \"0field\", \n * \"1295133970529764960316948294624974168921228814652993007266766481909235735940field\", \n * \"1295133970529764960316948294624974168921228814652993007266766481909235735940field\", \n * \"3501665755452795161867664882580888971213780722176652848275908626939553697821field\"\n * ]\n * ```\n */\n generateLeaves(addresses: string[], maxTreeDepth: number = 15): string[] {\n const maxNumLeaves = Math.floor(2 ** (maxTreeDepth - 1));\n\n // Filter out zero addresses\n addresses = addresses.filter(addr => addr !== ZERO_ADDRESS);\n\n let numLeaves = 0;\n if (addresses.length === 0 || addresses.length === 1) {\n numLeaves = 2;\n } else {\n numLeaves = Math.pow(2, Math.ceil(Math.log2(addresses.length)));\n }\n\n if (addresses.length > maxNumLeaves) {\n throw new Error(`Leaves limit exceeded. Max: ${maxNumLeaves}, provided: ${addresses.length}`);\n }\n\n // Convert addresses to fields\n const addressFields = addresses.map(addr => ({\n address: addr,\n field: this.convertAddressToField(addr),\n }));\n\n // Sort by field value\n const sortedFields = addressFields.sort((a, b) => (a.field < b.field ? -1 : 1)).map(item => item.field);\n\n // Convert to field strings\n const sortedFieldElements = sortedFields.map(field => field.toString() + \"field\");\n\n // Pad with zeros to reach power of 2\n const fullTree = Array(Math.max(numLeaves - sortedFieldElements.length, 0)).fill(\"0field\");\n\n return fullTree.concat(sortedFieldElements);\n }\n\n\n /**\n * Finds the leaf indices for non-inclusion proof of an address and returns the indices of the two adjacent leaves that surround the target address.\n *\n * @param merkleTree - The complete Merkle tree as array of BigInts.\n * @param address - The Aleo address for which to find indices.\n * @returns Tuple of [leftLeafIndex, rightLeafIndex].\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses);\n * const tree = sealance.buildTree(leaves);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1...\");\n * ```\n */\n getLeafIndices(merkleTree: bigint[], address: string): [number, number] {\n const num_leaves = Math.floor((merkleTree.length + 1) / 2);\n const addressBigInt = this.convertAddressToField(address);\n const leaves = merkleTree.slice(0, num_leaves);\n let rightLeafIndex = leaves.findIndex((leaf: bigint) => addressBigInt <= leaf);\n let leftLeafIndex = rightLeafIndex - 1;\n if (rightLeafIndex === -1) {\n rightLeafIndex = leaves.length - 1;\n leftLeafIndex = leaves.length - 1;\n }\n if (rightLeafIndex === 0) {\n leftLeafIndex = 0;\n }\n return [leftLeafIndex, rightLeafIndex];\n }\n\n /**\n * Generates the sibling path (Merkle proof) for a given leaf index\n *\n * @param tree - The complete Merkle tree.\n * @param leafIndex - Index of the leaf for which to generate the proof.\n * @param depth - Maximum depth of the tree.\n * @returns Object containing siblings array and leaf_index.\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses);\n * const tree = sealance.buildTree(leaves);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1...\");\n * const proof = sealance.getSiblingPath(tree, leftIdx, 15);\n * // proof = { siblings: [0n, 1n, ...], leaf_index: leftIdx }\n * ```\n */\n getSiblingPath(\n tree: bigint[],\n leafIndex: number,\n depth: number,\n ): { siblings: bigint[]; leaf_index: number } {\n let num_leaves = Math.floor((tree.length + 1) / 2);\n const siblingPath: bigint[] = [];\n\n let index = leafIndex;\n let parentIndex = num_leaves;\n siblingPath.push(tree[index]);\n let level = 1;\n while (parentIndex < tree.length) {\n let siblingIndex = index % 2 === 0 ? index + 1 : index - 1; // Get the sibling index\n siblingPath.push(tree[siblingIndex]);\n\n index = parentIndex + Math.floor(leafIndex / 2 ** level); // Move up to the parent node\n parentIndex += Math.floor(num_leaves / 2 ** level); // Halve the number of nodes for the next level\n level++;\n }\n\n while (level < depth) {\n siblingPath.push(0n);\n level++;\n }\n\n return { siblings: siblingPath, leaf_index: leafIndex };\n }\n\n /**\n * Generates a formatted exclusion proof suitable for Aleo transactions.\n *\n * @param proof - An array of two {sibling path, leafindex} objects.\n * @returns String representation of the exclusion proof.\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses);\n * const tree = sealance.buildTree(leaves);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1...\");\n * const proof1 = getSiblingPath(tree, leftIdx, 15);\n * const proof2 = getSiblingPath(tree, rightIdx, 15);\n * const formattedProof = formatMerkleProof([proof1, proof2]);\n * // formattedProof = \"[{ siblings: [0field, 1field, ...], leaf_index: 0u32 }, { siblings: [0field, 2field, ...], leaf_index: 1u32 }]\"\n * ```\n */\n formatMerkleProof(proof: { siblings: bigint[]; leaf_index: number }[]): string {\n const formatted = proof.map(item => {\n const siblings = item.siblings.map(s => `${s}field`).join(\", \");\n return `{siblings: [${siblings}], leaf_index: ${item.leaf_index}u32}`;\n }).join(\", \");\n \n return `[${formatted}]`;\n }\n}\n\nexport { SealanceMerkleTree };","import { Account } from \"./account.js\";\nimport { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from \"./network-client.js\";\nimport { ImportedPrograms, ImportedVerifyingKeys } from \"./models/imports.js\";\nimport { FunctionInput } from \"./models/functionInput\";\nimport { RecordProvider } from \"./record-provider.js\";\nimport { RecordSearchParams } from \"./models/record-provider/recordSearchParams.js\";\n\nimport {\n AleoKeyProvider,\n AleoKeyProviderParams,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider.js\";\n\nimport {\n Address,\n Authorization,\n ExecutionResponse,\n Execution as FunctionExecution,\n OfflineQuery,\n RecordPlaintext,\n PrivateKey,\n Program,\n ProvingKey,\n ProvingRequest,\n VerifyingKey,\n Transaction,\n ProgramManager as WasmProgramManager,\n verifyFunctionExecution,\n} from \"./wasm.js\";\n\nimport {\n CREDITS_PROGRAM_KEYS,\n PRIVATE_TRANSFER_TYPES,\n VALID_TRANSFER_TYPES,\n} from \"./constants.js\";\n\nimport { logAndThrow } from \"./utils.js\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord.js\";\n\n/**\n * Represents the options for deploying and upgrading a transaction in the Aleo network.\n * This interface is used to specify the parameters required for building and submitting an deployment transaction.\n *\n * @property {string} program - The program source code to be deployed.\n * @property {number} priorityFee - The optional priority fee to be paid for the transaction.\n * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.\n * @property {RecordSearchParams | undefined} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.\n * @property {string | RecordPlaintext | undefined} [feeRecord] - Optional fee record to use for the transaction.\n * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.\n */\ninterface DeployOptions {\n program: string;\n priorityFee: number;\n privateFee: boolean;\n recordSearchParams?: RecordSearchParams;\n feeRecord?: string | RecordPlaintext;\n privateKey?: PrivateKey;\n}\n\n/**\n * Represents the options for executing a transaction in the Aleo network.\n * This interface is used to specify the parameters required for building and submitting an execution transaction.\n *\n * @property {string} programName - The name of the program containing the function to be executed.\n * @property {string} functionName - The name of the function to execute within the program.\n * @property {number} priorityFee - The optional priority fee to be paid for the transaction.\n * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.\n * @property {string[]} inputs - The inputs to the function being executed.\n * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.\n * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.\n * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.\n * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.\n * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.\n * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.\n * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.\n * @property {string | Program} [program] - Optional program source code to use for the transaction.\n * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.\n */\ninterface ExecuteOptions {\n programName: string;\n functionName: string;\n priorityFee: number;\n privateFee: boolean;\n inputs: string[];\n recordSearchParams?: RecordSearchParams;\n keySearchParams?: KeySearchParams;\n feeRecord?: string | RecordPlaintext;\n provingKey?: ProvingKey;\n verifyingKey?: VerifyingKey;\n privateKey?: PrivateKey;\n offlineQuery?: OfflineQuery;\n program?: string | Program;\n imports?: ProgramImports;\n edition?: number,\n}\n\n/**\n * Options for building an Authorization for a function.\n *\n * @property {string} programName Name of the program containing the function to build the authorization for.\n * @property {string} functionName Name of the function name to build the authorization for.\n * @property {string[]} inputs The inputs to the function.\n * @property {string | Program} [programSource] The optional source code for the program to build an execution for.\n * @property {PrivateKey} [privateKey] Optional private key to use to build the authorization.\n * @property {ProgramImports} [programImports] The other programs the program imports.\n * @property {edition} [edition]\n */\ninterface AuthorizationOptions {\n programName: string;\n functionName: string;\n inputs: string[];\n programSource?: string | Program;\n privateKey?: PrivateKey;\n programImports?: ProgramImports;\n edition?: number,\n}\n\n/**\n * Options for executing a fee authorization.\n *\n * @property {string} deploymentOrExecutionId The id of a previously built Execution or Authorization.\n * @property {number} baseFeeCredits The number of Aleo Credits to pay for the base fee.\n * @property {number} [priorityFeeCredits] The number of Aleo Credits to pay for the priority fee.\n * @property {PrivateKey} [privateKey] Optional private key to specify for the authorization.\n * @property {RecordPlaintext} [feeRecord] A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.\n */\ninterface FeeAuthorizationOptions {\n deploymentOrExecutionId: string,\n baseFeeCredits: number,\n priorityFeeCredits?: number,\n privateKey?: PrivateKey,\n feeRecord?: RecordPlaintext,\n}\n\n/**\n * Represents the options for executing a transaction on the Aleo Network from an authorization.\n *\n * @property {string} programName - The name of the program containing the function to be executed.\n * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.\n * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.\n * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.\n * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.\n * @property {string | Program} [program] - Optional program source code to use for the transaction.\n * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.\n */\ninterface ExecuteAuthorizationOptions {\n programName: string;\n authorization: Authorization,\n feeAuthorization?: Authorization,\n keySearchParams?: KeySearchParams;\n provingKey?: ProvingKey;\n verifyingKey?: VerifyingKey;\n offlineQuery?: OfflineQuery;\n program?: string | Program;\n imports?: ProgramImports;\n}\n\n/**\n * Represents the options for executing a transaction in the Aleo network.\n * This interface is used to specify the parameters required for building and submitting an execution transaction.\n *\n * @property {string} programName - The name of the program containing the function to be executed.\n * @property {string} functionName - The name of the function to execute within the program.\n * @property {number} baseFee - The base fee to be paid for the transaction.\n * @property {number} priorityFee - The optional priority fee to be paid for the transaction.\n * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.\n * @property {string[]} inputs - The inputs to the function being executed.\n * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.\n * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.\n * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.\n * @property {string | Program} [program] - Optional program source code to use for the transaction.\n * @property {string} uri - The URI send the ProvingRequest to.\n * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.\n * @property {boolean} broadcast - Whether to broadcast the Transaction generated by the remove prover to the Aleo network.\n */\ninterface ProvingRequestOptions {\n programName: string;\n functionName: string;\n priorityFee: number;\n privateFee: boolean;\n inputs: string[];\n baseFee?: number,\n recordSearchParams?: RecordSearchParams;\n feeRecord?: string | RecordPlaintext;\n privateKey?: PrivateKey;\n programSource?: string | Program;\n programImports?: ProgramImports;\n broadcast?: boolean;\n unchecked?: boolean;\n edition?: number,\n}\n\n/**\n * Fee estimate options.\n *\n * @property {string} programName - The name of the program containing the function to estimate the fee for.\n * @property {string} functionName - The name of the function to execute within the program to estimate the fee for.\n * @property {string} [program] - Program source code to use for the fee estimate.\n * @property {ProgramImports} [imports] - Programs that the program imports.\n * @property {number} [edition] - Edition of the program to estimate the fee for.\n * @property {Authorization} authorization - An authorization to estimate the fee for.\n */\ninterface FeeEstimateOptions {\n programName: string;\n functionName?: string;\n program?: string | Program;\n imports?: ProgramImports;\n edition?: number,\n authorization?: Authorization;\n}\n\n/**\n * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.\n */\nclass ProgramManager {\n account: Account | undefined;\n keyProvider: FunctionKeyProvider;\n host: string;\n networkClient: AleoNetworkClient;\n recordProvider: RecordProvider | undefined;\n inclusionKeysLoaded: boolean = false;\n\n /** Create a new instance of the ProgramManager\n *\n * @param { string | undefined } host A host uri running the official Aleo API\n * @param { FunctionKeyProvider | undefined } keyProvider A key provider that implements {@link FunctionKeyProvider} interface\n * @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface\n */\n constructor(\n host?: string | undefined,\n keyProvider?: FunctionKeyProvider | undefined,\n recordProvider?: RecordProvider | undefined,\n networkClientOptions?: AleoNetworkClientOptions | undefined,\n ) {\n this.host = host ? host : \"https://api.explorer.provable.com/v1\";\n this.networkClient = new AleoNetworkClient(this.host, networkClientOptions);\n\n this.keyProvider = keyProvider ? keyProvider : new AleoKeyProvider();\n this.recordProvider = recordProvider;\n }\n\n /**\n * Check if the fee is sufficient to pay for the transaction\n */\n async checkFee(address: string, feeAmount: bigint) {\n const balance =\n BigInt(await this.networkClient.getPublicBalance(address));\n if (feeAmount > balance) {\n throw Error(\n `The desired execution requires a fee of ${feeAmount} microcredits, but the account paying the fee has ${balance} microcredits available.`,\n );\n }\n }\n\n /**\n * Set the account to use for transaction submission to the Aleo network\n *\n * @param {Account} account Account to use for transaction submission\n */\n setAccount(account: Account) {\n this.account = account;\n }\n\n /**\n * Set the key provider that provides the proving and verifying keys for programs\n *\n * @param {FunctionKeyProvider} keyProvider\n */\n setKeyProvider(keyProvider: FunctionKeyProvider) {\n this.keyProvider = keyProvider;\n }\n\n /**\n * Set the host peer to use for transaction submission to the Aleo network\n *\n * @param host {string} Peer url to use for transaction submission\n */\n setHost(host: string) {\n this.host = host;\n this.networkClient.setHost(host);\n }\n\n /**\n * Set the record provider that provides records for transactions\n *\n * @param {RecordProvider} recordProvider\n */\n setRecordProvider(recordProvider: RecordProvider) {\n this.recordProvider = recordProvider;\n }\n\n /**\n * Set a header in the `AleoNetworkClient`s header map\n *\n * @param {string} headerName The name of the header to set\n * @param {string} value The header value\n *\n * @example\n * import { ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a ProgramManager\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\");\n *\n * // Set the value of the `Accept-Language` header to `en-US`\n * programManager.setHeader('Accept-Language', 'en-US');\n */\n setHeader(headerName: string, value: string) {\n this.networkClient.headers[headerName] = value;\n }\n\n /**\n * Set the inclusion prover into the wasm memory. This should be done prior to any execution of a function with a\n * private record.\n *\n * @param {ProvingKey} [provingKey]\n *\n * @example\n * import { ProgramManager, AleoKeyProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a ProgramManager\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Set the inclusion keys.\n * programManager.setInclusionProver();\n */\n async setInclusionProver(provingKey?: ProvingKey) {\n if (this.inclusionKeysLoaded) {\n return\n }\n try {\n if (provingKey) {\n WasmProgramManager.loadInclusionProver(provingKey)\n this.inclusionKeysLoaded = true;\n } else {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n }\n return;\n } catch {\n console.log(\"Setting the inclusion prover requires either a key provider to be configured for the ProgramManager OR to pass the inclusion prover directly\");\n }\n }\n\n /**\n * Remove a header from the `AleoNetworkClient`s header map\n *\n * @param {string} headerName The name of the header to be removed\n *\n * @example\n * import { ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a ProgramManager\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\");\n *\n * // Remove the default `X-Aleo-SDK-Version` header\n * programManager.removeHeader('X-Aleo-SDK-Version');\n */\n removeHeader(headerName: string) {\n delete this.networkClient.headers[headerName]\n }\n\n /**\n * Builds a deployment transaction for submission to the Aleo network.\n *\n * @param {string} program Program source code\n * @param {number} priorityFee The optional priority fee to be paid for that transaction.\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to use pay the deployment fee\n * @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildDeploymentTransaction(program, fee, false);\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildDeploymentTransaction(\n program: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n feeRecord?: string | RecordPlaintext,\n privateKey?: PrivateKey,\n ): Promise<Transaction> {\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network, deployment can proceed\n console.log(\n `Program ${programObject.id()} does not exist on the network, deploying...`,\n );\n }\n if (typeof programSource === \"string\") {\n throw Error(`Program ${programObject.id()} already exists on the network, please rename your program`);\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n\n // Build a deployment transaction\n return await WasmProgramManager.buildDeploymentTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n feeProvingKey,\n feeVerifyingKey,\n );\n }\n\n /**\n * Builds a deployment transaction for submission to the Aleo network that upgrades an existing program.\n *\n * @param {DeployOptions} options The deployment options.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildUpgradeTransaction({program: program, priorityFee: fee, privateFee: false});\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildUpgradeTransaction(\n options: DeployOptions\n ): Promise<Transaction> {\n const { program, priorityFee, privateFee, recordSearchParams } = options;\n let feeRecord = options.feeRecord;\n let privateKey = options.privateKey;\n\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network, deployment can proceed\n console.log(\n `Program ${programObject.id()} does not exist on the network...`,\n );\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n\n // Build a deployment transaction\n return await WasmProgramManager.buildUpgradeTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n feeProvingKey,\n feeVerifyingKey,\n );\n }\n\n /**\n * Deploy an Aleo program to the Aleo network\n *\n * @param {string} program Program source code\n * @param {number} priorityFee The optional fee to be paid for the transaction\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to used pay the deployment fee\n * @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Deploy the program\n * const tx_id = await programManager.deploy(program, fee, false);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 20000);\n */\n async deploy(\n program: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n feeRecord?: string | RecordPlaintext,\n privateKey?: PrivateKey,\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildDeploymentTransaction(\n program,\n priorityFee,\n privateFee,\n recordSearchParams,\n feeRecord,\n privateKey,\n )\n );\n\n let feeAddress;\n\n if (typeof privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Builds an execution transaction for submission to the Aleo network.\n *\n * @param {ExecuteOptions} options - The options for the execution transaction.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build and execute the transaction\n * const tx = await programManager.buildExecutionTransaction({\n * programName: \"hello_hello.aleo\",\n * functionName: \"hello_hello\",\n * priorityFee: 0.0,\n * privateFee: false,\n * inputs: [\"5u32\", \"5u32\"],\n * keySearchParams: { \"cacheKey\": \"hello_hello:hello\" }\n * });\n *\n * // Submit the transaction to the network\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildExecutionTransaction(\n options: ExecuteOptions,\n ): Promise<Transaction> {\n // Destructure the options object to access the parameters\n const {\n functionName,\n priorityFee,\n privateFee,\n inputs,\n recordSearchParams,\n keySearchParams,\n privateKey,\n offlineQuery,\n } = options;\n\n let feeRecord = options.feeRecord;\n let provingKey = options.provingKey;\n let verifyingKey = options.verifyingKey;\n let program = options.program;\n let programName = options.programName;\n let imports = options.imports;\n let edition = options.edition;\n\n let programObject;\n // Ensure the function exists on the network\n if (program === undefined) {\n try {\n programObject = await this.networkClient.getProgramObject(programName);\n program = <string>programObject.toString();\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (typeof program == \"string\") {\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(`Program sources passed for ${programName} were invalid: ${e}`);\n }\n } else if (program instanceof Program) {\n programObject = program;\n program = program.toString();\n }\n\n if (!(programObject instanceof Program)) {\n logAndThrow(`Failed to validate program ${programName}`);\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = programObject.id();\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee proving and verifying keys from the key provider\n let feeKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // If the function proving and verifying keys are not provided, attempt to find them using the key provider\n if (!provingKey || !verifyingKey) {\n try {\n [provingKey, verifyingKey] = <FunctionKeyPair>(\n await this.keyProvider.functionKeys(keySearchParams)\n );\n } catch (e) {\n console.log(\n `Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`,\n );\n }\n }\n\n // Resolve the program imports if they exist\n const numberOfImports = programObject.getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a fee record wasn't provided, estimate the fee that needs to be paid.\n if (!feeRecord) {\n const baseFee = Number(await this.estimateExecutionFee({programName, functionName, program, imports}));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n if (offlineQuery && !this.inclusionKeysLoaded) {\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction\n return await WasmProgramManager.buildExecutionTransaction(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n provingKey,\n verifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n offlineQuery,\n edition\n );\n }\n\n /**\n * Builds an execution transaction for submission to the Aleo network from an Authorization and Fee Authorization.\n * This method is helpful if signing and authorization needs to be done in a secure environment separate from where\n * transactions are built.\n *\n * @param {ExecuteAuthorizationOptions} options - The options for executing the authorizations.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from \"@provablehq/sdk\";\n *\n * await initThreadPool();\n *\n * // Create a new KeyProvider.\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Build the `Authorization`.\n * const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.\n * const authorization = await programManager.buildAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * privateKey,\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n *\n * console.log(\"Getting execution id\");\n *\n * // Derive the execution ID and base fee.\n * const executionId = authorization.toExecutionId().toString();\n *\n * console.log(\"Estimating fee\");\n *\n * // Get the base fee in microcredits.\n * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization(authorization, \"credits.aleo\");\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n *\n * console.log(\"Building fee authorization\");\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const feeAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: executionId,\n * baseFeeCredits,\n * privateKey\n * });\n *\n * console.log(\"Executing authorizations\");\n *\n * // Build and execute the transaction.\n * const tx = await programManager.buildTransactionFromAuthorization({\n * programName: \"credits.aleo\",\n * authorization,\n * feeAuthorization,\n * });\n *\n * // Submit the transaction to the network.\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful.\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * console.log(transaction);\n * }, 10000);\n */\n async buildTransactionFromAuthorization(\n options: ExecuteAuthorizationOptions,\n ): Promise<Transaction> {\n // Destructure the options object to access the parameters.\n const {\n programName,\n authorization,\n } = options;\n\n const feeAuthorization = options.feeAuthorization;\n const keySearchParams = options.keySearchParams;\n const offlineQuery = options.offlineQuery;\n let provingKey = options.provingKey;\n let verifyingKey = options.verifyingKey;\n let program = options.program;\n let imports = options.imports;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the fee proving and verifying keys from the key provider.\n let feeKeys;\n const privateFee = feeAuthorization ? feeAuthorization.isFeePrivate() : false;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // If the function proving and verifying keys are not provided, attempt to find them using the key provider.\n if (!provingKey || !verifyingKey) {\n try {\n [provingKey, verifyingKey] = <FunctionKeyPair>(\n await this.keyProvider.functionKeys(keySearchParams)\n );\n } catch (e) {\n console.log(\n `Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`,\n );\n }\n }\n\n // Resolve the program imports if they exist.\n console.log(\"Resolving program imports\");\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // If the offline query exists, add the inclusion key.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n console.log(\"Loading inclusion keys for offline proving.\");\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction from the authorization.\n console.log(\"Executing authorizations\")\n return await WasmProgramManager.executeAuthorization(\n authorization,\n feeAuthorization,\n program,\n provingKey,\n verifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n imports,\n this.host,\n offlineQuery\n )\n }\n\n /**\n * Builds a SnarkVM `Authorization` for a specific function.\n *\n * @param {AuthorizationOptions} options - The options for building the `Authorization`\n * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build the `Authorization`.\n * const authorization = await programManager.buildAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n */\n async buildAuthorization(\n options: AuthorizationOptions,\n ): Promise<Authorization> {\n // Destructure the options object to access the parameters.\n const {\n functionName,\n inputs,\n } = options;\n\n const privateKey = options.privateKey;\n let program = options.programSource;\n let programName = options.programName;\n let imports = options.programImports;\n let edition = options.edition;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = Program.fromString(program).id();\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // Build and return an `Authorization` for the desired function.\n return await WasmProgramManager.authorize(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n imports,\n edition\n );\n }\n\n /**\n * Builds a SnarkVM `Authorization` for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.\n *\n * @param {AuthorizationOptions} options - The options for building the `Authorization`\n * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build the unchecked `Authorization`.\n * const authorization = await programManager.buildAuthorizationUnchecked({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n */\n async buildAuthorizationUnchecked(\n options: AuthorizationOptions,\n ): Promise<Authorization> {\n // Destructure the options object to access the parameters.\n const {\n functionName,\n inputs,\n } = options;\n\n const privateKey = options.privateKey;\n let program = options.programSource;\n let programName = options.programName;\n let imports = options.programImports;\n let edition = options.edition;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = Program.fromString(program).id();\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Build and return an `Authorization` for the desired function.\n return await WasmProgramManager.buildAuthorizationUnchecked(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n imports,\n edition\n );\n }\n\n /**\n * Builds a `ProvingRequest` for submission to a prover for execution.\n *\n * @param {ProvingRequestOptions} options - The options for building the proving request\n * @returns {Promise<ProvingRequest>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build the proving request.\n * const provingRequest = await programManager.provingRequest({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * priorityFee: 0,\n * privateFee: false,\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * broadcast: false,\n * });\n */\n async provingRequest(\n options: ProvingRequestOptions,\n ): Promise<ProvingRequest> {\n // Destructure the options object to access the parameters.\n const {\n functionName,\n priorityFee,\n privateFee,\n inputs,\n recordSearchParams,\n broadcast = false,\n unchecked = false,\n } = options;\n\n const privateKey = options.privateKey;\n const baseFee = options.baseFee ? options.baseFee : 0;\n let program = options.programSource;\n let programName = options.programName;\n let feeRecord = options.feeRecord;\n let imports = options.programImports;\n let edition = options.edition;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = Program.fromString(program).id();\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a fee record wasn't provided, estimate the fee that needs to be paid.\n if (!feeRecord) {\n const baseFee = Number(await this.estimateExecutionFee({programName, functionName, program: program.toString(), imports}));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Build and return the `ProvingRequest`.\n return await WasmProgramManager.buildProvingRequest(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n baseFee,\n priorityFee,\n feeRecord,\n imports,\n broadcast,\n unchecked,\n edition\n );\n }\n\n /**\n * Builds a SnarkVM fee `Authorization` for `credits.aleo/fee_private` or `credits.aleo/fee_public`. If a record is provided `fee_private` will be executed, otherwise `fee_public` will be executed.\n *\n * @param {FeeAuthorizationOptions} options - The options for building the `Authorization`.\n * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const feePublicAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: \"2423957656946557501636078245035919227529640894159332581642187482178647335171field\",\n * baseFeeCredits: 0.1,\n * });\n *\n * // Build a credits.aleo/fee_private `Authorization`.\n * const record = \"{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }\";\n * const feePrivateAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: \"2423957656946557501636078245035919227529640894159332581642187482178647335171field\",\n * baseFeeCredits: 0.1,\n * feeRecord: record,\n * });\n */\n async buildFeeAuthorization(\n options: FeeAuthorizationOptions,\n ): Promise<Authorization> {\n // Destructure the options object to access the parameters.\n const {\n privateKey,\n deploymentOrExecutionId,\n baseFeeCredits,\n priorityFeeCredits,\n feeRecord,\n } = options;\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Build and return the fee `Authorization`.\n return await WasmProgramManager.authorizeFee(\n executionPrivateKey,\n deploymentOrExecutionId,\n baseFeeCredits,\n priorityFeeCredits || 0,\n feeRecord,\n );\n }\n\n /**\n * Builds an execution transaction for submission to the Aleo network.\n *\n * @param {ExecuteOptions} options - The options for the execution transaction.\n * @returns {Promise<string>} - The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build and execute the transaction\n * const tx_id = await programManager.execute({\n * programName: \"hello_hello.aleo\",\n * functionName: \"hello_hello\",\n * priorityFee: 0.0,\n * privateFee: false,\n * inputs: [\"5u32\", \"5u32\"],\n * keySearchParams: { \"cacheKey\": \"hello_hello:hello\" }\n * });\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async execute(options: ExecuteOptions): Promise<string> {\n const tx = <Transaction>await this.buildExecutionTransaction(options);\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Run an Aleo program in offline mode\n *\n * @param {string} program Program source code containing the function to be executed\n * @param {string} function_name Function name to execute\n * @param {string[]} inputs Inputs to the function\n * @param {number} proveExecution Whether to prove the execution of the function and return an execution transcript that contains the proof.\n * @param {string[] | undefined} imports Optional imports to the program\n * @param {KeySearchParams | undefined} keySearchParams Optional parameters for finding the matching proving & verifying keys for the function\n * @param {ProvingKey | undefined} provingKey Optional proving key to use for the transaction\n * @param {VerifyingKey | undefined} verifyingKey Optional verifying key to use for the transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<ExecutionResponse>} The execution response containing the outputs of the function and the proof if the program is proved.\n *\n * @example\n * /// Import the mainnet version of the sdk used to build executions.\n * import { Account, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * /// Create the source for the \"helloworld\" program\n * const program = \"program helloworld.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(undefined, undefined, undefined);\n *\n * /// Create a temporary account for the execution of the program\n * const account = new Account();\n * programManager.setAccount(account);\n *\n * /// Get the response and ensure that the program executed correctly\n * const executionResponse = await programManager.run(program, \"hello\", [\"5u32\", \"5u32\"]);\n * const result = executionResponse.getOutputs();\n * assert(result === [\"10u32\"]);\n */\n async run(\n program: string,\n function_name: string,\n inputs: string[],\n proveExecution: boolean,\n imports?: ProgramImports,\n keySearchParams?: KeySearchParams,\n provingKey?: ProvingKey,\n verifyingKey?: VerifyingKey,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n edition?: number\n ): Promise<ExecutionResponse> {\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // If the function proving and verifying keys are not provided, attempt to find them using the key provider\n if (!provingKey || !verifyingKey) {\n try {\n [provingKey, verifyingKey] = <FunctionKeyPair>(\n await this.keyProvider.functionKeys(keySearchParams)\n );\n } catch (e) {\n console.log(\n `Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`,\n );\n }\n }\n\n // Run the program offline and return the result\n console.log(\"Running program offline\");\n console.log(\"Proving key: \", provingKey);\n console.log(\"Verifying key: \", verifyingKey);\n return WasmProgramManager.executeFunctionOffline(\n executionPrivateKey,\n program,\n function_name,\n inputs,\n proveExecution,\n false,\n imports,\n provingKey,\n verifyingKey,\n this.host,\n offlineQuery,\n edition\n );\n }\n\n /**\n * Join two credits records into a single credits record\n *\n * @param {RecordPlaintext | string} recordOne First credits record to join\n * @param {RecordPlaintext | string} recordTwo Second credits record to join\n * @param {number} priorityFee The optional priority fee to be paid for the transaction\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the fee record to use to pay the fee for the join transaction\n * @param {RecordPlaintext | string | undefined} feeRecord Fee record to use for the join transaction\n * @param {PrivateKey | undefined} privateKey Private key to use for the join transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const record_1 = \"{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}\"\n * const record_2 = \"{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 1540945439182663264862696551825005342995406165131907382295858612069623286213group.public}\"\n * const tx_id = await programManager.join(record_1, record_2, 0.05, false);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async join(\n recordOne: RecordPlaintext | string,\n recordTwo: RecordPlaintext | string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams | undefined,\n feeRecord?: RecordPlaintext | string | undefined,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<string> {\n // Get the private key from the account if it is not provided in the parameters and assign the fee address\n let executionPrivateKey = privateKey;\n let feeAddress;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n feeAddress = this.account?.address();\n }\n else if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n else {\n feeAddress = Address.from_private_key(executionPrivateKey);\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n let joinKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n joinKeys = <FunctionKeyPair>await this.keyProvider.joinKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n const [joinProvingKey, joinVerifyingKey] = joinKeys;\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a fee record wasn't provided, estimate the fee that needs to be paid.\n if (!feeRecord) {\n const baseFee = Number(await this.estimateExecutionFee({programName: \"credits.aleo\", functionName: \"join\"}));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Validate the records provided are valid plaintext records\n try {\n recordOne =\n recordOne instanceof RecordPlaintext\n ? recordOne\n : RecordPlaintext.fromString(recordOne);\n recordTwo =\n recordTwo instanceof RecordPlaintext\n ? recordTwo\n : RecordPlaintext.fromString(recordTwo);\n } catch (e: any) {\n logAndThrow(\n \"Records provided are not valid. Please ensure they are valid plaintext records.\",\n );\n }\n\n // Load the inclusion prover offline.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction and submit it to the network\n const tx = await WasmProgramManager.buildJoinTransaction(\n executionPrivateKey,\n recordOne,\n recordTwo,\n priorityFee,\n feeRecord,\n this.host,\n joinProvingKey,\n joinVerifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n offlineQuery,\n );\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Split credits into two new credits records\n *\n * @param {number} splitAmount Amount in microcredits to split from the original credits record\n * @param {RecordPlaintext | string} amountRecord Amount record to use for the split transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the split transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const record = \"{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}\"\n * const tx_id = await programManager.split(25000000, record);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async split(\n splitAmount: number,\n amountRecord: RecordPlaintext | string,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<string> {\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the split keys from the key provider\n let splitKeys;\n try {\n splitKeys = <FunctionKeyPair>await this.keyProvider.splitKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [splitProvingKey, splitVerifyingKey] = splitKeys;\n\n // Validate the record to be split\n try {\n amountRecord =\n amountRecord instanceof RecordPlaintext\n ? amountRecord\n : RecordPlaintext.fromString(amountRecord);\n } catch (e: any) {\n logAndThrow(\n \"Record provided is not valid. Please ensure it is a valid plaintext record.\",\n );\n }\n\n // Load the inclusion prover offline.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction and submit it to the network\n const tx = await WasmProgramManager.buildSplitTransaction(\n executionPrivateKey,\n splitAmount,\n amountRecord,\n this.host,\n splitProvingKey,\n splitVerifyingKey,\n offlineQuery,\n );\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Pre-synthesize proving and verifying keys for a program\n *\n * @param program {string} The program source code to synthesize keys for\n * @param function_id {string} The function id to synthesize keys for\n * @param inputs {Array<string>} Sample inputs to the function\n * @param privateKey {PrivateKey | undefined} Optional private key to use for the key synthesis\n *\n * @returns {Promise<FunctionKeyPair>}\n */\n async synthesizeKeys(\n program: string,\n function_id: string,\n inputs: Array<string>,\n privateKey?: PrivateKey,\n ): Promise<FunctionKeyPair> {\n // Resolve the program imports if they exist\n let imports;\n\n let executionPrivateKey = privateKey;\n if (typeof executionPrivateKey === \"undefined\") {\n if (typeof this.account !== \"undefined\") {\n executionPrivateKey = this.account.privateKey();\n } else {\n executionPrivateKey = new PrivateKey();\n }\n }\n\n // Attempt to run an offline execution of the program and extract the proving and verifying keys\n try {\n imports = await this.networkClient.getProgramImports(program);\n const keyPair = await WasmProgramManager.synthesizeKeyPair(\n executionPrivateKey,\n program,\n function_id,\n inputs,\n imports,\n );\n return [\n <ProvingKey>keyPair.provingKey(),\n <VerifyingKey>keyPair.verifyingKey(),\n ];\n } catch (e: any) {\n logAndThrow(\n `Could not synthesize keys - error ${e.message}. Please ensure the program is valid and the inputs are correct.`,\n );\n }\n }\n\n /**\n * Build a transaction to transfer credits to another account for later submission to the Aleo network\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'\n * @param {number} priorityFee The optional priority fee to be paid for the transaction\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee records for the transfer transaction\n * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer\n * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx = await programManager.buildTransferTransaction(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"public\", 0.2, false);\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildTransferTransaction(\n amount: number,\n recipient: string,\n transferType: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n amountRecord?: RecordPlaintext | string,\n feeRecord?: RecordPlaintext | string,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<Transaction> {\n // Validate the transfer type\n transferType = <string>validateTransferType(transferType);\n\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof executionPrivateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n let transferKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n transferKeys = <FunctionKeyPair>(\n await this.keyProvider.transferKeys(transferType)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n const [transferProvingKey, transferVerifyingKey] = transferKeys;\n\n // Get the amount and fee record from the account if it is not provided in the parameters\n try {\n // Track the nonces of the records found so no duplicate records are used\n const nonces: string[] = [];\n if (requiresAmountRecord(transferType)) {\n // If the transfer type is private and requires an amount record, get it from the record provider\n amountRecord = await this.getCreditsRecord(\n priorityFee,\n [],\n amountRecord,\n recordSearchParams,\n );\n nonces.push(amountRecord.nonce());\n } else {\n amountRecord = undefined;\n }\n if (privateFee) {\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n priorityFee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Load the inclusion prover offline.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction\n return await WasmProgramManager.buildTransferTransaction(\n executionPrivateKey,\n amount,\n recipient,\n transferType,\n amountRecord,\n priorityFee,\n feeRecord,\n this.host,\n transferProvingKey,\n transferVerifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n offlineQuery,\n );\n }\n\n /**\n * Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {number} priorityFee The optional priority fee to be paid for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx = await programManager.buildTransferPublicTransaction(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", 0.2);\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildTransferPublicTransaction(\n amount: number,\n recipient: string,\n priorityFee: number,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<Transaction> {\n return this.buildTransferTransaction(\n amount,\n recipient,\n \"public\",\n priorityFee,\n false,\n undefined,\n undefined,\n undefined,\n privateKey,\n offlineQuery,\n );\n }\n\n /**\n * Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {number} priorityFee The optional priority fee to be paid for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx = await programManager.buildTransferPublicAsSignerTransaction(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", 0.2);\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildTransferPublicAsSignerTransaction(\n amount: number,\n recipient: string,\n priorityFee: number,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<Transaction> {\n return this.buildTransferTransaction(\n amount,\n recipient,\n \"public\",\n priorityFee,\n false,\n undefined,\n undefined,\n undefined,\n privateKey,\n offlineQuery,\n );\n }\n\n /**\n * Transfer credits to another account\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'\n * @param {number} priorityFee The optional priority fee to be paid for the transfer\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee records for the transfer transaction\n * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer\n * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx_id = await programManager.transfer(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"public\", 0.2, false);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async transfer(\n amount: number,\n recipient: string,\n transferType: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n amountRecord?: RecordPlaintext | string,\n feeRecord?: RecordPlaintext | string,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildTransferTransaction(\n amount,\n recipient,\n transferType,\n priorityFee,\n privateFee,\n recordSearchParams,\n amountRecord,\n feeRecord,\n privateKey,\n offlineQuery,\n )\n );\n\n let feeAddress;\n\n if (typeof privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build transaction to bond credits to a validator for later submission to the Aleo Network\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the bonding transaction object for later submission\n * const tx = await programManager.buildBondPublicTransaction(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // The transaction can be later submitted to the network using the network client.\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildBondPublicTransaction(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const scaledAmount = Math.trunc(amount * 1000000);\n\n const {\n programName = \"credits.aleo\",\n functionName = \"bond_public\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [\n validator_address,\n withdrawal_address,\n `${scaledAmount.toString()}u64`,\n ],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.bond_public.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.bond_public.verifier,\n cacheKey: \"credits.aleo/bond_public\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Bond credits to validator.\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the signer (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 1,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond\n * @param {Options} options Options for the execution\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the bonding transaction\n * tx_id = await programManager.bondPublic(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async bondPublic(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const tx = <Transaction>(\n await this.buildBondPublicTransaction(\n validator_address,\n withdrawal_address,\n amount,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build a bond_validator transaction for later submission to the Aleo Network.\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond. A minimum of 10000 credits is required to bond as a delegator.\n * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the bond validator transaction object for later use.\n * const tx = await programManager.buildBondValidatorTransaction(\"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // The transaction can later be submitted to the network using the network client.\n * const tx_id = await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async buildBondValidatorTransaction(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n commission: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const scaledAmount = Math.trunc(amount * 1000000);\n\n const adjustedCommission = Math.trunc(commission);\n\n const {\n programName = \"credits.aleo\",\n functionName = \"bond_validator\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [\n validator_address,\n withdrawal_address,\n `${scaledAmount.toString()}u64`,\n `${adjustedCommission.toString()}u8`,\n ],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.bond_validator.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.bond_validator.verifier,\n cacheKey: \"credits.aleo/bond_validator\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Build transaction to bond a validator.\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond\n * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the bonding transaction\n * const tx_id = await programManager.bondValidator(\"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async bondValidator(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n commission: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const tx = <Transaction>(\n await this.buildBondValidatorTransaction(\n validator_address,\n withdrawal_address,\n amount,\n commission,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build an unbond_public execution transaction to unbond credits from a validator in the Aleo network.\n *\n * @param {string} staker_address - The address of the staker who is unbonding the credits.\n * @param {number} amount - The amount of credits to unbond (scaled by 1,000,000).\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management.\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to unbond credits.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * const tx = await programManager.buildUnbondPublicTransaction(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", 2000000);\n *\n * // The transaction can be submitted later to the network using the network client.\n * programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildUnbondPublicTransaction(\n staker_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ): Promise<Transaction> {\n const scaledAmount = Math.trunc(amount * 1000000);\n\n const {\n programName = \"credits.aleo\",\n functionName = \"unbond_public\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [staker_address, `${scaledAmount.toString()}u64`],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.unbond_public.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.unbond_public.verifier,\n cacheKey: \"credits.aleo/unbond_public\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Unbond a specified amount of staked credits. If the address of the executor of this function is an existing\n * validator, it will subtract this amount of credits from the validator's staked credits. If there are less than\n * 1,000,000 credits staked pool after the unbond, the validator will be removed from the validator set. If the\n * address of the executor of this function is not a validator and has credits bonded as a delegator, it will\n * subtract this amount of credits from the delegator's staked credits. If there are less than 10 credits bonded\n * after the unbond operation, the delegator will be removed from the validator's staking pool.\n *\n * @param {string} staker_address Address of the staker who is unbonding the credits\n * @param {number} amount Amount of credits to unbond.\n * @param {ExecuteOptions} options Options for the execution\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the unbond_public transaction and send it to the network\n * const tx_id = await programManager.unbondPublic(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", 10);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async unbondPublic(\n staker_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildUnbondPublicTransaction(\n staker_address,\n amount,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build a transaction to claim unbonded public credits in the Aleo network.\n *\n * @param {string} staker_address - The address of the staker who is claiming the credits.\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to claim unbonded credits.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the claim_unbond_public transaction object for later use.\n * const tx = await programManager.buildClaimUnbondPublicTransaction(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\");\n *\n * // The transaction can be submitted later to the network using the network client.\n * programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildClaimUnbondPublicTransaction(\n staker_address: string,\n options: Partial<ExecuteOptions> = {},\n ): Promise<Transaction> {\n const {\n programName = \"credits.aleo\",\n functionName = \"claim_unbond_public\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [staker_address],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.claim_unbond_public.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier,\n cacheKey: \"credits.aleo/claim_unbond_public\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n // Check if the account has sufficient credits to pay for the transaction\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will\n * claim them and add them to the public balance of the account.\n *\n * @param {string} staker_address Address of the staker who is claiming the credits\n * @param {ExecuteOptions} options\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the claim_unbond_public transaction\n * const tx_id = await programManager.claimUnbondPublic(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\");\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async claimUnbondPublic(\n staker_address: string,\n options: Partial<ExecuteOptions> = {},\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildClaimUnbondPublicTransaction(\n staker_address,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build a set_validator_state transaction for later usage.\n *\n * This function allows a validator to set their state to be either opened or closed to new stakers.\n * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\n * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n *\n * This function serves two primary purposes:\n * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.\n *\n * @param {boolean} validator_state\n * @param {Partial<ExecuteOptions>} options - Override default execution options\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the set_validator_state transaction\n * const tx = await programManager.buildSetValidatorStateTransaction(true);\n *\n * // The transaction can be submitted later to the network using the network client.\n * programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildSetValidatorStateTransaction(\n validator_state: boolean,\n options: Partial<ExecuteOptions> = {},\n ): Promise<Transaction> {\n const {\n programName = \"credits.aleo\",\n functionName = \"set_validator_state\",\n priorityFee = 0,\n privateFee = false,\n inputs = [validator_state.toString()],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.set_validator_state.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.set_validator_state.verifier,\n cacheKey: \"credits.aleo/set_validator_state\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Submit a set_validator_state transaction to the Aleo Network.\n *\n * This function allows a validator to set their state to be either opened or closed to new stakers.\n * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\n * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n *\n * This function serves two primary purposes:\n * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.\n *\n * @param {boolean} validator_state\n * @param {Partial<ExecuteOptions>} options - Override default execution options\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the set_validator_state transaction\n * const tx_id = await programManager.setValidatorState(true);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async setValidatorState(\n validator_state: boolean,\n options: Partial<ExecuteOptions> = {},\n ) {\n const tx = <Transaction>(\n await this.buildSetValidatorStateTransaction(\n validator_state,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Verify a proof from an offline execution. This is useful when it is desired to do offchain proving and verification.\n *\n * @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)\n * @param {blockHeight} blockHeight The ledger height when the execution was generated.\n * @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { \"programName\": \"programSourceCode\", ... }\n * @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { \"programName\": [[\"functionName\", \"verifyingKey\"], ...], ... }\n * @returns {boolean} True if the proof is valid, false otherwise\n *\n * @example\n * /// Import the mainnet version of the sdk used to build executions.\n * import { Account, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * /// Create the source for two programs.\n * const program = \"import add_it_up.aleo; \\n\\n program mul_add.aleo;\\n\\nfunction mul_and_add:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n mul r0 r1 into r2;\\n call add_it_up.aleo/add_it r1 r2 into r3; output r3 as u32.private;\\n\";\n * const program_import = \"program add_it_up.aleo;\\n\\nfunction add_it:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(undefined, undefined, undefined);\n *\n * /// Create a temporary account for the execution of the program\n * const account = Account.fromCipherText(process.env.ciphertext, process.env.password);\n * programManager.setAccount(account);\n *\n * /// Get the response and ensure that the program executed correctly\n * const executionResponse = await programManager.run(program, \"mul_and_add\", [\"5u32\", \"5u32\"], true);\n *\n * /// Construct the imports and verifying keys\n * const imports = { \"add_it_up.aleo\": program_import };\n * const importedVerifyingKeys = { \"add_it_up.aleo\": [[\"add_it\", \"verifyingKey1...\"]] };\n *\n * /// Verify the execution.\n * const blockHeight = 9000000;\n * const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);\n * assert(isValid);\n */\n verifyExecution(executionResponse: ExecutionResponse, blockHeight: number, imports?: ImportedPrograms, importedVerifyingKeys?: ImportedVerifyingKeys): boolean {\n try {\n const execution = <FunctionExecution>(\n executionResponse.getExecution()\n );\n const function_id = executionResponse.getFunctionId();\n const program = executionResponse.getProgram();\n const verifyingKey = executionResponse.getVerifyingKey();\n return verifyFunctionExecution(\n execution,\n verifyingKey,\n program,\n function_id,\n imports,\n importedVerifyingKeys,\n blockHeight\n );\n } catch (e) {\n console.warn(\n `The execution was not found in the response, cannot verify the execution: ${e}`,\n );\n return false;\n }\n }\n\n /**\n * Create a program object from a program's source code\n *\n * @param {string} program Program source code\n * @returns {Program} The program object\n */\n createProgramFromSource(program: string): Program {\n return Program.fromString(program);\n }\n\n /**\n * Get the credits program object\n *\n * @returns {Program} The credits program object\n */\n creditsProgram(): Program {\n return Program.getCreditsProgram();\n }\n\n /**\n * Verify a program is valid\n *\n * @param {string} program The program source code\n */\n verifyProgram(program: string): boolean {\n try {\n <Program>Program.fromString(program);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Estimate the execution fee for an authorization.\n *\n * @param {FeeEstimateOptions} options Options for fee estimate.\n *\n * @example\n * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from \"@provablehq/sdk\";\n *\n * await initThreadPool();\n *\n * // Create a new KeyProvider.\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Build the `Authorization`.\n * const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.\n * const authorization = await programManager.buildAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * privateKey,\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n *\n * console.log(\"Getting execution id\");\n *\n * // Derive the execution ID and base fee.\n * const executionId = authorization.toExecutionId().toString();\n *\n * console.log(\"Estimating fee\");\n *\n * // Get the base fee in microcredits.\n * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({\n * authorization,\n * programName: \"credits.aleo\"\n * });\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n *\n * console.log(\"Building fee authorization\");\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const feeAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: executionId,\n * baseFeeCredits,\n * privateKey\n * });\n */\n async estimateFeeForAuthorization(\n options: FeeEstimateOptions\n ): Promise<bigint> {\n const {\n authorization,\n programName,\n program,\n imports,\n edition\n } = options;\n if (!authorization) {\n throw new Error(\"Authorization must be provided if estimating fee for Authorization.\")\n }\n const programSource = program ? program.toString() : await this.networkClient.getProgram(programName, edition);\n const programImports = imports ? imports : await this.networkClient.getProgramImports(programSource);\n console.log(JSON.stringify(programImports));\n if (Object.keys(programImports)) {\n return WasmProgramManager.estimateFeeForAuthorization(authorization, programSource, programImports, edition);\n }\n return WasmProgramManager.estimateFeeForAuthorization(authorization, programSource, imports, edition);\n }\n\n /**\n * Estimate the execution fee for an Aleo function.\n *\n * @param {FeeEstimateOptions} options Options for the fee estimate.\n *\n * @returns {Promise<bigint>} Execution fee in microcredits for the authorization.\n *\n * @example\n * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from \"@provablehq/sdk\";\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Get the base fee in microcredits.\n * const baseFeeMicrocredits = await programManager.estimateExecutionFee({programName: \"credits.aleo\"});\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n *\n * console.log(\"Building fee authorization\");\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * });\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n */\n async estimateExecutionFee(\n options: FeeEstimateOptions,\n ): Promise<bigint> {\n const {\n functionName,\n programName,\n program,\n imports,\n edition\n } = options;\n if (!functionName) {\n throw new Error(\"Function name must be specified when estimating fee.\");\n }\n const programSource = program ? program.toString() : await this.networkClient.getProgram(programName, edition);\n const programImports = imports ? imports : await this.networkClient.getProgramImports(programSource);\n if (Object.keys(programImports)) {\n return WasmProgramManager.estimateExecutionFee(programSource, functionName, programImports, edition);\n }\n return WasmProgramManager.estimateExecutionFee(programSource, functionName, imports, edition);\n }\n\n // Internal utility function for getting a credits.aleo record\n async getCreditsRecord(\n amount: number,\n nonces: string[],\n record?: RecordPlaintext | string,\n params?: RecordSearchParams,\n ): Promise<RecordPlaintext> {\n if (record) {\n try {\n return record instanceof RecordPlaintext\n ? record : RecordPlaintext.fromString(<string>record);\n } catch {\n logAndThrow(`Record '${record}' could not be parsed, please ensure a valid credits.aleo record \n is passed prior to trying again`)\n }\n } else {\n try {\n const recordProvider = <RecordProvider>this.recordProvider;\n const record = await recordProvider.findCreditsRecord(\n amount,\n { ...params, unspent: true, nonces }\n );\n if (record.record_plaintext) {\n return RecordPlaintext.fromString(record.record_plaintext);\n } else {\n logAndThrow(\"Failed to deserialize record returned from record provider\");\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n }\n }\n\n /**\n * Builds an execution transaction for submission to the a local devnode.\n * This method skips proof generation and is not meant for use with the mainnet or testnet Aleo networks.\n * Note: getOrInitConsensusVersionTestHeights must be called prior to using this method for this method to work properly.\n *\n * @param {ExecuteOptions} options - The options for the execution transaction.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n * \n * // Initialize the development consensus heights in order to work with devnode.\n * getOrInitConsensusVersionTestHeights(\"0,1,2,3,4,5,6,7,8,9,10,11\");\n *\n * // Create a new NetworkClient and RecordProvider.\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager.\n * const programManager = new ProgramManager(\"http://localhost:3030\", recordProvider);\n *\n * // Build and execute the transaction.\n * const tx = await programManager.buildDevnodeExecutionTransaction({\n * programName: \"hello_hello.aleo\",\n * functionName: \"hello_hello\",\n * priorityFee: 0.0,\n * privateFee: false,\n * inputs: [\"5u32\", \"5u32\"],\n * });\n *\n * // Submit the transaction to the network\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildDevnodeExecutionTransaction(\n options: ExecuteOptions,\n ): Promise<Transaction> {\n // Destructure the options object to access the parameters\n const {\n functionName,\n priorityFee,\n privateFee,\n inputs,\n recordSearchParams,\n privateKey,\n } = options;\n\n let feeRecord = options.feeRecord;\n let program = options.program;\n let programName = options.programName;\n let imports = options.imports;\n let edition = options.edition;\n\n let programObject;\n // Ensure the function exists on the network\n if (program === undefined) {\n try {\n programObject = await this.networkClient.getProgramObject(programName);\n program = <string>programObject.toString();\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (typeof program == \"string\") {\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(`Program sources passed for ${programName} were invalid: ${e}`);\n }\n } else if (program instanceof Program) {\n programObject = program;\n program = program.toString();\n }\n\n if (!(programObject instanceof Program)) {\n logAndThrow(`Failed to validate program ${programName}`);\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = programObject.id();\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 0.`);\n edition = 0;\n }\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters.\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = programObject.getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n \n // Build a transaction without a proof\n return await WasmProgramManager.buildDevnodeExecutionTransaction(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n edition\n );\n }\n \n /**\n * Builds a deployment transaction with placeholder certificates and verifying keys for each function in the program.\n * Intended for use with a local devnode.\n * `getOrInitConsensusVersionTestHeights` must be called with development heights prior to invoking this method for it to work properly.\n *\n * @param {DeployOptions} options - The options for the deployment transaction.\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from \"@provablehq/sdk/mainnet.js\";\n * \n * // Initialize the development consensus heights in order to work with a local devnode.\n * getOrInitConsensusVersionTestHeights(\"0,1,2,3,4,5,6,7,8,9,10,11\");\n *\n * // Create a new NetworkClient, and RecordProvider\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"http://localhost:3030\", recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildDevnodeDeploymentTransaction({program: program, fee: priorityFee, privateFee: false});\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildDevnodeDeploymentTransaction(\n options: DeployOptions\n ): Promise<Transaction> {\n const { program, priorityFee, privateFee, recordSearchParams } = options;\n let feeRecord = options.feeRecord;\n let privateKey = options.privateKey;\n\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network, deployment can proceed\n console.log(\n `Program ${programObject.id()} does not exist on the network, deploying...`,\n );\n }\n if (typeof programSource === \"string\") {\n throw Error(`Program ${programObject.id()} already exists on the network, please rename your program`);\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n \n return await WasmProgramManager.buildDevnodeDeploymentTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n );\n }\n\n /**\n * Builds an upgrade transaction on a local devnodewith placeholder certificates and verifying keys for each function in the program.\n * This method is only intended for use with a local devnode.\n *\n * @param {DeployOptions} options - The options for the deployment transaction.\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, and RecordProvider\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"http://localhost:3030\", recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildDevnodeUpgradeTransaction({program: program, fee: priorityFee, privateFee: false});\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildDevnodeUpgradeTransaction(\n options: DeployOptions\n ): Promise<Transaction> {\n const { program, priorityFee, privateFee, recordSearchParams } = options;\n let feeRecord = options.feeRecord;\n let privateKey = options.privateKey;\n\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network.\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network.\n logAndThrow(\n `Program ${programObject.id()} does not exist on the network...`,\n );\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n return WasmProgramManager.buildDevnodeUpgradeTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n );\n }\n}\n\n// Ensure the transfer type requires an amount record\nfunction requiresAmountRecord(transferType: string): boolean {\n return PRIVATE_TRANSFER_TYPES.has(transferType);\n}\n\n// Validate the transfer type\nfunction validateTransferType(transferType: string): string {\n return VALID_TRANSFER_TYPES.has(transferType)\n ? transferType\n : logAndThrow(\n `Invalid transfer type '${transferType}'. Valid transfer types are 'private', 'privateToPublic', 'public', and 'publicToPrivate'.`,\n );\n}\n\nexport { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };\n","import \"./polyfill/shared.js\";\n\nimport { Account } from \"./account.js\";\nimport { AleoNetworkClient, ProgramImports } from \"./network-client.js\";\nimport { BlockJSON, Header, Metadata } from \"./models/blockJSON.js\";\nimport { ConfirmedTransactionJSON } from \"./models/confirmed_transaction.js\";\nimport { CryptoBoxPubKey } from \"./models/cryptoBoxPubkey.js\";\nimport { DeploymentJSON, VerifyingKeys } from \"./models/deployment/deploymentJSON.js\";\nimport { DeploymentObject } from \"./models/deployment/deploymentObject.js\";\nimport { EncryptedProvingRequest } from \"./models/encryptedProvingRequest.js\";\nimport { EncryptedRecord } from \"./models/record-provider/encryptedRecord.js\";\nimport { ExecutionJSON, FeeExecutionJSON } from \"./models/execution/executionJSON.js\";\nimport { ExecutionObject, FeeExecutionObject } from \"./models/execution/executionObject.js\";\nimport { FinalizeJSON } from \"./models/finalizeJSON.js\";\nimport { FunctionInput } from \"./models/functionInput\";\nimport { FunctionObject } from \"./models/functionObject.js\";\nimport { ImportedVerifyingKeys, ImportedPrograms } from \"./models/imports.js\";\nimport { InputJSON } from \"./models/input/inputJSON.js\";\nimport { InputObject } from \"./models/input/inputObject.js\";\nimport { OutputJSON } from \"./models/output/outputJSON.js\";\nimport { OutputObject } from \"./models/output/outputObject.js\";\nimport { OwnedFilter } from \"./models/record-scanner/ownedFilter.js\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord.js\";\nimport { OwnerJSON } from \"./models/owner/ownerJSON.js\";\nimport { PlaintextArray} from \"./models/plaintext/array.js\";\nimport { PlaintextLiteral} from \"./models/plaintext/literal.js\";\nimport { PlaintextObject } from \"./models/plaintext/plaintext.js\";\nimport { PlaintextStruct} from \"./models/plaintext/struct.js\";\nimport { ProvingRequestJSON } from \"./models/provingRequest.js\";\nimport { ProvingResponse, BroadcastResponse, BroadcastResult, ProvingResult, ProvingFailure, ProvingSuccess, ProveApiErrorBody, ProvingRequestError, isProvingResponse, isProveApiErrorBody } from \"./models/provingResponse.js\";\nimport { RatificationJSON } from \"./models/ratification.js\";\nimport { RecordsFilter } from \"./models/record-scanner/recordsFilter.js\";\nimport { RecordsResponseFilter } from \"./models/record-scanner/recordsResponseFilter.js\";\nimport { RecordSearchParams } from \"./models/record-provider/recordSearchParams.js\";\nimport { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from \"./models/solution.js\";\nimport { TransactionJSON } from \"./models/transaction/transactionJSON.js\";\nimport { TransactionObject } from \"./models/transaction/transactionObject.js\";\nimport { TransitionJSON } from \"./models/transition/transitionJSON.js\";\nimport { TransitionObject } from \"./models/transition/transitionObject.js\";\nimport {\n AleoKeyProvider,\n AleoKeyProviderParams,\n AleoKeyProviderInitParams,\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider.js\";\nimport {\n OfflineKeyProvider,\n OfflineSearchParams\n} from \"./offline-key-provider.js\";\nimport {\n BlockHeightSearch,\n NetworkRecordProvider,\n RecordProvider,\n} from \"./record-provider.js\";\nimport { RecordScanner } from \"./record-scanner.js\";\nimport { SealanceMerkleTree } from \"./integrations/sealance/merkle-tree.js\";\n\n// @TODO: This function is no longer needed, remove it.\nasync function initializeWasm() {\n console.warn(\"initializeWasm is deprecated, you no longer need to use it\");\n}\n\nexport { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from \"./program-manager.js\";\n\nexport { logAndThrow } from \"./utils.js\";\n\nexport {\n Address,\n Authorization,\n Boolean,\n BHP256,\n BHP512,\n BHP768,\n BHP1024,\n Ciphertext,\n ComputeKey,\n Execution as FunctionExecution,\n ExecutionRequest,\n ExecutionResponse,\n EncryptionToolkit,\n Field,\n GraphKey,\n Group,\n I8,\n I16,\n I32,\n I64,\n I128,\n OfflineQuery,\n Pedersen64,\n Pedersen128,\n Plaintext,\n Poseidon2,\n Poseidon4,\n Poseidon8,\n PrivateKey,\n PrivateKeyCiphertext,\n Program,\n ProgramManager as ProgramManagerBase,\n ProvingKey,\n ProvingRequest,\n RecordCiphertext,\n RecordPlaintext,\n Signature,\n Scalar,\n Transaction,\n Transition,\n U8,\n U16,\n U32,\n U64,\n U128,\n VerifyingKey,\n ViewKey,\n initThreadPool,\n getOrInitConsensusVersionTestHeights,\n verifyFunctionExecution,\n} from \"./wasm.js\";\n\nexport { initializeWasm };\n\nexport {\n Key,\n CREDITS_PROGRAM_KEYS,\n KEY_STORE,\n PRIVATE_TRANSFER,\n PRIVATE_TO_PUBLIC_TRANSFER,\n PRIVATE_TRANSFER_TYPES,\n PUBLIC_TRANSFER,\n PUBLIC_TRANSFER_AS_SIGNER,\n PUBLIC_TO_PRIVATE_TRANSFER,\n RECORD_DOMAIN,\n VALID_TRANSFER_TYPES,\n} from \"./constants.js\";\n\nexport {\n Account,\n AleoKeyProvider,\n AleoKeyProviderParams,\n AleoKeyProviderInitParams,\n AleoNetworkClient,\n BlockJSON,\n BlockHeightSearch,\n BroadcastResponse,\n BroadcastResult,\n CachedKeyPair,\n ConfirmedTransactionJSON,\n CryptoBoxPubKey,\n DeploymentJSON,\n DeploymentObject,\n EncryptedProvingRequest,\n EncryptedRecord,\n ExecutionJSON,\n ExecutionObject,\n FeeExecutionJSON,\n FeeExecutionObject,\n FinalizeJSON,\n FunctionInput,\n FunctionObject,\n FunctionKeyPair,\n FunctionKeyProvider,\n Header,\n isProvingResponse,\n isProveApiErrorBody,\n ImportedPrograms,\n ImportedVerifyingKeys,\n InputJSON,\n InputObject,\n KeySearchParams,\n Metadata,\n NetworkRecordProvider,\n OfflineKeyProvider,\n OfflineSearchParams,\n OutputJSON,\n OutputObject,\n OwnedFilter,\n OwnedRecord,\n OwnerJSON,\n PartialSolutionJSON,\n PlaintextArray,\n PlaintextLiteral,\n PlaintextObject,\n PlaintextStruct,\n ProgramImports,\n ProveApiErrorBody,\n ProvingFailure,\n ProvingRequestError,\n ProvingRequestJSON,\n ProvingResult,\n ProvingSuccess,\n ProvingResponse,\n RatificationJSON,\n RecordsFilter,\n RecordsResponseFilter,\n RecordProvider,\n RecordScanner,\n RecordSearchParams,\n SealanceMerkleTree,\n SolutionJSON,\n SolutionsJSON,\n TransactionJSON,\n TransactionObject,\n TransitionJSON,\n TransitionObject,\n VerifyingKeys,\n};\n\nexport { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest } from \"./security.js\";\n"],"names":["WasmProgramManager"],"mappings":";;;;;;AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;MACU,OAAO,CAAA;AAClB,IAAA,WAAW;AACX,IAAA,QAAQ;AACR,IAAA,WAAW;AACX,IAAA,QAAQ;AAER,IAAA,WAAA,CAAY,SAAuB,EAAE,EAAA;AACnC,QAAA,IAAI;YACF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC;QACtD;QAAE,OAAO,CAAC,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACnC,YAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;QACpC;QACA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;QAChE,IAAI,CAAC,QAAQ,GAAG,OAAO,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 {"version":3,"file":"browser.js","sources":["../../src/account.ts","../../src/utils.ts","../../src/constants.ts","../../src/network-client.ts","../../src/function-key-provider.ts","../../src/offline-key-provider.ts","../../src/record-provider.ts","../../src/record-scanner.ts","../../src/integrations/sealance/merkle-tree.ts","../../src/program-manager.ts","../../src/browser.ts"],"sourcesContent":["import {\n Address,\n ComputeKey,\n EncryptionToolkit,\n Field,\n Group,\n PrivateKey,\n Transition,\n Signature,\n ViewKey,\n PrivateKeyCiphertext,\n RecordCiphertext,\n RecordPlaintext,\n} from \"./wasm.js\";\n\ninterface AccountParam {\n privateKey?: string;\n seed?: Uint8Array;\n}\n\n/**\n * Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\n * an existing private key or seed, and message signing and verification functionality. An Aleo Account is generated\n * from a randomly generated seed (number) from which an account private key, view key, and a public account address are\n * derived. The private key lies at the root of an Aleo account. It is a highly sensitive secret and should be protected\n * as it allows for creation of Aleo Program executions and arbitrary value transfers. The View Key allows for decryption\n * of a user's activity on the blockchain. The Address is the public address to which other users of Aleo can send Aleo\n * credits and other records to. This class should only be used in environments where the safety of the underlying key\n * material can be assured.\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a new account\n * const myRandomAccount = new Account();\n *\n * // Create an account from a randomly generated seed\n * const seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);\n * const mySeededAccount = new Account({seed: seed});\n *\n * // Create an account from an existing private key\n * const myExistingAccount = new Account({privateKey: process.env.privateKey});\n *\n * // Sign a message\n * const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100]);\n * const signature = myRandomAccount.sign(hello_world);\n *\n * // Verify a signature\n * assert(myRandomAccount.verify(hello_world, signature));\n */\nexport class Account {\n _privateKey: PrivateKey;\n _viewKey: ViewKey;\n _computeKey: ComputeKey;\n _address: Address;\n\n constructor(params: AccountParam = {}) {\n try {\n this._privateKey = this.privateKeyFromParams(params);\n } catch (e) {\n console.error(\"Wrong parameter\", e);\n throw new Error(\"Wrong Parameter\");\n }\n this._viewKey = ViewKey.from_private_key(this._privateKey);\n this._computeKey = ComputeKey.from_private_key(this._privateKey);\n this._address = Address.from_private_key(this._privateKey);\n }\n\n /**\n * Attempts to create an account from a private key ciphertext\n * @param {PrivateKeyCiphertext | string} ciphertext The encrypted private key ciphertext or its string representation\n * @param {string} password The password used to decrypt the private key ciphertext\n * @returns {Account} A new Account instance created from the decrypted private key\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create an account object from a previously encrypted ciphertext and password.\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n */\n public static fromCiphertext(ciphertext: PrivateKeyCiphertext | string, password: string): Account {\n try {\n ciphertext = (typeof ciphertext === \"string\") ? PrivateKeyCiphertext.fromString(ciphertext) : ciphertext;\n const _privateKey = PrivateKey.fromPrivateKeyCiphertext(ciphertext, password);\n return new Account({ privateKey: _privateKey.to_string() });\n } catch(e) {\n throw new Error(\"Wrong password or invalid ciphertext\");\n }\n }\n\n /**\n * Creates a PrivateKey from the provided parameters.\n * @param {AccountParam} params The parameters containing either a private key string or a seed\n * @returns {PrivateKey} A PrivateKey instance derived from the provided parameters\n */\n private privateKeyFromParams(params: AccountParam): PrivateKey {\n if (params.seed) {\n return PrivateKey.from_seed_unchecked(params.seed);\n }\n if (params.privateKey) {\n return PrivateKey.from_string(params.privateKey);\n }\n return new PrivateKey();\n }\n\n /**\n * Returns the PrivateKey associated with the account.\n * @returns {PrivateKey} The private key of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const privateKey = account.privateKey();\n */\n privateKey(): PrivateKey {\n return this._privateKey;\n }\n\n /**\n * Returns the ViewKey associated with the account.\n * @returns {ViewKey} The view key of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const viewKey = account.viewKey();\n */\n viewKey(): ViewKey {\n return this._viewKey;\n }\n\n /**\n * Returns the ComputeKey associated with the account.\n * @returns {ComputeKey} The compute key of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const computeKey = account.computeKey();\n */\n computeKey(): ComputeKey {\n return this._computeKey;\n }\n\n /**\n * Returns the Aleo address associated with the account.\n * @returns {Address} The public address of the account\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const address = account.address();\n */\n address(): Address {\n return this._address;\n }\n\n /**\n * Deep clones the Account.\n * @returns {Account} A new Account instance with the same private key\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const clonedAccount = account.clone();\n */\n clone(): Account {\n return new Account({ privateKey: this._privateKey.to_string() });\n }\n\n /**\n * Returns the address of the account in a string representation.\n *\n * @returns {string} The string representation of the account address\n */\n toString(): string {\n return this.address().to_string()\n }\n\n /**\n * Encrypts the account's private key with a password.\n *\n * @param {string} password Password to encrypt the private key.\n * @returns {PrivateKeyCiphertext} The encrypted private key ciphertext\n *\n * @example\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * const account = new Account();\n * const ciphertext = account.encryptAccount(\"password\");\n * process.env.ciphertext = ciphertext.toString();\n */\n encryptAccount(password: string): PrivateKeyCiphertext {\n return this._privateKey.toCiphertext(password);\n }\n\n /**\n * Decrypts an encrypted record string into a plaintext record object.\n *\n * @param {string} ciphertext A string representing the ciphertext of a record.\n * @returns {RecordPlaintext} The decrypted record plaintext\n *\n * @example\n * // Import the AleoNetworkClient and Account classes\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n *\n * // Get the record ciphertexts from a transaction.\n * const transaction = await networkClient.getTransactionObject(\"at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd\");\n * const records = transaction.records();\n *\n * // Decrypt any records the account owns.\n * const decryptedRecords = [];\n * for (const record of records) {\n * if (account.decryptRecord(record)) {\n * decryptedRecords.push(record);\n * }\n * }\n */\n decryptRecord(ciphertext: string): RecordPlaintext {\n return this._viewKey.decrypt(ciphertext);\n }\n\n /**\n * Decrypts an array of Record ciphertext strings into an array of record plaintext objects.\n *\n * @param {string[]} ciphertexts An array of strings representing the ciphertexts of records.\n * @returns {RecordPlaintext[]} An array of decrypted record plaintexts\n *\n * @example\n * // Import the AleoNetworkClient and Account classes\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n *\n * // Get the record ciphertexts from a transaction.\n * const transaction = await networkClient.getTransactionObject(\"at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd\");\n * const records = transaction.records();\n *\n * // Decrypt any records the account owns. If the account owns no records, the array will be empty.\n * const decryptedRecords = account.decryptRecords(records);\n */\n decryptRecords(ciphertexts: string[]): RecordPlaintext[] {\n return ciphertexts.map((ciphertext) => this._viewKey.decrypt(ciphertext));\n }\n\n /**\n * Generates a record view key from the account owner's view key and the record ciphertext.\n * This key can be used to decrypt the record without revealing the account's view key.\n * @param {RecordCiphertext | string} recordCiphertext The record ciphertext to generate the view key for\n * @returns {Field} The record view key\n * \n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n * \n * // Create an account object from a previously encrypted ciphertext and password.\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n * \n * // Generate a record view key from the account's view key and a record ciphertext\n * const recordCiphertext = RecordCiphertext.fromString(\"your_record_ciphertext_here\");\n * const recordViewKey = account.generateRecordViewKey(recordCiphertext);\n */\n generateRecordViewKey(recordCiphertext: RecordCiphertext | string): Field {\n if (typeof recordCiphertext === 'string') {\n recordCiphertext = RecordCiphertext.fromString(recordCiphertext);\n }\n if (!(recordCiphertext.isOwner(this._viewKey))) {\n throw new Error(\"The record ciphertext does not belong to this account\");\n }\n return EncryptionToolkit.generateRecordViewKey(this._viewKey, recordCiphertext);\n }\n\n /**\n * Generates a transition view key from the account owner's view key and the transition public key.\n * This key can be used to decrypt the private inputs and outputs of a the transition without \n * revealing the account's view key.\n * @param {string | Group} tpk The transition public key\n * @returns {Field} The transition view key\n * \n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n * \n * // Generate a transition view key from the account's view key and a transition public key\n * const tpk = Group.fromString(\"your_transition_public_key_here\");\n * \n * const transitionViewKey = account.generateTransitionViewKey(tpk);\n */\n generateTransitionViewKey(tpk: string | Group): Field {\n if (typeof tpk === 'string') {\n tpk = Group.fromString(tpk);\n }\n return EncryptionToolkit.generateTvk(this._viewKey, tpk);\n }\n\n /**\n * Determines whether the account owns a ciphertext record.\n * @param {RecordCiphertext | string} ciphertext The record ciphertext to check ownership of\n * @returns {boolean} True if the account owns the record, false otherwise\n *\n * @example\n * // Import the AleoNetworkClient and Account classes\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);\n *\n * // Get the record ciphertexts from a transaction and check ownership of them.\n * const transaction = await networkClient.getTransactionObject(\"at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd\");\n * const records = transaction.records();\n *\n * // Check if the account owns any of the record ciphertexts present in the transaction.\n * const ownedRecords = [];\n * for (const record of records) {\n * if (account.ownsRecordCiphertext(record)) {\n * ownedRecords.push(record);\n * }\n * }\n */\n ownsRecordCiphertext(ciphertext: RecordCiphertext | string): boolean {\n if (typeof ciphertext === 'string') {\n try {\n const ciphertextObject = RecordCiphertext.fromString(ciphertext);\n return ciphertextObject.isOwner(this._viewKey);\n }\n catch (e) {\n return false;\n }\n }\n else {\n return ciphertext.isOwner(this._viewKey);\n }\n }\n\n /**\n * Signs a message with the account's private key.\n * Returns a Signature.\n *\n * @param {Uint8Array} message Message to be signed.\n * @returns {Signature} Signature over the message in bytes.\n *\n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Create an account and a message to sign.\n * const account = new Account();\n * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])\n * const signature = account.sign(message);\n *\n * // Verify the signature.\n * assert(account.verify(message, signature));\n */\n sign(message: Uint8Array): Signature {\n return this._privateKey.sign(message);\n }\n\n /**\n * Verifies the Signature on a message.\n *\n * @param {Uint8Array} message Message in bytes to be signed.\n * @param {Signature} signature Signature to be verified.\n * @returns {boolean} True if the signature is valid, false otherwise.\n *\n * @example\n * // Import the Account class\n * import { Account } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a connection to the Aleo network and an account\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Sign a message.\n * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])\n * const signature = account.sign(message);\n *\n * // Verify the signature.\n * assert(account.verify(message, signature));\n */\n verify(message: Uint8Array, signature: Signature): boolean {\n return this._address.verify(message, signature);\n }\n}\n","function detectBrowser() {\n const userAgent = navigator.userAgent;\n\n if (/chrome|crios|crmo/i.test(userAgent) && !/edge|edg|opr/i.test(userAgent)) {\n return \"chrome\";\n } else if (/firefox|fxios/i.test(userAgent)) {\n return \"firefox\";\n } else if (/safari/i.test(userAgent) && !/chrome|crios|crmo|android/i.test(userAgent)) {\n return \"safari\";\n } else if (/edg/i.test(userAgent)) {\n return \"edge\";\n } else if (/opr\\//i.test(userAgent)) {\n return \"opera\";\n } else {\n return \"browser\";\n }\n}\n\nexport function environment() {\n if ((typeof process !== 'undefined') &&\n (process.release?.name === 'node')) {\n return 'node';\n } else if (typeof window !== 'undefined') {\n return detectBrowser();\n } else {\n return 'unknown';\n }\n}\n\nexport function logAndThrow(message: string): never {\n console.error(message);\n throw new Error(message);\n}\n\nexport function parseJSON(json: string): any {\n function revive(key: string, value: any, context: any) {\n if (Number.isInteger(value)) {\n return BigInt(context.source);\n } else {\n return value;\n }\n }\n\n return JSON.parse(json, revive as any);\n}\n\nexport async function get(url: URL | string, options?: RequestInit) {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(response.status + \" could not get URL \" + url);\n }\n\n return response;\n}\n\nexport async function post(url: URL | string, options: RequestInit) {\n options.method = \"POST\";\n\n const response = await fetch(url, options);\n\n if (!response.ok) {\n const error = await response.text();\n let message = `${response.status} error received from ${url}`;\n if (error) {\n message = `${error}`\n }\n throw new Error(message);\n }\n\n return response;\n}\n\ntype RetryOptions = {\n maxAttempts?: number;\n baseDelay?: number;\n jitter?: number;\n retryOnStatus?: number[]; // e.g. [500, 502, 503]\n shouldRetry?: (err: any) => boolean;\n};\n\nexport async function retryWithBackoff<T>(\n fn: () => Promise<T>,\n {\n maxAttempts = 5,\n baseDelay = 100,\n jitter,\n retryOnStatus = [],\n shouldRetry,\n }: RetryOptions = {},\n): Promise<T> {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (err: any) {\n const isLast = attempt === maxAttempts;\n const error = err as Error & { code?: string; status?: number };\n\n let retryable = false;\n\n if (typeof error.status === \"number\") {\n if (error.status >= 500) {\n retryable = true;\n } else if (error.status >= 400 && shouldRetry) {\n retryable = shouldRetry(error);\n }\n } else if (shouldRetry) {\n retryable = shouldRetry(error);\n }\n\n if (!retryable || isLast) throw error;\n\n const jitterAmount = jitter ?? baseDelay;\n const actualJitter = Math.floor(Math.random() * jitterAmount);\n const delay = baseDelay * 2 ** (attempt - 1) + actualJitter;\n console.warn(\n `Retry ${attempt}/${maxAttempts} failed. Retrying in ${delay}ms...`,\n );\n\n await new Promise((res) => setTimeout(res, delay));\n }\n }\n\n throw new Error(\"retryWithBackoff: unreachable\");\n}\n","import {VerifyingKey, Metadata} from \"./wasm.js\";\n\nexport const KEY_STORE = Metadata.baseUrl();\n\nexport interface Key {\n name: string,\n locator: string,\n prover: string,\n verifier: string,\n verifyingKey: () => VerifyingKey,\n}\n\nfunction convert(metadata: Metadata): Key {\n // This looks up the method name in VerifyingKey\n const verifyingKey = (VerifyingKey as any)[metadata.verifyingKey];\n\n if (!verifyingKey) {\n throw new Error(\"Invalid method name: \" + metadata.verifyingKey);\n }\n\n return {\n name: metadata.name,\n locator: metadata.locator,\n prover: metadata.prover,\n verifier: metadata.verifier,\n verifyingKey,\n };\n}\n\nexport const CREDITS_PROGRAM_KEYS = {\n bond_public: convert(Metadata.bond_public()),\n bond_validator: convert(Metadata.bond_validator()),\n claim_unbond_public: convert(Metadata.claim_unbond_public()),\n fee_private: convert(Metadata.fee_private()),\n fee_public: convert(Metadata.fee_public()),\n inclusion: convert(Metadata.inclusion()),\n join: convert(Metadata.join()),\n set_validator_state: convert(Metadata.set_validator_state()),\n split: convert(Metadata.split()),\n transfer_private: convert(Metadata.transfer_private()),\n transfer_private_to_public: convert(Metadata.transfer_private_to_public()),\n transfer_public: convert(Metadata.transfer_public()),\n transfer_public_as_signer: convert(Metadata.transfer_public_as_signer()),\n transfer_public_to_private: convert(Metadata.transfer_public_to_private()),\n unbond_public: convert(Metadata.unbond_public()),\n getKey: function(key: string): Key {\n if (this.hasOwnProperty(key)) {\n return (this as any)[key] as Key;\n } else {\n throw new Error(`Key \"${key}\" not found.`);\n }\n }\n};\n\nexport const PRIVATE_TRANSFER_TYPES = new Set([\n \"transfer_private\",\n \"private\",\n \"transferPrivate\",\n \"transfer_private_to_public\",\n \"privateToPublic\",\n \"transferPrivateToPublic\",\n]);\n\nexport const VALID_TRANSFER_TYPES = new Set([\n \"transfer_private\",\n \"private\",\n \"transferPrivate\",\n \"transfer_private_to_public\",\n \"privateToPublic\",\n \"transferPrivateToPublic\",\n \"transfer_public\",\n \"transfer_public_as_signer\",\n \"public\",\n \"public_as_signer\",\n \"transferPublic\",\n \"transferPublicAsSigner\",\n \"transfer_public_to_private\",\n \"publicToPrivate\",\n \"publicAsSigner\",\n \"transferPublicToPrivate\",\n]);\n\nexport const PRIVATE_TRANSFER = new Set([\n \"private\",\n \"transfer_private\",\n \"transferPrivate\",\n]);\n\nexport const PRIVATE_TO_PUBLIC_TRANSFER = new Set([\n \"private_to_public\",\n \"privateToPublic\",\n \"transfer_private_to_public\",\n \"transferPrivateToPublic\",\n]);\n\nexport const PUBLIC_TRANSFER = new Set([\n \"public\",\n \"transfer_public\",\n \"transferPublic\",\n]);\n\nexport const PUBLIC_TRANSFER_AS_SIGNER = new Set([\n \"public_as_signer\",\n \"transfer_public_as_signer\",\n \"transferPublicAsSigner\",\n]);\n\nexport const PUBLIC_TO_PRIVATE_TRANSFER = new Set([\n \"public_to_private\",\n \"publicToPrivate\",\n \"transfer_public_to_private\",\n \"transferPublicToPrivate\",\n]);\n\nexport const RECORD_DOMAIN = \"RecordScannerV0\";\n\n/**\n * Zero address on Aleo blockchain that corresponds to field element 0. Used as padding in Merkle trees and as a sentinel value.\n */\nexport const ZERO_ADDRESS = \"aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc\";\n\nexport const FIVE_MINUTES = 5 * 60 * 1000; // 5 minutes in milliseconds\n","import { get, post, parseJSON, logAndThrow, retryWithBackoff, environment } from \"./utils.js\";\nimport { Account } from \"./account.js\";\nimport { FIVE_MINUTES } from \"./constants.js\";\nimport { BlockJSON } from \"./models/blockJSON.js\";\nimport { TransactionJSON } from \"./models/transaction/transactionJSON.js\";\nimport {\n Address,\n Plaintext,\n RecordCiphertext,\n Program,\n ProvingRequest,\n RecordPlaintext,\n PrivateKey,\n Transaction,\n} from \"./wasm.js\";\nimport { ConfirmedTransactionJSON } from \"./models/confirmed_transaction.js\";\nimport { ProvingResponse } from \"./models/provingResponse.js\";\n\ntype ProgramImports = { [key: string]: string | Program };\n\ninterface AleoNetworkClientOptions {\n headers?: { [key: string]: string };\n}\n\n/**\n * Interface for the JWT data.\n * \n * @property jwt {string} The JWT token string.\n * @property expiration {number} The expiration time of the JWT token in UNIX timestamp format.\n */\ninterface JWTData {\n jwt: string;\n expiration: number;\n}\n\n/**\n * Options for submitting a proving request.\n *\n * @property provingRequest {ProvingRequest | string} The proving request being submitted to the network.\n * @property url {string} The URL of the delegated proving service.\n * @property apiKey {string} The API key used for generating a JWT.\n * @property consumerId {string} The consumer ID associated with the API key.\n * @property jwt {string} An optional JWT token used for authenticating with the proving service.\n */\ninterface DelegatedProvingParams {\n provingRequest: ProvingRequest | string;\n url?: string;\n apiKey?: string;\n consumerId?: string;\n jwtData?: JWTData;\n}\n\n/**\n * Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this\n * allow users to query public information from the Aleo blockchain and submit transactions to the network.\n *\n * @param {string} host\n * @example\n * // Connection to a local node.\n * const localNetworkClient = new AleoNetworkClient(\"http://0.0.0.0:3030\", undefined, account);\n *\n * // Connection to a public beacon node\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n * const apiKey = process.env.apiKey;\n * const consumerId = process.env.consumerId;\n * const publicNetworkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined, account);\n */\nclass AleoNetworkClient {\n host: string;\n headers: { [key: string]: string };\n account: Account | undefined;\n ctx: { [key: string]: string };\n verboseErrors: boolean;\n readonly network: string;\n apiKey?: string;\n consumerId?: string;\n jwtData?: JWTData;\n\n constructor(host: string, options?: AleoNetworkClientOptions) {\n this.host = host + \"/%%NETWORK%%\";\n this.network = \"%%NETWORK%%\";\n this.ctx = {};\n this.verboseErrors = true;\n\n if (options && options.headers) {\n this.headers = options.headers;\n } else {\n this.headers = {\n // This is replaced by the actual version by a Rollup plugin\n \"X-Aleo-SDK-Version\": \"%%VERSION%%\",\n \"X-Aleo-environment\" : environment(),\n };\n }\n }\n\n /**\n * Set an account to use in networkClient calls\n *\n * @param {Account} account Set an account to use for record scanning functions.\n * @example\n * import { Account, AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\");\n * const account = new Account();\n * networkClient.setAccount(account);\n */\n setAccount(account: Account) {\n this.account = account;\n }\n\n /**\n * Return the Aleo account used in the networkClient\n *\n * @example\n * const account = networkClient.getAccount();\n */\n getAccount(): Account | undefined {\n return this.account;\n }\n\n /**\n * Set a new host for the networkClient\n *\n * @param {string} host The address of a node hosting the Aleo API\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient that connects to a local node.\n * const networkClient = new AleoNetworkClient(\"http://0.0.0.0:3030\", undefined);\n *\n * // Set the host to a public node.\n * networkClient.setHost(\"http://api.explorer.provable.com/v1\");\n */\n setHost(host: string) {\n this.host = host + \"/%%NETWORK%%\";\n }\n\n /**\n * Set verbose errors to true or false for the `AleoNetworkClient`. When set to true, if `submitTransaction` fails, the failure responses will report descriptive information as to why the transaction failed.\n *\n * @param {boolean} verboseErrors Set verbose error mode to true or false for the AleoNetworkClient.\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient\n * const networkClient = new AleoNetworkClient();\n *\n * // Set debug mode to true\n * networkClient.setVerboseTransactionErrors(true);\n **/\n setVerboseErrors(verboseErrors: boolean) {\n this.verboseErrors = verboseErrors;\n }\n\n /**\n * Set a header in the `AleoNetworkClient`s header map\n *\n * @param {string} headerName The name of the header to set\n * @param {string} value The header value\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a networkClient\n * const networkClient = new AleoNetworkClient();\n *\n * // Set the value of the `Accept-Language` header to `en-US`\n * networkClient.setHeader('Accept-Language', 'en-US');\n */\n setHeader(headerName: string, value: string) {\n this.headers[headerName] = value;\n }\n\n removeHeader(headerName: string) {\n delete this.headers[headerName];\n }\n\n /**\n * Fetches data from the Aleo network and returns it as a JSON object.\n *\n * @param url The URL to fetch data from.\n */\n async fetchData<Type>(url = \"/\"): Promise<Type> {\n try {\n const raw = await this.fetchRaw(url);\n return parseJSON(raw);\n } catch (error) {\n throw new Error(`Error fetching data: ${error}`);\n }\n }\n\n /**\n * Fetches data from the Aleo network and returns it as an unparsed string.\n *\n * This method should be used when it is desired to reconstitute data returned\n * from the network into a WASM object.\n *\n * @param url\n */\n async fetchRaw(url = \"/\"): Promise<string> {\n try {\n const ctx = {...this.ctx};\n return await retryWithBackoff(async () => {\n const response = await get(this.host + url, {\n headers: {\n ...this.headers,\n ...ctx,\n },\n });\n return await response.text();\n });\n } catch (error) {\n throw new Error(`Error fetching data: ${error}`);\n }\n }\n\n /**\n * Wrapper around the POST helper to allow mocking in tests. Not meant for use in production.\n *\n * @param url The URL to POST to.\n * @param options The RequestInit options for the POST request.\n * @returns The Response object from the POST request.\n */\n private async _sendPost(url: string, options: RequestInit) {\n return post(url, options);\n }\n\n /**\n * Attempt to find records in the Aleo blockchain.\n *\n * @param {number} startHeight - The height at which to start searching for unspent records\n * @param {number} endHeight - The height at which to stop searching for unspent records\n * @param {boolean} unspent - Whether to search for unspent records only\n * @param {string[]} programs - The program(s) to search for unspent records in\n * @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])\n * @param {number} maxMicrocredits - The maximum number of microcredits to search for\n * @param {string[]} nonces - The nonces of already found records to exclude from the search\n * @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.\n * @returns {Promise<Array<RecordPlaintext>>} An array of records belonging to the account configured in the network client.\n *\n * @example\n * import { Account, AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Import an account from a ciphertext and password.\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * networkClient.setAccount(account);\n *\n * // Find specific amounts\n * const startHeight = 500000;\n * const amounts = [600000, 1000000];\n * const records = networkClient.findRecords(startHeight, undefined, true, [\"credits.aleo\"] amounts);\n *\n * // Find specific amounts with a maximum number of cumulative microcredits\n * const maxMicrocredits = 100000;\n * const records = networkClient.findRecords(startHeight, undefined, true, [\"credits.aleo\"] undefined, maxMicrocredits);\n */\n async findRecords(\n startHeight: number,\n endHeight: number | undefined,\n unspent: boolean = false,\n programs?: string[],\n amounts?: number[] | undefined,\n maxMicrocredits?: number | undefined,\n nonces?: string[] | undefined,\n privateKey?: string | PrivateKey | undefined,\n ): Promise<Array<RecordPlaintext>> {\n nonces = nonces || [];\n // Ensure start height is not negative\n if (startHeight < 0) {\n throw new Error(\"Start height must be greater than or equal to 0\");\n }\n\n // Initialize search parameters\n const records = new Array<RecordPlaintext>();\n let start;\n let end;\n let resolvedPrivateKey: PrivateKey;\n let failures = 0;\n let totalRecordValue = BigInt(0);\n let latestHeight: number;\n\n // Ensure a private key is present to find owned records\n if (typeof privateKey === \"undefined\") {\n if (typeof this.account === \"undefined\") {\n throw new Error(\n \"Private key must be specified in an argument to findOwnedRecords or set in the AleoNetworkClient\",\n );\n } else {\n resolvedPrivateKey = this.account._privateKey;\n }\n } else {\n try {\n resolvedPrivateKey =\n privateKey instanceof PrivateKey\n ? privateKey\n : PrivateKey.from_string(privateKey);\n } catch (error) {\n throw new Error(\"Error parsing private key provided.\");\n }\n }\n const viewKey = resolvedPrivateKey.to_view_key();\n\n // Get the latest height to ensure the range being searched is valid\n try {\n const blockHeight = await this.getLatestHeight();\n if (typeof blockHeight === \"number\") {\n latestHeight = blockHeight;\n } else {\n throw new Error(\n `Error fetching latest block height: Expected type 'number' got '${typeof blockHeight}'`,\n );\n }\n } catch (error) {\n throw new Error(`Error fetching latest block height: ${error}`);\n }\n\n // If no end height is specified or is greater than the latest height, set the end height to the latest height\n if (typeof endHeight === \"number\" && endHeight <= latestHeight) {\n end = endHeight;\n } else {\n end = latestHeight;\n }\n\n // If the starting is greater than the ending height, return an error\n if (startHeight > end) {\n throw new Error(\n \"Start height must be less than or equal to end height.\",\n );\n }\n\n // Iterate through blocks in reverse order in chunks of 50\n while (end > startHeight) {\n start = end - 50;\n if (start < startHeight) {\n start = startHeight;\n }\n try {\n // Get 50 blocks (or the difference between the start and end if less than 50)\n const blocks = await this.getBlockRange(start, end);\n end = start;\n // Iterate through blocks to find unspent records\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n const transactions = block.transactions;\n if (!(typeof transactions === \"undefined\")) {\n for (let j = 0; j < transactions.length; j++) {\n const confirmedTransaction = transactions[j];\n // Search for unspent records in execute transactions of credits.aleo\n if (confirmedTransaction.type == \"execute\") {\n const transaction =\n confirmedTransaction.transaction;\n if (\n transaction.execution &&\n !(\n typeof transaction.execution\n .transitions == \"undefined\"\n )\n ) {\n for (\n let k = 0;\n k <\n transaction.execution.transitions\n .length;\n k++\n ) {\n const transition =\n transaction.execution.transitions[\n k\n ];\n // Only search for unspent records in the specified programs.\n if (\n !(typeof programs === \"undefined\")\n ) {\n if (\n !programs.includes(\n transition.program,\n )\n ) {\n continue;\n }\n }\n if (\n !(\n typeof transition.outputs ==\n \"undefined\"\n )\n ) {\n for (\n let l = 0;\n l < transition.outputs.length;\n l++\n ) {\n const output =\n transition.outputs[l];\n if (output.type === \"record\") {\n try {\n // Create a wasm record ciphertext object from the found output\n const record =\n RecordCiphertext.fromString(\n output.value,\n );\n // Determine if the record is owned by the specified view key\n if (\n record.isOwner(\n viewKey,\n )\n ) {\n // Decrypt the record and get the serial number\n const recordPlaintext =\n record.decrypt(\n viewKey,\n );\n\n // If the record has already been found, skip it\n const nonce =\n recordPlaintext.nonce();\n if (\n nonces.includes(\n nonce,\n )\n ) {\n continue;\n }\n\n if (unspent) {\n const recordViewKey = recordPlaintext.recordViewKey(viewKey).toString();\n // Otherwise record the nonce that has been found\n const serialNumber =\n recordPlaintext.serialNumberString(\n resolvedPrivateKey,\n \"credits.aleo\",\n \"credits\",\n recordViewKey\n );\n // Attempt to see if the serial number is spent\n try {\n await retryWithBackoff(\n () =>\n this.getTransitionId(\n serialNumber,\n ),\n );\n continue;\n } catch (error) {\n console.log(\n \"Found unspent record!\",\n );\n }\n }\n\n // Add the record to the list of records if the user did not specify amounts.\n if (!amounts) {\n records.push(\n recordPlaintext,\n );\n // If the user specified a maximum number of microcredits, check if the search has found enough\n if (\n typeof maxMicrocredits ===\n \"number\"\n ) {\n totalRecordValue +=\n recordPlaintext.microcredits();\n // Exit if the search has found the amount specified\n if (\n totalRecordValue >=\n BigInt(\n maxMicrocredits,\n )\n ) {\n return records;\n }\n }\n }\n\n // If the user specified a list of amounts, check if the search has found them\n if (\n !(\n typeof amounts ===\n \"undefined\"\n ) &&\n amounts.length >\n 0\n ) {\n let amounts_found = 0;\n if (\n recordPlaintext.microcredits() >\n amounts[\n amounts_found\n ]\n ) {\n amounts_found += 1;\n records.push(\n recordPlaintext,\n );\n // If the user specified a maximum number of microcredits, check if the search has found enough\n if (\n typeof maxMicrocredits ===\n \"number\"\n ) {\n totalRecordValue +=\n recordPlaintext.microcredits();\n // Exit if the search has found the amount specified\n if (\n totalRecordValue >=\n BigInt(\n maxMicrocredits,\n )\n ) {\n return records;\n }\n }\n if (\n records.length >=\n amounts.length\n ) {\n return records;\n }\n }\n }\n }\n } catch (error) {}\n }\n }\n }\n }\n }\n }\n }\n }\n }\n } catch (error) {\n // If there is an error fetching blocks, log it and keep searching\n console.warn(\n \"Error fetching blocks in range: \" +\n start.toString() +\n \"-\" +\n end.toString(),\n );\n console.warn(\"Error: \", error);\n failures += 1;\n if (failures > 10) {\n console.warn(\n \"10 failures fetching records reached. Returning records fetched so far\",\n );\n return records;\n }\n }\n }\n return records;\n }\n\n /**\n * Attempts to find unspent records in the Aleo blockchain.\n *\n * @param {number} startHeight - The height at which to start searching for unspent records\n * @param {number} endHeight - The height at which to stop searching for unspent records\n * @param {string[]} programs - The program(s) to search for unspent records in\n * @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])\n * @param {number} maxMicrocredits - The maximum number of microcredits to search for\n * @param {string[]} nonces - The nonces of already found records to exclude from the search\n * @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.\n * @returns {Promise<Array<RecordPlaintext>>} An array of unspent records belonging to the account configured in the network client.\n *\n * @example\n * import { Account, AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n *\n * // Create a network client and set an account to search for records with.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * networkClient.setAccount(account);\n *\n * // Find specific amounts\n * const startHeight = 500000;\n * const endHeight = 550000;\n * const amounts = [600000, 1000000];\n * const records = networkClient.findUnspentRecords(startHeight, endHeight, [\"credits.aleo\"], amounts);\n *\n * // Find specific amounts with a maximum number of cumulative microcredits\n * const maxMicrocredits = 100000;\n * const records = networkClient.findUnspentRecords(startHeight, undefined, [\"credits.aleo\"], undefined, maxMicrocredits);\n */\n async findUnspentRecords(\n startHeight: number,\n endHeight: number | undefined,\n programs?: string[],\n amounts?: number[] | undefined,\n maxMicrocredits?: number | undefined,\n nonces?: string[] | undefined,\n privateKey?: string | PrivateKey | undefined,\n ): Promise<Array<RecordPlaintext>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"findUnspentRecords\" };\n return await this.findRecords(\n startHeight,\n endHeight,\n true,\n programs,\n amounts,\n maxMicrocredits,\n nonces,\n privateKey,\n );\n } catch (error) {\n throw new Error(\"Error finding unspent records: \" + error);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the contents of the block at the specified block height.\n *\n * @param {number} blockHeight - The height of the block to fetch\n * @returns {Promise<BlockJSON>} A javascript object containing the block at the specified height\n *\n * @example\n * const block = networkClient.getBlock(1234);\n */\n async getBlock(blockHeight: number): Promise<BlockJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getBlock\" };\n const block = await this.fetchData<BlockJSON>(\n \"/block/\" + blockHeight,\n );\n return block;\n } catch (error) {\n throw new Error(`Error fetching block ${blockHeight}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the contents of the block with the specified hash.\n *\n * @param {string} blockHash The hash of the block to fetch.\n * @returns {Promise<BlockJSON>} A javascript object representation of the block matching the hash.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const block = networkClient.getBlockByHash(\"ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9\");\n */\n async getBlockByHash(blockHash: string): Promise<BlockJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getBlockByHash\" };\n const block = await this.fetchData<BlockJSON>(\n `/block/${blockHash}`,\n );\n return block;\n } catch (error) {\n throw new Error(`Error fetching block ${blockHash}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a range of blocks between the specified block heights. A maximum of 50 blocks can be fetched at a time.\n *\n * @param {number} start Starting block to fetch.\n * @param {number} end Ending block to fetch. This cannot be more than 50 blocks ahead of the start block.\n * @returns {Promise<Array<BlockJSON>>} An array of block objects\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Fetch 50 blocks.\n * const (start, end) = (2050, 2100);\n * const blockRange = networkClient.getBlockRange(start, end);\n *\n * let cursor = start;\n * blockRange.forEach((block) => {\n * assert(block.height == cursor);\n * cursor += 1;\n * }\n */\n async getBlockRange(start: number, end: number): Promise<Array<BlockJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getBlockRange\" };\n return await this.fetchData<Array<BlockJSON>>(\n \"/blocks?start=\" + start + \"&end=\" + end,\n );\n } catch (error) {\n throw new Error(\n `Error fetching blocks between ${start} and ${end}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the deployment transaction id associated with the specified program.\n *\n * @param {Program | string} program The name of the deployed program OR a wasm Program object.\n * @returns {Promise<string>} The transaction ID of the deployment transaction.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/testnet.js\";\n *\n * // Get the transaction ID of the deployment transaction for a program.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const transactionId = networkClient.getDeploymentTransactionIDForProgram(\"hello_hello.aleo\");\n *\n * // Get the transaction data for the deployment transaction.\n * const transaction = networkClient.getTransactionObject(transactionId);\n *\n * // Get the verifying keys for the functions in the deployed program.\n * const verifyingKeys = transaction.verifyingKeys();\n */\n async getDeploymentTransactionIDForProgram(\n program: Program | string,\n ): Promise<string> {\n this.ctx = { \"X-ALEO-METHOD\": \"getDeploymentTransactionIDForProgram\" };\n if (program instanceof Program) {\n program = program.id();\n }\n try {\n const id = await this.fetchData<string>(\n \"/find/transactionID/deployment/\" + program,\n );\n return id.replace('\"', \"\");\n } catch (error) {\n throw new Error(\n `Error fetching deployment transaction for program ${program}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the deployment transaction associated with a specified program as a JSON object.\n *\n * @param {Program | string} program The name of the deployed program OR a wasm Program object.\n * @returns {Promise<Transaction>} JSON representation of the deployment transaction.\n *\n * @example\n * import { AleoNetworkClient, DeploymentJSON } from \"@provablehq/sdk/testnet.js\";\n *\n * // Get the transaction ID of the deployment transaction for a program.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const transaction = networkClient.getDeploymentTransactionForProgram(\"hello_hello.aleo\");\n *\n * // Get the verifying keys for each function in the deployment.\n * const deployment = <DeploymentJSON>transaction.deployment;\n * const verifyingKeys = deployment.verifying_keys;\n */\n async getDeploymentTransactionForProgram(\n program: Program | string,\n ): Promise<TransactionJSON> {\n if (program instanceof Program) {\n program = program.id();\n }\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getDeploymentTransactionForProgram\" };\n const transaction_id = <string>(\n await this.getDeploymentTransactionIDForProgram(program)\n );\n return <TransactionJSON>await this.getTransaction(transaction_id);\n } catch (error) {\n throw new Error(\n `Error fetching deployment transaction for program ${program}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the deployment transaction associated with a specified program as a wasm object.\n *\n * @param {Program | string} program The name of the deployed program OR a wasm Program object.\n * @returns {Promise<Transaction>} Wasm object representation of the deployment transaction.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/testnet.js\";\n *\n * // Get the transaction ID of the deployment transaction for a program.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const transactionId = networkClient.getDeploymentTransactionIDForProgram(\"hello_hello.aleo\");\n *\n * // Get the transaction data for the deployment transaction.\n * const transaction = networkClient.getDeploymentTransactionObjectForProgram(transactionId);\n *\n * // Get the verifying keys for the functions in the deployed program.\n * const verifyingKeys = transaction.verifyingKeys();\n */\n async getDeploymentTransactionObjectForProgram(\n program: Program | string,\n ): Promise<Transaction> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getDeploymentTransactionObjectForProgram\" };\n const transaction_id = <string>(\n await this.getDeploymentTransactionIDForProgram(program)\n );\n return await this.getTransactionObject(transaction_id);\n } catch (error) {\n throw new Error(\n `Error fetching deployment transaction for program ${program}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the contents of the latest block as JSON.\n *\n * @returns {Promise<BlockJSON>} A javascript object containing the latest block\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/testnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const latestHeight = networkClient.getLatestBlock();\n */\n async getLatestBlock(): Promise<BlockJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestBlock\" };\n return (await this.fetchData<BlockJSON>(\n \"/block/latest\",\n )) as BlockJSON;\n } catch (error) {\n throw new Error(`Error fetching latest block: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest committee.\n *\n * @returns {Promise<object>} A javascript object containing the latest committee\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Create a network client and get the latest committee.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const latestCommittee = await networkClient.getLatestCommittee();\n */\n async getLatestCommittee(): Promise<object> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestCommittee\" };\n return await this.fetchData<object>(\"/committee/latest\");\n } catch (error) {\n throw new Error(`Error fetching latest committee: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the committee at the specified block height.\n *\n * @param {number} blockHeight - The height of the block to fetch the committee for\n * @returns {Promise<object>} A javascript object containing the committee\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Create a network client and get the committee for a specific block.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const committee = await networkClient.getCommitteeByBlockHeight(1234);\n */\n async getCommitteeByBlockHeight(blockHeight: number): Promise<object> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getCommitteeByBlockHeight\" };\n return await this.fetchData<object>(`/committee/${blockHeight}`);\n } catch (error) {\n throw new Error(\n `Error fetching committee at height ${blockHeight}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest block height.\n *\n * @returns {Promise<number>} The latest block height.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const latestHeight = networkClient.getLatestHeight();\n */\n async getLatestHeight(): Promise<number> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestHeight\" };\n return Number(await this.fetchData<bigint>(\"/block/height/latest\"));\n } catch (error) {\n throw new Error(`Error fetching latest height: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest block hash.\n *\n * @returns {Promise<string>} The latest block hash.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the latest block hash.\n * const latestHash = networkClient.getLatestBlockHash();\n */\n async getLatestBlockHash(): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestBlockHash\" };\n return String(await this.fetchData<string>(\"/block/hash/latest\"));\n } catch (error) {\n throw new Error(`Error fetching latest hash: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the source code of a program given a program ID.\n *\n * @param {string} programId The program ID of a program deployed to the Aleo Network.\n * @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.\n * @returns {Promise<string>} The source code of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the source code of a program.)\n * @returns {Promise<string>} Source code of the program\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const program = networkClient.getProgram(\"hello_hello.aleo\");\n * const expectedSource = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\"\n * assert.equal(program, expectedSource);\n */\n async getProgram(programId: string, edition?: number): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramVersion\" };\n if (typeof edition === \"number\") {\n return await this.fetchData<string>(\n `/program/${programId}/${edition}`,\n );\n } else {\n return await this.fetchData<string>(\"/program/\" + programId);\n }\n } catch (error) {\n throw new Error(`Error fetching program ${programId}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the current program edition deployed on the Aleo network.\n *\n * @param {string} programId The program ID of a program deployed to the Aleo Network.\n * @returns {Promise<number>} The edition of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const programVersion = networkClient.getLatestProgramEdition(\"hello_hello.aleo\");\n * assert.equal(programVersion, 1);\n */\n async getLatestProgramEdition(programId: string): Promise<number> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getLatestProgramEdition\" };\n const raw = await this.fetchRaw(\"/program/\" + programId + \"/latest_edition\");\n return JSON.parse(raw);\n } catch (error) {\n throw new Error(`Error fetching program ${programId}: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a program object from a program ID or program source code.\n *\n * @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network.\n * @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.\n * @returns {Promise<Program>} Source code of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const programID = \"hello_hello.aleo\";\n * const programSource = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\"\n *\n * // Get program object from program ID or program source code\n * const programObjectFromID = await networkClient.getProgramObject(programID);\n * const programObjectFromSource = await networkClient.getProgramObject(programSource);\n *\n * // Both program objects should be equal\n * assert(programObjectFromID.to_string() === programObjectFromSource.to_string());\n */\n async getProgramObject(inputProgram: string, edition?: number): Promise<Program> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramObject\" };\n return Program.fromString(\n <string>await this.getProgram(inputProgram, edition),\n );\n } catch (error) {\n throw new Error(\n `${inputProgram} is neither a program name or a valid program: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns an object containing the source code of a program and the source code of all programs it imports\n *\n * @param {Program | string} inputProgram The program ID or program source code of a program deployed to the Aleo Network\n * @returns {Promise<ProgramImports>} Object of the form { \"program_id\": \"program_source\", .. } containing program id & source code for all program imports\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * const double_test_source = \"import multiply_test.aleo;\\n\\nprogram double_test.aleo;\\n\\nfunction double_it:\\n input r0 as u32.private;\\n call multiply_test.aleo/multiply 2u32 r0 into r1;\\n output r1 as u32.private;\\n\"\n * const double_test = Program.fromString(double_test_source);\n * const expectedImports = {\n * \"multiply_test.aleo\": \"program multiply_test.aleo;\\n\\nfunction multiply:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n mul r0 r1 into r2;\\n output r2 as u32.private;\\n\"\n * }\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Imports can be fetched using the program ID, source code, or program object\n * let programImports = await networkClient.getProgramImports(\"double_test.aleo\");\n * assert.deepStrictEqual(programImports, expectedImports);\n *\n * // Using the program source code\n * programImports = await networkClient.getProgramImports(double_test_source);\n * assert.deepStrictEqual(programImports, expectedImports);\n *\n * // Using the program object\n * programImports = await networkClient.getProgramImports(double_test);\n * assert.deepStrictEqual(programImports, expectedImports);\n */\n async getProgramImports(inputProgram: Program | string, imports: ProgramImports = {}): Promise<ProgramImports> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramImports\" };\n\n // Normalize input to a Program object\n let program: Program;\n if (inputProgram instanceof Program) {\n program = inputProgram;\n } else {\n try {\n program = Program.fromString(inputProgram);\n } catch {\n try {\n program = await this.getProgramObject(inputProgram);\n } catch (error2) {\n throw new Error(\n `${inputProgram} is neither a program name nor a valid program: ${error2}`,\n );\n }\n }\n }\n\n // Get the list of programs that the program imports\n const importList = program.getImports();\n\n // Recursively get any imports that the imported programs have in a depth-first search\n for (let i = 0; i < importList.length; i++) {\n const import_id = importList[i];\n if (!imports.hasOwnProperty(import_id)) {\n const programSource = <string>await this.getProgram(import_id);\n const nestedImports = <ProgramImports>await this.getProgramImports(programSource, imports);\n\n for (const key in nestedImports) {\n if (!imports.hasOwnProperty(key)) {\n imports[key] = nestedImports[key];\n }\n }\n\n imports[import_id] = programSource;\n }\n }\n\n return imports;\n } catch (error: any) {\n logAndThrow(\"Error fetching program imports: \" + error.message);\n } finally {\n this.ctx = {};\n }\n }\n\n\n /**\n * Get a list of the program names that a program imports.\n *\n * @param {Program | string} inputProgram - The program id or program source code to get the imports of\n * @returns {string[]} - The list of program names that the program imports\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const programImportsNames = networkClient.getProgramImports(\"wrapped_credits.aleo\");\n * const expectedImportsNames = [\"credits.aleo\"];\n * assert.deepStrictEqual(programImportsNames, expectedImportsNames);\n */\n async getProgramImportNames(\n inputProgram: Program | string,\n ): Promise<string[]> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramImportNames\" };\n const program =\n inputProgram instanceof Program\n ? inputProgram\n : <Program>await this.getProgramObject(inputProgram);\n return program.getImports();\n } catch (error: any) {\n throw new Error(\n `Error fetching imports for program ${inputProgram instanceof Program ? inputProgram.id() : inputProgram}: ${error.message}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the names of the mappings of a program.\n *\n * @param {string} programId - The program ID to get the mappings of (e.g. \"credits.aleo\")\n * @returns {Promise<Array<string>>} - The names of the mappings of the program.\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const mappings = networkClient.getProgramMappingNames(\"credits.aleo\");\n * const expectedMappings = [\n * \"committee\",\n * \"delegated\",\n * \"metadata\",\n * \"bonded\",\n * \"unbonding\",\n * \"account\",\n * \"withdraw\"\n * ];\n * assert.deepStrictEqual(mappings, expectedMappings);\n */\n async getProgramMappingNames(programId: string): Promise<Array<string>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramMappingNames\" };\n return await this.fetchData<Array<string>>(\n `/program/${programId}/mappings`,\n );\n } catch (error) {\n throw new Error(\n `Error fetching mappings for program ${programId} - ensure the program exists on chain before trying again: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the value of a program's mapping for a specific key.\n *\n * @param {string} programId - The program ID to get the mapping value of (e.g. \"credits.aleo\")\n * @param {string} mappingName - The name of the mapping to get the value of (e.g. \"account\")\n * @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the \"account\" mapping)\n * @returns {Promise<string>} String representation of the value of the mapping\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get public balance of an account\n * const mappingValue = networkClient.getMappingValue(\"credits.aleo\", \"account\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\");\n * const expectedValue = \"0u64\";\n * assert(mappingValue === expectedValue);\n */\n async getProgramMappingValue(\n programId: string,\n mappingName: string,\n key: string | Plaintext,\n ): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramMappingValue\" };\n const keyString = key instanceof Plaintext ? key.toString() : key;\n return await this.fetchData<string>(\n `/program/${programId}/mapping/${mappingName}/${keyString}`,\n );\n } catch (error) {\n throw new Error(\n `Error fetching value for key '${key}' in mapping '${mappingName}' in program '${programId}' - ensure the mapping exists and the key is correct: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.\n *\n * @param {string} programId - The program ID to get the mapping value of (e.g. \"credits.aleo\")\n * @param {string} mappingName - The name of the mapping to get the value of (e.g. \"bonded\")\n * @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the \"bonded\" mapping)\n * @returns {Promise<Plaintext>} String representation of the value of the mapping\n *\n * @example\n * import { AleoNetworkClient } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the bond state as an account.\n * const unbondedState = networkClient.getMappingPlaintext(\"credits.aleo\", \"bonded\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\");\n *\n * // Get the two members of the object individually.\n * const validator = unbondedState.getMember(\"validator\");\n * const microcredits = unbondedState.getMember(\"microcredits\");\n *\n * // Ensure the expected values are correct.\n * assert.equal(validator, \"aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd\");\n * assert.equal(microcredits, BigInt(\"9007199254740991\"));\n *\n * // Get a JS object representation of the unbonded state.\n * const unbondedStateObject = unbondedState.toObject();\n *\n * const expectedState = {\n * validator: \"aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd\",\n * microcredits: BigInt(9007199254740991)\n * };\n * assert.equal(unbondedState, expectedState);\n */\n async getProgramMappingPlaintext(\n programId: string,\n mappingName: string,\n key: string | Plaintext,\n ): Promise<Plaintext> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getProgramMappingPlaintext\" };\n const keyString = key instanceof Plaintext ? key.toString() : key;\n const value = await this.fetchRaw(\n `/program/${programId}/mapping/${mappingName}/${keyString}`,\n );\n return Plaintext.fromString(JSON.parse(value));\n } catch (error) {\n throw new Error(\"Failed to fetch mapping value.\" + error);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the public balance of an address from the account mapping in credits.aleo\n *\n * @param {Address | string} address A string or wasm object representing an address.\n * @returns {Promise<number>} The public balance of the address in microcredits.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the balance of an account from either an address object or address string.\n * const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);\n * const publicBalance = await networkClient.getPublicBalance(account.address());\n * const publicBalanceFromString = await networkClient.getPublicBalance(account.address().to_string());\n * assert(publicBalance === publicBalanceFromString);\n */\n async getPublicBalance(address: Address | string): Promise<number> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getPublicBalance\" };\n const addressString =\n address instanceof Address ? address.to_string() : address;\n const balanceStr = await this.getProgramMappingValue(\n \"credits.aleo\",\n \"account\",\n addressString,\n );\n return balanceStr ? parseInt(balanceStr) : 0;\n } catch (error) {\n throw new Error(\n `Error fetching public balance for ${address}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the latest state/merkle root of the Aleo blockchain.\n *\n * @returns {Promise<string>} A string representing the latest state root of the Aleo blockchain.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the latest state root.\n * const stateRoot = networkClient.getStateRoot();\n */\n async getStateRoot(): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getStateRoot\" };\n return await this.fetchData<string>(\"/stateRoot/latest\");\n } catch (error) {\n throw new Error(`Error fetching latest state root: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a transaction by its unique identifier.\n *\n * @param {string} transactionId The transaction ID to fetch.\n * @returns {Promise<TransactionJSON>} A json representation of the transaction.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transaction = networkClient.getTransaction(\"at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj\");\n */\n async getTransaction(transactionId: string): Promise<TransactionJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransaction\" };\n return await this.fetchData<TransactionJSON>(\n \"/transaction/\" + transactionId,\n );\n } catch (error) {\n throw new Error(\n `Error fetching transaction ${transactionId}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a confirmed transaction by its unique identifier.\n *\n * @param {string} transactionId The transaction ID to fetch.\n * @returns {Promise<ConfirmedTransactionJSON>} A json object containing the confirmed transaction.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transaction = networkClient.getConfirmedTransaction(\"at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj\");\n * assert.equal(transaction.status, \"confirmed\");\n */\n async getConfirmedTransaction(\n transactionId: string,\n ): Promise<ConfirmedTransactionJSON> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getConfirmedTransaction\" };\n return await this.fetchData<ConfirmedTransactionJSON>(\n `/transaction/confirmed/${transactionId}`,\n );\n } catch (error) {\n throw new Error(\n `Error fetching confirmed transaction ${transactionId}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,\n * outputs, and records to be searched for and displayed.\n *\n * @param {string} transactionId - The unique identifier of the transaction to fetch\n * @returns {Promise<Transaction>} A wasm object representation of the transaction.\n *\n * @example\n * const transactionObject = networkClient.getTransaction(\"at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj\");\n * // Get the transaction inputs as a JS array.\n * const transactionInputs = transactionObject.inputs(true);\n *\n * // Get the transaction outputs as a JS object.\n * const transactionOutputs = transactionObject.outputs(true);\n *\n * // Get any records generated in transitions in the transaction as a JS object.\n * const records = transactionObject.records();\n *\n * // Get the transaction type.\n * const transactionType = transactionObject.transactionType();\n * assert.equal(transactionType, \"Execute\");\n *\n * // Get a JS representation of all inputs, outputs, and transaction metadata.\n * const transactionSummary = transactionObject.summary();\n */\n async getTransactionObject(transactionId: string): Promise<Transaction> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactionObject\" };\n const transaction = await this.fetchRaw(\n \"/transaction/\" + transactionId,\n );\n return Transaction.fromString(transaction);\n } catch (error) {\n throw new Error(\n `Error fetching transaction object ${transactionId}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the transactions present at the specified block height.\n *\n * @param {number} blockHeight The block height to fetch the confirmed transactions at.\n * @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block height.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transactions = networkClient.getTransactions(654);\n */\n async getTransactions(\n blockHeight: number,\n ): Promise<Array<ConfirmedTransactionJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactions\" };\n return await this.fetchData<Array<ConfirmedTransactionJSON>>(\n \"/block/\" + blockHeight.toString() + \"/transactions\",\n );\n } catch (error) {\n throw new Error(`Error fetching transactions: ${error}`);\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the confirmed transactions present in the block with the specified block hash.\n *\n * @param {string} blockHash The block hash to fetch the confirmed transactions at.\n * @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block hash.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * const transactions = networkClient.getTransactionsByBlockHash(\"ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9\");\n */\n async getTransactionsByBlockHash(\n blockHash: string,\n ): Promise<Array<ConfirmedTransactionJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactionsByBlockHash\" };\n const block = await this.fetchData<BlockJSON>(\n `/block/${blockHash}`,\n );\n const height = block.header.metadata.height;\n return await this.getTransactions(Number(height));\n } catch (error) {\n throw new Error(\n `Error fetching transactions for block ${blockHash}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the transactions in the memory pool. This method requires access to a validator's REST API.\n *\n * @returns {Promise<Array<TransactionJSON>>} An array of transactions (in JSON format) currently in the mempool.\n *\n * @example\n * import { AleoNetworkClient, Account } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n *\n * // Get the current transactions in the mempool.\n * const transactions = networkClient.getTransactionsInMempool();\n */\n async getTransactionsInMempool(): Promise<Array<TransactionJSON>> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransactionsInMempool\" };\n return await this.fetchData<Array<TransactionJSON>>(\n \"/memoryPool/transactions\",\n );\n } catch (error) {\n throw new Error(\n `Error fetching transactions from mempool: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Returns the transition ID of the transition corresponding to the ID of the input or output.\n * @param {string} inputOrOutputID - The unique identifier of the input or output to find the transition ID for\n * @returns {Promise<string>} - The transition ID of the input or output ID.\n *\n * @example\n * const transitionId = networkClient.getTransitionId(\"2429232855236830926144356377868449890830704336664550203176918782554219952323field\");\n */\n async getTransitionId(inputOrOutputID: string): Promise<string> {\n try {\n this.ctx = { \"X-ALEO-METHOD\": \"getTransitionId\" };\n return await this.fetchData<string>(\n \"/find/transitionID/\" + inputOrOutputID,\n );\n } catch (error) {\n throw new Error(\n `Error fetching transition ID for input/output ${inputOrOutputID}: ${error}`,\n );\n } finally {\n this.ctx = {};\n }\n }\n\n /**\n * Submit an execute or deployment transaction to the Aleo network.\n *\n * @param {Transaction | string} transaction - The transaction to submit, either as a Transaction object or string representation\n * @returns {Promise<string>} - The transaction id of the submitted transaction or the resulting error\n */\n async submitTransaction(\n transaction: Transaction | string,\n ): Promise<string> {\n const transactionString =\n transaction instanceof Transaction\n ? transaction.toString()\n : transaction;\n try {\n const endpoint = this.verboseErrors ? \"transaction/broadcast?check_transaction=true\" : \"transaction/broadcast\";\n const response = await retryWithBackoff(() =>\n this._sendPost(`${this.host}/${endpoint}`, {\n body: transactionString,\n headers: Object.assign({}, {...this.headers, \"X-ALEO-METHOD\" : \"submitTransaction\"}, {\n \"Content-Type\": \"application/json\",\n }),\n }),\n );\n\n try {\n const text = await response.text();\n return parseJSON(text);\n } catch (error: any) {\n throw new Error(\n `Error posting transaction. Aleo network response: ${error.message}`,\n );\n }\n } catch (error: any) {\n throw new Error(\n `Error posting transaction: ${error}`,\n );\n }\n }\n\n /**\n * Submit a solution to the Aleo network.\n *\n * @param {string} solution - The string representation of the solution to submit\n * @returns {Promise<string>} The solution id of the submitted solution or the resulting error.\n */\n async submitSolution(solution: string): Promise<string> {\n try {\n const response = await retryWithBackoff(() =>\n post(this.host + \"/solution/broadcast\", {\n body: solution,\n headers: Object.assign({}, {...this.headers, \"X-ALEO-METHOD\": \"submitSolution\"}, {\n \"Content-Type\": \"application/json\",\n }),\n }),\n );\n\n try {\n const text = await response.text();\n return parseJSON(text);\n } catch (error: any) {\n throw new Error(\n `Error posting solution. Aleo network response: ${error.message}`,\n );\n }\n } catch (error: any) {\n throw new Error(\n `Error posting solution: No response received: ${error.message}`,\n );\n }\n }\n\n /**\n * Refreshes the JWT by making a POST request to /jwts/{consumer_id}\n * \n * @param {string} apiKey - The API key for authentication.\n * @param {string} consumerId - The consumer ID associated with the API key.\n * @returns {Promise<JwtData>} The JWT token and expiration time\n */\n private async refreshJwt(apiKey: string, consumerId: string): Promise<JWTData> {\n if (!apiKey || !consumerId) {\n throw new Error('API key and consumer ID are required to refresh JWT');\n }\n const response = await post(\n `https://api.provable.com/jwts/${consumerId}`,\n {\n headers: {\n 'X-Provable-API-Key': apiKey\n }\n }\n );\n const authHeader = response.headers.get('authorization');\n if (!authHeader) {\n throw new Error('No authorization header in JWT refresh response');\n }\n const body = await response.json();\n \n return {\n jwt: authHeader,\n expiration: body.exp * 1000 // Convert to milliseconds\n };\n }\n\n /**\n * Submit a `ProvingRequest` to a remote proving service for delegated proving. If the broadcast flag of the `ProvingRequest` is set to `true` the remote service will attempt to broadcast the result `Transaction` on behalf of the requestor.\n *\n * @param {DelegatedProvingParams} options - The optional parameters required to submit a proving request.\n * @returns {Promise<ProvingResponse>} The ProvingResponse containing the transaction result and the result of the broadcast if the `broadcast` flag was set to `true`.\n */\n async submitProvingRequest(options: DelegatedProvingParams): Promise<ProvingResponse> {\n const proverUri = options.url ?? this.host;\n const provingRequestString = options.provingRequest instanceof ProvingRequest\n ? options.provingRequest.toString()\n : options.provingRequest;\n\n const apiKey = options.apiKey ?? this.apiKey;\n const consumerId = options.consumerId ?? this.consumerId; \n let jwtData = options.jwtData ?? this.jwtData\n\n // Check if JWT is expired or missing\n const bufferTime = FIVE_MINUTES; // 5 minutes buffer\n const isExpired = jwtData && Date.now() >= jwtData.expiration - bufferTime;\n if (!jwtData || isExpired) {\n if (options.apiKey && options.consumerId) {\n jwtData = await this.refreshJwt(apiKey!, consumerId!);\n // Update both the class and the options with the new JWT\n this.jwtData = jwtData;\n options.jwtData = jwtData;\n } else {\n throw new Error('JWT or both apiKey and consumerId are required');\n }\n }\n\n const headers: Record<string, string> = {\n ...this.headers,\n \"X-ALEO-METHOD\": \"submitProvingRequest\",\n \"Content-Type\": \"application/json\",\n };\n if (jwtData?.jwt) {\n headers[\"Authorization\"] = jwtData.jwt;\n }\n\n try {\n const response = await retryWithBackoff(() =>\n post(`${proverUri}`, {\n body: provingRequestString,\n headers\n })\n );\n const responseText = await response.text();\n return parseJSON(responseText);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error';\n throw new Error(`Failed to submit proving request: ${errorMessage}`);\n }\n }\n\n /**\n * Await a submitted transaction to be confirmed or rejected on the Aleo network.\n *\n * @param {string} transactionId - The transaction ID to wait for confirmation\n * @param {number} checkInterval - The interval in milliseconds to check for confirmation (default: 2000)\n * @param {number} timeout - The maximum time in milliseconds to wait for confirmation (default: 45000)\n * @returns {Promise<Transaction>} The confirmed transaction object that returns if the transaction is confirmed.\n *\n * @example\n * import { AleoNetworkClient, Account, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a network client and program manager.\n * const networkClient = new AleoNetworkClient(\"http://api.explorer.provable.com/v1\", undefined);\n * const programManager = new ProgramManager(networkClient);\n *\n * // Set the account for the program manager.\n * programManager.setAccount(Account.fromCiphertext(process.env.ciphertext, process.env.password));\n *\n * // Build a transfer transaction.\n * const tx = await programManager.buildTransferPublicTransaction(100, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", 0);\n *\n * // Submit the transaction to the network.\n * const transactionId = await networkClient.submitTransaction(tx);\n *\n * // Wait for the transaction to be confirmed.\n * const transaction = await networkClient.waitForTransactionConfirmation(transactionId);\n */\n async waitForTransactionConfirmation(\n transactionId: string,\n checkInterval: number = 2000,\n timeout: number = 45000,\n ): Promise<ConfirmedTransactionJSON> {\n const startTime = Date.now();\n\n return new Promise((resolve, reject) => {\n const interval = setInterval(async () => {\n const elapsed = Date.now() - startTime;\n\n if (elapsed > timeout) {\n clearInterval(interval);\n return reject(\n new Error(\n `Transaction ${transactionId} did not appear after the timeout period of ${interval}ms - consider resubmitting the transaction`,\n ),\n );\n }\n\n try {\n const res = await fetch(\n `${this.host}/transaction/confirmed/${transactionId}`,\n {\n headers: {\n ...this.headers,\n \"X-ALEO-METHOD\" : \"waitForTransactionConfirmation\",\n },\n },\n );\n if (!res.ok) {\n let text = \"\";\n try {\n text = await res.text();\n console.warn(\"Response text from server:\", text);\n } catch (err) {\n console.warn(\"Failed to read response text:\", err);\n }\n\n // If the transaction ID is malformed (e.g. invalid checksum, wrong length),\n // the API returns a 4XX with \"Invalid URL\" — we treat this as a fatal error and stop polling.\n if (\n res.status >= 400 &&\n res.status < 500 &&\n text.includes(\"Invalid URL\")\n ) {\n clearInterval(interval);\n return reject(\n new Error(`Malformed transaction ID: ${text}`),\n );\n }\n\n // Log and continue polling for 404s or 5XX errors in case a tx doesn't exist yet\n console.warn(\n \"Non-OK response (retrying):\",\n res.status,\n text,\n );\n return;\n }\n\n const data = parseJSON(await res.text());\n if (data?.status === \"accepted\") {\n clearInterval(interval);\n return resolve(data);\n }\n\n if (data?.status === \"rejected\") {\n clearInterval(interval);\n return reject(\n new Error(\n `Transaction ${transactionId} was rejected by the network. Ensure that the account paying the fee has enough credits and that the inputs to the on-chain function are valid.`,\n ),\n );\n }\n } catch (err) {\n console.error(\"Polling error:\", err);\n }\n }, checkInterval);\n });\n }\n}\n\nexport { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports };","import {\n CREDITS_PROGRAM_KEYS,\n KEY_STORE,\n Key,\n PRIVATE_TRANSFER,\n PRIVATE_TO_PUBLIC_TRANSFER,\n PUBLIC_TRANSFER,\n PUBLIC_TO_PRIVATE_TRANSFER,\n PUBLIC_TRANSFER_AS_SIGNER,\n} from \"./constants.js\";\n\nimport {\n ProvingKey,\n VerifyingKey,\n} from \"./wasm.js\";\n\nimport { get } from \"./utils.js\";\n\ntype FunctionKeyPair = [ProvingKey, VerifyingKey];\ntype CachedKeyPair = [Uint8Array, Uint8Array];\ntype AleoKeyProviderInitParams = {\n proverUri?: string;\n verifierUri?: string;\n cacheKey?: string;\n};\n\n/**\n * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider\n * implementations.\n */\ninterface KeySearchParams {\n [key: string]: any; // This allows for arbitrary keys with any type values\n}\n\n/**\n * AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and\n * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.\n */\nclass AleoKeyProviderParams implements KeySearchParams {\n name: string | undefined;\n proverUri: string | undefined;\n verifierUri: string | undefined;\n cacheKey: string | undefined;\n\n /**\n * Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally\n * specify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique\n * cacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must\n * be provided.\n *\n * @param { AleoKeyProviderInitParams } params - Optional search parameters\n */\n constructor(params: {proverUri?: string, verifierUri?: string, cacheKey?: string, name?: string}) {\n this.proverUri = params.proverUri;\n this.verifierUri = params.verifierUri;\n this.cacheKey = params.cacheKey;\n this.name = params.name;\n }\n}\n\n/**\n * KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs.\n */\ninterface FunctionKeyProvider {\n /**\n * Get bond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function\n */\n bondPublicKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get bond_validator function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_validator function\n */\n bondValidatorKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\n * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.\n *\n * @param {string} keyId access key for the cache\n * @param {FunctionKeyPair} keys keys to cache\n */\n cacheKeys(keyId: string, keys: FunctionKeyPair): void;\n\n /**\n * Get unbond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function\n */\n claimUnbondPublicKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get arbitrary function keys from a provider\n *\n * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * // Create a search object which implements the KeySearchParams interface\n * class IndexDbSearch implements KeySearchParams {\n * db: string\n * keyId: string\n * constructor(params: {db: string, keyId: string}) {\n * this.db = params.db;\n * this.keyId = params.keyId;\n * }\n * }\n *\n * // Create a new object which implements the KeyProvider interface\n * class IndexDbKeyProvider implements FunctionKeyProvider {\n * async functionKeys(params: KeySearchParams): Promise<FunctionKeyPair> {\n * return new Promise((resolve, reject) => {\n * const request = indexedDB.open(params.db, 1);\n *\n * request.onupgradeneeded = function(e) {\n * const db = e.target.result;\n * if (!db.objectStoreNames.contains('keys')) {\n * db.createObjectStore('keys', { keyPath: 'id' });\n * }\n * };\n *\n * request.onsuccess = function(e) {\n * const db = e.target.result;\n * const transaction = db.transaction([\"keys\"], \"readonly\");\n * const store = transaction.objectStore(\"keys\");\n * const request = store.get(params.keyId);\n * request.onsuccess = function(e) {\n * if (request.result) {\n * resolve(request.result as FunctionKeyPair);\n * } else {\n * reject(new Error(\"Key not found\"));\n * }\n * };\n * request.onerror = function(e) { reject(new Error(\"Error fetching key\")); };\n * };\n *\n * request.onerror = function(e) { reject(new Error(\"Error opening database\")); };\n * });\n * }\n *\n * // implement the other methods...\n * }\n *\n *\n * const keyProvider = new AleoKeyProvider();\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const searchParams = new IndexDbSearch({db: \"keys\", keyId: \"credits.aleo:transferPrivate\"});\n * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(searchParams);\n */\n functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;\n\n /**\n * Get fee_private function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePrivateKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get fee_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePublicKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get keys for the inclusion proof.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n inclusionKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get join function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n joinKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get split function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n splitKeys(): Promise<FunctionKeyPair>;\n\n /**\n * Get keys for a variant of the transfer function from the credits.aleo program\n *\n * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function\n *\n * @example\n * // Create a new object which implements the KeyProvider interface\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys(\"public\");\n */\n transferKeys(visibility: string): Promise<FunctionKeyPair>;\n\n /**\n * Get unbond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n unBondPublicKeys(): Promise<FunctionKeyPair>;\n\n}\n\n\n/**\n * AleoKeyProvider class. Implements the KeyProvider interface. Enables the retrieval of Aleo program proving and\n * verifying keys for the credits.aleo program over http from official Aleo sources and storing and retrieving function\n * keys from a local memory cache.\n */\nclass AleoKeyProvider implements FunctionKeyProvider {\n cache: Map<string, CachedKeyPair>;\n cacheOption: boolean;\n keyUris: string;\n\n async fetchBytes(\n url = \"/\",\n ): Promise<Uint8Array> {\n try {\n const response = await get(url);\n const data = await response.arrayBuffer();\n return new Uint8Array(data);\n } catch (error: any) {\n throw new Error(\"Error fetching data.\" + error.message);\n }\n }\n\n constructor() {\n this.keyUris = KEY_STORE;\n this.cache = new Map<string, CachedKeyPair>();\n this.cacheOption = false;\n }\n\n /**\n * Use local memory to store keys\n *\n * @param {boolean} useCache whether to store keys in local memory\n */\n useCache(useCache: boolean) {\n this.cacheOption = useCache;\n }\n\n /**\n * Clear the key cache\n */\n clearCache() {\n this.cache.clear();\n }\n\n /**\n * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\n * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.\n *\n * @param {string} keyId access key for the cache\n * @param {FunctionKeyPair} keys keys to cache\n */\n cacheKeys(keyId: string, keys: FunctionKeyPair) {\n const [provingKey, verifyingKey] = keys;\n this.cache.set(keyId, [provingKey.toBytes(), verifyingKey.toBytes()]);\n }\n\n /**\n * Determine if a keyId exists in the cache\n *\n * @param {string} keyId keyId of a proving and verifying key pair\n * @returns {boolean} true if the keyId exists in the cache, false otherwise\n */\n containsKeys(keyId: string): boolean {\n return this.cache.has(keyId)\n }\n\n /**\n * Delete a set of keys from the cache\n *\n * @param {string} keyId keyId of a proving and verifying key pair to delete from memory\n * @returns {boolean} true if the keyId exists in the cache and was deleted, false if the key did not exist\n */\n deleteKeys(keyId: string): boolean {\n return this.cache.delete(keyId)\n }\n\n /**\n * Get a set of keys from the cache\n * @param keyId keyId of a proving and verifying key pair\n *\n * @returns {FunctionKeyPair} Proving and verifying keys for the specified program\n */\n getKeys(keyId: string): FunctionKeyPair {\n console.debug(`Checking if key exists in cache. KeyId: ${keyId}`)\n if (this.cache.has(keyId)) {\n const [provingKeyBytes, verifyingKeyBytes] = <CachedKeyPair>this.cache.get(keyId);\n return [ProvingKey.fromBytes(provingKeyBytes), VerifyingKey.fromBytes(verifyingKeyBytes)];\n } else {\n throw new Error(\"Key not found in cache.\");\n }\n }\n\n /**\n * Get arbitrary function keys from a provider\n *\n * @param {KeySearchParams} params parameters for the key search in form of: {proverUri: string, verifierUri: string, cacheKey: string}\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * // Create a new object which implements the KeyProvider interface\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually using the key provider\n * const keySearchParams = { \"cacheKey\": \"myProgram:myFunction\" };\n * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(keySearchParams);\n */\n async functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair> {\n if (params) {\n let proverUrl;\n let verifierUrl;\n let cacheKey;\n if (\"name\" in params && typeof params[\"name\"] == \"string\") {\n let key = CREDITS_PROGRAM_KEYS.getKey(params[\"name\"]);\n return this.fetchCreditsKeys(key);\n }\n\n if (\"proverUri\" in params && typeof params[\"proverUri\"] == \"string\") {\n proverUrl = params[\"proverUri\"];\n }\n\n if (\"verifierUri\" in params && typeof params[\"verifierUri\"] == \"string\") {\n verifierUrl = params[\"verifierUri\"];\n }\n\n if (\"cacheKey\" in params && typeof params[\"cacheKey\"] == \"string\") {\n cacheKey = params[\"cacheKey\"];\n }\n\n if (proverUrl && verifierUrl) {\n return await this.fetchRemoteKeys(proverUrl, verifierUrl, cacheKey);\n }\n\n if (cacheKey) {\n return this.getKeys(cacheKey);\n }\n }\n throw new Error(\"Invalid parameters provided, must provide either a cacheKey and/or a proverUrl and a verifierUrl\");\n }\n\n /**\n * Returns the proving and verifying keys for a specified program from a specified url.\n *\n * @param {string} verifierUrl Url of the proving key\n * @param {string} proverUrl Url the verifying key\n * @param {string} cacheKey Key to store the keys in the cache\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * // Create a new AleoKeyProvider object\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.fetchKeys(\n * CREDITS_PROGRAM_KEYS.transfer_private.prover,\n * CREDITS_PROGRAM_KEYS.transfer_private.verifier,\n * );\n */\n async fetchRemoteKeys(proverUrl: string, verifierUrl: string, cacheKey?: string): Promise<FunctionKeyPair> {\n try {\n // If cache is enabled, check if the keys have already been fetched and return them if they have\n if (this.cacheOption) {\n if (!cacheKey) {\n cacheKey = proverUrl;\n }\n const value = this.cache.get(cacheKey);\n if (typeof value !== \"undefined\") {\n return [ProvingKey.fromBytes(value[0]), VerifyingKey.fromBytes(value[1])];\n } else {\n console.debug(\"Fetching proving keys from url \" + proverUrl);\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl))\n console.debug(\"Fetching verifying keys \" + verifierUrl);\n const verifyingKey = <VerifyingKey>(await this.getVerifyingKey(verifierUrl));\n this.cache.set(cacheKey, [provingKey.toBytes(), verifyingKey.toBytes()]);\n return [provingKey, verifyingKey];\n }\n }\n else {\n // If cache is disabled, fetch the keys and return them\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl))\n const verifyingKey = <VerifyingKey>(await this.getVerifyingKey(verifierUrl));\n return [provingKey, verifyingKey];\n }\n } catch (error: any) {\n throw new Error(`Error: ${error.message} fetching fee proving and verifying keys from ${proverUrl} and ${verifierUrl}.`);\n }\n }\n\n /***\n * Fetches the proving key from a remote source.\n *\n * @param proverUrl\n * @param cacheKey\n *\n * @returns {Promise<ProvingKey>} Proving key for the specified program\n */\n async fetchProvingKey(proverUrl: string, cacheKey?: string): Promise<ProvingKey> {\n try {\n // If cache is enabled, check if the keys have already been fetched and return them if they have\n if (this.cacheOption) {\n if (!cacheKey) {\n cacheKey = proverUrl;\n }\n const value = this.cache.get(cacheKey);\n if (typeof value !== \"undefined\") {\n return ProvingKey.fromBytes(value[0]);\n } else {\n console.debug(\"Fetching proving keys from url \" + proverUrl);\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl));\n return provingKey;\n }\n }\n else {\n const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl));\n return provingKey;\n }\n } catch (error: any) {\n throw new Error(`Error: ${error.message} fetching fee proving keys from ${proverUrl}`);\n }\n }\n\n async fetchCreditsKeys(key: Key): Promise<FunctionKeyPair> {\n try {\n if (!this.cache.has(key.locator) || !this.cacheOption) {\n const verifying_key = key.verifyingKey()\n const proving_key = <ProvingKey>await this.fetchProvingKey(key.prover, key.locator);\n if (this.cacheOption) {\n this.cache.set(CREDITS_PROGRAM_KEYS.getKey(key.name).locator, [proving_key.toBytes(), verifying_key.toBytes()]);\n }\n return [proving_key, verifying_key];\n } else {\n const keyPair = <CachedKeyPair>this.cache.get(key.locator);\n return [ProvingKey.fromBytes(keyPair[0]), VerifyingKey.fromBytes(keyPair[1])];\n }\n } catch (error: any) {\n throw new Error(`Error: fetching credits.aleo keys: ${error.message}`);\n }\n }\n\n async bondPublicKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_public);\n }\n\n bondValidatorKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_validator);\n }\n\n claimUnbondPublicKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public)\n }\n\n /**\n * Returns the proving and verifying keys for the transfer functions in the credits.aleo program\n * @param {string} visibility Visibility of the transfer function\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer functions\n *\n * @example\n * // Create a new AleoKeyProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for value transfers\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * // Keys can also be fetched manually\n * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys(\"public\");\n */\n async transferKeys(visibility: string): Promise<FunctionKeyPair> {\n if (PRIVATE_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private);\n } else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public);\n } else if (PUBLIC_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);\n } else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_as_signer);\n } else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private);\n } else {\n throw new Error(\"Invalid visibility type\");\n }\n }\n\n /**\n * Returns the proving and verifying keys for the transfer_public function.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function\n */\n async transferPublicKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);\n }\n\n /**\n * Returns the proving and verifying keys for the inclusion proof.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.\n */\n async inclusionKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.inclusion);\n }\n\n /**\n * Returns the proving and verifying keys for the join function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n async joinKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.join);\n }\n\n /**\n * Returns the proving and verifying keys for the split function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the split function\n * */\n async splitKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.split);\n }\n\n /**\n * Returns the proving and verifying keys for the fee_private function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function\n */\n async feePrivateKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_private);\n }\n\n /**\n * Returns the proving and verifying keys for the fee_public function in the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function\n */\n async feePublicKeys(): Promise<FunctionKeyPair> {\n return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public);\n }\n\n /**\n * Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise\n *\n * @returns {Promise<VerifyingKey>} Verifying key for the function\n */\n // attempt to fetch it from the network\n async getVerifyingKey(verifierUri: string): Promise<VerifyingKey> {\n switch (verifierUri) {\n case CREDITS_PROGRAM_KEYS.bond_public.verifier:\n return CREDITS_PROGRAM_KEYS.bond_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.bond_validator.verifier:\n return CREDITS_PROGRAM_KEYS.bond_validator.verifyingKey();\n case CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier:\n return CREDITS_PROGRAM_KEYS.claim_unbond_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.fee_private.verifier:\n return CREDITS_PROGRAM_KEYS.fee_private.verifyingKey();\n case CREDITS_PROGRAM_KEYS.fee_public.verifier:\n return CREDITS_PROGRAM_KEYS.fee_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.inclusion.verifier:\n return CREDITS_PROGRAM_KEYS.inclusion.verifyingKey();\n case CREDITS_PROGRAM_KEYS.join.verifier:\n return CREDITS_PROGRAM_KEYS.join.verifyingKey();\n case CREDITS_PROGRAM_KEYS.set_validator_state.verifier:\n return CREDITS_PROGRAM_KEYS.set_validator_state.verifyingKey();\n case CREDITS_PROGRAM_KEYS.split.verifier:\n return CREDITS_PROGRAM_KEYS.split.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_private.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_private.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_public.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_public.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifyingKey();\n case CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifier:\n return CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifyingKey();\n case CREDITS_PROGRAM_KEYS.unbond_public.verifier:\n return CREDITS_PROGRAM_KEYS.unbond_public.verifyingKey();\n default:\n try {\n /// Try to fetch the verifying key from the network as a string\n const response = await get(verifierUri);\n const text = await response.text();\n return <VerifyingKey>VerifyingKey.fromString(text);\n } catch (e) {\n /// If that fails, try to fetch the verifying key from the network as bytes\n try {\n return <VerifyingKey>VerifyingKey.fromBytes(await this.fetchBytes(verifierUri));\n } catch (inner: any) {\n throw new Error(\"Invalid verifying key. Error: \" + inner.message);\n }\n }\n }\n }\n\n unBondPublicKeys(): Promise<FunctionKeyPair> {\n return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.unbond_public);\n }\n}\n\nexport {AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams}\n","import {\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider.js\";\n\nimport {\n ProvingKey,\n VerifyingKey,\n} from \"./wasm.js\";\n\nimport {\n CREDITS_PROGRAM_KEYS,\n PRIVATE_TRANSFER,\n PRIVATE_TO_PUBLIC_TRANSFER,\n PUBLIC_TRANSFER,\n PUBLIC_TO_PRIVATE_TRANSFER,\n PUBLIC_TRANSFER_AS_SIGNER,\n} from \"./constants.js\";\n\n/**\n * Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes\n * a convenience method for creating a new instance of this class for each function of the credits.aleo program.\n *\n * @example\n * // If storing a key for a custom program function\n * offlineSearchParams = new OfflineSearchParams(\"myprogram.aleo/myfunction\");\n *\n * // If storing a key for a credits.aleo program function\n * bondPublicKeyParams = OfflineSearchParams.bondPublicKeyParams();\n */\nclass OfflineSearchParams implements KeySearchParams {\n cacheKey: string | undefined;\n verifyCreditsKeys: boolean | undefined;\n\n /**\n * Create a new OfflineSearchParams instance.\n *\n * @param {string} cacheKey - Key used to store the local function proving & verifying keys. This should be stored\n * under the naming convention \"programName/functionName\" (i.e. \"myprogram.aleo/myfunction\")\n * @param {boolean} verifyCreditsKeys - Whether to verify the keys against the credits.aleo program,\n * defaults to false, but should be set to true if using keys from the credits.aleo program\n */\n constructor(cacheKey: string, verifyCreditsKeys = false) {\n this.cacheKey = cacheKey;\n this.verifyCreditsKeys = verifyCreditsKeys;\n }\n\n /**\n * Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program.\n */\n static bondPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.bond_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program.\n */\n static bondValidatorKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.bond_validator.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the claim_unbond_public function of the\n */\n static claimUnbondPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.claim_unbond_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program.\n */\n static feePrivateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.fee_private.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program.\n */\n static feePublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.fee_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the inclusion prover function.\n */\n static inclusionKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.inclusion.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the join function of the credits.aleo program.\n */\n static joinKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.join.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program.\n */\n static setValidatorStateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.set_validator_state.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the split function of the credits.aleo program.\n */\n static splitKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.split.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program.\n */\n static transferPrivateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_private.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program.\n */\n static transferPrivateToPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program.\n */\n static transferPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program.\n */\n static transferPublicAsSignerKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public_as_signer.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program.\n */\n static transferPublicToPrivateKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator, true);\n }\n\n /**\n * Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program.\n */\n static unbondPublicKeyParams(): OfflineSearchParams {\n return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.unbond_public.locator, true);\n }\n}\n\n/**\n * A key provider meant for building transactions offline on devices such as hardware wallets. This key provider is not\n * able to contact the internet for key material and instead relies on the user to insert Aleo function proving &\n * verifying keys from local storage prior to usage.\n *\n * @example\n * // Create an offline program manager\n * const programManager = new ProgramManager();\n *\n * // Create a temporary account for the execution of the program\n * const account = new Account();\n * programManager.setAccount(account);\n *\n * // Create the proving keys from the key bytes on the offline machine\n * console.log(\"Creating proving keys from local key files\");\n * const program = \"program hello_hello.aleo; function hello: input r0 as u32.public; input r1 as u32.private; add r0 r1 into r2; output r2 as u32.private;\";\n * const myFunctionProver = await getLocalKey(\"/path/to/my/function/hello_hello.prover\");\n * const myFunctionVerifier = await getLocalKey(\"/path/to/my/function/hello_hello.verifier\");\n * const feePublicProvingKeyBytes = await getLocalKey(\"/path/to/credits.aleo/feePublic.prover\");\n *\n * myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProver);\n * myFunctionVerifyingKey = VerifyingKey.fromBytes(myFunctionVerifier);\n * const feePublicProvingKey = ProvingKey.fromBytes(feePublicKeyBytes);\n *\n * // Create an offline key provider\n * console.log(\"Creating offline key provider\");\n * const offlineKeyProvider = new OfflineKeyProvider();\n *\n * // Cache the keys\n * // Cache the proving and verifying keys for the custom hello function\n * OfflineKeyProvider.cacheKeys(\"hello_hello.aleo/hello\", myFunctionProvingKey, myFunctionVerifyingKey);\n *\n * // Cache the proving key for the fee_public function (the verifying key is automatically cached)\n * OfflineKeyProvider.insertFeePublicKey(feePublicProvingKey);\n *\n * // Create an offline query using the latest state root in order to create the inclusion proof\n * const offlineQuery = new OfflineQuery(\"latestStateRoot\");\n *\n * // Insert the key provider into the program manager\n * programManager.setKeyProvider(offlineKeyProvider);\n *\n * // Create the offline search params\n * const offlineSearchParams = new OfflineSearchParams(\"hello_hello.aleo/hello\");\n *\n * // Create the offline transaction\n * const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction(\"hello_hello.aleo\", \"hello\", 1, false, [\"5u32\", \"5u32\"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);\n *\n * // Broadcast the transaction later on a machine with internet access\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const txId = await networkClient.broadcastTransaction(offlineExecuteTx);\n */\nclass OfflineKeyProvider implements FunctionKeyProvider {\n cache: Map<string, CachedKeyPair>;\n\n constructor() {\n this.cache = new Map<string, CachedKeyPair>();\n }\n\n /**\n * Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function\n */\n bondPublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.bondPublicKeyParams());\n };\n\n /**\n * Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function\n */\n bondValidatorKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.bondValidatorKeyParams());\n };\n\n\n /**\n * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\n * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.\n *\n * @param {string} keyId access key for the cache\n * @param {FunctionKeyPair} keys keys to cache\n */\n cacheKeys(keyId: string, keys: FunctionKeyPair): void {\n const [provingKey, verifyingKey] = keys;\n this.cache.set(keyId, [provingKey.toBytes(), verifyingKey.toBytes()]);\n };\n\n /**\n * Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function\n */\n claimUnbondPublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.claimUnbondPublicKeyParams());\n };\n\n /**\n * Get arbitrary function key from the offline key provider cache.\n *\n * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program\n *\n * @example\n * /// First cache the keys from local offline resources\n * const offlineKeyProvider = new OfflineKeyProvider();\n * const myFunctionVerifyingKey = VerifyingKey.fromString(\"verifier...\");\n * const myFunctionProvingKeyBytes = await readBinaryFile('./resources/myfunction.prover');\n * const myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProvingKeyBytes);\n *\n * /// Cache the keys for future use with a memorable locator\n * offlineKeyProvider.cacheKeys(\"myprogram.aleo/myfunction\", [myFunctionProvingKey, myFunctionVerifyingKey]);\n *\n * /// When they're needed, retrieve the keys from the cache\n *\n * /// First create a search parameter object with the same locator used to cache the keys\n * const keyParams = new OfflineSearchParams(\"myprogram.aleo/myfunction\");\n *\n * /// Then retrieve the keys\n * const [myFunctionProver, myFunctionVerifier] = await offlineKeyProvider.functionKeys(keyParams);\n */\n functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair> {\n return new Promise((resolve, reject) => {\n if (params === undefined) {\n reject(new Error(\"No search parameters provided, cannot retrieve keys\"));\n } else {\n const keyId = params.cacheKey;\n const verifyCreditsKeys = params.verifyCreditsKeys;\n if (this.cache.has(keyId)) {\n const [provingKeyBytes, verifyingKeyBytes] = this.cache.get(keyId) as CachedKeyPair;\n const provingKey = ProvingKey.fromBytes(provingKeyBytes);\n const verifyingKey = VerifyingKey.fromBytes(verifyingKeyBytes);\n if (verifyCreditsKeys) {\n const keysMatchExpected = this.verifyCreditsKeys(keyId, provingKey, verifyingKey)\n if (!keysMatchExpected) {\n reject (new Error(`Cached keys do not match expected keys for ${keyId}`));\n }\n }\n resolve([provingKey, verifyingKey]);\n } else {\n reject(new Error(\"Keys not found in cache for \" + keyId));\n }\n }\n });\n };\n\n /**\n * Determines if the keys for a given credits function match the expected keys.\n *\n * @returns {boolean} Whether the keys match the expected keys\n */\n verifyCreditsKeys(locator: string, provingKey: ProvingKey, verifyingKey: VerifyingKey): boolean {\n switch (locator) {\n case CREDITS_PROGRAM_KEYS.bond_public.locator:\n return provingKey.isBondPublicProver() && verifyingKey.isBondPublicVerifier();\n case CREDITS_PROGRAM_KEYS.claim_unbond_public.locator:\n return provingKey.isClaimUnbondPublicProver() && verifyingKey.isClaimUnbondPublicVerifier();\n case CREDITS_PROGRAM_KEYS.fee_private.locator:\n return provingKey.isFeePrivateProver() && verifyingKey.isFeePrivateVerifier();\n case CREDITS_PROGRAM_KEYS.fee_public.locator:\n return provingKey.isFeePublicProver() && verifyingKey.isFeePublicVerifier();\n case CREDITS_PROGRAM_KEYS.inclusion.locator:\n return provingKey.isInclusionProver() && verifyingKey.isInclusionVerifier();\n case CREDITS_PROGRAM_KEYS.join.locator:\n return provingKey.isJoinProver() && verifyingKey.isJoinVerifier();\n case CREDITS_PROGRAM_KEYS.set_validator_state.locator:\n return provingKey.isSetValidatorStateProver() && verifyingKey.isSetValidatorStateVerifier();\n case CREDITS_PROGRAM_KEYS.split.locator:\n return provingKey.isSplitProver() && verifyingKey.isSplitVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_private.locator:\n return provingKey.isTransferPrivateProver() && verifyingKey.isTransferPrivateVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator:\n return provingKey.isTransferPrivateToPublicProver() && verifyingKey.isTransferPrivateToPublicVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_public.locator:\n return provingKey.isTransferPublicProver() && verifyingKey.isTransferPublicVerifier();\n case CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator:\n return provingKey.isTransferPublicToPrivateProver() && verifyingKey.isTransferPublicToPrivateVerifier();\n case CREDITS_PROGRAM_KEYS.unbond_public.locator:\n return provingKey.isUnbondPublicProver() && verifyingKey.isUnbondPublicVerifier();\n default:\n return false;\n }\n }\n\n /**\n * Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePrivateKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.feePrivateKeyParams());\n };\n\n /**\n * Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n feePublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.feePublicKeyParams());\n };\n\n /**\n * Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover\n */\n inclusionKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.inclusionKeyParams());\n };\n\n /**\n * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n joinKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.joinKeyParams());\n };\n\n /**\n * Get split function keys from the credits.aleo program. The keys must be cached prior to calling this\n * method for it to work.\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n splitKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.splitKeyParams());\n };\n\n /**\n * Get keys for a variant of the transfer function from the credits.aleo program.\n *\n *\n * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function\n *\n * @example\n * // Create a new OfflineKeyProvider\n * const offlineKeyProvider = new OfflineKeyProvider();\n *\n * // Cache the keys for future use with the official locator\n * const transferPublicProvingKeyBytes = await readBinaryFile('./resources/transfer_public.prover.a74565e');\n * const transferPublicProvingKey = ProvingKey.fromBytes(transferPublicProvingKeyBytes);\n *\n * // Cache the transfer_public keys for future use with the OfflinKeyProvider's convenience method for\n * // transfer_public (the verifying key will be cached automatically)\n * offlineKeyProvider.insertTransferPublicKeys(transferPublicProvingKey);\n *\n * /// When they're needed, retrieve the keys from the cache\n * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys(\"public\");\n */\n transferKeys(visibility: string): Promise<FunctionKeyPair> {\n if (PRIVATE_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPrivateKeyParams());\n } else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPrivateToPublicKeyParams());\n } else if (PUBLIC_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPublicKeyParams());\n } else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPublicAsSignerKeyParams());\n } else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {\n return this.functionKeys(OfflineSearchParams.transferPublicToPrivateKeyParams());\n } else {\n throw new Error(\"Invalid visibility type\");\n }\n };\n\n /**\n * Get unbond_public function keys from the credits.aleo program\n *\n * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function\n */\n async unBondPublicKeys(): Promise<FunctionKeyPair> {\n return this.functionKeys(OfflineSearchParams.unbondPublicKeyParams());\n };\n\n /**\n * Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for bond_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertBondPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isBondPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.bond_public.locator, [provingKey.toBytes(), VerifyingKey.bondPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for bond_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for claim_unbond_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertClaimUnbondPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isClaimUnbondPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.claim_unbond_public.locator, [provingKey.toBytes(), VerifyingKey.claimUnbondPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for claim_unbond_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for fee_private before inserting them into the cache.\n *\n * @param provingKey\n */\n insertFeePrivateKeys(provingKey: ProvingKey) {\n if (provingKey.isFeePrivateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.fee_private.locator, [provingKey.toBytes(), VerifyingKey.feePrivateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for fee_private\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for fee_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertFeePublicKeys(provingKey: ProvingKey) {\n if (provingKey.isFeePublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.fee_public.locator, [provingKey.toBytes(), VerifyingKey.feePublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for fee_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for the inclusion prover.\n *\n * @param provingKey\n */\n insertInclusionKeys(provingKey: ProvingKey) {\n if (provingKey.isInclusionProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.inclusion.locator, [provingKey.toBytes(), VerifyingKey.inclusionVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for the inclusion prover\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for join before inserting them into the cache.\n *\n * @param provingKey\n */\n insertJoinKeys(provingKey: ProvingKey) {\n if (provingKey.isJoinProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.join.locator, [provingKey.toBytes(), VerifyingKey.joinVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for join\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for set_validator_state before inserting them into the cache.\n *\n * @param provingKey\n */\n insertSetValidatorStateKeys(provingKey: ProvingKey) {\n if (provingKey.isSetValidatorStateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.set_validator_state.locator, [provingKey.toBytes(), VerifyingKey.setValidatorStateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for set_validator_state\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the split function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for split before inserting them into the cache.\n *\n * @param provingKey\n */\n insertSplitKeys(provingKey: ProvingKey) {\n if (provingKey.isSplitProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.split.locator, [provingKey.toBytes(), VerifyingKey.splitVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for split\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_private before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPrivateKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPrivateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_private.locator, [provingKey.toBytes(), VerifyingKey.transferPrivateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_private\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_private_to_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPrivateToPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPrivateToPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator, [provingKey.toBytes(), VerifyingKey.transferPrivateToPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_private_to_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_public before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_public.locator, [provingKey.toBytes(), VerifyingKey.transferPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_public\");\n }\n }\n\n /**\n * Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs\n * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\n * that the keys match the expected checksum for transfer_public_to_private before inserting them into the cache.\n *\n * @param provingKey\n */\n insertTransferPublicToPrivateKeys(provingKey: ProvingKey) {\n if (provingKey.isTransferPublicToPrivateProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator, [provingKey.toBytes(), VerifyingKey.transferPublicToPrivateVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for transfer_public_to_private\");\n }\n }\n\n insertUnbondPublicKeys(provingKey: ProvingKey) {\n if (provingKey.isUnbondPublicProver()) {\n this.cache.set(CREDITS_PROGRAM_KEYS.unbond_public.locator, [provingKey.toBytes(), VerifyingKey.unbondPublicVerifier().toBytes()]);\n } else {\n throw new Error(\"Attempted to insert invalid proving keys for unbond_public\");\n }\n }\n}\n\n\nexport {OfflineKeyProvider, OfflineSearchParams}\n","import { Account } from \"./account.js\";\nimport { AleoNetworkClient } from \"./network-client.js\";\nimport { EncryptedRecord } from \"./models/record-provider/encryptedRecord.js\";\nimport { logAndThrow } from \"./utils.js\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord.js\";\nimport { RecordSearchParams } from \"./models/record-provider/recordSearchParams.js\";\nimport { RecordsResponseFilter } from \"./models/record-scanner/recordsResponseFilter.js\";\n\n/**\n * Interface for a record provider. A record provider is used to find records for use in deployment and execution\n * transactions on the Aleo Network. A default implementation is provided by the NetworkRecordProvider class. However,\n * a custom implementation can be provided (say if records are synced locally to a database from the network) by\n * implementing this interface.\n */\ninterface RecordProvider {\n /**\n * The account used to search for records.\n */\n account?: Account;\n\n /**\n * Find encrypted records from the chosen provider.\n *\n * @param {RecordSearchParams} recordsFilter The filter used to find the records.\n * @param {RecordsResponseFilter} responseFilter The filter used to filter the response.\n * @returns {Promise<EncryptedRecord[]>} The encrypted records.\n */\n encryptedRecords(recordsFilter: RecordSearchParams, responseFilter?: RecordsResponseFilter): Promise<EncryptedRecord[]>;\n\n /**\n * Check if a list of serial numbers exist in the chosen provider.\n *\n * @param {string[]} serialNumbers The serial numbers to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.\n */\n checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;\n\n /**\n * Check if a list of tags exist in the chosen provider.\n *\n * @param {string[]} tags The tags to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.\n */\n checkTags(tags: string[]): Promise<Record<string, boolean>>;\n\n /**\n * Find a credits.aleo record with a given number of microcredits from the chosen provider.\n *\n * @param {number} microcredits The number of microcredits to search for.\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord>} The record if one is found.\n *\n * @example\n * // A class implementing record provider can be used to find a record with a given number of microcredits\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, its nonce should be added to the nonces array so that it is not\n * // found again if a subsequent search is performed\n * const record2 = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [record.nonce()] });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n */\n findCreditsRecord(microcredits: number, searchParameters: RecordSearchParams): Promise<OwnedRecord>;\n\n /**\n * Find a list of credit.aleo records with a given number of microcredits from the chosen provider\n *\n * @param {number[]} microcreditAmounts A list of separate microcredit amounts to search for (e.g. [5000, 100000]).\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord[]>} A list of records with a value greater or equal to the amounts specified if such records exist, otherwise an error.\n *\n * @example\n * // A class implementing record provider can be used to find a record with a given number of microcredits\n * const records = await recordProvider.findCreditsRecords([5000, 5000], { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, it's nonce should be added to the nonces array so that it is not\n * // found again if a subsequent search is performed\n * const nonces = [];\n * records.forEach(record => { nonces.push(record.nonce()) });\n * const records2 = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n */\n findCreditsRecords(microcreditAmounts: number[], searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;\n\n /**\n * Find an arbitrary record\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord>} The record if found, otherwise an error.\n *\n * @example\n * // The RecordSearchParams interface can be used to create parameters for custom record searches which can then\n * // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown\n * // below.\n *\n * class CustomRecordSearch implements RecordSearchParams {\n * startHeight: number;\n * endHeight: number;\n * amount: number;\n * program: string;\n * recordName: string;\n * nonces: string[];\n * unspent: boolean;\n * constructor(\n * startHeight: number,\n * endHeight: number,\n * credits: number,\n * maxRecords: number,\n * programName: string,\n * recordName: string,\n * nonces: string[],\n * unspent: boolean\n * ) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.amount = amount;\n * this.program = programName;\n * this.recordName = recordName;\n * this.nonces = nonces;\n * this.unspent = unspent;\n * }\n * }\n *\n * const params = new CustomRecordSearch(0, 100, 5000, \"credits.aleo\", \"credits\", [], true);\n *\n * const record = await recordProvider.findRecord(params);\n */\n findRecord(searchParameters: RecordSearchParams): Promise<OwnedRecord>;\n\n /**\n * Find multiple records from arbitrary programs\n *\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.\n *\n * @example\n * // The RecordSearchParams interface can be used to create parameters for custom record searches which can then\n * // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown\n * // below.\n *\n * class CustomRecordSearch implements RecordSearchParams {\n * startHeight: number;\n * endHeight: number;\n * credits: number;\n * program: string;\n * recordName: string;\n * nonces: string[];\n * unspent: boolean;\n * constructor(\n * startHeight: number,\n * endHeight: number,\n * credits: number,\n * maxRecords: number,\n * programName: string,\n * recordName: string,\n * nonces: string[],\n * unspent: boolean\n * ) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.credits = credits;\n * this.program = programName;\n * this.recordName = recordName;\n * this.nonces = nonces;\n * this.unspent = unspent;\n * }\n * }\n *\n * const params = new CustomRecordSearch(0, 100, 5000, 2, \"credits.aleo\", \"credits\");\n * const records = await recordProvider.findRecord(true, [], params);\n */\n findRecords(searchParameters: RecordSearchParams): Promise<OwnedRecord[]>;\n}\n\n/**\n * A record provider implementation that uses the official Aleo API to find records for usage in program execution and\n * deployment, wallet functionality, and other use cases.\n */\nclass NetworkRecordProvider implements RecordProvider {\n account: Account;\n networkClient: AleoNetworkClient;\n constructor(account: Account, networkClient: AleoNetworkClient) {\n this.account = account;\n this.networkClient = networkClient;\n }\n\n /**\n * Set the account used to search for records\n *\n * @param {Account} account The account used to use for searching for records.\n */\n setAccount(account: Account) {\n this.account = account;\n }\n\n /**\n * Find a list of credit records with a given number of microcredits by via the official Aleo API\n *\n * @param {number[]} microcredits The number of microcredits to search for.\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord[]>} The records if found, otherwise an error.\n *\n * @example\n * // Create a new NetworkRecordProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // The record provider can be used to find records with a given number of microcredits\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not\n * // found again if a subsequent search is performed\n * const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n *\n * */\n async findCreditsRecords(microcredits: number[], searchParameters: RecordSearchParams): Promise<OwnedRecord[]> {\n let startHeight = 0;\n let endHeight = 0;\n let maxAmount = undefined;\n\n if (searchParameters) {\n if (\"startHeight\" in searchParameters && typeof searchParameters[\"startHeight\"] == \"number\") {\n startHeight = searchParameters[\"startHeight\"];\n }\n\n if (\"endHeight\" in searchParameters && typeof searchParameters[\"endHeight\"] == \"number\") {\n endHeight = searchParameters[\"endHeight\"];\n }\n\n if (\"amounts\" in searchParameters && Array.isArray(searchParameters[\"amounts\"]) && searchParameters[\"amount\"].every((item: any) => typeof item === 'number')) {\n microcredits = searchParameters[\"amounts\"];\n }\n\n if (\"maxAmount\" in searchParameters && typeof searchParameters[\"maxAmount\"] == \"number\") {\n maxAmount = searchParameters[\"maxAmount\"];\n }\n }\n\n // If the end height is not specified, use the current block height\n if (endHeight == 0) {\n const end = await this.networkClient.getLatestHeight();\n endHeight = end;\n }\n\n // If the start height is greater than the end height, throw an error\n if (startHeight >= endHeight) {\n logAndThrow(\"Start height must be less than end height\");\n }\n\n const recordsPts = await this.networkClient.findRecords(startHeight, endHeight, searchParameters.unspent, [\"credits.aleo\"], microcredits, maxAmount, searchParameters.nonces, this.account.privateKey());\n return recordsPts.map((record) => ({\n owner: record.owner().toString(),\n programName: 'credits.aleo',\n recordName: 'credits',\n recordPlaintext: record.toString(),\n }));\n }\n\n /**\n * Find a credit record with a given number of microcredits by via the official Aleo API\n *\n * @param {number} microcredits The number of microcredits to search for.\n * @param {RecordSearchParams} searchParameters Additional parameters to search for.\n * @returns {Promise<OwnedRecord>} The record if found, otherwise an error.\n *\n * @example\n * // Create a new NetworkRecordProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // The record provider can be used to find records with a given number of microcredits\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [] });\n *\n * // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not\n * // found again if a subsequent search is performed\n * const records = await recordProvider.findCreditsRecords(5000, { unspent: true, nonces: [record.nonce()] });\n *\n * // When the program manager is initialized with the record provider it will be used to find automatically find\n * // fee records and amount records for value transfers so that they do not need to be specified manually\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.transfer(1, \"aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at\", \"public\", 0.5);\n */\n async findCreditsRecord(microcredits: number, searchParameters: RecordSearchParams): Promise<OwnedRecord> {\n let records = null;\n\n try {\n records = await this.findCreditsRecords([microcredits], searchParameters);\n } catch (e) {\n console.log(\"No records found with error:\", e);\n }\n\n if (records && records.length > 0) {\n return records[0];\n }\n\n console.error(\"Record not found with error:\", records);\n throw new Error(\"Record not found\");\n }\n\n /**\n * Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.\n */\n async findRecord(searchParameters: RecordSearchParams): Promise<OwnedRecord> {\n let records;\n\n try {\n records = await this.findRecords(searchParameters);\n } catch (e) {\n console.log(\"No records found with error:\", e);\n }\n\n if (records && records.length > 0) {\n return records[0];\n }\n\n console.error(\"Record not found with error:\", records);\n throw new Error(\"Record not found\");\n }\n\n /**\n * Find multiple records from a specified program.\n */\n async findRecords(searchParameters: RecordSearchParams): Promise<OwnedRecord[]> {\n let startHeight = 0;\n let endHeight = 0;\n let amounts = undefined;\n let maxAmount = undefined;\n let programs = undefined;\n\n if (searchParameters) {\n if (\"startHeight\" in searchParameters && typeof searchParameters[\"startHeight\"] == \"number\") {\n startHeight = searchParameters[\"startHeight\"];\n }\n\n if (\"endHeight\" in searchParameters && typeof searchParameters[\"endHeight\"] == \"number\") {\n endHeight = searchParameters[\"endHeight\"];\n }\n\n if (\"amounts\" in searchParameters && Array.isArray(searchParameters[\"amounts\"]) && searchParameters[\"amounts\"].every((item: any) => typeof item === 'number')) {\n amounts = searchParameters[\"amounts\"];\n }\n\n if (\"maxAmount\" in searchParameters && typeof searchParameters[\"maxAmount\"] == \"number\") {\n maxAmount = searchParameters[\"maxAmount\"];\n }\n\n if (\"program\" in searchParameters && typeof searchParameters[\"program\"] == \"string\") {\n programs = [searchParameters[\"program\"]];\n }\n\n if (\"programs\" in searchParameters && Array.isArray(searchParameters[\"programs\"]) && searchParameters[\"programs\"].every((item: any) => typeof item === \"string\")) {\n programs = searchParameters[\"programs\"];\n }\n }\n\n // If the end height is not specified, use the current block height.\n if (endHeight == 0) {\n const end = await this.networkClient.getLatestHeight();\n endHeight = end;\n }\n\n // If the start height is greater than the end height, throw an error.\n if (startHeight >= endHeight) {\n logAndThrow(\"Start height must be less than end height\");\n }\n\n const recordPts = await this.networkClient.findRecords(startHeight, endHeight, searchParameters.unspent, programs, amounts, maxAmount, searchParameters.nonces, this.account.privateKey());\n return recordPts.map((record) => ({\n record_plaintext: record.toString(),\n }));\n }\n\n async encryptedRecords(recordsFilter: RecordSearchParams, responseFilter?: RecordsResponseFilter): Promise<EncryptedRecord[]> {\n throw new Error(\"Not implemented\");\n }\n\n async checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>> {\n throw new Error(\"Not implemented\");\n }\n\n async checkTags(tags: string[]): Promise<Record<string, boolean>> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/**\n * BlockHeightSearch is a RecordSearchParams implementation that allows for searching for records within a given\n * block height range.\n *\n * @example\n * // Create a new BlockHeightSearch\n * const params = new BlockHeightSearch(89995, 99995);\n *\n * // Create a new NetworkRecordProvider\n * const networkClient = new AleoNetworkClient(\"https://api.explorer.provable.com/v1\");\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n *\n * // The record provider can be used to find records with a given number of microcredits and the block height search\n * // can be used to find records within a given block height range\n * const record = await recordProvider.findCreditsRecord(5000, { unspent: true, nonces: [], ...params });\n *\n */\nclass BlockHeightSearch implements RecordSearchParams {\n startHeight: number;\n endHeight: number;\n unspent: boolean;\n constructor(startHeight: number, endHeight: number, unspent?: boolean) {\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n this.unspent = !!unspent;\n }\n}\n\nexport {\n BlockHeightSearch,\n NetworkRecordProvider,\n RecordProvider,\n};","import { EncryptedRecord } from \"./models/record-provider/encryptedRecord\";\nimport { OwnedFilter } from \"./models/record-scanner/ownedFilter\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord\";\nimport { RecordProvider } from \"./record-provider\";\nimport { Field, Poseidon4, RecordPlaintext, ViewKey } from \"./wasm\";\nimport { RecordsFilter } from \"./models/record-scanner/recordsFilter\";\nimport { RegistrationRequest } from \"./models/record-scanner/registrationRequest\";\nimport { RegistrationResponse } from \"./models/record-scanner/registrationResponse\";\nimport { StatusResponse } from \"./models/record-scanner/statusResponse\";\nimport { RECORD_DOMAIN } from \"./constants\";\n\ntype RecordScannerOptions = {\n url: string;\n apiKey?: string | { header: string, value: string };\n}\n\n/**\n * RecordScanner is a RecordProvider implementation that uses the record scanner service to find records.\n * \n * @example\n * const account = new Account({ privateKey: 'APrivateKey1...' });\n * \n * const recordScanner = new RecordScanner({ url: \"https://record-scanner.aleo.org\" });\n * recordScanner.setAccount(account);\n * recordScanner.setApiKey(\"your-api-key\");\n * const uuid = await recordScanner.register(0);\n * \n * const filter = {\n * uuid,\n * filter: {\n * program: \"credits.aleo\",\n * records: [\"credits\"],\n * },\n * responseFilter: {\n * commitment: true,\n * owner: true,\n * tag: true,\n * tag?: boolean;\n * sender: true,\n * spent: true,\n * record_ciphertext: true,\n * block_height: true;\n * block_timestamp: true;\n * output_index: true;\n * record_name: true;\n * function_name: true;\n * program_name: true;\n * transition_id: true;\n * transaction_id: true;\n * transaction_index: true;\n * transition_index: true;\n * },\n * unspent: true,\n * };\n * \n * const records = await recordScanner.findRecords(filter);\n */\nclass RecordScanner implements RecordProvider {\n readonly url: string;\n private apiKey?: { header: string, value: string };\n private uuid?: Field;\n\n constructor(options: RecordScannerOptions) {\n this.url = options.url;\n this.apiKey = typeof options.apiKey === \"string\" ? { header: \"X-Provable-API-Key\", value: options.apiKey } : options.apiKey;\n }\n\n /**\n * Set the API key to use for the record scanner.\n * \n * @param {string} apiKey The API key to use for the record scanner.\n */\n async setApiKey(apiKey: string | { header: string, value: string }): Promise<void> {\n this.apiKey = typeof apiKey === \"string\" ? { header: \"X-Provable-API-Key\", value: apiKey } : apiKey;\n }\n\n /**\n * Set the UUID to use for the record scanner.\n * \n * @param {Field} uuid The UUID to use for the record scanner.\n */\n async setUuid(uuidOrViewKey: Field | ViewKey): Promise<void> {\n this.uuid = uuidOrViewKey instanceof ViewKey ? this.computeUUID(uuidOrViewKey) : uuidOrViewKey;\n }\n\n /**\n * Register the account with the record scanner service.\n * \n * @param {number} startBlock The block height to start scanning from.\n * @returns {Promise<RegistrationResponse>} The response from the record scanner service.\n */\n async register(viewKey: ViewKey, startBlock: number): Promise<RegistrationResponse> {\n try {\n let request: RegistrationRequest = {\n view_key: viewKey.to_string(),\n start: startBlock,\n };\n\n const response = await this.request(\n new Request(`${this.url}/register`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(request),\n })\n );\n\n const data = await response.json();\n this.uuid = data.uuid;\n return data;\n } catch (error) {\n console.error(`Failed to register view key: ${error}`);\n throw error;\n }\n }\n\n /**\n * Get encrypted records from the record scanner service.\n * \n * @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.\n * @returns {Promise<EncryptedRecord[]>} The encrypted records.\n */\n async encryptedRecords(recordsFilter: RecordsFilter): Promise<EncryptedRecord[]> {\n try {\n const response = await this.request(\n new Request(`${this.url}/records/encrypted`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(recordsFilter),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to get encrypted records: ${error}`);\n throw error;\n }\n }\n\n /**\n * Check if a list of serial numbers exist in the record scanner service.\n * \n * @param {string[]} serialNumbers The serial numbers to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.\n */\n async checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>> {\n try {\n const response = await this.request(\n new Request(`${this.url}/records/sns`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(serialNumbers),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to check if serial numbers exist: ${error}`);\n throw error;\n }\n }\n\n /**\n * Check if a list of tags exist in the record scanner service.\n * \n * @param {string[]} tags The tags to check.\n * @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.\n */\n async checkTags(tags: string[]): Promise<Record<string, boolean>> {\n try {\n const response = await this.request(\n new Request(`${this.url}/records/tags`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(tags),\n }),\n );\n \n return await response.json();\n } catch (error) {\n console.error(`Failed to check if tags exist: ${error}`);\n throw error;\n }\n }\n\n /**\n * Check the status of a record scanner indexing job.\n * \n * @param {string} jobId The job id to check.\n * @returns {Promise<StatusResponse>} The status of the job.\n */\n async checkStatus(): Promise<StatusResponse> {\n try {\n const response = await this.request(\n new Request(`${this.url}/status`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(this.uuid?.toString()),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to check status of job: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find a record in the record scanner service.\n * \n * @param {OwnedFilter} searchParameters The filter to use to find the record.\n * @returns {Promise<OwnedRecord>} The record.\n */\n async findRecord(searchParameters: OwnedFilter): Promise<OwnedRecord> {\n try {\n const records = await this.findRecords(searchParameters);\n\n if (records.length > 0) {\n return records[0];\n }\n\n throw new Error(\"Record not found\");\n } catch (error) {\n console.error(`Failed to find record: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find records in the record scanner service.\n * \n * @param {OwnedFilter} filter The filter to use to find the records.\n * @returns {Promise<OwnedRecord[]>} The records.\n */\n async findRecords(filter: OwnedFilter): Promise<OwnedRecord[]> {\n if (!this.uuid) {\n throw new Error(\"You are using the RecordScanner implementation of the RecordProvider. No account has been registered with the RecordScanner which is required to use the findRecords method. Please set an with the setAccount method before calling the findRecords method again.\");\n }\n\n filter.uuid = this.uuid?.toString();\n\n try {\n const response = await this.request(\n new Request(`${this.url}/records/owned`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(filter),\n }),\n );\n\n return await response.json();\n } catch (error) {\n console.error(`Failed to get owned records: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find a credits record in the record scanner service.\n * \n * @param {number} microcredits The amount of microcredits to find.\n * @param {OwnedFilter} searchParameters The filter to use to find the record.\n * @returns {Promise<OwnedRecord>} The record.\n */\n async findCreditsRecord(microcredits: number, searchParameters: OwnedFilter): Promise<OwnedRecord> {\n try {\n const records = await this.findRecords({\n decrypt: true,\n unspent: searchParameters.unspent,\n filter: {\n start: searchParameters.filter?.start ?? 0,\n program: \"credits.aleo\",\n record: \"credits\",\n },\n uuid: this.uuid?.toString(),\n });\n\n const record = records.find(record => {\n const plaintext = RecordPlaintext.fromString(record.record_plaintext ?? '');\n const amountStr = plaintext.getMember(\"microcredits\").toString();\n const amount = parseInt(amountStr.replace(\"u64\", \"\"));\n return amount >= microcredits;\n });\n\n if (!record) {\n throw new Error(`No records found matching the supplied search filter:\\n${JSON.stringify(searchParameters, null, 2)}`);\n }\n\n return record;\n } catch (error) {\n console.error(`Failed to find credits record: ${error}`);\n throw error;\n }\n }\n\n /**\n * Find credits records using a record scanning service.\n * \n * @param {number[]} microcreditAmounts The amounts of microcredits to find.\n * @param {OwnedFilter} searchParameters The filter to use to find the records.\n * @returns {Promise<OwnedRecord[]>} The records\n */\n async findCreditsRecords(microcreditAmounts: number[], searchParameters: OwnedFilter): Promise<OwnedRecord[]> {\n try {\n const records = await this.findRecords({\n decrypt: true,\n unspent: searchParameters.unspent,\n filter: {\n start: searchParameters.filter?.start ?? 0,\n program: \"credits.aleo\",\n record: \"credits\",\n },\n uuid: this.uuid?.toString(),\n });\n return records.filter(record => {\n const plaintext = RecordPlaintext.fromString(record.record_plaintext ?? '');\n const amount = plaintext.getMember(\"microcredits\").toString();\n return microcreditAmounts.includes(parseInt(amount.replace(\"u64\", \"\")));\n });\n } catch (error) {\n console.error(`Failed to find credits records: ${error}`);\n throw error;\n }\n }\n\n /**\n * Wrapper function to make a request to the record scanner service and handle any errors.\n * \n * @param {Request} req The request to make.\n * @returns {Promise<Response>} The response.\n */\n private async request(req: Request): Promise<Response> {\n try {\n if (this.apiKey) {\n req.headers.set(this.apiKey.header, this.apiKey.value);\n }\n const response = await fetch(req);\n \n if (!response.ok) {\n throw new Error(await response.text() ?? `Request to ${req.url} failed with status ${response.status}`);\n }\n\n return response;\n } catch (error) {\n console.error(`Failed to make request to ${req.url}: ${error}`);\n throw error;\n }\n }\n\n computeUUID(vk: ViewKey): Field {\n // Construct the material needed for the Poseidon oracle.\n const inputs = [Field.newDomainSeparator(RECORD_DOMAIN), vk.toField(), Field.one()]\n // Calculate the uuid.\n const hasher = new Poseidon4();\n return hasher.hash(inputs);\n }\n}\n\nexport { RecordScanner };\n","import { Field, Plaintext, Poseidon4 } from \"../../wasm.js\";\nimport { bech32m } from \"@scure/base\";\nimport { ZERO_ADDRESS } from \"../../constants.js\";\n\n/**\n * Client library that encapsulates methods for constructing Merkle exclusion proofs for compliant stablecoin programs following the Sealance architecture.\n *\n\n * @example\n * Construct a Merkle exclusion proof.\n * ```typescript\n * const sealance = new SealanceMerkleTree();\n * const leaves = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const result = sealance.generateLeaves(leaves); \n * const tree = sealance.buildTree(result);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1kypwp5m7qtk9mwazgcpg0tq8aal23mnrvwfvug65qgcg9xvsrqgspyjm6n\");\n * const proof_left = sealance.getSiblingPath(tree, leftIdx, 15);\n * const proof_right = sealance.getSiblingPath(tree, rightIdx, 15);\n * const exclusion_proof = [proof_left, proof_right];\n * const formatted_proof = sealance.formatMerkleProof(exclusion_proof);\n * ```\n */\nclass SealanceMerkleTree {\n private static hasher = new Poseidon4();\n \n /**\n * Converts an Aleo blockchain address to a field element.\n *\n * This function decodes a bech32m-encoded Aleo address and converts it to a field element\n * represented as a BigInt. The address format follows the Aleo protocol specification,\n * starting with the prefix \"aleo1\" followed by encoded data.\n *\n * @param address - The Aleo blockchain address (e.g., \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\")\n * @returns A BigInt representing the field element.\n * @throws Error if the address is invalid or cannot be decoded.\n *\n * @example\n * ```typescript\n * const sealance = new SealanceMerkleTree();\n * const address = \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\";\n * const fieldValue = sealance.convertAddressToField(address);\n * console.log(fieldValue); // 123456789...n\n * ```\n */\n convertAddressToField(address: string): bigint {\n const { words } = bech32m.decode(address as `${string}1${string}`);\n const bytes = bech32m.fromWords(words);\n\n // Convert bytes to BigInt (little-endian)\n let fieldValue = BigInt(0);\n for (let i = 0; i < bytes.length; i++) {\n fieldValue |= BigInt(bytes[i]) << BigInt(i * 8);\n }\n\n return fieldValue;\n }\n\n /**\n * Hashes two elements using Poseidon4 hash function\n * @param prefix - Prefix for the hash (e.g., \"0field\" for nodes, \"1field\" for leaves)\n * @param el1 - First element to hash\n * @param el2 - Second element to hash\n * @returns The hash result as a Field\n * @throws {Error} If inputs are empty or invalid\n */\n hashTwoElements(prefix: string, el1: string, el2: string): Field {\n if (!el1 || !el2) {\n throw new Error(\"Invalid inputs: elements cannot be empty\");\n }\n const fields = [Field.fromString(prefix), Field.fromString(el1), Field.fromString(el2)];\n const arrayPlaintext = Plaintext.fromString(`[${fields.map(f => f.toString()).join(\",\")}]`);\n\n return SealanceMerkleTree.hasher.hash(arrayPlaintext.toFields());\n }\n\n /**\n * Builds a Merkle tree from given leaves. The tree is built bottom-up, hashing pairs of elements at each level.\n *\n * @param leaves - Array of leaf elements (must have even number of elements).\n * @returns Array representing the complete Merkle tree as BigInts.\n * @throws {Error} If leaves array is empty or has odd number of elements.\n *\n * @example\n * ```typescript\n * const sealance = new SealanceMerkleTree();\n * const leaves = [\"0field\", \"1field\", \"2field\", \"3field\"];\n * const tree = sealance.buildTree(leaves);\n * const root = tree[tree.length - 1]; // Get the Merkle root\n * ```\n */\n buildTree(leaves: string[]): bigint[] {\n if (leaves.length === 0) {\n throw new Error(\"Leaves array cannot be empty\");\n }\n if (leaves.length % 2 !== 0) {\n throw new Error(\"Leaves array must have even number of elements\");\n }\n let currentLevel = leaves;\n let tree = [...currentLevel];\n let levelSize = currentLevel.length;\n\n while (levelSize > 1) {\n const nextLevel = [];\n for (let i = 0; i < levelSize; i += 2) {\n const left = currentLevel[i];\n const right = currentLevel[i + 1];\n const prefix = leaves.length === levelSize ? \"1field\" : \"0field\";\n const hash = this.hashTwoElements(prefix, left, right);\n nextLevel.push(hash.toString());\n }\n tree = [...tree, ...nextLevel];\n currentLevel = nextLevel;\n levelSize = currentLevel.length;\n }\n return tree.map(element => BigInt(element.slice(0, element.length - \"field\".length)));\n }\n\n /** \n * Converts an array of decimal string representations of U256 numbers to an array of BigInts.\n *\n * @param tree - Array of decimal string representations of U256 numbers.\n * @returns Array of BigInts.\n * \n * @example\n * ```typescript\n * const treeStrings = [\"0\",\"4328470178059738374782465505490977516512210899136548187530607227309847251692\",\"1741259420362056497457198439964202806733137875365061915996980524089960046336\"];\n * const sealance = new SealanceMerkleTree();\n * const treeBigInts = sealance.convertTreeToBigInt(treeStrings);\n * console.log(treeBigInts); // [\n * 0, \n * 4328470178059738374782465505490977516512210899136548187530607227309847251692, \n * 1741259420362056497457198439964202806733137875365061915996980524089960046336\n * ]\n * ```\n */\n convertTreeToBigInt(tree: string[]): bigint[] {\n return tree.map((element) => {\n try {\n // decimal string → native bigint\n return BigInt(element);\n } catch {\n throw new Error(`Invalid decimal U256 string: ${element}`);\n }\n });\n }\n\n /**\n * Converts Aleo addresses to field elements, sorts them, pads with zero fields, and returns an array. This prepares addresses for Merkle tree construction.\n *\n * @param addresses - Array of Aleo addresses.\n * @param maxTreeDepth - Maximum depth of the Merkle tree (default: 15).\n * @returns Array of field elements ready for Merkle tree construction.\n * @throws {Error} If the number of addresses exceeds the maximum capacity.\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses, 15);\n * console.log(leaves); // [\n * \"0field\", \n * \"1295133970529764960316948294624974168921228814652993007266766481909235735940field\", \n * \"1295133970529764960316948294624974168921228814652993007266766481909235735940field\", \n * \"3501665755452795161867664882580888971213780722176652848275908626939553697821field\"\n * ]\n * ```\n */\n generateLeaves(addresses: string[], maxTreeDepth: number = 15): string[] {\n const maxNumLeaves = Math.floor(2 ** (maxTreeDepth - 1));\n\n // Filter out zero addresses\n addresses = addresses.filter(addr => addr !== ZERO_ADDRESS);\n\n let numLeaves = 0;\n if (addresses.length === 0 || addresses.length === 1) {\n numLeaves = 2;\n } else {\n numLeaves = Math.pow(2, Math.ceil(Math.log2(addresses.length)));\n }\n\n if (addresses.length > maxNumLeaves) {\n throw new Error(`Leaves limit exceeded. Max: ${maxNumLeaves}, provided: ${addresses.length}`);\n }\n\n // Convert addresses to fields\n const addressFields = addresses.map(addr => ({\n address: addr,\n field: this.convertAddressToField(addr),\n }));\n\n // Sort by field value\n const sortedFields = addressFields.sort((a, b) => (a.field < b.field ? -1 : 1)).map(item => item.field);\n\n // Convert to field strings\n const sortedFieldElements = sortedFields.map(field => field.toString() + \"field\");\n\n // Pad with zeros to reach power of 2\n const fullTree = Array(Math.max(numLeaves - sortedFieldElements.length, 0)).fill(\"0field\");\n\n return fullTree.concat(sortedFieldElements);\n }\n\n\n /**\n * Finds the leaf indices for non-inclusion proof of an address and returns the indices of the two adjacent leaves that surround the target address.\n *\n * @param merkleTree - The complete Merkle tree as array of BigInts.\n * @param address - The Aleo address for which to find indices.\n * @returns Tuple of [leftLeafIndex, rightLeafIndex].\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses);\n * const tree = sealance.buildTree(leaves);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1...\");\n * ```\n */\n getLeafIndices(merkleTree: bigint[], address: string): [number, number] {\n const num_leaves = Math.floor((merkleTree.length + 1) / 2);\n const addressBigInt = this.convertAddressToField(address);\n const leaves = merkleTree.slice(0, num_leaves);\n let rightLeafIndex = leaves.findIndex((leaf: bigint) => addressBigInt <= leaf);\n let leftLeafIndex = rightLeafIndex - 1;\n if (rightLeafIndex === -1) {\n rightLeafIndex = leaves.length - 1;\n leftLeafIndex = leaves.length - 1;\n }\n if (rightLeafIndex === 0) {\n leftLeafIndex = 0;\n }\n return [leftLeafIndex, rightLeafIndex];\n }\n\n /**\n * Generates the sibling path (Merkle proof) for a given leaf index\n *\n * @param tree - The complete Merkle tree.\n * @param leafIndex - Index of the leaf for which to generate the proof.\n * @param depth - Maximum depth of the tree.\n * @returns Object containing siblings array and leaf_index.\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses);\n * const tree = sealance.buildTree(leaves);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1...\");\n * const proof = sealance.getSiblingPath(tree, leftIdx, 15);\n * // proof = { siblings: [0n, 1n, ...], leaf_index: leftIdx }\n * ```\n */\n getSiblingPath(\n tree: bigint[],\n leafIndex: number,\n depth: number,\n ): { siblings: bigint[]; leaf_index: number } {\n let num_leaves = Math.floor((tree.length + 1) / 2);\n const siblingPath: bigint[] = [];\n\n let index = leafIndex;\n let parentIndex = num_leaves;\n siblingPath.push(tree[index]);\n let level = 1;\n while (parentIndex < tree.length) {\n let siblingIndex = index % 2 === 0 ? index + 1 : index - 1; // Get the sibling index\n siblingPath.push(tree[siblingIndex]);\n\n index = parentIndex + Math.floor(leafIndex / 2 ** level); // Move up to the parent node\n parentIndex += Math.floor(num_leaves / 2 ** level); // Halve the number of nodes for the next level\n level++;\n }\n\n while (level < depth) {\n siblingPath.push(0n);\n level++;\n }\n\n return { siblings: siblingPath, leaf_index: leafIndex };\n }\n\n /**\n * Generates a formatted exclusion proof suitable for Aleo transactions.\n *\n * @param proof - An array of two {sibling path, leafindex} objects.\n * @returns String representation of the exclusion proof.\n *\n * @example\n * ```typescript\n * const addresses = [\n * \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * \"aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\",\n * ];\n * const sealance = new SealanceMerkleTree();\n * const leaves = sealance.generateLeaves(addresses);\n * const tree = sealance.buildTree(leaves);\n * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, \"aleo1...\");\n * const proof1 = getSiblingPath(tree, leftIdx, 15);\n * const proof2 = getSiblingPath(tree, rightIdx, 15);\n * const formattedProof = formatMerkleProof([proof1, proof2]);\n * // formattedProof = \"[{ siblings: [0field, 1field, ...], leaf_index: 0u32 }, { siblings: [0field, 2field, ...], leaf_index: 1u32 }]\"\n * ```\n */\n formatMerkleProof(proof: { siblings: bigint[]; leaf_index: number }[]): string {\n const formatted = proof.map(item => {\n const siblings = item.siblings.map(s => `${s}field`).join(\", \");\n return `{siblings: [${siblings}], leaf_index: ${item.leaf_index}u32}`;\n }).join(\", \");\n \n return `[${formatted}]`;\n }\n}\n\nexport { SealanceMerkleTree };","import { Account } from \"./account.js\";\nimport { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from \"./network-client.js\";\nimport { ImportedPrograms, ImportedVerifyingKeys } from \"./models/imports.js\";\nimport { FunctionInput } from \"./models/functionInput\";\nimport { RecordProvider } from \"./record-provider.js\";\nimport { RecordSearchParams } from \"./models/record-provider/recordSearchParams.js\";\n\nimport {\n AleoKeyProvider,\n AleoKeyProviderParams,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider.js\";\n\nimport {\n Address,\n Authorization,\n ExecutionResponse,\n Execution as FunctionExecution,\n OfflineQuery,\n RecordPlaintext,\n PrivateKey,\n Program,\n ProvingKey,\n ProvingRequest,\n VerifyingKey,\n Transaction,\n ProgramManager as WasmProgramManager,\n verifyFunctionExecution,\n} from \"./wasm.js\";\n\nimport {\n CREDITS_PROGRAM_KEYS,\n PRIVATE_TRANSFER_TYPES,\n VALID_TRANSFER_TYPES,\n} from \"./constants.js\";\n\nimport { logAndThrow } from \"./utils.js\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord.js\";\n\n/**\n * Represents the options for deploying and upgrading a transaction in the Aleo network.\n * This interface is used to specify the parameters required for building and submitting an deployment transaction.\n *\n * @property {string} program - The program source code to be deployed.\n * @property {number} priorityFee - The optional priority fee to be paid for the transaction.\n * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.\n * @property {RecordSearchParams | undefined} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.\n * @property {string | RecordPlaintext | undefined} [feeRecord] - Optional fee record to use for the transaction.\n * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.\n */\ninterface DeployOptions {\n program: string;\n priorityFee: number;\n privateFee: boolean;\n recordSearchParams?: RecordSearchParams;\n feeRecord?: string | RecordPlaintext;\n privateKey?: PrivateKey;\n}\n\n/**\n * Represents the options for executing a transaction in the Aleo network.\n * This interface is used to specify the parameters required for building and submitting an execution transaction.\n *\n * @property {string} programName - The name of the program containing the function to be executed.\n * @property {string} functionName - The name of the function to execute within the program.\n * @property {number} priorityFee - The optional priority fee to be paid for the transaction.\n * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.\n * @property {string[]} inputs - The inputs to the function being executed.\n * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.\n * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.\n * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.\n * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.\n * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.\n * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.\n * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.\n * @property {string | Program} [program] - Optional program source code to use for the transaction.\n * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.\n */\ninterface ExecuteOptions {\n programName: string;\n functionName: string;\n priorityFee: number;\n privateFee: boolean;\n inputs: string[];\n recordSearchParams?: RecordSearchParams;\n keySearchParams?: KeySearchParams;\n feeRecord?: string | RecordPlaintext;\n provingKey?: ProvingKey;\n verifyingKey?: VerifyingKey;\n privateKey?: PrivateKey;\n offlineQuery?: OfflineQuery;\n program?: string | Program;\n imports?: ProgramImports;\n edition?: number,\n}\n\n/**\n * Options for building an Authorization for a function.\n *\n * @property {string} programName Name of the program containing the function to build the authorization for.\n * @property {string} functionName Name of the function name to build the authorization for.\n * @property {string[]} inputs The inputs to the function.\n * @property {string | Program} [programSource] The optional source code for the program to build an execution for.\n * @property {PrivateKey} [privateKey] Optional private key to use to build the authorization.\n * @property {ProgramImports} [programImports] The other programs the program imports.\n * @property {edition} [edition]\n */\ninterface AuthorizationOptions {\n programName: string;\n functionName: string;\n inputs: string[];\n programSource?: string | Program;\n privateKey?: PrivateKey;\n programImports?: ProgramImports;\n edition?: number,\n}\n\n/**\n * Options for executing a fee authorization.\n *\n * @property {string} deploymentOrExecutionId The id of a previously built Execution or Authorization.\n * @property {number} baseFeeCredits The number of Aleo Credits to pay for the base fee.\n * @property {number} [priorityFeeCredits] The number of Aleo Credits to pay for the priority fee.\n * @property {PrivateKey} [privateKey] Optional private key to specify for the authorization.\n * @property {RecordPlaintext} [feeRecord] A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.\n */\ninterface FeeAuthorizationOptions {\n deploymentOrExecutionId: string,\n baseFeeCredits: number,\n priorityFeeCredits?: number,\n privateKey?: PrivateKey,\n feeRecord?: RecordPlaintext,\n}\n\n/**\n * Represents the options for executing a transaction on the Aleo Network from an authorization.\n *\n * @property {string} programName - The name of the program containing the function to be executed.\n * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.\n * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.\n * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.\n * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.\n * @property {string | Program} [program] - Optional program source code to use for the transaction.\n * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.\n */\ninterface ExecuteAuthorizationOptions {\n programName: string;\n authorization: Authorization,\n feeAuthorization?: Authorization,\n keySearchParams?: KeySearchParams;\n provingKey?: ProvingKey;\n verifyingKey?: VerifyingKey;\n offlineQuery?: OfflineQuery;\n program?: string | Program;\n imports?: ProgramImports;\n}\n\n/**\n * Represents the options for executing a transaction in the Aleo network.\n * This interface is used to specify the parameters required for building and submitting an execution transaction.\n *\n * @property {string} programName - The name of the program containing the function to be executed.\n * @property {string} functionName - The name of the function to execute within the program.\n * @property {number} baseFee - The base fee to be paid for the transaction.\n * @property {number} priorityFee - The optional priority fee to be paid for the transaction.\n * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.\n * @property {string[]} inputs - The inputs to the function being executed.\n * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.\n * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.\n * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.\n * @property {string | Program} [program] - Optional program source code to use for the transaction.\n * @property {string} uri - The URI send the ProvingRequest to.\n * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.\n * @property {boolean} broadcast - Whether to broadcast the Transaction generated by the remove prover to the Aleo network.\n */\ninterface ProvingRequestOptions {\n programName: string;\n functionName: string;\n priorityFee: number;\n privateFee: boolean;\n inputs: string[];\n baseFee?: number,\n recordSearchParams?: RecordSearchParams;\n feeRecord?: string | RecordPlaintext;\n privateKey?: PrivateKey;\n programSource?: string | Program;\n programImports?: ProgramImports;\n broadcast?: boolean;\n unchecked?: boolean;\n edition?: number,\n}\n\n/**\n * Fee estimate options.\n *\n * @property {string} programName - The name of the program containing the function to estimate the fee for.\n * @property {string} functionName - The name of the function to execute within the program to estimate the fee for.\n * @property {string} [program] - Program source code to use for the fee estimate.\n * @property {ProgramImports} [imports] - Programs that the program imports.\n * @property {number} [edition] - Edition of the program to estimate the fee for.\n * @property {Authorization} authorization - An authorization to estimate the fee for.\n */\ninterface FeeEstimateOptions {\n programName: string;\n functionName?: string;\n program?: string | Program;\n imports?: ProgramImports;\n edition?: number,\n authorization?: Authorization;\n}\n\n/**\n * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.\n */\nclass ProgramManager {\n account: Account | undefined;\n keyProvider: FunctionKeyProvider;\n host: string;\n networkClient: AleoNetworkClient;\n recordProvider: RecordProvider | undefined;\n inclusionKeysLoaded: boolean = false;\n\n /** Create a new instance of the ProgramManager\n *\n * @param { string | undefined } host A host uri running the official Aleo API\n * @param { FunctionKeyProvider | undefined } keyProvider A key provider that implements {@link FunctionKeyProvider} interface\n * @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface\n */\n constructor(\n host?: string | undefined,\n keyProvider?: FunctionKeyProvider | undefined,\n recordProvider?: RecordProvider | undefined,\n networkClientOptions?: AleoNetworkClientOptions | undefined,\n ) {\n this.host = host ? host : \"https://api.explorer.provable.com/v1\";\n this.networkClient = new AleoNetworkClient(this.host, networkClientOptions);\n\n this.keyProvider = keyProvider ? keyProvider : new AleoKeyProvider();\n this.recordProvider = recordProvider;\n }\n\n /**\n * Check if the fee is sufficient to pay for the transaction\n */\n async checkFee(address: string, feeAmount: bigint) {\n const balance =\n BigInt(await this.networkClient.getPublicBalance(address));\n if (feeAmount > balance) {\n throw Error(\n `The desired execution requires a fee of ${feeAmount} microcredits, but the account paying the fee has ${balance} microcredits available.`,\n );\n }\n }\n\n /**\n * Set the account to use for transaction submission to the Aleo network\n *\n * @param {Account} account Account to use for transaction submission\n */\n setAccount(account: Account) {\n this.account = account;\n }\n\n /**\n * Set the key provider that provides the proving and verifying keys for programs\n *\n * @param {FunctionKeyProvider} keyProvider\n */\n setKeyProvider(keyProvider: FunctionKeyProvider) {\n this.keyProvider = keyProvider;\n }\n\n /**\n * Set the host peer to use for transaction submission to the Aleo network\n *\n * @param host {string} Peer url to use for transaction submission\n */\n setHost(host: string) {\n this.host = host;\n this.networkClient.setHost(host);\n }\n\n /**\n * Set the record provider that provides records for transactions\n *\n * @param {RecordProvider} recordProvider\n */\n setRecordProvider(recordProvider: RecordProvider) {\n this.recordProvider = recordProvider;\n }\n\n /**\n * Set a header in the `AleoNetworkClient`s header map\n *\n * @param {string} headerName The name of the header to set\n * @param {string} value The header value\n *\n * @example\n * import { ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a ProgramManager\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\");\n *\n * // Set the value of the `Accept-Language` header to `en-US`\n * programManager.setHeader('Accept-Language', 'en-US');\n */\n setHeader(headerName: string, value: string) {\n this.networkClient.headers[headerName] = value;\n }\n\n /**\n * Set the inclusion prover into the wasm memory. This should be done prior to any execution of a function with a\n * private record.\n *\n * @param {ProvingKey} [provingKey]\n *\n * @example\n * import { ProgramManager, AleoKeyProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a ProgramManager\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Set the inclusion keys.\n * programManager.setInclusionProver();\n */\n async setInclusionProver(provingKey?: ProvingKey) {\n if (this.inclusionKeysLoaded) {\n return\n }\n try {\n if (provingKey) {\n WasmProgramManager.loadInclusionProver(provingKey)\n this.inclusionKeysLoaded = true;\n } else {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n }\n return;\n } catch {\n console.log(\"Setting the inclusion prover requires either a key provider to be configured for the ProgramManager OR to pass the inclusion prover directly\");\n }\n }\n\n /**\n * Remove a header from the `AleoNetworkClient`s header map\n *\n * @param {string} headerName The name of the header to be removed\n *\n * @example\n * import { ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a ProgramManager\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\");\n *\n * // Remove the default `X-Aleo-SDK-Version` header\n * programManager.removeHeader('X-Aleo-SDK-Version');\n */\n removeHeader(headerName: string) {\n delete this.networkClient.headers[headerName]\n }\n\n /**\n * Builds a deployment transaction for submission to the Aleo network.\n *\n * @param {string} program Program source code\n * @param {number} priorityFee The optional priority fee to be paid for that transaction.\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to use pay the deployment fee\n * @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildDeploymentTransaction(program, fee, false);\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildDeploymentTransaction(\n program: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n feeRecord?: string | RecordPlaintext,\n privateKey?: PrivateKey,\n ): Promise<Transaction> {\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network, deployment can proceed\n console.log(\n `Program ${programObject.id()} does not exist on the network, deploying...`,\n );\n }\n if (typeof programSource === \"string\") {\n throw Error(`Program ${programObject.id()} already exists on the network, please rename your program`);\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n\n // Build a deployment transaction\n return await WasmProgramManager.buildDeploymentTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n feeProvingKey,\n feeVerifyingKey,\n );\n }\n\n /**\n * Builds a deployment transaction for submission to the Aleo network that upgrades an existing program.\n *\n * @param {DeployOptions} options The deployment options.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildUpgradeTransaction({program: program, priorityFee: fee, privateFee: false});\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildUpgradeTransaction(\n options: DeployOptions\n ): Promise<Transaction> {\n const { program, priorityFee, privateFee, recordSearchParams } = options;\n let feeRecord = options.feeRecord;\n let privateKey = options.privateKey;\n\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network, deployment can proceed\n console.log(\n `Program ${programObject.id()} does not exist on the network...`,\n );\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n\n // Build a deployment transaction\n return await WasmProgramManager.buildUpgradeTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n feeProvingKey,\n feeVerifyingKey,\n );\n }\n\n /**\n * Deploy an Aleo program to the Aleo network\n *\n * @param {string} program Program source code\n * @param {number} priorityFee The optional fee to be paid for the transaction\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to used pay the deployment fee\n * @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Deploy the program\n * const tx_id = await programManager.deploy(program, fee, false);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 20000);\n */\n async deploy(\n program: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n feeRecord?: string | RecordPlaintext,\n privateKey?: PrivateKey,\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildDeploymentTransaction(\n program,\n priorityFee,\n privateFee,\n recordSearchParams,\n feeRecord,\n privateKey,\n )\n );\n\n let feeAddress;\n\n if (typeof privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Builds an execution transaction for submission to the Aleo network.\n *\n * @param {ExecuteOptions} options - The options for the execution transaction.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build and execute the transaction\n * const tx = await programManager.buildExecutionTransaction({\n * programName: \"hello_hello.aleo\",\n * functionName: \"hello_hello\",\n * priorityFee: 0.0,\n * privateFee: false,\n * inputs: [\"5u32\", \"5u32\"],\n * keySearchParams: { \"cacheKey\": \"hello_hello:hello\" }\n * });\n *\n * // Submit the transaction to the network\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildExecutionTransaction(\n options: ExecuteOptions,\n ): Promise<Transaction> {\n // Destructure the options object to access the parameters\n const {\n functionName,\n priorityFee,\n privateFee,\n inputs,\n recordSearchParams,\n keySearchParams,\n privateKey,\n offlineQuery,\n } = options;\n\n let feeRecord = options.feeRecord;\n let provingKey = options.provingKey;\n let verifyingKey = options.verifyingKey;\n let program = options.program;\n let programName = options.programName;\n let imports = options.imports;\n let edition = options.edition;\n\n let programObject;\n // Ensure the function exists on the network\n if (program === undefined) {\n try {\n programObject = await this.networkClient.getProgramObject(programName);\n program = <string>programObject.toString();\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (typeof program == \"string\") {\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(`Program sources passed for ${programName} were invalid: ${e}`);\n }\n } else if (program instanceof Program) {\n programObject = program;\n program = program.toString();\n }\n\n if (!(programObject instanceof Program)) {\n logAndThrow(`Failed to validate program ${programName}`);\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = programObject.id();\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee proving and verifying keys from the key provider\n let feeKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // If the function proving and verifying keys are not provided, attempt to find them using the key provider\n if (!provingKey || !verifyingKey) {\n try {\n [provingKey, verifyingKey] = <FunctionKeyPair>(\n await this.keyProvider.functionKeys(keySearchParams)\n );\n } catch (e) {\n console.log(\n `Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`,\n );\n }\n }\n\n // Resolve the program imports if they exist\n const numberOfImports = programObject.getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a fee record wasn't provided, estimate the fee that needs to be paid.\n if (!feeRecord) {\n const baseFee = Number(await this.estimateExecutionFee({programName, functionName, program, imports}));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n if (offlineQuery && !this.inclusionKeysLoaded) {\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction\n return await WasmProgramManager.buildExecutionTransaction(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n provingKey,\n verifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n offlineQuery,\n edition\n );\n }\n\n /**\n * Builds an execution transaction for submission to the Aleo network from an Authorization and Fee Authorization.\n * This method is helpful if signing and authorization needs to be done in a secure environment separate from where\n * transactions are built.\n *\n * @param {ExecuteAuthorizationOptions} options - The options for executing the authorizations.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from \"@provablehq/sdk\";\n *\n * await initThreadPool();\n *\n * // Create a new KeyProvider.\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Build the `Authorization`.\n * const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.\n * const authorization = await programManager.buildAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * privateKey,\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n *\n * console.log(\"Getting execution id\");\n *\n * // Derive the execution ID and base fee.\n * const executionId = authorization.toExecutionId().toString();\n *\n * console.log(\"Estimating fee\");\n *\n * // Get the base fee in microcredits.\n * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization(authorization, \"credits.aleo\");\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n *\n * console.log(\"Building fee authorization\");\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const feeAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: executionId,\n * baseFeeCredits,\n * privateKey\n * });\n *\n * console.log(\"Executing authorizations\");\n *\n * // Build and execute the transaction.\n * const tx = await programManager.buildTransactionFromAuthorization({\n * programName: \"credits.aleo\",\n * authorization,\n * feeAuthorization,\n * });\n *\n * // Submit the transaction to the network.\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful.\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * console.log(transaction);\n * }, 10000);\n */\n async buildTransactionFromAuthorization(\n options: ExecuteAuthorizationOptions,\n ): Promise<Transaction> {\n // Destructure the options object to access the parameters.\n const {\n programName,\n authorization,\n } = options;\n\n const feeAuthorization = options.feeAuthorization;\n const keySearchParams = options.keySearchParams;\n const offlineQuery = options.offlineQuery;\n let provingKey = options.provingKey;\n let verifyingKey = options.verifyingKey;\n let program = options.program;\n let imports = options.imports;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the fee proving and verifying keys from the key provider.\n let feeKeys;\n const privateFee = feeAuthorization ? feeAuthorization.isFeePrivate() : false;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n\n // If the function proving and verifying keys are not provided, attempt to find them using the key provider.\n if (!provingKey || !verifyingKey) {\n try {\n [provingKey, verifyingKey] = <FunctionKeyPair>(\n await this.keyProvider.functionKeys(keySearchParams)\n );\n } catch (e) {\n console.log(\n `Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`,\n );\n }\n }\n\n // Resolve the program imports if they exist.\n console.log(\"Resolving program imports\");\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // If the offline query exists, add the inclusion key.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n console.log(\"Loading inclusion keys for offline proving.\");\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction from the authorization.\n console.log(\"Executing authorizations\")\n return await WasmProgramManager.executeAuthorization(\n authorization,\n feeAuthorization,\n program,\n provingKey,\n verifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n imports,\n this.host,\n offlineQuery\n )\n }\n\n /**\n * Builds a SnarkVM `Authorization` for a specific function.\n *\n * @param {AuthorizationOptions} options - The options for building the `Authorization`\n * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build the `Authorization`.\n * const authorization = await programManager.buildAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n */\n async buildAuthorization(\n options: AuthorizationOptions,\n ): Promise<Authorization> {\n // Destructure the options object to access the parameters.\n const {\n functionName,\n inputs,\n } = options;\n\n const privateKey = options.privateKey;\n let program = options.programSource;\n let programName = options.programName;\n let imports = options.programImports;\n let edition = options.edition;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = Program.fromString(program).id();\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // Build and return an `Authorization` for the desired function.\n return await WasmProgramManager.authorize(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n imports,\n edition\n );\n }\n\n /**\n * Builds a SnarkVM `Authorization` for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.\n *\n * @param {AuthorizationOptions} options - The options for building the `Authorization`\n * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build the unchecked `Authorization`.\n * const authorization = await programManager.buildAuthorizationUnchecked({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n */\n async buildAuthorizationUnchecked(\n options: AuthorizationOptions,\n ): Promise<Authorization> {\n // Destructure the options object to access the parameters.\n const {\n functionName,\n inputs,\n } = options;\n\n const privateKey = options.privateKey;\n let program = options.programSource;\n let programName = options.programName;\n let imports = options.programImports;\n let edition = options.edition;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = Program.fromString(program).id();\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Build and return an `Authorization` for the desired function.\n return await WasmProgramManager.buildAuthorizationUnchecked(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n imports,\n edition\n );\n }\n\n /**\n * Builds a `ProvingRequest` for submission to a prover for execution.\n *\n * @param {ProvingRequestOptions} options - The options for building the proving request\n * @returns {Promise<ProvingRequest>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build the proving request.\n * const provingRequest = await programManager.provingRequest({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * priorityFee: 0,\n * privateFee: false,\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * broadcast: false,\n * });\n */\n async provingRequest(\n options: ProvingRequestOptions,\n ): Promise<ProvingRequest> {\n // Destructure the options object to access the parameters.\n const {\n functionName,\n priorityFee,\n privateFee,\n inputs,\n recordSearchParams,\n broadcast = false,\n unchecked = false,\n } = options;\n\n const privateKey = options.privateKey;\n const baseFee = options.baseFee ? options.baseFee : 0;\n let program = options.programSource;\n let programName = options.programName;\n let feeRecord = options.feeRecord;\n let imports = options.programImports;\n let edition = options.edition;\n\n // Ensure the function exists on the network.\n if (program === undefined) {\n try {\n program = <string>(\n await this.networkClient.getProgram(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (program instanceof Program) {\n program = program.toString();\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = Program.fromString(program).id();\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 1.`);\n edition = 1;\n }\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = Program.fromString(program).getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a fee record wasn't provided, estimate the fee that needs to be paid.\n if (!feeRecord) {\n const baseFee = Number(await this.estimateExecutionFee({programName, functionName, program: program.toString(), imports}));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Build and return the `ProvingRequest`.\n return await WasmProgramManager.buildProvingRequest(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n baseFee,\n priorityFee,\n feeRecord,\n imports,\n broadcast,\n unchecked,\n edition\n );\n }\n\n /**\n * Builds a SnarkVM fee `Authorization` for `credits.aleo/fee_private` or `credits.aleo/fee_public`. If a record is provided `fee_private` will be executed, otherwise `fee_public` will be executed.\n *\n * @param {FeeAuthorizationOptions} options - The options for building the `Authorization`.\n * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider.\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a ProgramManager with the key and record providers.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const feePublicAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: \"2423957656946557501636078245035919227529640894159332581642187482178647335171field\",\n * baseFeeCredits: 0.1,\n * });\n *\n * // Build a credits.aleo/fee_private `Authorization`.\n * const record = \"{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }\";\n * const feePrivateAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: \"2423957656946557501636078245035919227529640894159332581642187482178647335171field\",\n * baseFeeCredits: 0.1,\n * feeRecord: record,\n * });\n */\n async buildFeeAuthorization(\n options: FeeAuthorizationOptions,\n ): Promise<Authorization> {\n // Destructure the options object to access the parameters.\n const {\n privateKey,\n deploymentOrExecutionId,\n baseFeeCredits,\n priorityFeeCredits,\n feeRecord,\n } = options;\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Build and return the fee `Authorization`.\n return await WasmProgramManager.authorizeFee(\n executionPrivateKey,\n deploymentOrExecutionId,\n baseFeeCredits,\n priorityFeeCredits || 0,\n feeRecord,\n );\n }\n\n /**\n * Builds an execution transaction for submission to the Aleo network.\n *\n * @param {ExecuteOptions} options - The options for the execution transaction.\n * @returns {Promise<string>} - The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n *\n * // Build and execute the transaction\n * const tx_id = await programManager.execute({\n * programName: \"hello_hello.aleo\",\n * functionName: \"hello_hello\",\n * priorityFee: 0.0,\n * privateFee: false,\n * inputs: [\"5u32\", \"5u32\"],\n * keySearchParams: { \"cacheKey\": \"hello_hello:hello\" }\n * });\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async execute(options: ExecuteOptions): Promise<string> {\n const tx = <Transaction>await this.buildExecutionTransaction(options);\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Run an Aleo program in offline mode\n *\n * @param {string} program Program source code containing the function to be executed\n * @param {string} function_name Function name to execute\n * @param {string[]} inputs Inputs to the function\n * @param {number} proveExecution Whether to prove the execution of the function and return an execution transcript that contains the proof.\n * @param {string[] | undefined} imports Optional imports to the program\n * @param {KeySearchParams | undefined} keySearchParams Optional parameters for finding the matching proving & verifying keys for the function\n * @param {ProvingKey | undefined} provingKey Optional proving key to use for the transaction\n * @param {VerifyingKey | undefined} verifyingKey Optional verifying key to use for the transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<ExecutionResponse>} The execution response containing the outputs of the function and the proof if the program is proved.\n *\n * @example\n * /// Import the mainnet version of the sdk used to build executions.\n * import { Account, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * /// Create the source for the \"helloworld\" program\n * const program = \"program helloworld.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(undefined, undefined, undefined);\n *\n * /// Create a temporary account for the execution of the program\n * const account = new Account();\n * programManager.setAccount(account);\n *\n * /// Get the response and ensure that the program executed correctly\n * const executionResponse = await programManager.run(program, \"hello\", [\"5u32\", \"5u32\"]);\n * const result = executionResponse.getOutputs();\n * assert(result === [\"10u32\"]);\n */\n async run(\n program: string,\n function_name: string,\n inputs: string[],\n proveExecution: boolean,\n imports?: ProgramImports,\n keySearchParams?: KeySearchParams,\n provingKey?: ProvingKey,\n verifyingKey?: VerifyingKey,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n edition?: number\n ): Promise<ExecutionResponse> {\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // If the function proving and verifying keys are not provided, attempt to find them using the key provider\n if (!provingKey || !verifyingKey) {\n try {\n [provingKey, verifyingKey] = <FunctionKeyPair>(\n await this.keyProvider.functionKeys(keySearchParams)\n );\n } catch (e) {\n console.log(\n `Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`,\n );\n }\n }\n\n // Run the program offline and return the result\n console.log(\"Running program offline\");\n console.log(\"Proving key: \", provingKey);\n console.log(\"Verifying key: \", verifyingKey);\n return WasmProgramManager.executeFunctionOffline(\n executionPrivateKey,\n program,\n function_name,\n inputs,\n proveExecution,\n false,\n imports,\n provingKey,\n verifyingKey,\n this.host,\n offlineQuery,\n edition\n );\n }\n\n /**\n * Join two credits records into a single credits record\n *\n * @param {RecordPlaintext | string} recordOne First credits record to join\n * @param {RecordPlaintext | string} recordTwo Second credits record to join\n * @param {number} priorityFee The optional priority fee to be paid for the transaction\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the fee record to use to pay the fee for the join transaction\n * @param {RecordPlaintext | string | undefined} feeRecord Fee record to use for the join transaction\n * @param {PrivateKey | undefined} privateKey Private key to use for the join transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const record_1 = \"{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}\"\n * const record_2 = \"{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 1540945439182663264862696551825005342995406165131907382295858612069623286213group.public}\"\n * const tx_id = await programManager.join(record_1, record_2, 0.05, false);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async join(\n recordOne: RecordPlaintext | string,\n recordTwo: RecordPlaintext | string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams | undefined,\n feeRecord?: RecordPlaintext | string | undefined,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<string> {\n // Get the private key from the account if it is not provided in the parameters and assign the fee address\n let executionPrivateKey = privateKey;\n let feeAddress;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n feeAddress = this.account?.address();\n }\n else if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n else {\n feeAddress = Address.from_private_key(executionPrivateKey);\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n let joinKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n joinKeys = <FunctionKeyPair>await this.keyProvider.joinKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n const [joinProvingKey, joinVerifyingKey] = joinKeys;\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a fee record wasn't provided, estimate the fee that needs to be paid.\n if (!feeRecord) {\n const baseFee = Number(await this.estimateExecutionFee({programName: \"credits.aleo\", functionName: \"join\"}));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Validate the records provided are valid plaintext records\n try {\n recordOne =\n recordOne instanceof RecordPlaintext\n ? recordOne\n : RecordPlaintext.fromString(recordOne);\n recordTwo =\n recordTwo instanceof RecordPlaintext\n ? recordTwo\n : RecordPlaintext.fromString(recordTwo);\n } catch (e: any) {\n logAndThrow(\n \"Records provided are not valid. Please ensure they are valid plaintext records.\",\n );\n }\n\n // Load the inclusion prover offline.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction and submit it to the network\n const tx = await WasmProgramManager.buildJoinTransaction(\n executionPrivateKey,\n recordOne,\n recordTwo,\n priorityFee,\n feeRecord,\n this.host,\n joinProvingKey,\n joinVerifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n offlineQuery,\n );\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Split credits into two new credits records\n *\n * @param {number} splitAmount Amount in microcredits to split from the original credits record\n * @param {RecordPlaintext | string} amountRecord Amount record to use for the split transaction\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the split transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const record = \"{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}\"\n * const tx_id = await programManager.split(25000000, record);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async split(\n splitAmount: number,\n amountRecord: RecordPlaintext | string,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<string> {\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the split keys from the key provider\n let splitKeys;\n try {\n splitKeys = <FunctionKeyPair>await this.keyProvider.splitKeys();\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [splitProvingKey, splitVerifyingKey] = splitKeys;\n\n // Validate the record to be split\n try {\n amountRecord =\n amountRecord instanceof RecordPlaintext\n ? amountRecord\n : RecordPlaintext.fromString(amountRecord);\n } catch (e: any) {\n logAndThrow(\n \"Record provided is not valid. Please ensure it is a valid plaintext record.\",\n );\n }\n\n // Load the inclusion prover offline.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction and submit it to the network\n const tx = await WasmProgramManager.buildSplitTransaction(\n executionPrivateKey,\n splitAmount,\n amountRecord,\n this.host,\n splitProvingKey,\n splitVerifyingKey,\n offlineQuery,\n );\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Pre-synthesize proving and verifying keys for a program\n *\n * @param program {string} The program source code to synthesize keys for\n * @param function_id {string} The function id to synthesize keys for\n * @param inputs {Array<string>} Sample inputs to the function\n * @param privateKey {PrivateKey | undefined} Optional private key to use for the key synthesis\n *\n * @returns {Promise<FunctionKeyPair>}\n */\n async synthesizeKeys(\n program: string,\n function_id: string,\n inputs: Array<string>,\n privateKey?: PrivateKey,\n ): Promise<FunctionKeyPair> {\n // Resolve the program imports if they exist\n let imports;\n\n let executionPrivateKey = privateKey;\n if (typeof executionPrivateKey === \"undefined\") {\n if (typeof this.account !== \"undefined\") {\n executionPrivateKey = this.account.privateKey();\n } else {\n executionPrivateKey = new PrivateKey();\n }\n }\n\n // Attempt to run an offline execution of the program and extract the proving and verifying keys\n try {\n imports = await this.networkClient.getProgramImports(program);\n const keyPair = await WasmProgramManager.synthesizeKeyPair(\n executionPrivateKey,\n program,\n function_id,\n inputs,\n imports,\n );\n return [\n <ProvingKey>keyPair.provingKey(),\n <VerifyingKey>keyPair.verifyingKey(),\n ];\n } catch (e: any) {\n logAndThrow(\n `Could not synthesize keys - error ${e.message}. Please ensure the program is valid and the inputs are correct.`,\n );\n }\n }\n\n /**\n * Build a transaction to transfer credits to another account for later submission to the Aleo network\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'\n * @param {number} priorityFee The optional priority fee to be paid for the transaction\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee records for the transfer transaction\n * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer\n * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx = await programManager.buildTransferTransaction(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"public\", 0.2, false);\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildTransferTransaction(\n amount: number,\n recipient: string,\n transferType: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n amountRecord?: RecordPlaintext | string,\n feeRecord?: RecordPlaintext | string,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<Transaction> {\n // Validate the transfer type\n transferType = <string>validateTransferType(transferType);\n\n // Get the private key from the account if it is not provided in the parameters\n let executionPrivateKey = privateKey;\n if (\n typeof executionPrivateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the proving and verifying keys from the key provider\n let feeKeys;\n let transferKeys;\n try {\n feeKeys = privateFee\n ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys()\n : <FunctionKeyPair>await this.keyProvider.feePublicKeys();\n transferKeys = <FunctionKeyPair>(\n await this.keyProvider.transferKeys(transferType)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`,\n );\n }\n const [feeProvingKey, feeVerifyingKey] = feeKeys;\n const [transferProvingKey, transferVerifyingKey] = transferKeys;\n\n // Get the amount and fee record from the account if it is not provided in the parameters\n try {\n // Track the nonces of the records found so no duplicate records are used\n const nonces: string[] = [];\n if (requiresAmountRecord(transferType)) {\n // If the transfer type is private and requires an amount record, get it from the record provider\n amountRecord = await this.getCreditsRecord(\n priorityFee,\n [],\n amountRecord,\n recordSearchParams,\n );\n nonces.push(amountRecord.nonce());\n } else {\n amountRecord = undefined;\n }\n if (privateFee) {\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n priorityFee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Load the inclusion prover offline.\n if (offlineQuery && !this.inclusionKeysLoaded) {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n try {\n const inclusionKeys = await this.keyProvider.inclusionKeys();\n WasmProgramManager.loadInclusionProver(inclusionKeys[0])\n this.inclusionKeysLoaded = true;\n console.log(\"Successfully loaded inclusion key\");\n } catch {\n logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`)\n }\n }\n\n // Build an execution transaction\n return await WasmProgramManager.buildTransferTransaction(\n executionPrivateKey,\n amount,\n recipient,\n transferType,\n amountRecord,\n priorityFee,\n feeRecord,\n this.host,\n transferProvingKey,\n transferVerifyingKey,\n feeProvingKey,\n feeVerifyingKey,\n offlineQuery,\n );\n }\n\n /**\n * Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {number} priorityFee The optional priority fee to be paid for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx = await programManager.buildTransferPublicTransaction(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", 0.2);\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildTransferPublicTransaction(\n amount: number,\n recipient: string,\n priorityFee: number,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<Transaction> {\n return this.buildTransferTransaction(\n amount,\n recipient,\n \"public\",\n priorityFee,\n false,\n undefined,\n undefined,\n undefined,\n privateKey,\n offlineQuery,\n );\n }\n\n /**\n * Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {number} priorityFee The optional priority fee to be paid for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx = await programManager.buildTransferPublicAsSignerTransaction(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", 0.2);\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildTransferPublicAsSignerTransaction(\n amount: number,\n recipient: string,\n priorityFee: number,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<Transaction> {\n return this.buildTransferTransaction(\n amount,\n recipient,\n \"public\",\n priorityFee,\n false,\n undefined,\n undefined,\n undefined,\n privateKey,\n offlineQuery,\n );\n }\n\n /**\n * Transfer credits to another account\n *\n * @param {number} amount The amount of credits to transfer\n * @param {string} recipient The recipient of the transfer\n * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'\n * @param {number} priorityFee The optional priority fee to be paid for the transfer\n * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance\n * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee records for the transfer transaction\n * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer\n * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer\n * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction\n * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, KeyProvider, and RecordProvider\n * const keyProvider = new AleoKeyProvider();\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, recordProvider);\n * const tx_id = await programManager.transfer(1, \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"public\", 0.2, false);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async transfer(\n amount: number,\n recipient: string,\n transferType: string,\n priorityFee: number,\n privateFee: boolean,\n recordSearchParams?: RecordSearchParams,\n amountRecord?: RecordPlaintext | string,\n feeRecord?: RecordPlaintext | string,\n privateKey?: PrivateKey,\n offlineQuery?: OfflineQuery,\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildTransferTransaction(\n amount,\n recipient,\n transferType,\n priorityFee,\n privateFee,\n recordSearchParams,\n amountRecord,\n feeRecord,\n privateKey,\n offlineQuery,\n )\n );\n\n let feeAddress;\n\n if (typeof privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build transaction to bond credits to a validator for later submission to the Aleo Network\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the bonding transaction object for later submission\n * const tx = await programManager.buildBondPublicTransaction(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // The transaction can be later submitted to the network using the network client.\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildBondPublicTransaction(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const scaledAmount = Math.trunc(amount * 1000000);\n\n const {\n programName = \"credits.aleo\",\n functionName = \"bond_public\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [\n validator_address,\n withdrawal_address,\n `${scaledAmount.toString()}u64`,\n ],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.bond_public.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.bond_public.verifier,\n cacheKey: \"credits.aleo/bond_public\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Bond credits to validator.\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the signer (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 1,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond\n * @param {Options} options Options for the execution\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the bonding transaction\n * tx_id = await programManager.bondPublic(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", \"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async bondPublic(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const tx = <Transaction>(\n await this.buildBondPublicTransaction(\n validator_address,\n withdrawal_address,\n amount,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build a bond_validator transaction for later submission to the Aleo Network.\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond. A minimum of 10000 credits is required to bond as a delegator.\n * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the bond validator transaction object for later use.\n * const tx = await programManager.buildBondValidatorTransaction(\"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // The transaction can later be submitted to the network using the network client.\n * const tx_id = await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async buildBondValidatorTransaction(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n commission: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const scaledAmount = Math.trunc(amount * 1000000);\n\n const adjustedCommission = Math.trunc(commission);\n\n const {\n programName = \"credits.aleo\",\n functionName = \"bond_validator\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [\n validator_address,\n withdrawal_address,\n `${scaledAmount.toString()}u64`,\n `${adjustedCommission.toString()}u8`,\n ],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.bond_validator.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.bond_validator.verifier,\n cacheKey: \"credits.aleo/bond_validator\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Build transaction to bond a validator.\n *\n * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.\n * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.\n * @param {number} amount The amount of credits to bond\n * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the bonding transaction\n * const tx_id = await programManager.bondValidator(\"aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\", \"aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9\", 2000000);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async bondValidator(\n validator_address: string,\n withdrawal_address: string,\n amount: number,\n commission: number,\n options: Partial<ExecuteOptions> = {},\n ) {\n const tx = <Transaction>(\n await this.buildBondValidatorTransaction(\n validator_address,\n withdrawal_address,\n amount,\n commission,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build an unbond_public execution transaction to unbond credits from a validator in the Aleo network.\n *\n * @param {string} staker_address - The address of the staker who is unbonding the credits.\n * @param {number} amount - The amount of credits to unbond (scaled by 1,000,000).\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management.\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to unbond credits.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * const tx = await programManager.buildUnbondPublicTransaction(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", 2000000);\n *\n * // The transaction can be submitted later to the network using the network client.\n * programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildUnbondPublicTransaction(\n staker_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ): Promise<Transaction> {\n const scaledAmount = Math.trunc(amount * 1000000);\n\n const {\n programName = \"credits.aleo\",\n functionName = \"unbond_public\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [staker_address, `${scaledAmount.toString()}u64`],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.unbond_public.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.unbond_public.verifier,\n cacheKey: \"credits.aleo/unbond_public\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Unbond a specified amount of staked credits. If the address of the executor of this function is an existing\n * validator, it will subtract this amount of credits from the validator's staked credits. If there are less than\n * 1,000,000 credits staked pool after the unbond, the validator will be removed from the validator set. If the\n * address of the executor of this function is not a validator and has credits bonded as a delegator, it will\n * subtract this amount of credits from the delegator's staked credits. If there are less than 10 credits bonded\n * after the unbond operation, the delegator will be removed from the validator's staking pool.\n *\n * @param {string} staker_address Address of the staker who is unbonding the credits\n * @param {number} amount Amount of credits to unbond.\n * @param {ExecuteOptions} options Options for the execution\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the unbond_public transaction and send it to the network\n * const tx_id = await programManager.unbondPublic(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\", 10);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async unbondPublic(\n staker_address: string,\n amount: number,\n options: Partial<ExecuteOptions> = {},\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildUnbondPublicTransaction(\n staker_address,\n amount,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build a transaction to claim unbonded public credits in the Aleo network.\n *\n * @param {string} staker_address - The address of the staker who is claiming the credits.\n * @param {Partial<ExecuteOptions>} options - Override default execution options.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to claim unbonded credits.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the claim_unbond_public transaction object for later use.\n * const tx = await programManager.buildClaimUnbondPublicTransaction(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\");\n *\n * // The transaction can be submitted later to the network using the network client.\n * programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildClaimUnbondPublicTransaction(\n staker_address: string,\n options: Partial<ExecuteOptions> = {},\n ): Promise<Transaction> {\n const {\n programName = \"credits.aleo\",\n functionName = \"claim_unbond_public\",\n priorityFee = options.priorityFee || 0,\n privateFee = false,\n inputs = [staker_address],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.claim_unbond_public.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier,\n cacheKey: \"credits.aleo/claim_unbond_public\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n // Check if the account has sufficient credits to pay for the transaction\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will\n * claim them and add them to the public balance of the account.\n *\n * @param {string} staker_address Address of the staker who is claiming the credits\n * @param {ExecuteOptions} options\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n * programManager.setAccount(new Account(\"YourPrivateKey\"));\n *\n * // Create the claim_unbond_public transaction\n * const tx_id = await programManager.claimUnbondPublic(\"aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j\");\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async claimUnbondPublic(\n staker_address: string,\n options: Partial<ExecuteOptions> = {},\n ): Promise<string> {\n const tx = <Transaction>(\n await this.buildClaimUnbondPublicTransaction(\n staker_address,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return await this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Build a set_validator_state transaction for later usage.\n *\n * This function allows a validator to set their state to be either opened or closed to new stakers.\n * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\n * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n *\n * This function serves two primary purposes:\n * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.\n *\n * @param {boolean} validator_state\n * @param {Partial<ExecuteOptions>} options - Override default execution options\n * @returns {Promise<Transaction>} The transaction object\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the set_validator_state transaction\n * const tx = await programManager.buildSetValidatorStateTransaction(true);\n *\n * // The transaction can be submitted later to the network using the network client.\n * programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildSetValidatorStateTransaction(\n validator_state: boolean,\n options: Partial<ExecuteOptions> = {},\n ): Promise<Transaction> {\n const {\n programName = \"credits.aleo\",\n functionName = \"set_validator_state\",\n priorityFee = 0,\n privateFee = false,\n inputs = [validator_state.toString()],\n keySearchParams = new AleoKeyProviderParams({\n proverUri: CREDITS_PROGRAM_KEYS.set_validator_state.prover,\n verifierUri: CREDITS_PROGRAM_KEYS.set_validator_state.verifier,\n cacheKey: \"credits.aleo/set_validator_state\",\n }),\n program = this.creditsProgram(),\n ...additionalOptions\n } = options;\n\n const executeOptions: ExecuteOptions = {\n programName,\n functionName,\n priorityFee,\n privateFee,\n inputs,\n keySearchParams,\n program,\n ...additionalOptions,\n };\n\n return await this.buildExecutionTransaction(executeOptions);\n }\n\n /**\n * Submit a set_validator_state transaction to the Aleo Network.\n *\n * This function allows a validator to set their state to be either opened or closed to new stakers.\n * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\n * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n *\n * This function serves two primary purposes:\n * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.\n *\n * @param {boolean} validator_state\n * @param {Partial<ExecuteOptions>} options - Override default execution options\n * @returns {Promise<string>} The transaction id\n *\n * @example\n * // Import the mainnet version of the sdk.\n * import { AleoKeyProvider, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a keyProvider to handle key management\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Create a new ProgramManager with the key that will be used to bond credits\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider, undefined);\n *\n * // Create the set_validator_state transaction\n * const tx_id = await programManager.setValidatorState(true);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx_id);\n * assert(transaction.id() === tx_id);\n * }, 10000);\n */\n async setValidatorState(\n validator_state: boolean,\n options: Partial<ExecuteOptions> = {},\n ) {\n const tx = <Transaction>(\n await this.buildSetValidatorStateTransaction(\n validator_state,\n options,\n )\n );\n\n let feeAddress;\n\n if (typeof options.privateKey !== \"undefined\") {\n feeAddress = Address.from_private_key(options.privateKey);\n } else if (this.account !== undefined) {\n feeAddress = this.account?.address();\n } else {\n throw Error(\n \"No private key provided and no private key set in the ProgramManager. Please set an account or provide a private key.\",\n );\n }\n\n // Check if the account has sufficient credits to pay for the transaction\n if (!options.privateFee) {\n await this.checkFee(feeAddress.to_string(), tx.feeAmount());\n }\n\n return this.networkClient.submitTransaction(tx);\n }\n\n /**\n * Verify a proof from an offline execution. This is useful when it is desired to do offchain proving and verification.\n *\n * @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)\n * @param {blockHeight} blockHeight The ledger height when the execution was generated.\n * @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { \"programName\": \"programSourceCode\", ... }\n * @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { \"programName\": [[\"functionName\", \"verifyingKey\"], ...], ... }\n * @returns {boolean} True if the proof is valid, false otherwise\n *\n * @example\n * /// Import the mainnet version of the sdk used to build executions.\n * import { Account, ProgramManager } from \"@provablehq/sdk/mainnet.js\";\n *\n * /// Create the source for two programs.\n * const program = \"import add_it_up.aleo; \\n\\n program mul_add.aleo;\\n\\nfunction mul_and_add:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n mul r0 r1 into r2;\\n call add_it_up.aleo/add_it r1 r2 into r3; output r3 as u32.private;\\n\";\n * const program_import = \"program add_it_up.aleo;\\n\\nfunction add_it:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(undefined, undefined, undefined);\n *\n * /// Create a temporary account for the execution of the program\n * const account = Account.fromCipherText(process.env.ciphertext, process.env.password);\n * programManager.setAccount(account);\n *\n * /// Get the response and ensure that the program executed correctly\n * const executionResponse = await programManager.run(program, \"mul_and_add\", [\"5u32\", \"5u32\"], true);\n *\n * /// Construct the imports and verifying keys\n * const imports = { \"add_it_up.aleo\": program_import };\n * const importedVerifyingKeys = { \"add_it_up.aleo\": [[\"add_it\", \"verifyingKey1...\"]] };\n *\n * /// Verify the execution.\n * const blockHeight = 9000000;\n * const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);\n * assert(isValid);\n */\n verifyExecution(executionResponse: ExecutionResponse, blockHeight: number, imports?: ImportedPrograms, importedVerifyingKeys?: ImportedVerifyingKeys): boolean {\n try {\n const execution = <FunctionExecution>(\n executionResponse.getExecution()\n );\n const function_id = executionResponse.getFunctionId();\n const program = executionResponse.getProgram();\n const verifyingKey = executionResponse.getVerifyingKey();\n return verifyFunctionExecution(\n execution,\n verifyingKey,\n program,\n function_id,\n imports,\n importedVerifyingKeys,\n blockHeight\n );\n } catch (e) {\n console.warn(\n `The execution was not found in the response, cannot verify the execution: ${e}`,\n );\n return false;\n }\n }\n\n /**\n * Create a program object from a program's source code\n *\n * @param {string} program Program source code\n * @returns {Program} The program object\n */\n createProgramFromSource(program: string): Program {\n return Program.fromString(program);\n }\n\n /**\n * Get the credits program object\n *\n * @returns {Program} The credits program object\n */\n creditsProgram(): Program {\n return Program.getCreditsProgram();\n }\n\n /**\n * Verify a program is valid\n *\n * @param {string} program The program source code\n */\n verifyProgram(program: string): boolean {\n try {\n <Program>Program.fromString(program);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Estimate the execution fee for an authorization.\n *\n * @param {FeeEstimateOptions} options Options for fee estimate.\n *\n * @example\n * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from \"@provablehq/sdk\";\n *\n * await initThreadPool();\n *\n * // Create a new KeyProvider.\n * const keyProvider = new AleoKeyProvider();\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Build the `Authorization`.\n * const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.\n * const authorization = await programManager.buildAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * privateKey,\n * inputs: [\n * \"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08\",\n * \"10000000u64\",\n * ],\n * });\n *\n * console.log(\"Getting execution id\");\n *\n * // Derive the execution ID and base fee.\n * const executionId = authorization.toExecutionId().toString();\n *\n * console.log(\"Estimating fee\");\n *\n * // Get the base fee in microcredits.\n * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({\n * authorization,\n * programName: \"credits.aleo\"\n * });\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n *\n * console.log(\"Building fee authorization\");\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const feeAuthorization = await programManager.buildFeeAuthorization({\n * deploymentOrExecutionId: executionId,\n * baseFeeCredits,\n * privateKey\n * });\n */\n async estimateFeeForAuthorization(\n options: FeeEstimateOptions\n ): Promise<bigint> {\n const {\n authorization,\n programName,\n program,\n imports,\n edition\n } = options;\n if (!authorization) {\n throw new Error(\"Authorization must be provided if estimating fee for Authorization.\")\n }\n const programSource = program ? program.toString() : await this.networkClient.getProgram(programName, edition);\n const programImports = imports ? imports : await this.networkClient.getProgramImports(programSource);\n console.log(JSON.stringify(programImports));\n if (Object.keys(programImports)) {\n return WasmProgramManager.estimateFeeForAuthorization(authorization, programSource, programImports, edition);\n }\n return WasmProgramManager.estimateFeeForAuthorization(authorization, programSource, imports, edition);\n }\n\n /**\n * Estimate the execution fee for an Aleo function.\n *\n * @param {FeeEstimateOptions} options Options for the fee estimate.\n *\n * @returns {Promise<bigint>} Execution fee in microcredits for the authorization.\n *\n * @example\n * import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from \"@provablehq/sdk\";\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for executions.\n * const programManager = new ProgramManager(\"https://api.explorer.provable.com/v1\", keyProvider);\n *\n * // Get the base fee in microcredits.\n * const baseFeeMicrocredits = await programManager.estimateExecutionFee({programName: \"credits.aleo\"});\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n *\n * console.log(\"Building fee authorization\");\n *\n * // Build a credits.aleo/fee_public `Authorization`.\n * const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({\n * programName: \"credits.aleo\",\n * functionName: \"transfer_public\",\n * });\n * const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;\n */\n async estimateExecutionFee(\n options: FeeEstimateOptions,\n ): Promise<bigint> {\n const {\n functionName,\n programName,\n program,\n imports,\n edition\n } = options;\n if (!functionName) {\n throw new Error(\"Function name must be specified when estimating fee.\");\n }\n const programSource = program ? program.toString() : await this.networkClient.getProgram(programName, edition);\n const programImports = imports ? imports : await this.networkClient.getProgramImports(programSource);\n if (Object.keys(programImports)) {\n return WasmProgramManager.estimateExecutionFee(programSource, functionName, programImports, edition);\n }\n return WasmProgramManager.estimateExecutionFee(programSource, functionName, imports, edition);\n }\n\n // Internal utility function for getting a credits.aleo record\n async getCreditsRecord(\n amount: number,\n nonces: string[],\n record?: RecordPlaintext | string,\n params?: RecordSearchParams,\n ): Promise<RecordPlaintext> {\n if (record) {\n try {\n return record instanceof RecordPlaintext\n ? record : RecordPlaintext.fromString(<string>record);\n } catch {\n logAndThrow(`Record '${record}' could not be parsed, please ensure a valid credits.aleo record \n is passed prior to trying again`)\n }\n } else {\n try {\n const recordProvider = <RecordProvider>this.recordProvider;\n const record = await recordProvider.findCreditsRecord(\n amount,\n { ...params, unspent: true, nonces }\n );\n if (record.record_plaintext) {\n return RecordPlaintext.fromString(record.record_plaintext);\n } else {\n logAndThrow(\"Failed to deserialize record returned from record provider\");\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n }\n }\n\n /**\n * Builds an execution transaction for submission to the a local devnode.\n * This method skips proof generation and is not meant for use with the mainnet or testnet Aleo networks.\n * Note: getOrInitConsensusVersionTestHeights must be called prior to using this method for this method to work properly.\n *\n * @param {ExecuteOptions} options - The options for the execution transaction.\n * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n * \n * // Initialize the development consensus heights in order to work with devnode.\n * getOrInitConsensusVersionTestHeights(\"0,1,2,3,4,5,6,7,8,9,10,11\");\n *\n * // Create a new NetworkClient and RecordProvider.\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager.\n * const programManager = new ProgramManager(\"http://localhost:3030\", recordProvider);\n *\n * // Build and execute the transaction.\n * const tx = await programManager.buildDevnodeExecutionTransaction({\n * programName: \"hello_hello.aleo\",\n * functionName: \"hello_hello\",\n * priorityFee: 0.0,\n * privateFee: false,\n * inputs: [\"5u32\", \"5u32\"],\n * });\n *\n * // Submit the transaction to the network\n * await programManager.networkClient.submitTransaction(tx.toString());\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 10000);\n */\n async buildDevnodeExecutionTransaction(\n options: ExecuteOptions,\n ): Promise<Transaction> {\n // Destructure the options object to access the parameters\n const {\n functionName,\n priorityFee,\n privateFee,\n inputs,\n recordSearchParams,\n privateKey,\n } = options;\n\n let feeRecord = options.feeRecord;\n let program = options.program;\n let programName = options.programName;\n let imports = options.imports;\n let edition = options.edition;\n\n let programObject;\n // Ensure the function exists on the network\n if (program === undefined) {\n try {\n programObject = await this.networkClient.getProgramObject(programName);\n program = <string>programObject.toString();\n } catch (e: any) {\n logAndThrow(\n `Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`,\n );\n }\n } else if (typeof program == \"string\") {\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(`Program sources passed for ${programName} were invalid: ${e}`);\n }\n } else if (program instanceof Program) {\n programObject = program;\n program = program.toString();\n }\n\n if (!(programObject instanceof Program)) {\n logAndThrow(`Failed to validate program ${programName}`);\n }\n\n // Get the program name if it is not provided in the parameters.\n if (programName === undefined) {\n programName = programObject.id();\n }\n\n if (edition == undefined) {\n try {\n edition = await this.networkClient.getLatestProgramEdition(programName);\n } catch (e: any) {\n console.warn(`Error finding edition for ${programName}. Network response: '${e.message}'. Assuming edition 0.`);\n edition = 0;\n }\n }\n\n // Get the private key from the account if it is not provided in the parameters.\n let executionPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n executionPrivateKey = this.account.privateKey();\n }\n\n if (typeof executionPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters.\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Resolve the program imports if they exist.\n const numberOfImports = programObject.getImports().length;\n if (numberOfImports > 0 && !imports) {\n try {\n imports = <ProgramImports>(\n await this.networkClient.getProgramImports(programName)\n );\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n }\n \n // Build a transaction without a proof\n return await WasmProgramManager.buildDevnodeExecutionTransaction(\n executionPrivateKey,\n program,\n functionName,\n inputs,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n edition\n );\n }\n \n /**\n * Builds a deployment transaction with placeholder certificates and verifying keys for each function in the program.\n * Intended for use with a local devnode.\n * `getOrInitConsensusVersionTestHeights` must be called with development heights prior to invoking this method for it to work properly.\n *\n * @param {DeployOptions} options - The options for the deployment transaction.\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from \"@provablehq/sdk/mainnet.js\";\n * \n * // Initialize the development consensus heights in order to work with a local devnode.\n * getOrInitConsensusVersionTestHeights(\"0,1,2,3,4,5,6,7,8,9,10,11\");\n *\n * // Create a new NetworkClient, and RecordProvider\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"http://localhost:3030\", recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildDevnodeDeploymentTransaction({program: program, fee: priorityFee, privateFee: false});\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildDevnodeDeploymentTransaction(\n options: DeployOptions\n ): Promise<Transaction> {\n const { program, priorityFee, privateFee, recordSearchParams } = options;\n let feeRecord = options.feeRecord;\n let privateKey = options.privateKey;\n\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network, deployment can proceed\n console.log(\n `Program ${programObject.id()} does not exist on the network, deploying...`,\n );\n }\n if (typeof programSource === \"string\") {\n throw Error(`Program ${programObject.id()} already exists on the network, please rename your program`);\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n \n return await WasmProgramManager.buildDevnodeDeploymentTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n );\n }\n\n /**\n * Builds an upgrade transaction on a local devnodewith placeholder certificates and verifying keys for each function in the program.\n * This method is only intended for use with a local devnode.\n *\n * @param {DeployOptions} options - The options for the deployment transaction.\n * @returns {string} The transaction id of the deployed program or a failure message from the network\n *\n * @example\n * /// Import the mainnet version of the sdk.\n * import { ProgramManager, NetworkRecordProvider } from \"@provablehq/sdk/mainnet.js\";\n *\n * // Create a new NetworkClient, and RecordProvider\n * const recordProvider = new NetworkRecordProvider(account, networkClient);\n * keyProvider.useCache(true);\n *\n * // Initialize a program manager with the key provider to automatically fetch keys for deployments\n * const program = \"program hello_hello.aleo;\\n\\nfunction hello:\\n input r0 as u32.public;\\n input r1 as u32.private;\\n add r0 r1 into r2;\\n output r2 as u32.private;\\n\";\n * const programManager = new ProgramManager(\"http://localhost:3030\", recordProvider);\n * programManager.setAccount(Account);\n *\n * // Define a fee in credits\n * const priorityFee = 0.0;\n *\n * // Create the deployment transaction.\n * const tx = await programManager.buildDevnodeUpgradeTransaction({program: program, fee: priorityFee, privateFee: false});\n * await programManager.networkClient.submitTransaction(tx);\n *\n * // Verify the transaction was successful\n * setTimeout(async () => {\n * const transaction = await programManager.networkClient.getTransaction(tx.id());\n * assert(transaction.id() === tx.id());\n * }, 20000);\n */\n async buildDevnodeUpgradeTransaction(\n options: DeployOptions\n ): Promise<Transaction> {\n const { program, priorityFee, privateFee, recordSearchParams } = options;\n let feeRecord = options.feeRecord;\n let privateKey = options.privateKey;\n\n // Ensure the program is valid.\n let programObject;\n try {\n programObject = Program.fromString(program);\n } catch (e: any) {\n logAndThrow(\n `Error parsing program: '${e.message}'. Please ensure the program is valid.`,\n );\n }\n\n // Ensure the program is valid and does not exist on the network.\n try {\n let programSource;\n try {\n programSource = await this.networkClient.getProgram(\n programObject.id(),\n );\n } catch (e) {\n // Program does not exist on the network.\n logAndThrow(\n `Program ${programObject.id()} does not exist on the network...`,\n );\n }\n } catch (e: any) {\n logAndThrow(`Error validating program: ${e.message}`);\n }\n\n // Get the private key from the account if it is not provided in the parameters\n let deploymentPrivateKey = privateKey;\n if (\n typeof privateKey === \"undefined\" &&\n typeof this.account !== \"undefined\"\n ) {\n deploymentPrivateKey = this.account.privateKey();\n }\n\n if (typeof deploymentPrivateKey === \"undefined\") {\n throw \"No private key provided and no private key set in the ProgramManager\";\n }\n\n // Get the fee record from the account if it is not provided in the parameters\n try {\n if (privateFee) {\n let fee = priorityFee;\n // If a private fee is specified, but no fee record is provided, estimate the fee and find a matching record.\n if (!feeRecord) {\n console.log(\"Private fee specified, but no private fee record provided, estimating fee and finding a matching fee record.\")\n const programString = programObject.toString();\n const imports = await this.networkClient.getProgramImports(programString);\n const baseFee = Number(WasmProgramManager.estimateDeploymentFee(programString, imports));\n fee = baseFee + priorityFee;\n }\n\n // Get a credits.aleo record for the fee.\n feeRecord = await this.getCreditsRecord(\n fee,\n [],\n feeRecord,\n recordSearchParams\n )\n } else {\n // If it's specified NOT to use a privateFee, use a public fee.\n feeRecord = undefined\n }\n } catch (e: any) {\n logAndThrow(\n `Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`,\n );\n }\n\n // Resolve the program imports if they exist\n let imports;\n try {\n imports = await this.networkClient.getProgramImports(program);\n } catch (e: any) {\n logAndThrow(\n `Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`,\n );\n }\n return WasmProgramManager.buildDevnodeUpgradeTransaction(\n deploymentPrivateKey,\n program,\n priorityFee,\n feeRecord,\n this.host,\n imports,\n );\n }\n}\n\n// Ensure the transfer type requires an amount record\nfunction requiresAmountRecord(transferType: string): boolean {\n return PRIVATE_TRANSFER_TYPES.has(transferType);\n}\n\n// Validate the transfer type\nfunction validateTransferType(transferType: string): string {\n return VALID_TRANSFER_TYPES.has(transferType)\n ? transferType\n : logAndThrow(\n `Invalid transfer type '${transferType}'. Valid transfer types are 'private', 'privateToPublic', 'public', and 'publicToPrivate'.`,\n );\n}\n\nexport { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };\n","import \"./polyfill/shared.js\";\n\nimport { Account } from \"./account.js\";\nimport { AleoNetworkClient, ProgramImports } from \"./network-client.js\";\nimport { BlockJSON, Header, Metadata } from \"./models/blockJSON.js\";\nimport { ConfirmedTransactionJSON } from \"./models/confirmed_transaction.js\";\nimport { DeploymentJSON, VerifyingKeys } from \"./models/deployment/deploymentJSON.js\";\nimport { DeploymentObject } from \"./models/deployment/deploymentObject.js\";\nimport { EncryptedRecord } from \"./models/record-provider/encryptedRecord.js\";\nimport { ExecutionJSON, FeeExecutionJSON } from \"./models/execution/executionJSON.js\";\nimport { ExecutionObject, FeeExecutionObject } from \"./models/execution/executionObject.js\";\nimport { FinalizeJSON } from \"./models/finalizeJSON.js\";\nimport { FunctionInput } from \"./models/functionInput\";\nimport { FunctionObject } from \"./models/functionObject.js\";\nimport { ImportedVerifyingKeys, ImportedPrograms } from \"./models/imports.js\";\nimport { InputJSON } from \"./models/input/inputJSON.js\";\nimport { InputObject } from \"./models/input/inputObject.js\";\nimport { OutputJSON } from \"./models/output/outputJSON.js\";\nimport { OutputObject } from \"./models/output/outputObject.js\";\nimport { OwnedFilter } from \"./models/record-scanner/ownedFilter.js\";\nimport { OwnedRecord } from \"./models/record-provider/ownedRecord.js\";\nimport { OwnerJSON } from \"./models/owner/ownerJSON.js\";\nimport { PlaintextArray} from \"./models/plaintext/array.js\";\nimport { PlaintextLiteral} from \"./models/plaintext/literal.js\";\nimport { PlaintextObject } from \"./models/plaintext/plaintext.js\";\nimport { PlaintextStruct} from \"./models/plaintext/struct.js\";\nimport { ProvingRequestJSON } from \"./models/provingRequest.js\";\nimport { ProvingResponse } from \"./models/provingResponse.js\";\nimport { RatificationJSON } from \"./models/ratification.js\";\nimport { RecordsFilter } from \"./models/record-scanner/recordsFilter.js\";\nimport { RecordsResponseFilter } from \"./models/record-scanner/recordsResponseFilter.js\";\nimport { RecordSearchParams } from \"./models/record-provider/recordSearchParams.js\";\nimport { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from \"./models/solution.js\";\nimport { TransactionJSON } from \"./models/transaction/transactionJSON.js\";\nimport { TransactionObject } from \"./models/transaction/transactionObject.js\";\nimport { TransitionJSON } from \"./models/transition/transitionJSON.js\";\nimport { TransitionObject } from \"./models/transition/transitionObject.js\";\nimport {\n AleoKeyProvider,\n AleoKeyProviderParams,\n AleoKeyProviderInitParams,\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider.js\";\nimport {\n OfflineKeyProvider,\n OfflineSearchParams\n} from \"./offline-key-provider.js\";\nimport {\n BlockHeightSearch,\n NetworkRecordProvider,\n RecordProvider,\n} from \"./record-provider.js\";\nimport { RecordScanner } from \"./record-scanner.js\";\nimport { SealanceMerkleTree } from \"./integrations/sealance/merkle-tree.js\";\n\n// @TODO: This function is no longer needed, remove it.\nasync function initializeWasm() {\n console.warn(\"initializeWasm is deprecated, you no longer need to use it\");\n}\n\nexport { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from \"./program-manager.js\";\n\nexport { logAndThrow } from \"./utils.js\";\n\nexport {\n Address,\n Authorization,\n Boolean,\n BHP256,\n BHP512,\n BHP768,\n BHP1024,\n Ciphertext,\n ComputeKey,\n Execution as FunctionExecution,\n ExecutionRequest,\n ExecutionResponse,\n EncryptionToolkit,\n Field,\n GraphKey,\n Group,\n I8,\n I16,\n I32,\n I64,\n I128,\n OfflineQuery,\n Pedersen64,\n Pedersen128,\n Plaintext,\n Poseidon2,\n Poseidon4,\n Poseidon8,\n PrivateKey,\n PrivateKeyCiphertext,\n Program,\n ProgramManager as ProgramManagerBase,\n ProvingKey,\n ProvingRequest,\n RecordCiphertext,\n RecordPlaintext,\n Signature,\n Scalar,\n Transaction,\n Transition,\n U8,\n U16,\n U32,\n U64,\n U128,\n VerifyingKey,\n ViewKey,\n initThreadPool,\n getOrInitConsensusVersionTestHeights,\n verifyFunctionExecution,\n} from \"./wasm.js\";\n\nexport { initializeWasm };\n\nexport {\n Key,\n CREDITS_PROGRAM_KEYS,\n KEY_STORE,\n PRIVATE_TRANSFER,\n PRIVATE_TO_PUBLIC_TRANSFER,\n PRIVATE_TRANSFER_TYPES,\n PUBLIC_TRANSFER,\n PUBLIC_TRANSFER_AS_SIGNER,\n PUBLIC_TO_PRIVATE_TRANSFER,\n RECORD_DOMAIN,\n VALID_TRANSFER_TYPES,\n} from \"./constants.js\";\n\nexport {\n Account,\n AleoKeyProvider,\n AleoKeyProviderParams,\n AleoKeyProviderInitParams,\n AleoNetworkClient,\n BlockJSON,\n BlockHeightSearch,\n CachedKeyPair,\n ConfirmedTransactionJSON,\n DeploymentJSON,\n DeploymentObject,\n EncryptedRecord,\n ExecutionJSON,\n ExecutionObject,\n FeeExecutionJSON,\n FeeExecutionObject,\n FinalizeJSON,\n FunctionInput,\n FunctionObject,\n FunctionKeyPair,\n FunctionKeyProvider,\n Header,\n ImportedPrograms,\n ImportedVerifyingKeys,\n InputJSON,\n InputObject,\n KeySearchParams,\n Metadata,\n NetworkRecordProvider,\n OfflineKeyProvider,\n OfflineSearchParams,\n OutputJSON,\n OutputObject,\n OwnedFilter,\n OwnedRecord,\n OwnerJSON,\n PartialSolutionJSON,\n PlaintextArray,\n PlaintextLiteral,\n PlaintextObject,\n PlaintextStruct,\n ProgramImports,\n ProvingRequestJSON,\n ProvingResponse,\n RatificationJSON,\n RecordsFilter,\n RecordsResponseFilter,\n RecordProvider,\n RecordScanner,\n RecordSearchParams,\n SealanceMerkleTree,\n SolutionJSON,\n SolutionsJSON,\n TransactionJSON,\n TransactionObject,\n TransitionJSON,\n TransitionObject,\n VerifyingKeys,\n};\n"],"names":["WasmProgramManager"],"mappings":";;;;;AAoBA;;;;;;;;;;;;;;;;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