@provablehq/sdk 0.9.10-testnet-rc → 0.9.10

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.
@@ -0,0 +1,8 @@
1
+ interface Networks {
2
+ "testnet": typeof import("../testnet/browser"),
3
+ "mainnet": typeof import("../mainnet/browser"),
4
+ }
5
+
6
+ export { Networks };
7
+
8
+ export declare function loadNetwork<Key extends keyof Networks>(name: Key): Promise<Networks[Key]>;
@@ -0,0 +1,8 @@
1
+ const networks = {
2
+ "testnet": () => import("../testnet/browser.js"),
3
+ "mainnet": () => import("../mainnet/browser.js"),
4
+ };
5
+
6
+ export function loadNetwork(name) {
7
+ return networks[name]();
8
+ }
@@ -0,0 +1,8 @@
1
+ interface Networks {
2
+ "testnet": typeof import("../testnet/node"),
3
+ "mainnet": typeof import("../mainnet/node"),
4
+ }
5
+
6
+ export { Networks };
7
+
8
+ export declare function loadNetwork<Key extends keyof Networks>(name: Key): Promise<Networks[Key]>;
@@ -0,0 +1,8 @@
1
+ const networks = {
2
+ "testnet": () => import("../testnet/node.js"),
3
+ "mainnet": () => import("../mainnet/node.js"),
4
+ };
5
+
6
+ export function loadNetwork(name) {
7
+ return networks[name]();
8
+ }
@@ -37,10 +37,11 @@ import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, Cach
37
37
  import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider.js";
38
38
  import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
39
39
  import { RecordScanner } from "./record-scanner.js";
40
+ import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
40
41
  declare function initializeWasm(): Promise<void>;
41
42
  export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from "./program-manager.js";
42
43
  export { logAndThrow } from "./utils.js";
43
44
  export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, verifyFunctionExecution, } from "./wasm.js";
44
45
  export { initializeWasm };
45
46
  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, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
46
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, EncryptedRecord, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
47
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, EncryptedRecord, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordSearchParams, SealanceMerkleTree, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
@@ -1,6 +1,7 @@
1
1
  import 'core-js/proposals/json-parse-with-source.js';
2
2
  import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, Program, Plaintext, Transaction, ProvingRequest, Metadata, VerifyingKey, ProvingKey, RecordPlaintext, Field, Poseidon4, ProgramManager as ProgramManager$1, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
3
3
  export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, VerifyingKey, ViewKey, getOrInitConsensusVersionTestHeights, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
4
+ import { bech32m } from '@scure/base';
4
5
 
5
6
  /**
6
7
  * Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from
@@ -491,7 +492,7 @@ class AleoNetworkClient {
491
492
  else {
492
493
  this.headers = {
493
494
  // This is replaced by the actual version by a Rollup plugin
494
- "X-Aleo-SDK-Version": "0.9.10-testnet-rc",
495
+ "X-Aleo-SDK-Version": "0.9.10",
495
496
  "X-Aleo-environment": environment(),
496
497
  };
497
498
  }
@@ -2045,6 +2046,10 @@ const PUBLIC_TO_PRIVATE_TRANSFER = new Set([
2045
2046
  "transferPublicToPrivate",
2046
2047
  ]);
2047
2048
  const RECORD_DOMAIN = "RecordScannerV0";
2049
+ /**
2050
+ * Zero address on Aleo blockchain that corresponds to field element 0. Used as padding in Merkle trees and as a sentinel value.
2051
+ */
2052
+ const ZERO_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
2048
2053
 
2049
2054
  /**
2050
2055
  * AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and
@@ -3587,6 +3592,222 @@ class RecordScanner {
3587
3592
  }
3588
3593
  }
3589
3594
 
3595
+ /**
3596
+ * Client library that encapsulates methods for constructing Merkle exclusion proofs for compliant stablecoin programs following the Sealance architecture.
3597
+ *
3598
+
3599
+ * @example
3600
+ * Construct a Merkle exclusion proof.
3601
+ * ```typescript
3602
+ * const sealance = new SealanceMerkleTree();
3603
+ * const leaves = [
3604
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
3605
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
3606
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
3607
+ * ];
3608
+ * const result = sealance.generateLeaves(leaves);
3609
+ * const tree = sealance.buildTree(result);
3610
+ * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, "aleo1kypwp5m7qtk9mwazgcpg0tq8aal23mnrvwfvug65qgcg9xvsrqgspyjm6n");
3611
+ * const proof_left = sealance.getSiblingPath(tree, leftIdx, 15);
3612
+ * const proof_right = sealance.getSiblingPath(tree, rightIdx, 15);
3613
+ * const exclusion_proof = [proof_left, proof_right];
3614
+ * ```
3615
+ */
3616
+ class SealanceMerkleTree {
3617
+ static hasher = new Poseidon4();
3618
+ /**
3619
+ * Converts an Aleo blockchain address to a field element.
3620
+ *
3621
+ * This function decodes a bech32m-encoded Aleo address and converts it to a field element
3622
+ * represented as a BigInt. The address format follows the Aleo protocol specification,
3623
+ * starting with the prefix "aleo1" followed by encoded data.
3624
+ *
3625
+ * @param address - The Aleo blockchain address (e.g., "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
3626
+ * @returns A BigInt representing the field element.
3627
+ * @throws Error if the address is invalid or cannot be decoded.
3628
+ *
3629
+ * @example
3630
+ * ```typescript
3631
+ * const address = "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px";
3632
+ * const fieldValue = convertAddressToField(address);
3633
+ * console.log(fieldValue); // 123456789...n
3634
+ * ```
3635
+ */
3636
+ convertAddressToField(address) {
3637
+ const { words } = bech32m.decode(address);
3638
+ const bytes = bech32m.fromWords(words);
3639
+ // Convert bytes to BigInt (little-endian)
3640
+ let fieldValue = BigInt(0);
3641
+ for (let i = 0; i < bytes.length; i++) {
3642
+ fieldValue |= BigInt(bytes[i]) << BigInt(i * 8);
3643
+ }
3644
+ return fieldValue;
3645
+ }
3646
+ /**
3647
+ * Hashes two elements using Poseidon4 hash function
3648
+ * @param prefix - Prefix for the hash (e.g., "0field" for nodes, "1field" for leaves)
3649
+ * @param el1 - First element to hash
3650
+ * @param el2 - Second element to hash
3651
+ * @returns The hash result as a Field
3652
+ * @throws {Error} If inputs are empty or invalid
3653
+ */
3654
+ hashTwoElements(prefix, el1, el2) {
3655
+ if (!el1 || !el2) {
3656
+ throw new Error("Invalid inputs: elements cannot be empty");
3657
+ }
3658
+ const fields = [Field.fromString(prefix), Field.fromString(el1), Field.fromString(el2)];
3659
+ const arrayPlaintext = Plaintext.fromString(`[${fields.map(f => f.toString()).join(",")}]`);
3660
+ return SealanceMerkleTree.hasher.hash(arrayPlaintext.toFields());
3661
+ }
3662
+ /**
3663
+ * Builds a Merkle tree from given leaves. The tree is built bottom-up, hashing pairs of elements at each level.
3664
+ *
3665
+ * @param leaves - Array of leaf elements (must have even number of elements).
3666
+ * @returns Array representing the complete Merkle tree as BigInts.
3667
+ * @throws {Error} If leaves array is empty or has odd number of elements.
3668
+ *
3669
+ * @example
3670
+ * ```typescript
3671
+ * const leaves = ["0field", "1field", "2field", "3field"];
3672
+ * const tree = buildTree(leaves);
3673
+ * const root = tree[tree.length - 1]; // Get the Merkle root
3674
+ * ```
3675
+ */
3676
+ buildTree(leaves) {
3677
+ if (leaves.length === 0) {
3678
+ throw new Error("Leaves array cannot be empty");
3679
+ }
3680
+ if (leaves.length % 2 !== 0) {
3681
+ throw new Error("Leaves array must have even number of elements");
3682
+ }
3683
+ let currentLevel = leaves;
3684
+ let tree = [...currentLevel];
3685
+ let levelSize = currentLevel.length;
3686
+ while (levelSize > 1) {
3687
+ const nextLevel = [];
3688
+ for (let i = 0; i < levelSize; i += 2) {
3689
+ const left = currentLevel[i];
3690
+ const right = currentLevel[i + 1];
3691
+ const prefix = leaves.length === levelSize ? "1field" : "0field";
3692
+ const hash = this.hashTwoElements(prefix, left, right);
3693
+ nextLevel.push(hash.toString());
3694
+ }
3695
+ tree = [...tree, ...nextLevel];
3696
+ currentLevel = nextLevel;
3697
+ levelSize = currentLevel.length;
3698
+ }
3699
+ return tree.map(element => BigInt(element.slice(0, element.length - "field".length)));
3700
+ }
3701
+ /**
3702
+ * Converts Aleo addresses to field elements, sorts them, pads with zero fields, and returns an array. This prepares addresses for Merkle tree construction.
3703
+ *
3704
+ * @param addresses - Array of Aleo addresses.
3705
+ * @param maxTreeDepth - Maximum depth of the Merkle tree (default: 15).
3706
+ * @returns Array of field elements ready for Merkle tree construction.
3707
+ * @throws {Error} If the number of addresses exceeds the maximum capacity.
3708
+ *
3709
+ * @example
3710
+ * ```typescript
3711
+ * const addresses = [
3712
+ * "aleo1...",
3713
+ * "aleo1..."
3714
+ * ];
3715
+ * const leaves = generateLeaves(addresses, 15);
3716
+ * const tree = buildTree(leaves);
3717
+ * ```
3718
+ */
3719
+ generateLeaves(addresses, maxTreeDepth = 15) {
3720
+ const maxNumLeaves = Math.floor(2 ** (maxTreeDepth - 1));
3721
+ // Filter out zero addresses
3722
+ addresses = addresses.filter(addr => addr !== ZERO_ADDRESS);
3723
+ let numLeaves = 0;
3724
+ if (addresses.length === 0 || addresses.length === 1) {
3725
+ numLeaves = 2;
3726
+ }
3727
+ else {
3728
+ numLeaves = Math.pow(2, Math.ceil(Math.log2(addresses.length)));
3729
+ }
3730
+ if (addresses.length > maxNumLeaves) {
3731
+ throw new Error(`Leaves limit exceeded. Max: ${maxNumLeaves}, provided: ${addresses.length}`);
3732
+ }
3733
+ // Convert addresses to fields
3734
+ const addressFields = addresses.map(addr => ({
3735
+ address: addr,
3736
+ field: this.convertAddressToField(addr),
3737
+ }));
3738
+ // Sort by field value
3739
+ const sortedFields = addressFields.sort((a, b) => (a.field < b.field ? -1 : 1)).map(item => item.field);
3740
+ // Convert to field strings
3741
+ const sortedFieldElements = sortedFields.map(field => field.toString() + "field");
3742
+ // Pad with zeros to reach power of 2
3743
+ const fullTree = Array(Math.max(numLeaves - sortedFieldElements.length, 0)).fill("0field");
3744
+ return fullTree.concat(sortedFieldElements);
3745
+ }
3746
+ /**
3747
+ * Finds the leaf indices for non-inclusion proof of an address and returns the indices of the two adjacent leaves that surround the target address.
3748
+ *
3749
+ * @param merkleTree - The complete Merkle tree as array of BigInts.
3750
+ * @param address - The Aleo address for which to find indices.
3751
+ * @returns Tuple of [leftLeafIndex, rightLeafIndex].
3752
+ *
3753
+ * @example
3754
+ * ```typescript
3755
+ * const tree = buildTree(leaves);
3756
+ * const [leftIdx, rightIdx] = getLeafIndices(tree, "aleo1...");
3757
+ * ```
3758
+ */
3759
+ getLeafIndices(merkleTree, address) {
3760
+ const num_leaves = Math.floor((merkleTree.length + 1) / 2);
3761
+ const addressBigInt = this.convertAddressToField(address);
3762
+ const leaves = merkleTree.slice(0, num_leaves);
3763
+ let rightLeafIndex = leaves.findIndex((leaf) => addressBigInt <= leaf);
3764
+ let leftLeafIndex = rightLeafIndex - 1;
3765
+ if (rightLeafIndex === -1) {
3766
+ rightLeafIndex = leaves.length - 1;
3767
+ leftLeafIndex = leaves.length - 1;
3768
+ }
3769
+ if (rightLeafIndex === 0) {
3770
+ leftLeafIndex = 0;
3771
+ }
3772
+ return [leftLeafIndex, rightLeafIndex];
3773
+ }
3774
+ /**
3775
+ * Generates the sibling path (Merkle proof) for a given leaf index
3776
+ *
3777
+ * @param tree - The complete Merkle tree.
3778
+ * @param leafIndex - Index of the leaf for which to generate the proof.
3779
+ * @param depth - Maximum depth of the tree.
3780
+ * @returns Object containing siblings array and leaf_index.
3781
+ *
3782
+ * @example
3783
+ * ```typescript
3784
+ * const tree = buildTree(leaves);
3785
+ * const proof = getSiblingPath(tree, 0, 15);
3786
+ * // proof = { siblings: [0n, 1n, ...], leaf_index: 0 }
3787
+ * ```
3788
+ */
3789
+ getSiblingPath(tree, leafIndex, depth) {
3790
+ let num_leaves = Math.floor((tree.length + 1) / 2);
3791
+ const siblingPath = [];
3792
+ let index = leafIndex;
3793
+ let parentIndex = num_leaves;
3794
+ siblingPath.push(tree[index]);
3795
+ let level = 1;
3796
+ while (parentIndex < tree.length) {
3797
+ let siblingIndex = index % 2 === 0 ? index + 1 : index - 1; // Get the sibling index
3798
+ siblingPath.push(tree[siblingIndex]);
3799
+ index = parentIndex + Math.floor(leafIndex / 2 ** level); // Move up to the parent node
3800
+ parentIndex += Math.floor(num_leaves / 2 ** level); // Halve the number of nodes for the next level
3801
+ level++;
3802
+ }
3803
+ while (level < depth) {
3804
+ siblingPath.push(0n);
3805
+ level++;
3806
+ }
3807
+ return { siblings: siblingPath, leaf_index: leafIndex };
3808
+ }
3809
+ }
3810
+
3590
3811
  /**
3591
3812
  * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
3592
3813
  */
@@ -3976,6 +4197,132 @@ class ProgramManager {
3976
4197
  // Build an execution transaction
3977
4198
  return await ProgramManager$1.buildExecutionTransaction(executionPrivateKey, program, functionName, inputs, priorityFee, feeRecord, this.host, imports, provingKey, verifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery, edition);
3978
4199
  }
4200
+ /**
4201
+ * Builds an execution transaction for submission to the Aleo network from an Authorization and Fee Authorization.
4202
+ * This method is helpful if signing and authorization needs to be done in a secure environment separate from where
4203
+ * transactions are built.
4204
+ *
4205
+ * @param {ExecuteAuthorizationOptions} options - The options for executing the authorizations.
4206
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
4207
+ *
4208
+ * @example
4209
+ * /// Import the mainnet version of the sdk.
4210
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
4211
+ *
4212
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
4213
+ * const keyProvider = new AleoKeyProvider();
4214
+ * keyProvider.useCache(true);
4215
+ *
4216
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
4217
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider);
4218
+ *
4219
+ * // Build the `Authorization`.
4220
+ * const authorization = await programManager.buildAuthorization({
4221
+ * programName: "credits.aleo",
4222
+ * functionName: "transfer_public",
4223
+ * inputs: [
4224
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
4225
+ * "10000000u64",
4226
+ * ],
4227
+ * });
4228
+ *
4229
+ * // Derive the execution ID and base fee.
4230
+ * const executionId = authorization.toExecutionId().toString();
4231
+ *
4232
+ * // Get the base fee in microcredits.
4233
+ * const baseFeeMicrocredits = ProgramManager.estimateFeeForAuthorization(authorization, "credits.aleo");
4234
+ * const baseFeeCredits = baseFeeMicrocredits/1000000;
4235
+ *
4236
+ * // Build a credits.aleo/fee_public `Authorization`.
4237
+ * const feeAuthorization = await programManager.buildFeeAuthorization({
4238
+ * deploymentOrExecutionId: executionId,
4239
+ * baseFeeCredits,
4240
+ * });
4241
+ *
4242
+ * // Build and execute the transaction
4243
+ * const tx = await programManager.buildTransactionFromAuthorization({
4244
+ * programName: "hello_hello.aleo",
4245
+ * authorization,
4246
+ * feeAuthorization,
4247
+ * });
4248
+ *
4249
+ * // Submit the transaction to the network
4250
+ * await programManager.networkClient.submitTransaction(tx.toString());
4251
+ *
4252
+ * // Verify the transaction was successful
4253
+ * setTimeout(async () => {
4254
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
4255
+ * assert(transaction.id() === tx.id());
4256
+ * }, 10000);
4257
+ */
4258
+ async buildTransactionFromAuthorization(options) {
4259
+ // Destructure the options object to access the parameters.
4260
+ const { programName, authorization, } = options;
4261
+ const feeAuthorization = options.feeAuthorization;
4262
+ const keySearchParams = options.keySearchParams;
4263
+ const offlineQuery = options.offlineQuery;
4264
+ let provingKey = options.provingKey;
4265
+ let verifyingKey = options.verifyingKey;
4266
+ let program = options.program;
4267
+ let imports = options.imports;
4268
+ // Ensure the function exists on the network.
4269
+ if (program === undefined) {
4270
+ try {
4271
+ program = (await this.networkClient.getProgram(programName));
4272
+ }
4273
+ catch (e) {
4274
+ logAndThrow(`Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`);
4275
+ }
4276
+ }
4277
+ else if (program instanceof Program) {
4278
+ program = program.toString();
4279
+ }
4280
+ // Get the fee proving and verifying keys from the key provider.
4281
+ let feeKeys;
4282
+ const privateFee = feeAuthorization ? feeAuthorization.isFeePrivate() : false;
4283
+ try {
4284
+ feeKeys = privateFee
4285
+ ? await this.keyProvider.feePrivateKeys()
4286
+ : await this.keyProvider.feePublicKeys();
4287
+ }
4288
+ catch (e) {
4289
+ logAndThrow(`Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`);
4290
+ }
4291
+ const [feeProvingKey, feeVerifyingKey] = feeKeys;
4292
+ // If the function proving and verifying keys are not provided, attempt to find them using the key provider.
4293
+ if (!provingKey || !verifyingKey) {
4294
+ try {
4295
+ [provingKey, verifyingKey] = (await this.keyProvider.functionKeys(keySearchParams));
4296
+ }
4297
+ catch (e) {
4298
+ console.log(`Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`);
4299
+ }
4300
+ }
4301
+ // Resolve the program imports if they exist.
4302
+ const numberOfImports = Program.fromString(program).getImports().length;
4303
+ if (numberOfImports > 0 && !imports) {
4304
+ try {
4305
+ imports = (await this.networkClient.getProgramImports(programName));
4306
+ }
4307
+ catch (e) {
4308
+ logAndThrow(`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`);
4309
+ }
4310
+ }
4311
+ // If the offline query exists, add the inclusion key.
4312
+ if (offlineQuery && !this.inclusionKeysLoaded) {
4313
+ try {
4314
+ const inclusionKeys = await this.keyProvider.inclusionKeys();
4315
+ ProgramManager$1.loadInclusionProver(inclusionKeys[0]);
4316
+ this.inclusionKeysLoaded = true;
4317
+ console.log("Successfully loaded inclusion key");
4318
+ }
4319
+ catch {
4320
+ logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`);
4321
+ }
4322
+ }
4323
+ // Build an execution transaction from the authorization.
4324
+ return await ProgramManager$1.executeAuthorization(authorization, feeAuthorization, program, provingKey, verifyingKey, feeProvingKey, feeVerifyingKey, imports, this.host, offlineQuery);
4325
+ }
3979
4326
  /**
3980
4327
  * Builds a SnarkVM `Authorization` for a specific function.
3981
4328
  *
@@ -4258,14 +4605,14 @@ class ProgramManager {
4258
4605
  * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
4259
4606
  *
4260
4607
  * // Build a credits.aleo/fee_public `Authorization`.
4261
- * const feePublicAuthorization = await programManager.authorizeFee({
4608
+ * const feePublicAuthorization = await programManager.buildFeeAuthorization({
4262
4609
  * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
4263
4610
  * baseFeeCredits: 0.1,
4264
4611
  * });
4265
4612
  *
4266
4613
  * // Build a credits.aleo/fee_private `Authorization`.
4267
4614
  * const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
4268
- * const feePrivateAuthorization = await programManager.authorizeFee({
4615
+ * const feePrivateAuthorization = await programManager.buildFeeAuthorization({
4269
4616
  * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
4270
4617
  * baseFeeCredits: 0.1,
4271
4618
  * feeRecord: record,
@@ -5454,5 +5801,5 @@ async function initializeWasm() {
5454
5801
  console.warn("initializeWasm is deprecated, you no longer need to use it");
5455
5802
  }
5456
5803
 
5457
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordScanner, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow };
5804
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordScanner, SealanceMerkleTree, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow };
5458
5805
  //# sourceMappingURL=browser.js.map