@provablehq/sdk 0.8.6 → 0.8.8
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/account.d.ts +179 -62
- package/dist/mainnet/browser.js +175 -58
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/network-client.d.ts +299 -63
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/{program-manager-ZQyvNmJs.js → program-manager-OK_mdi-y.js} +869 -301
- package/dist/mainnet/program-manager-OK_mdi-y.js.map +1 -0
- package/dist/mainnet/program-manager.d.ts +328 -159
- package/dist/mainnet/worker.js +1 -1
- package/dist/testnet/account.d.ts +179 -62
- package/dist/testnet/browser.js +175 -58
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/network-client.d.ts +299 -63
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/{program-manager-CjvnOyfn.js → program-manager-BuK9g9xJ.js} +869 -301
- package/dist/testnet/program-manager-BuK9g9xJ.js.map +1 -0
- package/dist/testnet/program-manager.d.ts +328 -159
- package/dist/testnet/worker.js +1 -1
- package/package.json +3 -2
- package/dist/mainnet/program-manager-ZQyvNmJs.js.map +0 -1
- package/dist/testnet/program-manager-CjvnOyfn.js.map +0 -1
|
@@ -17,12 +17,12 @@ interface AleoNetworkClientOptions {
|
|
|
17
17
|
*
|
|
18
18
|
* @param {string} host
|
|
19
19
|
* @example
|
|
20
|
-
* // Connection to a local node
|
|
21
|
-
* const localNetworkClient = new AleoNetworkClient("http://
|
|
20
|
+
* // Connection to a local node.
|
|
21
|
+
* const localNetworkClient = new AleoNetworkClient("http://0.0.0.0:3030", undefined, account);
|
|
22
22
|
*
|
|
23
23
|
* // Connection to a public beacon node
|
|
24
24
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
25
|
-
* const
|
|
25
|
+
* const publicNetworkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined, account);
|
|
26
26
|
*/
|
|
27
27
|
declare class AleoNetworkClient {
|
|
28
28
|
host: string;
|
|
@@ -34,8 +34,11 @@ declare class AleoNetworkClient {
|
|
|
34
34
|
/**
|
|
35
35
|
* Set an account to use in networkClient calls
|
|
36
36
|
*
|
|
37
|
-
* @param {Account} account
|
|
37
|
+
* @param {Account} account Set an account to use for record scanning functions.
|
|
38
38
|
* @example
|
|
39
|
+
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
40
|
+
*
|
|
41
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1");
|
|
39
42
|
* const account = new Account();
|
|
40
43
|
* networkClient.setAccount(account);
|
|
41
44
|
*/
|
|
@@ -52,12 +55,21 @@ declare class AleoNetworkClient {
|
|
|
52
55
|
*
|
|
53
56
|
* @param {string} host The address of a node hosting the Aleo API
|
|
54
57
|
* @param host
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
61
|
+
*
|
|
62
|
+
* // Create a networkClient that connects to a local node.
|
|
63
|
+
* const networkClient = new AleoNetworkClient("http://0.0.0.0:3030", undefined);
|
|
64
|
+
*
|
|
65
|
+
* // Set the host to a public node.
|
|
66
|
+
* networkClient.setHost("http://api.explorer.provable.com/v1");
|
|
55
67
|
*/
|
|
56
68
|
setHost(host: string): void;
|
|
57
69
|
/**
|
|
58
70
|
* Fetches data from the Aleo network and returns it as a JSON object.
|
|
59
71
|
*
|
|
60
|
-
* @param url
|
|
72
|
+
* @param url The URL to fetch data from.
|
|
61
73
|
*/
|
|
62
74
|
fetchData<Type>(url?: string): Promise<Type>;
|
|
63
75
|
/**
|
|
@@ -80,8 +92,18 @@ declare class AleoNetworkClient {
|
|
|
80
92
|
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
81
93
|
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
82
94
|
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
95
|
+
* @returns {Promise<Array<RecordPlaintext>>} An array of records belonging to the account configured in the network client.
|
|
83
96
|
*
|
|
84
97
|
* @example
|
|
98
|
+
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
99
|
+
*
|
|
100
|
+
* // Import an account from a ciphertext and password.
|
|
101
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
102
|
+
*
|
|
103
|
+
* // Create a network client.
|
|
104
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
105
|
+
* networkClient.setAccount(account);
|
|
106
|
+
*
|
|
85
107
|
* // Find specific amounts
|
|
86
108
|
* const startHeight = 500000;
|
|
87
109
|
* const amounts = [600000, 1000000];
|
|
@@ -102,8 +124,17 @@ declare class AleoNetworkClient {
|
|
|
102
124
|
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
103
125
|
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
104
126
|
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
127
|
+
* @returns {Promise<Array<RecordPlaintext>>} An array of unspent records belonging to the account configured in the network client.
|
|
105
128
|
*
|
|
106
129
|
* @example
|
|
130
|
+
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
131
|
+
*
|
|
132
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
133
|
+
*
|
|
134
|
+
* // Create a network client and set an account to search for records with.
|
|
135
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
136
|
+
* networkClient.setAccount(account);
|
|
137
|
+
*
|
|
107
138
|
* // Find specific amounts
|
|
108
139
|
* const startHeight = 500000;
|
|
109
140
|
* const endHeight = 550000;
|
|
@@ -118,7 +149,9 @@ declare class AleoNetworkClient {
|
|
|
118
149
|
/**
|
|
119
150
|
* Returns the contents of the block at the specified block height.
|
|
120
151
|
*
|
|
121
|
-
* @param {number} blockHeight
|
|
152
|
+
* @param {number} blockHeight - The height of the block to fetch
|
|
153
|
+
* @returns {Promise<BlockJSON>} A javascript object containing the block at the specified height
|
|
154
|
+
*
|
|
122
155
|
* @example
|
|
123
156
|
* const block = networkClient.getBlock(1234);
|
|
124
157
|
*/
|
|
@@ -126,45 +159,106 @@ declare class AleoNetworkClient {
|
|
|
126
159
|
/**
|
|
127
160
|
* Returns the contents of the block with the specified hash.
|
|
128
161
|
*
|
|
129
|
-
* @param {string} blockHash
|
|
162
|
+
* @param {string} blockHash The hash of the block to fetch.
|
|
163
|
+
* @returns {Promise<BlockJSON>} A javascript object representation of the block matching the hash.
|
|
164
|
+
*
|
|
130
165
|
* @example
|
|
166
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
167
|
+
*
|
|
168
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
131
169
|
* const block = networkClient.getBlockByHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
132
170
|
*/
|
|
133
171
|
getBlockByHash(blockHash: string): Promise<BlockJSON>;
|
|
134
172
|
/**
|
|
135
|
-
* Returns a range of blocks between the specified block heights.
|
|
173
|
+
* Returns a range of blocks between the specified block heights. A maximum of 50 blocks can be fetched at a time.
|
|
174
|
+
*
|
|
175
|
+
* @param {number} start Starting block to fetch.
|
|
176
|
+
* @param {number} end Ending block to fetch. This cannot be more than 50 blocks ahead of the start block.
|
|
177
|
+
* @returns {Promise<Array<BlockJSON>>} An array of block objects
|
|
136
178
|
*
|
|
137
|
-
* @param {number} start
|
|
138
|
-
* @param {number} end
|
|
139
179
|
* @example
|
|
140
|
-
*
|
|
180
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
181
|
+
*
|
|
182
|
+
* // Fetch 50 blocks.
|
|
183
|
+
* const (start, end) = (2050, 2100);
|
|
184
|
+
* const blockRange = networkClient.getBlockRange(start, end);
|
|
185
|
+
*
|
|
186
|
+
* let cursor = start;
|
|
187
|
+
* blockRange.forEach((block) => {
|
|
188
|
+
* assert(block.height == cursor);
|
|
189
|
+
* cursor += 1;
|
|
190
|
+
* }
|
|
141
191
|
*/
|
|
142
192
|
getBlockRange(start: number, end: number): Promise<Array<BlockJSON>>;
|
|
143
193
|
/**
|
|
144
194
|
* Returns the deployment transaction id associated with the specified program.
|
|
145
195
|
*
|
|
146
|
-
* @param {Program | string} program
|
|
147
|
-
* @returns {
|
|
196
|
+
* @param {Program | string} program The name of the deployed program OR a wasm Program object.
|
|
197
|
+
* @returns {Promise<string>} The transaction ID of the deployment transaction.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
201
|
+
*
|
|
202
|
+
* // Get the transaction ID of the deployment transaction for a program.
|
|
203
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
204
|
+
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
205
|
+
*
|
|
206
|
+
* // Get the transaction data for the deployment transaction.
|
|
207
|
+
* const transaction = networkClient.getTransactionObject(transactionId);
|
|
208
|
+
*
|
|
209
|
+
* // Get the verifying keys for the functions in the deployed program.
|
|
210
|
+
* const verifyingKeys = transaction.verifyingKeys();
|
|
148
211
|
*/
|
|
149
212
|
getDeploymentTransactionIDForProgram(program: Program | string): Promise<string>;
|
|
150
213
|
/**
|
|
151
|
-
* Returns the deployment transaction associated with a specified program.
|
|
214
|
+
* Returns the deployment transaction associated with a specified program as a JSON object.
|
|
215
|
+
*
|
|
216
|
+
* @param {Program | string} program The name of the deployed program OR a wasm Program object.
|
|
217
|
+
* @returns {Promise<Transaction>} JSON representation of the deployment transaction.
|
|
152
218
|
*
|
|
153
|
-
* @
|
|
154
|
-
*
|
|
219
|
+
* @example
|
|
220
|
+
* import { AleoNetworkClient, DeploymentJSON } from "@provablehq/sdk/testnet.js";
|
|
221
|
+
*
|
|
222
|
+
* // Get the transaction ID of the deployment transaction for a program.
|
|
223
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
224
|
+
* const transaction = networkClient.getDeploymentTransactionForProgram("hello_hello.aleo");
|
|
225
|
+
*
|
|
226
|
+
* // Get the verifying keys for each function in the deployment.
|
|
227
|
+
* const deployment = <DeploymentJSON>transaction.deployment;
|
|
228
|
+
* const verifyingKeys = deployment.verifying_keys;
|
|
155
229
|
*/
|
|
156
230
|
getDeploymentTransactionForProgram(program: Program | string): Promise<TransactionJSON>;
|
|
157
231
|
/**
|
|
158
232
|
* Returns the deployment transaction associated with a specified program as a wasm object.
|
|
159
233
|
*
|
|
160
|
-
* @param {Program | string} program
|
|
161
|
-
* @returns {
|
|
234
|
+
* @param {Program | string} program The name of the deployed program OR a wasm Program object.
|
|
235
|
+
* @returns {Promise<Transaction>} Wasm object representation of the deployment transaction.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
239
|
+
*
|
|
240
|
+
* // Get the transaction ID of the deployment transaction for a program.
|
|
241
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
242
|
+
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
243
|
+
*
|
|
244
|
+
* // Get the transaction data for the deployment transaction.
|
|
245
|
+
* const transaction = networkClient.getDeploymentTransactionObjectForProgram(transactionId);
|
|
246
|
+
*
|
|
247
|
+
* // Get the verifying keys for the functions in the deployed program.
|
|
248
|
+
* const verifyingKeys = transaction.verifyingKeys();
|
|
162
249
|
*/
|
|
163
250
|
getDeploymentTransactionObjectForProgram(program: Program | string): Promise<Transaction>;
|
|
164
251
|
/**
|
|
165
|
-
* Returns the contents of the latest block.
|
|
252
|
+
* Returns the contents of the latest block as JSON.
|
|
253
|
+
*
|
|
254
|
+
* @returns {Promise<BlockJSON>} A javascript object containing the latest block
|
|
166
255
|
*
|
|
167
256
|
* @example
|
|
257
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
258
|
+
*
|
|
259
|
+
* // Create a network client.
|
|
260
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
261
|
+
*
|
|
168
262
|
* const latestHeight = networkClient.getLatestBlock();
|
|
169
263
|
*/
|
|
170
264
|
getLatestBlock(): Promise<BlockJSON>;
|
|
@@ -172,40 +266,76 @@ declare class AleoNetworkClient {
|
|
|
172
266
|
* Returns the latest committee.
|
|
173
267
|
*
|
|
174
268
|
* @returns {Promise<object>} A javascript object containing the latest committee
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
272
|
+
*
|
|
273
|
+
* // Create a network client.
|
|
274
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
275
|
+
*
|
|
276
|
+
* // Create a network client and get the latest committee.
|
|
277
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
278
|
+
* const latestCommittee = await networkClient.getLatestCommittee();
|
|
175
279
|
*/
|
|
176
280
|
getLatestCommittee(): Promise<object>;
|
|
177
281
|
/**
|
|
178
|
-
* Returns the
|
|
179
|
-
*
|
|
180
|
-
* @param {number} blockHeight
|
|
282
|
+
* Returns the committee at the specified block height.
|
|
181
283
|
*
|
|
284
|
+
* @param {number} blockHeight - The height of the block to fetch the committee for
|
|
182
285
|
* @returns {Promise<object>} A javascript object containing the committee
|
|
183
286
|
*
|
|
184
287
|
* @example
|
|
185
|
-
*
|
|
288
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
289
|
+
*
|
|
290
|
+
* // Create a network client.
|
|
291
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
292
|
+
*
|
|
293
|
+
* // Create a network client and get the committee for a specific block.
|
|
294
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
295
|
+
* const committee = await networkClient.getCommitteeByBlockHeight(1234);
|
|
186
296
|
*/
|
|
187
297
|
getCommitteeByBlockHeight(blockHeight: number): Promise<object>;
|
|
188
298
|
/**
|
|
189
299
|
* Returns the latest block height.
|
|
190
300
|
*
|
|
301
|
+
* @returns {Promise<number>} The latest block height.
|
|
302
|
+
*
|
|
191
303
|
* @example
|
|
304
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
305
|
+
*
|
|
306
|
+
* // Create a network client.
|
|
307
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
308
|
+
*
|
|
192
309
|
* const latestHeight = networkClient.getLatestHeight();
|
|
193
310
|
*/
|
|
194
311
|
getLatestHeight(): Promise<number>;
|
|
195
312
|
/**
|
|
196
313
|
* Returns the latest block hash.
|
|
197
314
|
*
|
|
315
|
+
* @returns {Promise<string>} The latest block hash.
|
|
316
|
+
*
|
|
198
317
|
* @example
|
|
199
|
-
*
|
|
318
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
319
|
+
*
|
|
320
|
+
* // Create a network client.
|
|
321
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
322
|
+
*
|
|
323
|
+
* // Get the latest block hash.
|
|
324
|
+
* const latestHash = networkClient.getLatestBlockHash();
|
|
200
325
|
*/
|
|
201
326
|
getLatestBlockHash(): Promise<string>;
|
|
202
327
|
/**
|
|
203
328
|
* Returns the source code of a program given a program ID.
|
|
204
329
|
*
|
|
205
330
|
* @param {string} programId The program ID of a program deployed to the Aleo Network
|
|
206
|
-
* @
|
|
331
|
+
* @returns {Promise<string>} Source code of the program
|
|
207
332
|
*
|
|
208
333
|
* @example
|
|
334
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
335
|
+
*
|
|
336
|
+
* // Create a network client.
|
|
337
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
338
|
+
*
|
|
209
339
|
* const program = networkClient.getProgram("hello_hello.aleo");
|
|
210
340
|
* const expectedSource = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n"
|
|
211
341
|
* assert.equal(program, expectedSource);
|
|
@@ -215,9 +345,14 @@ declare class AleoNetworkClient {
|
|
|
215
345
|
* Returns a program object from a program ID or program source code.
|
|
216
346
|
*
|
|
217
347
|
* @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
|
|
218
|
-
* @
|
|
348
|
+
* @returns {Promise<Program>} Source code of the program
|
|
219
349
|
*
|
|
220
350
|
* @example
|
|
351
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
352
|
+
*
|
|
353
|
+
* // Create a network client.
|
|
354
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
355
|
+
*
|
|
221
356
|
* const programID = "hello_hello.aleo";
|
|
222
357
|
* const programSource = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n"
|
|
223
358
|
*
|
|
@@ -226,7 +361,7 @@ declare class AleoNetworkClient {
|
|
|
226
361
|
* const programObjectFromSource = await networkClient.getProgramObject(programSource);
|
|
227
362
|
*
|
|
228
363
|
* // Both program objects should be equal
|
|
229
|
-
* assert
|
|
364
|
+
* assert(programObjectFromID.to_string() === programObjectFromSource.to_string());
|
|
230
365
|
*/
|
|
231
366
|
getProgramObject(inputProgram: string): Promise<Program>;
|
|
232
367
|
/**
|
|
@@ -236,12 +371,17 @@ declare class AleoNetworkClient {
|
|
|
236
371
|
* @returns {Promise<ProgramImports>} Object of the form { "program_id": "program_source", .. } containing program id & source code for all program imports
|
|
237
372
|
*
|
|
238
373
|
* @example
|
|
374
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
375
|
+
*
|
|
239
376
|
* const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n input r0 as u32.private;\n call multiply_test.aleo/multiply 2u32 r0 into r1;\n output r1 as u32.private;\n"
|
|
240
377
|
* const double_test = Program.fromString(double_test_source);
|
|
241
378
|
* const expectedImports = {
|
|
242
379
|
* "multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n input r0 as u32.public;\n input r1 as u32.private;\n mul r0 r1 into r2;\n output r2 as u32.private;\n"
|
|
243
380
|
* }
|
|
244
381
|
*
|
|
382
|
+
* // Create a network client.
|
|
383
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
384
|
+
*
|
|
245
385
|
* // Imports can be fetched using the program ID, source code, or program object
|
|
246
386
|
* let programImports = await networkClient.getProgramImports("double_test.aleo");
|
|
247
387
|
* assert.deepStrictEqual(programImports, expectedImports);
|
|
@@ -262,8 +402,13 @@ declare class AleoNetworkClient {
|
|
|
262
402
|
* @returns {string[]} - The list of program names that the program imports
|
|
263
403
|
*
|
|
264
404
|
* @example
|
|
265
|
-
*
|
|
266
|
-
*
|
|
405
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
406
|
+
*
|
|
407
|
+
* // Create a network client.
|
|
408
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
409
|
+
*
|
|
410
|
+
* const programImportsNames = networkClient.getProgramImports("wrapped_credits.aleo");
|
|
411
|
+
* const expectedImportsNames = ["credits.aleo"];
|
|
267
412
|
* assert.deepStrictEqual(programImportsNames, expectedImportsNames);
|
|
268
413
|
*/
|
|
269
414
|
getProgramImportNames(inputProgram: Program | string): Promise<string[]>;
|
|
@@ -271,7 +416,14 @@ declare class AleoNetworkClient {
|
|
|
271
416
|
* Returns the names of the mappings of a program.
|
|
272
417
|
*
|
|
273
418
|
* @param {string} programId - The program ID to get the mappings of (e.g. "credits.aleo")
|
|
419
|
+
* @returns {Promise<Array<string>>} - The names of the mappings of the program.
|
|
420
|
+
*
|
|
274
421
|
* @example
|
|
422
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
423
|
+
*
|
|
424
|
+
* // Create a network client.
|
|
425
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
426
|
+
*
|
|
275
427
|
* const mappings = networkClient.getProgramMappingNames("credits.aleo");
|
|
276
428
|
* const expectedMappings = [
|
|
277
429
|
* "committee",
|
|
@@ -290,22 +442,35 @@ declare class AleoNetworkClient {
|
|
|
290
442
|
*
|
|
291
443
|
* @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
|
|
292
444
|
* @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
|
|
293
|
-
* @param {string | Plaintext} key - The key
|
|
294
|
-
* @
|
|
445
|
+
* @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the "account" mapping)
|
|
446
|
+
* @returns {Promise<string>} String representation of the value of the mapping
|
|
295
447
|
*
|
|
296
448
|
* @example
|
|
449
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
450
|
+
*
|
|
451
|
+
* // Create a network client.
|
|
452
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
453
|
+
*
|
|
297
454
|
* // Get public balance of an account
|
|
298
455
|
* const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
299
456
|
* const expectedValue = "0u64";
|
|
300
|
-
* assert
|
|
457
|
+
* assert(mappingValue === expectedValue);
|
|
301
458
|
*/
|
|
302
459
|
getProgramMappingValue(programId: string, mappingName: string, key: string | Plaintext): Promise<string>;
|
|
303
460
|
/**
|
|
304
|
-
* Returns the value of a mapping as a wasm Plaintext object. Returning an
|
|
305
|
-
*
|
|
306
|
-
*
|
|
461
|
+
* Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.
|
|
462
|
+
*
|
|
463
|
+
* @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
|
|
464
|
+
* @param {string} mappingName - The name of the mapping to get the value of (e.g. "bonded")
|
|
465
|
+
* @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the "bonded" mapping)
|
|
466
|
+
* @returns {Promise<Plaintext>} String representation of the value of the mapping
|
|
307
467
|
*
|
|
308
468
|
* @example
|
|
469
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
470
|
+
*
|
|
471
|
+
* // Create a network client.
|
|
472
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
473
|
+
*
|
|
309
474
|
* // Get the bond state as an account.
|
|
310
475
|
* const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
311
476
|
*
|
|
@@ -322,61 +487,90 @@ declare class AleoNetworkClient {
|
|
|
322
487
|
*
|
|
323
488
|
* const expectedState = {
|
|
324
489
|
* validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
|
|
325
|
-
* microcredits: BigInt(
|
|
490
|
+
* microcredits: BigInt(9007199254740991)
|
|
326
491
|
* };
|
|
327
492
|
* assert.equal(unbondedState, expectedState);
|
|
328
|
-
*
|
|
329
|
-
* @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
|
|
330
|
-
* @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
|
|
331
|
-
* @param {string | Plaintext} key - The key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
|
|
332
|
-
*
|
|
333
|
-
* @return {Promise<string>} String representation of the value of the mapping
|
|
334
493
|
*/
|
|
335
494
|
getProgramMappingPlaintext(programId: string, mappingName: string, key: string | Plaintext): Promise<Plaintext>;
|
|
336
495
|
/**
|
|
337
496
|
* Returns the public balance of an address from the account mapping in credits.aleo
|
|
338
497
|
*
|
|
339
|
-
* @param {string} address
|
|
498
|
+
* @param {Address | string} address A string or wasm object representing an address.
|
|
499
|
+
* @returns {Promise<number>} The public balance of the address in microcredits.
|
|
340
500
|
*
|
|
341
501
|
* @example
|
|
342
|
-
*
|
|
343
|
-
*
|
|
502
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
503
|
+
*
|
|
504
|
+
* // Create a network client.
|
|
505
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
506
|
+
*
|
|
507
|
+
* // Get the balance of an account from either an address object or address string.
|
|
508
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
509
|
+
* const publicBalance = await networkClient.getPublicBalance(account.address());
|
|
510
|
+
* const publicBalanceFromString = await networkClient.getPublicBalance(account.address().to_string());
|
|
511
|
+
* assert(publicBalance === publicBalanceFromString);
|
|
344
512
|
*/
|
|
345
|
-
getPublicBalance(address: Address): Promise<number>;
|
|
513
|
+
getPublicBalance(address: Address | string): Promise<number>;
|
|
346
514
|
/**
|
|
347
515
|
* Returns the latest state/merkle root of the Aleo blockchain.
|
|
348
516
|
*
|
|
517
|
+
* @returns {Promise<string>} A string representing the latest state root of the Aleo blockchain.
|
|
518
|
+
*
|
|
349
519
|
* @example
|
|
520
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
521
|
+
*
|
|
522
|
+
* // Create a network client.
|
|
523
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
524
|
+
*
|
|
525
|
+
* // Get the latest state root.
|
|
350
526
|
* const stateRoot = networkClient.getStateRoot();
|
|
351
527
|
*/
|
|
352
528
|
getStateRoot(): Promise<string>;
|
|
353
529
|
/**
|
|
354
530
|
* Returns a transaction by its unique identifier.
|
|
355
531
|
*
|
|
356
|
-
* @param {string} transactionId
|
|
532
|
+
* @param {string} transactionId The transaction ID to fetch.
|
|
533
|
+
* @returns {Promise<TransactionJSON>} A json representation of the transaction.
|
|
534
|
+
*
|
|
357
535
|
* @example
|
|
536
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
537
|
+
*
|
|
538
|
+
* // Create a network client.
|
|
539
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
540
|
+
*
|
|
358
541
|
* const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
359
542
|
*/
|
|
360
543
|
getTransaction(transactionId: string): Promise<TransactionJSON>;
|
|
361
544
|
/**
|
|
362
545
|
* Returns a confirmed transaction by its unique identifier.
|
|
363
546
|
*
|
|
364
|
-
* @param {string} transactionId
|
|
547
|
+
* @param {string} transactionId The transaction ID to fetch.
|
|
548
|
+
* @returns {Promise<ConfirmedTransactionJSON>} A json object containing the confirmed transaction.
|
|
549
|
+
*
|
|
365
550
|
* @example
|
|
551
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
552
|
+
*
|
|
553
|
+
* // Create a network client.
|
|
554
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
555
|
+
*
|
|
366
556
|
* const transaction = networkClient.getConfirmedTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
557
|
+
* assert.equal(transaction.status, "confirmed");
|
|
367
558
|
*/
|
|
368
559
|
getConfirmedTransaction(transactionId: string): Promise<ConfirmedTransactionJSON>;
|
|
369
560
|
/**
|
|
370
561
|
* Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,
|
|
371
562
|
* outputs, and records to be searched for and displayed.
|
|
372
563
|
*
|
|
564
|
+
* @param {string} transactionId - The unique identifier of the transaction to fetch
|
|
565
|
+
* @returns {Promise<Transaction>} A wasm object representation of the transaction.
|
|
566
|
+
*
|
|
373
567
|
* @example
|
|
374
568
|
* const transactionObject = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
375
569
|
* // Get the transaction inputs as a JS array.
|
|
376
|
-
* const
|
|
570
|
+
* const transactionInputs = transactionObject.inputs(true);
|
|
377
571
|
*
|
|
378
572
|
* // Get the transaction outputs as a JS object.
|
|
379
|
-
* const
|
|
573
|
+
* const transactionOutputs = transactionObject.outputs(true);
|
|
380
574
|
*
|
|
381
575
|
* // Get any records generated in transitions in the transaction as a JS object.
|
|
382
576
|
* const records = transactionObject.records();
|
|
@@ -387,38 +581,57 @@ declare class AleoNetworkClient {
|
|
|
387
581
|
*
|
|
388
582
|
* // Get a JS representation of all inputs, outputs, and transaction metadata.
|
|
389
583
|
* const transactionSummary = transactionObject.summary();
|
|
390
|
-
*
|
|
391
|
-
* @param {string} transactionId
|
|
392
|
-
* @example
|
|
393
|
-
* const transaction = networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
394
584
|
*/
|
|
395
585
|
getTransactionObject(transactionId: string): Promise<Transaction>;
|
|
396
586
|
/**
|
|
397
587
|
* Returns the transactions present at the specified block height.
|
|
398
588
|
*
|
|
399
|
-
* @param {number} blockHeight
|
|
589
|
+
* @param {number} blockHeight The block height to fetch the confirmed transactions at.
|
|
590
|
+
* @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block height.
|
|
591
|
+
*
|
|
400
592
|
* @example
|
|
593
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
594
|
+
*
|
|
595
|
+
* // Create a network client.
|
|
596
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
597
|
+
*
|
|
401
598
|
* const transactions = networkClient.getTransactions(654);
|
|
402
599
|
*/
|
|
403
600
|
getTransactions(blockHeight: number): Promise<Array<ConfirmedTransactionJSON>>;
|
|
404
601
|
/**
|
|
405
602
|
* Returns the confirmed transactions present in the block with the specified block hash.
|
|
406
603
|
*
|
|
407
|
-
* @param {string} blockHash
|
|
604
|
+
* @param {string} blockHash The block hash to fetch the confirmed transactions at.
|
|
605
|
+
* @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block hash.
|
|
606
|
+
*
|
|
408
607
|
* @example
|
|
409
|
-
*
|
|
608
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
609
|
+
*
|
|
610
|
+
* // Create a network client.
|
|
611
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
612
|
+
*
|
|
613
|
+
* const transactions = networkClient.getTransactionsByBlockHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
410
614
|
*/
|
|
411
615
|
getTransactionsByBlockHash(blockHash: string): Promise<Array<ConfirmedTransactionJSON>>;
|
|
412
616
|
/**
|
|
413
617
|
* Returns the transactions in the memory pool. This method requires access to a validator's REST API.
|
|
414
618
|
*
|
|
619
|
+
* @returns {Promise<Array<TransactionJSON>>} An array of transactions (in JSON format) currently in the mempool.
|
|
620
|
+
*
|
|
415
621
|
* @example
|
|
622
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
623
|
+
*
|
|
624
|
+
* // Create a network client.
|
|
625
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
626
|
+
*
|
|
627
|
+
* // Get the current transactions in the mempool.
|
|
416
628
|
* const transactions = networkClient.getTransactionsInMempool();
|
|
417
629
|
*/
|
|
418
630
|
getTransactionsInMempool(): Promise<Array<TransactionJSON>>;
|
|
419
631
|
/**
|
|
420
632
|
* Returns the transition ID of the transition corresponding to the ID of the input or output.
|
|
421
|
-
* @param {string} inputOrOutputID -
|
|
633
|
+
* @param {string} inputOrOutputID - The unique identifier of the input or output to find the transition ID for
|
|
634
|
+
* @returns {Promise<string>} - The transition ID of the input or output ID.
|
|
422
635
|
*
|
|
423
636
|
* @example
|
|
424
637
|
* const transitionId = networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");
|
|
@@ -427,20 +640,43 @@ declare class AleoNetworkClient {
|
|
|
427
640
|
/**
|
|
428
641
|
* Submit an execute or deployment transaction to the Aleo network.
|
|
429
642
|
*
|
|
430
|
-
* @param {Transaction | string} transaction
|
|
431
|
-
* @returns {string} - The transaction id of the submitted transaction or the resulting error
|
|
643
|
+
* @param {Transaction | string} transaction - The transaction to submit, either as a Transaction object or string representation
|
|
644
|
+
* @returns {Promise<string>} - The transaction id of the submitted transaction or the resulting error
|
|
432
645
|
*/
|
|
433
646
|
submitTransaction(transaction: Transaction | string): Promise<string>;
|
|
434
647
|
/**
|
|
435
648
|
* Submit a solution to the Aleo network.
|
|
436
649
|
*
|
|
437
|
-
* @param {string} solution The string representation of the solution
|
|
650
|
+
* @param {string} solution - The string representation of the solution to submit
|
|
651
|
+
* @returns {Promise<string>} The solution id of the submitted solution or the resulting error.
|
|
438
652
|
*/
|
|
439
653
|
submitSolution(solution: string): Promise<string>;
|
|
440
654
|
/**
|
|
441
|
-
* Await a transaction to be confirmed on the Aleo network.
|
|
655
|
+
* Await a submitted transaction to be confirmed or rejected on the Aleo network.
|
|
656
|
+
*
|
|
657
|
+
* @param {string} transactionId - The transaction ID to wait for confirmation
|
|
658
|
+
* @param {number} checkInterval - The interval in milliseconds to check for confirmation (default: 2000)
|
|
659
|
+
* @param {number} timeout - The maximum time in milliseconds to wait for confirmation (default: 45000)
|
|
660
|
+
* @returns {Promise<Transaction>} The confirmed transaction object that returns if the transaction is confirmed.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* import { AleoNetworkClient, Account, ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
664
|
+
*
|
|
665
|
+
* // Create a network client and program manager.
|
|
666
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
667
|
+
* const programManager = new ProgramManager(networkClient);
|
|
668
|
+
*
|
|
669
|
+
* // Set the account for the program manager.
|
|
670
|
+
* programManager.setAccount(Account.fromCiphertext(process.env.ciphertext, process.env.password));
|
|
671
|
+
*
|
|
672
|
+
* // Build a transfer transaction.
|
|
673
|
+
* const tx = await programManager.buildTransferPublicTransaction(100, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0);
|
|
674
|
+
*
|
|
675
|
+
* // Submit the transaction to the network.
|
|
676
|
+
* const transactionId = await networkClient.submitTransaction(tx);
|
|
442
677
|
*
|
|
443
|
-
*
|
|
678
|
+
* // Wait for the transaction to be confirmed.
|
|
679
|
+
* const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
|
|
444
680
|
*/
|
|
445
681
|
waitForTransactionConfirmation(transactionId: string, checkInterval?: number, // Poll every 2 seconds
|
|
446
682
|
timeout?: number): Promise<Transaction>;
|
package/dist/mainnet/node.js
CHANGED
|
@@ -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-
|
|
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';
|
|
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';
|