@provablehq/sdk 0.9.11 → 0.9.13
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.
- package/dist/mainnet/browser.d.ts +2 -1
- package/dist/mainnet/browser.js +645 -47
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/integrations/sealance/merkle-tree.d.ts +25 -0
- package/dist/mainnet/models/functionInput.d.ts +7 -0
- package/dist/mainnet/program-manager.d.ts +185 -2
- package/dist/testnet/browser.d.ts +2 -1
- package/dist/testnet/browser.js +645 -47
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/integrations/sealance/merkle-tree.d.ts +25 -0
- package/dist/testnet/models/functionInput.d.ts +7 -0
- package/dist/testnet/program-manager.d.ts +185 -2
- package/package.json +2 -2
|
@@ -65,6 +65,12 @@ declare class SealanceMerkleTree {
|
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
67
|
buildTree(leaves: string[]): bigint[];
|
|
68
|
+
/** Converts an array of decimal string representations of U256 numbers to an array of BigInts.
|
|
69
|
+
*
|
|
70
|
+
* @param tree - Array of decimal string representations of U256 numbers.
|
|
71
|
+
* @returns Array of BigInts.
|
|
72
|
+
*/
|
|
73
|
+
convertTreeToBigInt(tree: string[]): bigint[];
|
|
68
74
|
/**
|
|
69
75
|
* Converts Aleo addresses to field elements, sorts them, pads with zero fields, and returns an array. This prepares addresses for Merkle tree construction.
|
|
70
76
|
*
|
|
@@ -117,5 +123,24 @@ declare class SealanceMerkleTree {
|
|
|
117
123
|
siblings: bigint[];
|
|
118
124
|
leaf_index: number;
|
|
119
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Generates a formatted exclusion proof suitable for Aleo transactions.
|
|
128
|
+
*
|
|
129
|
+
* @param proof - An array of two {sibling path, leafindex} objects.
|
|
130
|
+
* @returns String representation of the exclusion proof.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const tree = buildTree(leaves);
|
|
135
|
+
* const proof = getSiblingPath(tree, 0, 15);
|
|
136
|
+
* const proof2 = getSiblingPath(tree, 1, 15);
|
|
137
|
+
* const formattedProof = formatMerkleProof([proof, proof2]);
|
|
138
|
+
* // formattedProof = "[{ siblings: [0field, 1field, ...], leaf_index: 0u32 }, { siblings: [0field, 2field, ...], leaf_index: 1u32 }]"
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
formatMerkleProof(proof: {
|
|
142
|
+
siblings: bigint[];
|
|
143
|
+
leaf_index: number;
|
|
144
|
+
}[]): string;
|
|
120
145
|
}
|
|
121
146
|
export { SealanceMerkleTree };
|
|
@@ -5,7 +5,25 @@ import { RecordProvider } from "./record-provider.js";
|
|
|
5
5
|
import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
|
|
6
6
|
import { FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
|
|
7
7
|
import { Authorization, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Represents the options for deploying and upgrading a transaction in the Aleo network.
|
|
10
|
+
* This interface is used to specify the parameters required for building and submitting an deployment transaction.
|
|
11
|
+
*
|
|
12
|
+
* @property {string} program - The program source code to be deployed.
|
|
13
|
+
* @property {number} priorityFee - The optional priority fee to be paid for the transaction.
|
|
14
|
+
* @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
|
|
15
|
+
* @property {RecordSearchParams | undefined} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.
|
|
16
|
+
* @property {string | RecordPlaintext | undefined} [feeRecord] - Optional fee record to use for the transaction.
|
|
17
|
+
* @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.
|
|
18
|
+
*/
|
|
19
|
+
interface DeployOptions {
|
|
20
|
+
program: string;
|
|
21
|
+
priorityFee: number;
|
|
22
|
+
privateFee: boolean;
|
|
23
|
+
recordSearchParams?: RecordSearchParams;
|
|
24
|
+
feeRecord?: string | RecordPlaintext;
|
|
25
|
+
privateKey?: PrivateKey;
|
|
26
|
+
}
|
|
9
27
|
/**
|
|
10
28
|
* Represents the options for executing a transaction in the Aleo network.
|
|
11
29
|
* This interface is used to specify the parameters required for building and submitting an execution transaction.
|
|
@@ -213,6 +231,25 @@ declare class ProgramManager {
|
|
|
213
231
|
* programManager.setHeader('Accept-Language', 'en-US');
|
|
214
232
|
*/
|
|
215
233
|
setHeader(headerName: string, value: string): void;
|
|
234
|
+
/**
|
|
235
|
+
* Set the inclusion prover into the wasm memory. This should be done prior to any execution of a function with a
|
|
236
|
+
* private record.
|
|
237
|
+
*
|
|
238
|
+
* @param {ProvingKey} [provingKey]
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* import { ProgramManager, AleoKeyProvider } from "@provablehq/sdk/mainnet.js";
|
|
242
|
+
*
|
|
243
|
+
* const keyProvider = new AleoKeyProvider();
|
|
244
|
+
* keyProvider.useCache(true);
|
|
245
|
+
*
|
|
246
|
+
* // Create a ProgramManager
|
|
247
|
+
* const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider);
|
|
248
|
+
*
|
|
249
|
+
* // Set the inclusion keys.
|
|
250
|
+
* programManager.setInclusionProver();
|
|
251
|
+
*/
|
|
252
|
+
setInclusionProver(provingKey?: ProvingKey): Promise<void>;
|
|
216
253
|
/**
|
|
217
254
|
* Remove a header from the `AleoNetworkClient`s header map
|
|
218
255
|
*
|
|
@@ -267,6 +304,39 @@ declare class ProgramManager {
|
|
|
267
304
|
* }, 20000);
|
|
268
305
|
*/
|
|
269
306
|
buildDeploymentTransaction(program: string, priorityFee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams, feeRecord?: string | RecordPlaintext, privateKey?: PrivateKey): Promise<Transaction>;
|
|
307
|
+
/**
|
|
308
|
+
* Builds a deployment transaction for submission to the Aleo network that upgrades an existing program.
|
|
309
|
+
*
|
|
310
|
+
* @param {DeployOptions} options The deployment options.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* /// Import the mainnet version of the sdk.
|
|
314
|
+
* import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
315
|
+
*
|
|
316
|
+
* // Create a new NetworkClient, KeyProvider, and RecordProvider
|
|
317
|
+
* const keyProvider = new AleoKeyProvider();
|
|
318
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
319
|
+
* keyProvider.useCache(true);
|
|
320
|
+
*
|
|
321
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
322
|
+
* const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
|
|
323
|
+
* const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
324
|
+
* programManager.setAccount(Account);
|
|
325
|
+
*
|
|
326
|
+
* // Define a fee in credits
|
|
327
|
+
* const priorityFee = 0.0;
|
|
328
|
+
*
|
|
329
|
+
* // Create the deployment transaction.
|
|
330
|
+
* const tx = await programManager.buildUpgradeTransaction({program: program, priorityFee: fee, privateFee: false});
|
|
331
|
+
* await programManager.networkClient.submitTransaction(tx);
|
|
332
|
+
*
|
|
333
|
+
* // Verify the transaction was successful
|
|
334
|
+
* setTimeout(async () => {
|
|
335
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
336
|
+
* assert(transaction.id() === tx.id());
|
|
337
|
+
* }, 20000);
|
|
338
|
+
*/
|
|
339
|
+
buildUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
|
|
270
340
|
/**
|
|
271
341
|
* Deploy an Aleo program to the Aleo network
|
|
272
342
|
*
|
|
@@ -1279,6 +1349,119 @@ declare class ProgramManager {
|
|
|
1279
1349
|
* const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
|
|
1280
1350
|
*/
|
|
1281
1351
|
estimateExecutionFee(options: FeeEstimateOptions): Promise<bigint>;
|
|
1282
|
-
getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<
|
|
1352
|
+
getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Builds an execution transaction for submission to the a local devnode.
|
|
1355
|
+
* This method skips proof generation and is not meant for use with the mainnet or testnet Aleo networks.
|
|
1356
|
+
* Note: getOrInitConsensusVersionTestHeights must be called prior to using this method for this method to work properly.
|
|
1357
|
+
*
|
|
1358
|
+
* @param {ExecuteOptions} options - The options for the execution transaction.
|
|
1359
|
+
* @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
|
|
1360
|
+
*
|
|
1361
|
+
* @example
|
|
1362
|
+
* /// Import the mainnet version of the sdk.
|
|
1363
|
+
* import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
1364
|
+
*
|
|
1365
|
+
* // Initialize the development consensus heights in order to work with devnode.
|
|
1366
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11");
|
|
1367
|
+
*
|
|
1368
|
+
* // Create a new NetworkClient and RecordProvider.
|
|
1369
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
1370
|
+
* keyProvider.useCache(true);
|
|
1371
|
+
*
|
|
1372
|
+
* // Initialize a program manager.
|
|
1373
|
+
* const programManager = new ProgramManager("http://localhost:3030", recordProvider);
|
|
1374
|
+
*
|
|
1375
|
+
* // Build and execute the transaction.
|
|
1376
|
+
* const tx = await programManager.buildDevnodeExecutionTransaction({
|
|
1377
|
+
* programName: "hello_hello.aleo",
|
|
1378
|
+
* functionName: "hello_hello",
|
|
1379
|
+
* priorityFee: 0.0,
|
|
1380
|
+
* privateFee: false,
|
|
1381
|
+
* inputs: ["5u32", "5u32"],
|
|
1382
|
+
* });
|
|
1383
|
+
*
|
|
1384
|
+
* // Submit the transaction to the network
|
|
1385
|
+
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
1386
|
+
*
|
|
1387
|
+
* // Verify the transaction was successful
|
|
1388
|
+
* setTimeout(async () => {
|
|
1389
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
1390
|
+
* assert(transaction.id() === tx.id());
|
|
1391
|
+
* }, 10000);
|
|
1392
|
+
*/
|
|
1393
|
+
buildDevnodeExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
|
|
1394
|
+
/**
|
|
1395
|
+
* Builds a deployment transaction with placeholder certificates and verifying keys for each function in the program.
|
|
1396
|
+
* Intended for use with a local devnode.
|
|
1397
|
+
* `getOrInitConsensusVersionTestHeights` must be called with development heights prior to invoking this method for it to work properly.
|
|
1398
|
+
*
|
|
1399
|
+
* @param {DeployOptions} options - The options for the deployment transaction.
|
|
1400
|
+
* @returns {string} The transaction id of the deployed program or a failure message from the network
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* /// Import the mainnet version of the sdk.
|
|
1404
|
+
* import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
|
|
1405
|
+
*
|
|
1406
|
+
* // Initialize the development consensus heights in order to work with a local devnode.
|
|
1407
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11");
|
|
1408
|
+
*
|
|
1409
|
+
* // Create a new NetworkClient, and RecordProvider
|
|
1410
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
1411
|
+
* keyProvider.useCache(true);
|
|
1412
|
+
*
|
|
1413
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
1414
|
+
* const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
|
|
1415
|
+
* const programManager = new ProgramManager("http://localhost:3030", recordProvider);
|
|
1416
|
+
* programManager.setAccount(Account);
|
|
1417
|
+
*
|
|
1418
|
+
* // Define a fee in credits
|
|
1419
|
+
* const priorityFee = 0.0;
|
|
1420
|
+
*
|
|
1421
|
+
* // Create the deployment transaction.
|
|
1422
|
+
* const tx = await programManager.buildDevnodeDeploymentTransaction({program: program, fee: priorityFee, privateFee: false});
|
|
1423
|
+
* await programManager.networkClient.submitTransaction(tx);
|
|
1424
|
+
*
|
|
1425
|
+
* // Verify the transaction was successful
|
|
1426
|
+
* setTimeout(async () => {
|
|
1427
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
1428
|
+
* assert(transaction.id() === tx.id());
|
|
1429
|
+
* }, 20000);
|
|
1430
|
+
*/
|
|
1431
|
+
buildDevnodeDeploymentTransaction(options: DeployOptions): Promise<Transaction>;
|
|
1432
|
+
/**
|
|
1433
|
+
* Builds an upgrade transaction on a local devnodewith placeholder certificates and verifying keys for each function in the program.
|
|
1434
|
+
* This method is only intended for use with a local devnode.
|
|
1435
|
+
*
|
|
1436
|
+
* @param {DeployOptions} options - The options for the deployment transaction.
|
|
1437
|
+
* @returns {string} The transaction id of the deployed program or a failure message from the network
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* /// Import the mainnet version of the sdk.
|
|
1441
|
+
* import { ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
1442
|
+
*
|
|
1443
|
+
* // Create a new NetworkClient, and RecordProvider
|
|
1444
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
1445
|
+
* keyProvider.useCache(true);
|
|
1446
|
+
*
|
|
1447
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
1448
|
+
* const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
|
|
1449
|
+
* const programManager = new ProgramManager("http://localhost:3030", recordProvider);
|
|
1450
|
+
* programManager.setAccount(Account);
|
|
1451
|
+
*
|
|
1452
|
+
* // Define a fee in credits
|
|
1453
|
+
* const priorityFee = 0.0;
|
|
1454
|
+
*
|
|
1455
|
+
* // Create the deployment transaction.
|
|
1456
|
+
* const tx = await programManager.buildDevnodeUpgradeTransaction({program: program, fee: priorityFee, privateFee: false});
|
|
1457
|
+
* await programManager.networkClient.submitTransaction(tx);
|
|
1458
|
+
*
|
|
1459
|
+
* // Verify the transaction was successful
|
|
1460
|
+
* setTimeout(async () => {
|
|
1461
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
1462
|
+
* assert(transaction.id() === tx.id());
|
|
1463
|
+
* }, 20000);
|
|
1464
|
+
*/
|
|
1465
|
+
buildDevnodeUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
|
|
1283
1466
|
}
|
|
1284
1467
|
export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };
|
|
@@ -9,6 +9,7 @@ import { EncryptedRecord } from "./models/record-provider/encryptedRecord.js";
|
|
|
9
9
|
import { ExecutionJSON, FeeExecutionJSON } from "./models/execution/executionJSON.js";
|
|
10
10
|
import { ExecutionObject, FeeExecutionObject } from "./models/execution/executionObject.js";
|
|
11
11
|
import { FinalizeJSON } from "./models/finalizeJSON.js";
|
|
12
|
+
import { FunctionInput } from "./models/functionInput";
|
|
12
13
|
import { FunctionObject } from "./models/functionObject.js";
|
|
13
14
|
import { ImportedVerifyingKeys, ImportedPrograms } from "./models/imports.js";
|
|
14
15
|
import { InputJSON } from "./models/input/inputJSON.js";
|
|
@@ -44,4 +45,4 @@ export { logAndThrow } from "./utils.js";
|
|
|
44
45
|
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";
|
|
45
46
|
export { initializeWasm };
|
|
46
47
|
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";
|
|
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, };
|
|
48
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, EncryptedRecord, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, 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, };
|