@provablehq/sdk 0.9.9 → 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.
Files changed (35) hide show
  1. package/dist/dynamic/browser.d.ts +8 -0
  2. package/dist/dynamic/browser.js +8 -0
  3. package/dist/dynamic/node.d.ts +8 -0
  4. package/dist/dynamic/node.js +8 -0
  5. package/dist/mainnet/browser.d.ts +5 -3
  6. package/dist/mainnet/browser.js +769 -7
  7. package/dist/mainnet/browser.js.map +1 -1
  8. package/dist/mainnet/constants.d.ts +5 -0
  9. package/dist/mainnet/function-key-provider.d.ts +18 -0
  10. package/dist/mainnet/integrations/sealance/merkle-tree.d.ts +121 -0
  11. package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +5 -1
  12. package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +2 -2
  13. package/dist/mainnet/models/record-scanner/statusResponse.d.ts +13 -0
  14. package/dist/mainnet/node.js +3 -2
  15. package/dist/mainnet/node.js.map +1 -1
  16. package/dist/mainnet/offline-key-provider.d.ts +14 -0
  17. package/dist/mainnet/program-manager.d.ts +105 -13
  18. package/dist/mainnet/record-scanner.d.ts +151 -0
  19. package/dist/mainnet/wasm.d.ts +1 -1
  20. package/dist/testnet/browser.d.ts +5 -3
  21. package/dist/testnet/browser.js +769 -7
  22. package/dist/testnet/browser.js.map +1 -1
  23. package/dist/testnet/constants.d.ts +5 -0
  24. package/dist/testnet/function-key-provider.d.ts +18 -0
  25. package/dist/testnet/integrations/sealance/merkle-tree.d.ts +121 -0
  26. package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +5 -1
  27. package/dist/testnet/models/record-scanner/registrationResponse.d.ts +2 -2
  28. package/dist/testnet/models/record-scanner/statusResponse.d.ts +13 -0
  29. package/dist/testnet/node.js +3 -2
  30. package/dist/testnet/node.js.map +1 -1
  31. package/dist/testnet/offline-key-provider.d.ts +14 -0
  32. package/dist/testnet/program-manager.d.ts +105 -13
  33. package/dist/testnet/record-scanner.d.ts +151 -0
  34. package/dist/testnet/wasm.d.ts +1 -1
  35. package/package.json +8 -3
@@ -32,3 +32,8 @@ export declare const PRIVATE_TO_PUBLIC_TRANSFER: Set<string>;
32
32
  export declare const PUBLIC_TRANSFER: Set<string>;
33
33
  export declare const PUBLIC_TRANSFER_AS_SIGNER: Set<string>;
34
34
  export declare const PUBLIC_TO_PRIVATE_TRANSFER: Set<string>;
35
+ export declare const RECORD_DOMAIN = "RecordScannerV0";
36
+ /**
37
+ * Zero address on Aleo blockchain that corresponds to field element 0. Used as padding in Merkle trees and as a sentinel value.
38
+ */
39
+ export declare const ZERO_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
@@ -146,6 +146,12 @@ interface FunctionKeyProvider {
146
146
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
147
147
  */
148
148
  feePublicKeys(): Promise<FunctionKeyPair>;
149
+ /**
150
+ * Get keys for the inclusion proof.
151
+ *
152
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
153
+ */
154
+ inclusionKeys(): Promise<FunctionKeyPair>;
149
155
  /**
150
156
  * Get join function keys from the credits.aleo program
151
157
  *
@@ -314,6 +320,18 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
314
320
  * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
315
321
  */
316
322
  transferKeys(visibility: string): Promise<FunctionKeyPair>;
323
+ /**
324
+ * Returns the proving and verifying keys for the transfer_public function.
325
+ *
326
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function
327
+ */
328
+ transferPublicKeys(): Promise<FunctionKeyPair>;
329
+ /**
330
+ * Returns the proving and verifying keys for the inclusion proof.
331
+ *
332
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.
333
+ */
334
+ inclusionKeys(): Promise<FunctionKeyPair>;
317
335
  /**
318
336
  * Returns the proving and verifying keys for the join function in the credits.aleo program
319
337
  *
@@ -0,0 +1,121 @@
1
+ import { Field } from "../../wasm.js";
2
+ /**
3
+ * Client library that encapsulates methods for constructing Merkle exclusion proofs for compliant stablecoin programs following the Sealance architecture.
4
+ *
5
+
6
+ * @example
7
+ * Construct a Merkle exclusion proof.
8
+ * ```typescript
9
+ * const sealance = new SealanceMerkleTree();
10
+ * const leaves = [
11
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
12
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
13
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
14
+ * ];
15
+ * const result = sealance.generateLeaves(leaves);
16
+ * const tree = sealance.buildTree(result);
17
+ * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, "aleo1kypwp5m7qtk9mwazgcpg0tq8aal23mnrvwfvug65qgcg9xvsrqgspyjm6n");
18
+ * const proof_left = sealance.getSiblingPath(tree, leftIdx, 15);
19
+ * const proof_right = sealance.getSiblingPath(tree, rightIdx, 15);
20
+ * const exclusion_proof = [proof_left, proof_right];
21
+ * ```
22
+ */
23
+ declare class SealanceMerkleTree {
24
+ private static hasher;
25
+ /**
26
+ * Converts an Aleo blockchain address to a field element.
27
+ *
28
+ * This function decodes a bech32m-encoded Aleo address and converts it to a field element
29
+ * represented as a BigInt. The address format follows the Aleo protocol specification,
30
+ * starting with the prefix "aleo1" followed by encoded data.
31
+ *
32
+ * @param address - The Aleo blockchain address (e.g., "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
33
+ * @returns A BigInt representing the field element.
34
+ * @throws Error if the address is invalid or cannot be decoded.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const address = "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px";
39
+ * const fieldValue = convertAddressToField(address);
40
+ * console.log(fieldValue); // 123456789...n
41
+ * ```
42
+ */
43
+ convertAddressToField(address: string): bigint;
44
+ /**
45
+ * Hashes two elements using Poseidon4 hash function
46
+ * @param prefix - Prefix for the hash (e.g., "0field" for nodes, "1field" for leaves)
47
+ * @param el1 - First element to hash
48
+ * @param el2 - Second element to hash
49
+ * @returns The hash result as a Field
50
+ * @throws {Error} If inputs are empty or invalid
51
+ */
52
+ hashTwoElements(prefix: string, el1: string, el2: string): Field;
53
+ /**
54
+ * Builds a Merkle tree from given leaves. The tree is built bottom-up, hashing pairs of elements at each level.
55
+ *
56
+ * @param leaves - Array of leaf elements (must have even number of elements).
57
+ * @returns Array representing the complete Merkle tree as BigInts.
58
+ * @throws {Error} If leaves array is empty or has odd number of elements.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const leaves = ["0field", "1field", "2field", "3field"];
63
+ * const tree = buildTree(leaves);
64
+ * const root = tree[tree.length - 1]; // Get the Merkle root
65
+ * ```
66
+ */
67
+ buildTree(leaves: string[]): bigint[];
68
+ /**
69
+ * Converts Aleo addresses to field elements, sorts them, pads with zero fields, and returns an array. This prepares addresses for Merkle tree construction.
70
+ *
71
+ * @param addresses - Array of Aleo addresses.
72
+ * @param maxTreeDepth - Maximum depth of the Merkle tree (default: 15).
73
+ * @returns Array of field elements ready for Merkle tree construction.
74
+ * @throws {Error} If the number of addresses exceeds the maximum capacity.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const addresses = [
79
+ * "aleo1...",
80
+ * "aleo1..."
81
+ * ];
82
+ * const leaves = generateLeaves(addresses, 15);
83
+ * const tree = buildTree(leaves);
84
+ * ```
85
+ */
86
+ generateLeaves(addresses: string[], maxTreeDepth?: number): string[];
87
+ /**
88
+ * 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.
89
+ *
90
+ * @param merkleTree - The complete Merkle tree as array of BigInts.
91
+ * @param address - The Aleo address for which to find indices.
92
+ * @returns Tuple of [leftLeafIndex, rightLeafIndex].
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const tree = buildTree(leaves);
97
+ * const [leftIdx, rightIdx] = getLeafIndices(tree, "aleo1...");
98
+ * ```
99
+ */
100
+ getLeafIndices(merkleTree: bigint[], address: string): [number, number];
101
+ /**
102
+ * Generates the sibling path (Merkle proof) for a given leaf index
103
+ *
104
+ * @param tree - The complete Merkle tree.
105
+ * @param leafIndex - Index of the leaf for which to generate the proof.
106
+ * @param depth - Maximum depth of the tree.
107
+ * @returns Object containing siblings array and leaf_index.
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const tree = buildTree(leaves);
112
+ * const proof = getSiblingPath(tree, 0, 15);
113
+ * // proof = { siblings: [0n, 1n, ...], leaf_index: 0 }
114
+ * ```
115
+ */
116
+ getSiblingPath(tree: bigint[], leafIndex: number, depth: number): {
117
+ siblings: bigint[];
118
+ leaf_index: number;
119
+ };
120
+ }
121
+ export { SealanceMerkleTree };
@@ -5,6 +5,7 @@
5
5
  * @example
6
6
  * const recordsResponseFilter: RecordsResponseFilter = {
7
7
  * block_height: true,
8
+ * block_timestamp: true,
8
9
  * checksum: true,
9
10
  * commitment: true,
10
11
  * record_ciphertext: true,
@@ -14,6 +15,7 @@
14
15
  * owner: true,
15
16
  * program_name: true,
16
17
  * record_name: true,
18
+ * sender_ciphertext: true,
17
19
  * transaction_id: true,
18
20
  * transition_id: true,
19
21
  * transaction_index: true,
@@ -21,10 +23,12 @@
21
23
  * }
22
24
  */
23
25
  export type RecordsResponseFilter = {
24
- blockHeight?: boolean;
26
+ block_height?: boolean;
27
+ block_timestamp?: boolean;
25
28
  checksum?: boolean;
26
29
  commitment?: boolean;
27
30
  record_ciphertext?: boolean;
31
+ sender_ciphertext?: boolean;
28
32
  function_name?: boolean;
29
33
  nonce?: boolean;
30
34
  output_index?: boolean;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * RegistrationResponse is a type that represents a response from a record scanning service.
2
+ * RegistrationResponse is a type that represents a response from a record scanning service's registration endpoint.
3
3
  *
4
4
  * @example
5
5
  * const registrationResponse: RegistrationResponse = {
@@ -8,7 +8,7 @@
8
8
  * status: "pending",
9
9
  * }
10
10
  */
11
- interface RegistrationResponse {
11
+ export interface RegistrationResponse {
12
12
  uuid: string;
13
13
  job_id?: string;
14
14
  status?: string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * StatusResponse is a type that represents a response from a record scanning service's status endpoint.
3
+ *
4
+ * @example
5
+ * const statusResponse: StatusResponse = {
6
+ * synced: true,
7
+ * percentage: 100,
8
+ * }
9
+ */
10
+ export interface StatusResponse {
11
+ synced: boolean;
12
+ percentage: number;
13
+ }
@@ -1,6 +1,6 @@
1
1
  import './node-polyfill.js';
2
- 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, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow } from './browser.js';
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, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
2
+ 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 } from './browser.js';
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/testnet.js';
4
4
  import 'core-js/proposals/json-parse-with-source.js';
5
5
  import 'node:crypto';
6
6
  import 'node:fs';
@@ -9,4 +9,5 @@ import 'xmlhttprequest-ssl';
9
9
  import 'sync-request';
10
10
  import 'node:worker_threads';
11
11
  import 'node:os';
12
+ import '@scure/base';
12
13
  //# sourceMappingURL=node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -212,6 +212,12 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
212
212
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
213
213
  */
214
214
  feePublicKeys(): Promise<FunctionKeyPair>;
215
+ /**
216
+ * Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.
217
+ *
218
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover
219
+ */
220
+ inclusionKeys(): Promise<FunctionKeyPair>;
215
221
  /**
216
222
  * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
217
223
  * method for it to work.
@@ -287,6 +293,14 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
287
293
  * @param provingKey
288
294
  */
289
295
  insertFeePublicKeys(provingKey: ProvingKey): void;
296
+ /**
297
+ * Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs
298
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
299
+ * that the keys match the expected checksum for the inclusion prover.
300
+ *
301
+ * @param provingKey
302
+ */
303
+ insertInclusionKeys(provingKey: ProvingKey): void;
290
304
  /**
291
305
  * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
292
306
  * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
@@ -45,12 +45,13 @@ interface ExecuteOptions {
45
45
  /**
46
46
  * Options for building an Authorization for a function.
47
47
  *
48
- * @property programName {string} Name of the program containing the function to build the authorization for.
49
- * @property functionName {string} Name of the function name to build the authorization for.
50
- * @property inputs {string[]} The inputs to the function.
51
- * @property programSource {string | Program} The optional source code for the program to build an execution for.
52
- * @property privateKey {PrivateKey} Optional private key to use to build the authorization.
53
- * @property programImports {ProgramImports} The other programs the program imports.
48
+ * @property {string} programName Name of the program containing the function to build the authorization for.
49
+ * @property {string} functionName Name of the function name to build the authorization for.
50
+ * @property {string[]} inputs The inputs to the function.
51
+ * @property {string | Program} [programSource] The optional source code for the program to build an execution for.
52
+ * @property {PrivateKey} [privateKey] Optional private key to use to build the authorization.
53
+ * @property {ProgramImports} [programImports] The other programs the program imports.
54
+ * @property {edition} [edition]
54
55
  */
55
56
  interface AuthorizationOptions {
56
57
  programName: string;
@@ -64,11 +65,11 @@ interface AuthorizationOptions {
64
65
  /**
65
66
  * Options for executing a fee authorization.
66
67
  *
67
- * @property deploymentOrExecutionId {string} The id of a previously built Execution or Authorization.
68
- * @property baseFeeCredits {number} The number of Aleo Credits to pay for the base fee.
69
- * @property priorityFeeCredits {number} The number of Aleo Credits to pay for the priority fee.
70
- * @property privateKey {PrivateKey} Optional private key to specify for the authorization.
71
- * @property feeRecord {RecordPlaintext} A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
68
+ * @property {string} deploymentOrExecutionId The id of a previously built Execution or Authorization.
69
+ * @property {number} baseFeeCredits The number of Aleo Credits to pay for the base fee.
70
+ * @property {number} [priorityFeeCredits] The number of Aleo Credits to pay for the priority fee.
71
+ * @property {PrivateKey} [privateKey] Optional private key to specify for the authorization.
72
+ * @property {RecordPlaintext} [feeRecord] A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
72
73
  */
73
74
  interface FeeAuthorizationOptions {
74
75
  deploymentOrExecutionId: string;
@@ -77,6 +78,28 @@ interface FeeAuthorizationOptions {
77
78
  privateKey?: PrivateKey;
78
79
  feeRecord?: RecordPlaintext;
79
80
  }
81
+ /**
82
+ * Represents the options for executing a transaction on the Aleo Network from an authorization.
83
+ *
84
+ * @property {string} programName - The name of the program containing the function to be executed.
85
+ * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.
86
+ * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.
87
+ * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.
88
+ * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.
89
+ * @property {string | Program} [program] - Optional program source code to use for the transaction.
90
+ * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
91
+ */
92
+ interface ExecuteAuthorizationOptions {
93
+ programName: string;
94
+ authorization: Authorization;
95
+ feeAuthorization?: Authorization;
96
+ keySearchParams?: KeySearchParams;
97
+ provingKey?: ProvingKey;
98
+ verifyingKey?: VerifyingKey;
99
+ offlineQuery?: OfflineQuery;
100
+ program?: string | Program;
101
+ imports?: ProgramImports;
102
+ }
80
103
  /**
81
104
  * Represents the options for executing a transaction in the Aleo network.
82
105
  * This interface is used to specify the parameters required for building and submitting an execution transaction.
@@ -120,6 +143,7 @@ declare class ProgramManager {
120
143
  host: string;
121
144
  networkClient: AleoNetworkClient;
122
145
  recordProvider: RecordProvider | undefined;
146
+ inclusionKeysLoaded: boolean;
123
147
  /** Create a new instance of the ProgramManager
124
148
  *
125
149
  * @param { string | undefined } host A host uri running the official Aleo API
@@ -300,6 +324,65 @@ declare class ProgramManager {
300
324
  * }, 10000);
301
325
  */
302
326
  buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
327
+ /**
328
+ * Builds an execution transaction for submission to the Aleo network from an Authorization and Fee Authorization.
329
+ * This method is helpful if signing and authorization needs to be done in a secure environment separate from where
330
+ * transactions are built.
331
+ *
332
+ * @param {ExecuteAuthorizationOptions} options - The options for executing the authorizations.
333
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
334
+ *
335
+ * @example
336
+ * /// Import the mainnet version of the sdk.
337
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
338
+ *
339
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
340
+ * const keyProvider = new AleoKeyProvider();
341
+ * keyProvider.useCache(true);
342
+ *
343
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
344
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider);
345
+ *
346
+ * // Build the `Authorization`.
347
+ * const authorization = await programManager.buildAuthorization({
348
+ * programName: "credits.aleo",
349
+ * functionName: "transfer_public",
350
+ * inputs: [
351
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
352
+ * "10000000u64",
353
+ * ],
354
+ * });
355
+ *
356
+ * // Derive the execution ID and base fee.
357
+ * const executionId = authorization.toExecutionId().toString();
358
+ *
359
+ * // Get the base fee in microcredits.
360
+ * const baseFeeMicrocredits = ProgramManager.estimateFeeForAuthorization(authorization, "credits.aleo");
361
+ * const baseFeeCredits = baseFeeMicrocredits/1000000;
362
+ *
363
+ * // Build a credits.aleo/fee_public `Authorization`.
364
+ * const feeAuthorization = await programManager.buildFeeAuthorization({
365
+ * deploymentOrExecutionId: executionId,
366
+ * baseFeeCredits,
367
+ * });
368
+ *
369
+ * // Build and execute the transaction
370
+ * const tx = await programManager.buildTransactionFromAuthorization({
371
+ * programName: "hello_hello.aleo",
372
+ * authorization,
373
+ * feeAuthorization,
374
+ * });
375
+ *
376
+ * // Submit the transaction to the network
377
+ * await programManager.networkClient.submitTransaction(tx.toString());
378
+ *
379
+ * // Verify the transaction was successful
380
+ * setTimeout(async () => {
381
+ * const transaction = await programManager.networkClient.getTransaction(tx.id());
382
+ * assert(transaction.id() === tx.id());
383
+ * }, 10000);
384
+ */
385
+ buildTransactionFromAuthorization(options: ExecuteAuthorizationOptions): Promise<Transaction>;
303
386
  /**
304
387
  * Builds a SnarkVM `Authorization` for a specific function.
305
388
  *
@@ -410,14 +493,14 @@ declare class ProgramManager {
410
493
  * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
411
494
  *
412
495
  * // Build a credits.aleo/fee_public `Authorization`.
413
- * const feePublicAuthorization = await programManager.authorizeFee({
496
+ * const feePublicAuthorization = await programManager.buildFeeAuthorization({
414
497
  * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
415
498
  * baseFeeCredits: 0.1,
416
499
  * });
417
500
  *
418
501
  * // Build a credits.aleo/fee_private `Authorization`.
419
502
  * const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
420
- * const feePrivateAuthorization = await programManager.authorizeFee({
503
+ * const feePrivateAuthorization = await programManager.buildFeeAuthorization({
421
504
  * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
422
505
  * baseFeeCredits: 0.1,
423
506
  * feeRecord: record,
@@ -1068,6 +1151,15 @@ declare class ProgramManager {
1068
1151
  * assert(isValid);
1069
1152
  */
1070
1153
  verifyExecution(executionResponse: ExecutionResponse, blockHeight: number, imports?: ImportedPrograms, importedVerifyingKeys?: ImportedVerifyingKeys): boolean;
1154
+ /**
1155
+ * Set the inclusion key bytes.
1156
+ *
1157
+ * @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)
1158
+ * @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { "programName": "programSourceCode", ... }
1159
+ * @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { "programName": [["functionName", "verifyingKey"], ...], ... }
1160
+ * @returns {boolean} True if the proof is valid, false otherwise
1161
+ *
1162
+
1071
1163
  /**
1072
1164
  * Create a program object from a program's source code
1073
1165
  *
@@ -0,0 +1,151 @@
1
+ import { EncryptedRecord } from "./models/record-provider/encryptedRecord";
2
+ import { OwnedFilter } from "./models/record-scanner/ownedFilter";
3
+ import { OwnedRecord } from "./models/record-provider/ownedRecord";
4
+ import { RecordProvider } from "./record-provider";
5
+ import { Field, ViewKey } from "./wasm";
6
+ import { RecordsFilter } from "./models/record-scanner/recordsFilter";
7
+ import { RegistrationResponse } from "./models/record-scanner/registrationResponse";
8
+ import { StatusResponse } from "./models/record-scanner/statusResponse";
9
+ type RecordScannerOptions = {
10
+ url: string;
11
+ apiKey?: string | {
12
+ header: string;
13
+ value: string;
14
+ };
15
+ };
16
+ /**
17
+ * RecordScanner is a RecordProvider implementation that uses the record scanner service to find records.
18
+ *
19
+ * @example
20
+ * const account = new Account({ privateKey: 'APrivateKey1...' });
21
+ *
22
+ * const recordScanner = new RecordScanner({ url: "https://record-scanner.aleo.org" });
23
+ * recordScanner.setAccount(account);
24
+ * recordScanner.setApiKey("your-api-key");
25
+ * const uuid = await recordScanner.register(0);
26
+ *
27
+ * const filter = {
28
+ * uuid,
29
+ * filter: {
30
+ * program: "credits.aleo",
31
+ * records: ["credits"],
32
+ * },
33
+ * responseFilter: {
34
+ * commitment: true,
35
+ * owner: true,
36
+ * tag: true,
37
+ * tag?: boolean;
38
+ * sender: true,
39
+ * spent: true,
40
+ * record_ciphertext: true,
41
+ * block_height: true;
42
+ * block_timestamp: true;
43
+ * output_index: true;
44
+ * record_name: true;
45
+ * function_name: true;
46
+ * program_name: true;
47
+ * transition_id: true;
48
+ * transaction_id: true;
49
+ * transaction_index: true;
50
+ * transition_index: true;
51
+ * },
52
+ * unspent: true,
53
+ * };
54
+ *
55
+ * const records = await recordScanner.findRecords(filter);
56
+ */
57
+ declare class RecordScanner implements RecordProvider {
58
+ readonly url: string;
59
+ private apiKey?;
60
+ private uuid?;
61
+ constructor(options: RecordScannerOptions);
62
+ /**
63
+ * Set the API key to use for the record scanner.
64
+ *
65
+ * @param {string} apiKey The API key to use for the record scanner.
66
+ */
67
+ setApiKey(apiKey: string | {
68
+ header: string;
69
+ value: string;
70
+ }): Promise<void>;
71
+ /**
72
+ * Set the UUID to use for the record scanner.
73
+ *
74
+ * @param {Field} uuid The UUID to use for the record scanner.
75
+ */
76
+ setUuid(uuidOrViewKey: Field | ViewKey): Promise<void>;
77
+ /**
78
+ * Register the account with the record scanner service.
79
+ *
80
+ * @param {number} startBlock The block height to start scanning from.
81
+ * @returns {Promise<RegistrationResponse>} The response from the record scanner service.
82
+ */
83
+ register(viewKey: ViewKey, startBlock: number): Promise<RegistrationResponse>;
84
+ /**
85
+ * Get encrypted records from the record scanner service.
86
+ *
87
+ * @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.
88
+ * @returns {Promise<EncryptedRecord[]>} The encrypted records.
89
+ */
90
+ encryptedRecords(recordsFilter: RecordsFilter): Promise<EncryptedRecord[]>;
91
+ /**
92
+ * Check if a list of serial numbers exist in the record scanner service.
93
+ *
94
+ * @param {string[]} serialNumbers The serial numbers to check.
95
+ * @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.
96
+ */
97
+ checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;
98
+ /**
99
+ * Check if a list of tags exist in the record scanner service.
100
+ *
101
+ * @param {string[]} tags The tags to check.
102
+ * @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.
103
+ */
104
+ checkTags(tags: string[]): Promise<Record<string, boolean>>;
105
+ /**
106
+ * Check the status of a record scanner indexing job.
107
+ *
108
+ * @param {string} jobId The job id to check.
109
+ * @returns {Promise<StatusResponse>} The status of the job.
110
+ */
111
+ checkStatus(): Promise<StatusResponse>;
112
+ /**
113
+ * Find a record in the record scanner service.
114
+ *
115
+ * @param {OwnedFilter} searchParameters The filter to use to find the record.
116
+ * @returns {Promise<OwnedRecord>} The record.
117
+ */
118
+ findRecord(searchParameters: OwnedFilter): Promise<OwnedRecord>;
119
+ /**
120
+ * Find records in the record scanner service.
121
+ *
122
+ * @param {OwnedFilter} filter The filter to use to find the records.
123
+ * @returns {Promise<OwnedRecord[]>} The records.
124
+ */
125
+ findRecords(filter: OwnedFilter): Promise<OwnedRecord[]>;
126
+ /**
127
+ * Find a credits record in the record scanner service.
128
+ *
129
+ * @param {number} microcredits The amount of microcredits to find.
130
+ * @param {OwnedFilter} searchParameters The filter to use to find the record.
131
+ * @returns {Promise<OwnedRecord>} The record.
132
+ */
133
+ findCreditsRecord(microcredits: number, searchParameters: OwnedFilter): Promise<OwnedRecord>;
134
+ /**
135
+ * Find credits records using a record scanning service.
136
+ *
137
+ * @param {number[]} microcreditAmounts The amounts of microcredits to find.
138
+ * @param {OwnedFilter} searchParameters The filter to use to find the records.
139
+ * @returns {Promise<OwnedRecord[]>} The records
140
+ */
141
+ findCreditsRecords(microcreditAmounts: number[], searchParameters: OwnedFilter): Promise<OwnedRecord[]>;
142
+ /**
143
+ * Wrapper function to make a request to the record scanner service and handle any errors.
144
+ *
145
+ * @param {Request} req The request to make.
146
+ * @returns {Promise<Response>} The response.
147
+ */
148
+ private request;
149
+ computeUUID(vk: ViewKey): Field;
150
+ }
151
+ export { RecordScanner };
@@ -1 +1 @@
1
- export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
1
+ export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provablehq/sdk",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
5
5
  "collaborators": [
6
6
  "The Provable Team"
@@ -21,6 +21,10 @@
21
21
  "./mainnet.js": {
22
22
  "node": "./dist/mainnet/node.js",
23
23
  "default": "./dist/mainnet/browser.js"
24
+ },
25
+ "./dynamic.js": {
26
+ "node": "./dist/dynamic/node.js",
27
+ "default": "./dist/dynamic/browser.js"
24
28
  }
25
29
  },
26
30
  "files": [
@@ -30,7 +34,7 @@
30
34
  ],
31
35
  "scripts": {
32
36
  "build": "rimraf dist && rollup -c rollup.config.js",
33
- "test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --timeout 60000"
37
+ "test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --timeout 60000 && RUN_SKIPPED=true mocha tmp/**/wasm.test.js --timeout 60000 --grep Consensus"
34
38
  },
35
39
  "repository": {
36
40
  "type": "git",
@@ -47,7 +51,8 @@
47
51
  },
48
52
  "homepage": "https://github.com/ProvableHQ/sdk#readme",
49
53
  "dependencies": {
50
- "@provablehq/wasm": "^0.9.9",
54
+ "@provablehq/wasm": "^0.9.10",
55
+ "@scure/base": "^2.0.0",
51
56
  "comlink": "^4.4.2",
52
57
  "core-js": "^3.40.0",
53
58
  "mime": "^4.0.6",