@provablehq/sdk 0.8.8 → 0.9.1

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.
@@ -9,6 +9,7 @@ import { ExecutionJSON, FeeExecutionJSON } from "./models/execution/executionJSO
9
9
  import { ExecutionObject, FeeExecutionObject } from "./models/execution/executionObject";
10
10
  import { FinalizeJSON } from "./models/finalizeJSON";
11
11
  import { FunctionObject } from "./models/functionObject";
12
+ import { ImportedVerifyingKeys, ImportedPrograms } from "./models/imports";
12
13
  import { InputJSON } from "./models/input/inputJSON";
13
14
  import { InputObject } from "./models/input/inputObject";
14
15
  import { OutputJSON } from "./models/output/outputJSON";
@@ -34,4 +35,4 @@ export { logAndThrow } from "./utils";
34
35
  export { Address, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionResponse, Field, Group, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm";
35
36
  export { initializeWasm };
36
37
  export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, } from "./constants";
37
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
38
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
@@ -1,8 +1,8 @@
1
1
  import 'core-js/proposals/json-parse-with-source.js';
2
2
  import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, ProvingKey, VerifyingKey } from '@provablehq/wasm/mainnet.js';
3
3
  export { Address, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
4
- import { C as CREDITS_PROGRAM_KEYS, c as PRIVATE_TRANSFER, d as PRIVATE_TO_PUBLIC_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, h as PUBLIC_TO_PRIVATE_TRANSFER, l as logAndThrow } from './program-manager-OK_mdi-y.js';
5
- export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, K as KEY_STORE, e as PRIVATE_TRANSFER_TYPES, P as ProgramManager, V as VALID_TRANSFER_TYPES } from './program-manager-OK_mdi-y.js';
4
+ import { C as CREDITS_PROGRAM_KEYS, c as PRIVATE_TRANSFER, d as PRIVATE_TO_PUBLIC_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, h as PUBLIC_TO_PRIVATE_TRANSFER, l as logAndThrow } from './program-manager-DMDKstZ8.js';
5
+ export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, K as KEY_STORE, e as PRIVATE_TRANSFER_TYPES, P as ProgramManager, V as VALID_TRANSFER_TYPES } from './program-manager-DMDKstZ8.js';
6
6
  import { wrap } from 'comlink';
7
7
 
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sources":["../../src/account.ts","../../src/offline-key-provider.ts","../../src/record-provider.ts","../../src/managed-worker.ts","../../src/browser.ts"],"sourcesContent":["import {\n Address,\n ComputeKey,\n PrivateKey,\n Signature,\n ViewKey,\n PrivateKeyCiphertext,\n RecordCiphertext,\n RecordPlaintext,\n} from \"./wasm\";\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 * 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","import {\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider\";\n\nimport {\n ProvingKey,\n VerifyingKey,\n} from \"./wasm\";\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\";\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 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 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 { RecordPlaintext } from \"./wasm\";\nimport { logAndThrow } from \"./utils\";\nimport { Account } from \"./account\";\nimport { AleoNetworkClient } from \"./network-client\";\n\n/**\n * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider\n * implementations.\n */\ninterface RecordSearchParams {\n [key: string]: any; // This allows for arbitrary keys with any type values\n}\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 account: Account\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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} The record if found, 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 record = await recordProvider.findCreditsRecord(5000, true, []);\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, true, [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, unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext>;\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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext[]>} 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], true, []);\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, 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[], unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]>;\n\n /**\n * Find an arbitrary record\n * @param {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} 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 * constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.amount = amount;\n * this.program = programName;\n * this.recordName = recordName;\n * }\n * }\n *\n * const params = new CustomRecordSearch(0, 100, 5000, \"credits.aleo\", \"credits\");\n *\n * const record = await recordProvider.findRecord(true, [], params);\n */\n findRecord(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext>;\n\n /**\n * Find multiple records from arbitrary programs\n *\n * @param {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error\n *\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 * maxRecords: number;\n * programName: string;\n * recordName: string;\n * constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.amount = amount;\n * this.maxRecords = maxRecords;\n * this.programName = programName;\n * this.recordName = recordName;\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(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]>;\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 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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} 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, true, []);\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, true, [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[], unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]> {\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 if (\"unspent\" in searchParameters && typeof searchParameters[\"unspent\"] == \"boolean\") {\n unspent = searchParameters[\"unspent\"]\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 return await this.networkClient.findRecords(startHeight, endHeight, unspent, [\"credits.aleo\"], microcredits, maxAmount, nonces, this.account.privateKey());\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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} 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, true, []);\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, true, [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, unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext> {\n let records = null;\n\n try {\n records = await this.findCreditsRecords([microcredits], unspent, nonces, 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(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext> {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Find multiple records from a specified program.\n */\n async findRecords(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]> {\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 (\"nonces\" in searchParameters && Array.isArray(searchParameters[\"nonces\"]) && searchParameters[\"nonces\"].every((item: any) => typeof item === \"string\")) {\n nonces = searchParameters[\"nonces\"];\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 if (\"unspent\" in searchParameters && typeof searchParameters[\"unspent\"] == \"boolean\") {\n unspent = searchParameters[\"unspent\"]\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 return await this.networkClient.findRecords(startHeight, endHeight, unspent, programs, amounts, maxAmount, nonces, this.account.privateKey());\n }\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, true, [], params);\n *\n */\nclass BlockHeightSearch implements RecordSearchParams {\n startHeight: number;\n endHeight: number;\n constructor(startHeight: number, endHeight: number) {\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n }\n}\n\nexport { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams};\n","// Experimental example where SDK manages worker\n\nimport { wrap } from \"comlink\";\nimport { WorkerAPI } from './worker';\n\nlet singletonWorker: WorkerAPI | null = null;\n\nconst createAleoWorker = (): WorkerAPI => {\n if (!singletonWorker) {\n const worker = new Worker(new URL(\"worker.js\", import.meta.url), {\n type: \"module\",\n });\n singletonWorker = wrap<WorkerAPI>(worker);\n }\n return singletonWorker;\n};\n\nexport { createAleoWorker };","import \"./polyfill/shared\";\n\nimport { Account } from \"./account\";\nimport { AleoNetworkClient, ProgramImports } from \"./network-client\";\nimport { BlockJSON, Header, Metadata } from \"./models/blockJSON\";\nimport { ConfirmedTransactionJSON } from \"./models/confirmed_transaction\";\nimport { DeploymentJSON, VerifyingKeys } from \"./models/deployment/deploymentJSON\";\nimport { DeploymentObject } from \"./models/deployment/deploymentObject\";\nimport { ExecutionJSON, FeeExecutionJSON } from \"./models/execution/executionJSON\";\nimport { ExecutionObject, FeeExecutionObject } from \"./models/execution/executionObject\";\nimport { FinalizeJSON } from \"./models/finalizeJSON\";\nimport { FunctionObject } from \"./models/functionObject\";\nimport { InputJSON } from \"./models/input/inputJSON\";\nimport { InputObject } from \"./models/input/inputObject\";\nimport { OutputJSON } from \"./models/output/outputJSON\";\nimport { OutputObject } from \"./models/output/outputObject\";\nimport { OwnerJSON } from \"./models/owner/ownerJSON\";\nimport { PlaintextArray} from \"./models/plaintext/array\";\nimport { PlaintextLiteral} from \"./models/plaintext/literal\";\nimport { PlaintextObject } from \"./models/plaintext/plaintext\";\nimport { PlaintextStruct} from \"./models/plaintext/struct\";\nimport { RatificationJSON } from \"./models/ratification\";\nimport { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from \"./models/solution\";\nimport { TransactionJSON } from \"./models/transaction/transactionJSON\";\nimport { TransactionObject } from \"./models/transaction/transactionObject\";\nimport { TransitionJSON } from \"./models/transition/transitionJSON\";\nimport { TransitionObject } from \"./models/transition/transitionObject\";\nimport {\n AleoKeyProvider,\n AleoKeyProviderParams,\n AleoKeyProviderInitParams,\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider\";\nimport {\n OfflineKeyProvider,\n OfflineSearchParams\n} from \"./offline-key-provider\";\nimport {\n BlockHeightSearch,\n NetworkRecordProvider,\n RecordProvider,\n RecordSearchParams,\n} from \"./record-provider\";\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 { createAleoWorker } from \"./managed-worker\";\n\nexport { ProgramManager } from \"./program-manager\";\n\nexport { logAndThrow } from \"./utils\";\n\nexport {\n Address,\n BHP256,\n BHP512,\n BHP768,\n BHP1024,\n Ciphertext,\n ComputeKey,\n Execution as FunctionExecution,\n ExecutionResponse,\n Field,\n Group,\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 RecordCiphertext,\n RecordPlaintext,\n Signature,\n Scalar,\n Transaction,\n Transition,\n VerifyingKey,\n ViewKey,\n initThreadPool,\n verifyFunctionExecution,\n} from \"./wasm\";\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 VALID_TRANSFER_TYPES,\n} from \"./constants\";\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 ExecutionJSON,\n ExecutionObject,\n FeeExecutionJSON,\n FeeExecutionObject,\n FinalizeJSON,\n FunctionObject,\n FunctionKeyPair,\n FunctionKeyProvider,\n Header,\n InputJSON,\n InputObject,\n KeySearchParams,\n Metadata,\n NetworkRecordProvider,\n OfflineKeyProvider,\n OfflineSearchParams,\n OutputJSON,\n OutputObject,\n OwnerJSON,\n PartialSolutionJSON,\n PlaintextArray,\n PlaintextLiteral,\n PlaintextObject,\n PlaintextStruct,\n ProgramImports,\n RatificationJSON,\n RecordProvider,\n RecordSearchParams,\n SolutionJSON,\n SolutionsJSON,\n TransactionJSON,\n TransactionObject,\n TransitionJSON,\n TransitionObject,\n VerifyingKeys,\n};\n"],"names":[],"mappings":";;;;;;;AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;QACpD,OAAO,CAAC,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACnC,YAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;;QAEpC,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,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;;AAG5D;;;;;;;;;;;AAWG;AACI,IAAA,OAAO,cAAc,CAAC,UAAyC,EAAE,QAAgB,EAAA;AACtF,QAAA,IAAI;YACF,UAAU,GAAG,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,oBAAoB,CAAC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AW;AAC9B,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;;AAEjC;;AC9WD;AAKA,IAAI,eAAe,GAAqB,IAAI;AAEtC,MAAA,gBAAgB,GAAG,MAAgB;IACrC,IAAI,CAAC,eAAe,EAAE;AAClB,QAAA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAC7D,YAAA,IAAI,EAAE,QAAQ;AACjB,SAAA,CAAC;AACF,QAAA,eAAe,GAAG,IAAI,CAAY,MAAM,CAAC;;AAE7C,IAAA,OAAO,eAAe;AAC1B;;ACgCA;AACA,eAAe,cAAc,GAAA;AACzB,IAAA,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC;AAC9E;;;;"}
1
+ {"version":3,"file":"browser.js","sources":["../../src/account.ts","../../src/offline-key-provider.ts","../../src/record-provider.ts","../../src/managed-worker.ts","../../src/browser.ts"],"sourcesContent":["import {\n Address,\n ComputeKey,\n PrivateKey,\n Signature,\n ViewKey,\n PrivateKeyCiphertext,\n RecordCiphertext,\n RecordPlaintext,\n} from \"./wasm\";\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 * 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","import {\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider\";\n\nimport {\n ProvingKey,\n VerifyingKey,\n} from \"./wasm\";\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\";\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 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 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 { RecordPlaintext } from \"./wasm\";\nimport { logAndThrow } from \"./utils\";\nimport { Account } from \"./account\";\nimport { AleoNetworkClient } from \"./network-client\";\n\n/**\n * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider\n * implementations.\n */\ninterface RecordSearchParams {\n [key: string]: any; // This allows for arbitrary keys with any type values\n}\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 account: Account\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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} The record if found, 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 record = await recordProvider.findCreditsRecord(5000, true, []);\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, true, [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, unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext>;\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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext[]>} 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], true, []);\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, 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[], unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]>;\n\n /**\n * Find an arbitrary record\n * @param {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} 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 * constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.amount = amount;\n * this.program = programName;\n * this.recordName = recordName;\n * }\n * }\n *\n * const params = new CustomRecordSearch(0, 100, 5000, \"credits.aleo\", \"credits\");\n *\n * const record = await recordProvider.findRecord(true, [], params);\n */\n findRecord(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext>;\n\n /**\n * Find multiple records from arbitrary programs\n *\n * @param {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error\n *\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 * maxRecords: number;\n * programName: string;\n * recordName: string;\n * constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {\n * this.startHeight = startHeight;\n * this.endHeight = endHeight;\n * this.amount = amount;\n * this.maxRecords = maxRecords;\n * this.programName = programName;\n * this.recordName = recordName;\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(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]>;\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 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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} 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, true, []);\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, true, [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[], unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]> {\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 if (\"unspent\" in searchParameters && typeof searchParameters[\"unspent\"] == \"boolean\") {\n unspent = searchParameters[\"unspent\"]\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 return await this.networkClient.findRecords(startHeight, endHeight, unspent, [\"credits.aleo\"], microcredits, maxAmount, nonces, this.account.privateKey());\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 {boolean} unspent Whether or not the record is unspent\n * @param {string[]} nonces Nonces of records already found so that they are not found again\n * @param {RecordSearchParams} searchParameters Additional parameters to search for\n * @returns {Promise<RecordPlaintext>} 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, true, []);\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, true, [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, unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext> {\n let records = null;\n\n try {\n records = await this.findCreditsRecords([microcredits], unspent, nonces, 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(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext> {\n throw new Error(\"Not implemented\");\n }\n\n /**\n * Find multiple records from a specified program.\n */\n async findRecords(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]> {\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 (\"nonces\" in searchParameters && Array.isArray(searchParameters[\"nonces\"]) && searchParameters[\"nonces\"].every((item: any) => typeof item === \"string\")) {\n nonces = searchParameters[\"nonces\"];\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 if (\"unspent\" in searchParameters && typeof searchParameters[\"unspent\"] == \"boolean\") {\n unspent = searchParameters[\"unspent\"]\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 return await this.networkClient.findRecords(startHeight, endHeight, unspent, programs, amounts, maxAmount, nonces, this.account.privateKey());\n }\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, true, [], params);\n *\n */\nclass BlockHeightSearch implements RecordSearchParams {\n startHeight: number;\n endHeight: number;\n constructor(startHeight: number, endHeight: number) {\n this.startHeight = startHeight;\n this.endHeight = endHeight;\n }\n}\n\nexport { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams};\n","// Experimental example where SDK manages worker\n\nimport { wrap } from \"comlink\";\nimport { WorkerAPI } from './worker';\n\nlet singletonWorker: WorkerAPI | null = null;\n\nconst createAleoWorker = (): WorkerAPI => {\n if (!singletonWorker) {\n const worker = new Worker(new URL(\"worker.js\", import.meta.url), {\n type: \"module\",\n });\n singletonWorker = wrap<WorkerAPI>(worker);\n }\n return singletonWorker;\n};\n\nexport { createAleoWorker };","import \"./polyfill/shared\";\n\nimport { Account } from \"./account\";\nimport { AleoNetworkClient, ProgramImports } from \"./network-client\";\nimport { BlockJSON, Header, Metadata } from \"./models/blockJSON\";\nimport { ConfirmedTransactionJSON } from \"./models/confirmed_transaction\";\nimport { DeploymentJSON, VerifyingKeys } from \"./models/deployment/deploymentJSON\";\nimport { DeploymentObject } from \"./models/deployment/deploymentObject\";\nimport { ExecutionJSON, FeeExecutionJSON } from \"./models/execution/executionJSON\";\nimport { ExecutionObject, FeeExecutionObject } from \"./models/execution/executionObject\";\nimport { FinalizeJSON } from \"./models/finalizeJSON\";\nimport { FunctionObject } from \"./models/functionObject\";\nimport { ImportedVerifyingKeys, ImportedPrograms } from \"./models/imports\";\nimport { InputJSON } from \"./models/input/inputJSON\";\nimport { InputObject } from \"./models/input/inputObject\";\nimport { OutputJSON } from \"./models/output/outputJSON\";\nimport { OutputObject } from \"./models/output/outputObject\";\nimport { OwnerJSON } from \"./models/owner/ownerJSON\";\nimport { PlaintextArray} from \"./models/plaintext/array\";\nimport { PlaintextLiteral} from \"./models/plaintext/literal\";\nimport { PlaintextObject } from \"./models/plaintext/plaintext\";\nimport { PlaintextStruct} from \"./models/plaintext/struct\";\nimport { RatificationJSON } from \"./models/ratification\";\nimport { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from \"./models/solution\";\nimport { TransactionJSON } from \"./models/transaction/transactionJSON\";\nimport { TransactionObject } from \"./models/transaction/transactionObject\";\nimport { TransitionJSON } from \"./models/transition/transitionJSON\";\nimport { TransitionObject } from \"./models/transition/transitionObject\";\nimport {\n AleoKeyProvider,\n AleoKeyProviderParams,\n AleoKeyProviderInitParams,\n CachedKeyPair,\n FunctionKeyPair,\n FunctionKeyProvider,\n KeySearchParams,\n} from \"./function-key-provider\";\nimport {\n OfflineKeyProvider,\n OfflineSearchParams\n} from \"./offline-key-provider\";\nimport {\n BlockHeightSearch,\n NetworkRecordProvider,\n RecordProvider,\n RecordSearchParams,\n} from \"./record-provider\";\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 { createAleoWorker } from \"./managed-worker\";\n\nexport { ProgramManager } from \"./program-manager\";\n\nexport { logAndThrow } from \"./utils\";\n\nexport {\n Address,\n BHP256,\n BHP512,\n BHP768,\n BHP1024,\n Ciphertext,\n ComputeKey,\n Execution as FunctionExecution,\n ExecutionResponse,\n Field,\n Group,\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 RecordCiphertext,\n RecordPlaintext,\n Signature,\n Scalar,\n Transaction,\n Transition,\n VerifyingKey,\n ViewKey,\n initThreadPool,\n verifyFunctionExecution,\n} from \"./wasm\";\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 VALID_TRANSFER_TYPES,\n} from \"./constants\";\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 ExecutionJSON,\n ExecutionObject,\n FeeExecutionJSON,\n FeeExecutionObject,\n FinalizeJSON,\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 OwnerJSON,\n PartialSolutionJSON,\n PlaintextArray,\n PlaintextLiteral,\n PlaintextObject,\n PlaintextStruct,\n ProgramImports,\n RatificationJSON,\n RecordProvider,\n RecordSearchParams,\n SolutionJSON,\n SolutionsJSON,\n TransactionJSON,\n TransactionObject,\n TransitionJSON,\n TransitionObject,\n VerifyingKeys,\n};\n"],"names":[],"mappings":";;;;;;;AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;QACpD,OAAO,CAAC,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACnC,YAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;;QAEpC,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,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC;;AAG5D;;;;;;;;;;;AAWG;AACI,IAAA,OAAO,cAAc,CAAC,UAAyC,EAAE,QAAgB,EAAA;AACtF,QAAA,IAAI;YACF,UAAU,GAAG,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,oBAAoB,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU;YACxG,MAAM,WAAW,GAAG,UAAU,CAAC,wBAAwB,CAAC,UAAU,EAAE,QAAQ,CAAC;AAC7E,YAAA,OAAO,IAAI,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AI,CAAC,eAAe,EAAE;AAClB,QAAA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAC7D,YAAA,IAAI,EAAE,QAAQ;AACjB,SAAA,CAAC;AACF,QAAA,eAAe,GAAG,IAAI,CAAY,MAAM,CAAC;;AAE7C,IAAA,OAAO,eAAe;AAC1B;;ACiCA;AACA,eAAe,cAAc,GAAA;AACzB,IAAA,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC;AAC9E;;;;"}
@@ -0,0 +1,7 @@
1
+ interface ImportedVerifyingKeys {
2
+ [key: string]: Array<[string, string]>;
3
+ }
4
+ interface ImportedPrograms {
5
+ [key: string]: string;
6
+ }
7
+ export { ImportedVerifyingKeys, ImportedPrograms };
@@ -30,6 +30,10 @@ declare class AleoNetworkClient {
30
30
  [key: string]: string;
31
31
  };
32
32
  account: Account | undefined;
33
+ ctx: {
34
+ [key: string]: string;
35
+ };
36
+ readonly network: string;
33
37
  constructor(host: string, options?: AleoNetworkClientOptions);
34
38
  /**
35
39
  * Set an account to use in networkClient calls
@@ -66,6 +70,37 @@ declare class AleoNetworkClient {
66
70
  * networkClient.setHost("http://api.explorer.provable.com/v1");
67
71
  */
68
72
  setHost(host: string): void;
73
+ /**
74
+ * Set a header in the `AleoNetworkClient`s header map
75
+ *
76
+ * @param {string} headerName The name of the header to set
77
+ * @param {string} value The header value
78
+ *
79
+ * @example
80
+ * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
81
+ *
82
+ * // Create a networkClient
83
+ * const networkClient = new AleoNetworkClient();
84
+ *
85
+ * // Set the value of the `Accept-Language` header to `en-US`
86
+ * networkClient.setHeader('Accept-Language', 'en-US');
87
+ */
88
+ setHeader(headerName: string, value: string): void;
89
+ /**
90
+ * Remove a header from the `AleoNetworkClient`s header map
91
+ *
92
+ * @param {string} headerName The name of the header to be removed
93
+ *
94
+ * @example
95
+ * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
96
+ *
97
+ * // Create a networkClient
98
+ * const networkClient = new AleoNetworkClient();
99
+ *
100
+ * // Remove the default `X-Aleo-SDK-Version` header
101
+ * networkClient.removeHeader('X-Aleo-SDK-Version');
102
+ */
103
+ removeHeader(headerName: string): void;
69
104
  /**
70
105
  * Fetches data from the Aleo network and returns it as a JSON object.
71
106
  *
@@ -81,6 +116,14 @@ declare class AleoNetworkClient {
81
116
  * @param url
82
117
  */
83
118
  fetchRaw(url?: string): Promise<string>;
119
+ /**
120
+ * Wrapper around the POST helper to allow mocking in tests. Not meant for use in production.
121
+ *
122
+ * @param url The URL to POST to.
123
+ * @param options The RequestInit options for the POST request.
124
+ * @returns The Response object from the POST request.
125
+ */
126
+ private _sendPost;
84
127
  /**
85
128
  * Attempt to find records in the Aleo blockchain.
86
129
  *
@@ -678,7 +721,6 @@ declare class AleoNetworkClient {
678
721
  * // Wait for the transaction to be confirmed.
679
722
  * const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
680
723
  */
681
- waitForTransactionConfirmation(transactionId: string, checkInterval?: number, // Poll every 2 seconds
682
- timeout?: number): Promise<Transaction>;
724
+ waitForTransactionConfirmation(transactionId: string, checkInterval?: number, timeout?: number): Promise<ConfirmedTransactionJSON>;
683
725
  }
684
726
  export { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports };
@@ -1,6 +1,6 @@
1
1
  import './node-polyfill.js';
2
2
  export { Account, BlockHeightSearch, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, createAleoWorker, initializeWasm } from './browser.js';
3
- export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, C as CREDITS_PROGRAM_KEYS, K as KEY_STORE, d as PRIVATE_TO_PUBLIC_TRANSFER, c as PRIVATE_TRANSFER, e as PRIVATE_TRANSFER_TYPES, h as PUBLIC_TO_PRIVATE_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, P as ProgramManager, V as VALID_TRANSFER_TYPES, l as logAndThrow } from './program-manager-OK_mdi-y.js';
3
+ export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, C as CREDITS_PROGRAM_KEYS, K as KEY_STORE, d as PRIVATE_TO_PUBLIC_TRANSFER, c as PRIVATE_TRANSFER, e as PRIVATE_TRANSFER_TYPES, h as PUBLIC_TO_PRIVATE_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, P as ProgramManager, V as VALID_TRANSFER_TYPES, l as logAndThrow } from './program-manager-DMDKstZ8.js';
4
4
  export { Address, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
5
5
  import 'core-js/proposals/json-parse-with-source.js';
6
6
  import 'node:crypto';