@provablehq/sdk 0.8.2 → 0.8.4
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/README.md +44 -928
- package/dist/mainnet/account.d.ts +4 -1
- package/dist/mainnet/browser.d.ts +4 -2
- package/dist/mainnet/browser.js +69 -9
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/models/blockJSON.d.ts +18 -6
- package/dist/mainnet/models/confirmed_transaction.d.ts +1 -1
- package/dist/mainnet/models/ratification.d.ts +4 -0
- package/dist/mainnet/models/solution.d.ts +14 -0
- package/dist/mainnet/network-client.d.ts +49 -11
- package/dist/mainnet/node.js +2 -2
- package/dist/mainnet/{program-manager-pTXN5gjF.js → program-manager-DUAbZEGO.js} +108 -43
- package/dist/mainnet/program-manager-DUAbZEGO.js.map +1 -0
- package/dist/mainnet/record-provider.d.ts +1 -1
- package/dist/mainnet/wasm.d.ts +1 -1
- package/dist/mainnet/worker.js +1 -1
- package/dist/testnet/account.d.ts +4 -1
- package/dist/testnet/browser.d.ts +4 -2
- package/dist/testnet/browser.js +69 -9
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/models/blockJSON.d.ts +18 -6
- package/dist/testnet/models/confirmed_transaction.d.ts +1 -1
- package/dist/testnet/models/ratification.d.ts +4 -0
- package/dist/testnet/models/solution.d.ts +14 -0
- package/dist/testnet/network-client.d.ts +49 -11
- package/dist/testnet/node.js +2 -2
- package/dist/testnet/{program-manager-DQZd0G79.js → program-manager-B2GtLTAh.js} +108 -43
- package/dist/testnet/program-manager-B2GtLTAh.js.map +1 -0
- package/dist/testnet/record-provider.d.ts +1 -1
- package/dist/testnet/wasm.d.ts +1 -1
- package/dist/testnet/worker.js +1 -1
- package/package.json +2 -2
- package/dist/mainnet/program-manager-pTXN5gjF.js.map +0 -1
- package/dist/testnet/program-manager-DQZd0G79.js.map +0 -1
|
@@ -21,7 +21,8 @@ interface AleoNetworkClientOptions {
|
|
|
21
21
|
* const localNetworkClient = new AleoNetworkClient("http://localhost:3030");
|
|
22
22
|
*
|
|
23
23
|
* // Connection to a public beacon node
|
|
24
|
-
* const
|
|
24
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
25
|
+
* const publicnetworkClient = new AleoNetworkClient("http://localhost:3030", undefined, account);
|
|
25
26
|
*/
|
|
26
27
|
declare class AleoNetworkClient {
|
|
27
28
|
host: string;
|
|
@@ -69,29 +70,51 @@ declare class AleoNetworkClient {
|
|
|
69
70
|
*/
|
|
70
71
|
fetchRaw(url?: string): Promise<string>;
|
|
71
72
|
/**
|
|
72
|
-
*
|
|
73
|
+
* Attempt to find records in the Aleo blockchain.
|
|
74
|
+
*
|
|
73
75
|
* @param {number} startHeight - The height at which to start searching for unspent records
|
|
74
76
|
* @param {number} endHeight - The height at which to stop searching for unspent records
|
|
75
|
-
* @param {
|
|
77
|
+
* @param {boolean} unspent - Whether to search for unspent records only
|
|
78
|
+
* @param {string[]} programs - The program(s) to search for unspent records in
|
|
76
79
|
* @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
|
|
77
80
|
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
78
81
|
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
82
|
+
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
79
83
|
*
|
|
80
84
|
* @example
|
|
81
|
-
* // Find
|
|
82
|
-
* const
|
|
83
|
-
* const
|
|
85
|
+
* // Find specific amounts
|
|
86
|
+
* const startHeight = 500000;
|
|
87
|
+
* const amounts = [600000, 1000000];
|
|
88
|
+
* const records = networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"] amounts);
|
|
89
|
+
*
|
|
90
|
+
* // Find specific amounts with a maximum number of cumulative microcredits
|
|
91
|
+
* const maxMicrocredits = 100000;
|
|
92
|
+
* const records = networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"] undefined, maxMicrocredits);
|
|
93
|
+
*/
|
|
94
|
+
findRecords(startHeight: number, endHeight: number | undefined, unspent?: boolean, programs?: string[], amounts?: number[] | undefined, maxMicrocredits?: number | undefined, nonces?: string[] | undefined, privateKey?: string | PrivateKey | undefined): Promise<Array<RecordPlaintext>>;
|
|
95
|
+
/**
|
|
96
|
+
* Attempts to find unspent records in the Aleo blockchain.
|
|
97
|
+
*
|
|
98
|
+
* @param {number} startHeight - The height at which to start searching for unspent records
|
|
99
|
+
* @param {number} endHeight - The height at which to stop searching for unspent records
|
|
100
|
+
* @param {string[]} programs - The program(s) to search for unspent records in
|
|
101
|
+
* @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
|
|
102
|
+
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
103
|
+
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
104
|
+
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
84
105
|
*
|
|
106
|
+
* @example
|
|
85
107
|
* // Find specific amounts
|
|
86
108
|
* const startHeight = 500000;
|
|
109
|
+
* const endHeight = 550000;
|
|
87
110
|
* const amounts = [600000, 1000000];
|
|
88
|
-
* const records = networkClient.findUnspentRecords(startHeight,
|
|
111
|
+
* const records = networkClient.findUnspentRecords(startHeight, endHeight, ["credits.aleo"], amounts);
|
|
89
112
|
*
|
|
90
113
|
* // Find specific amounts with a maximum number of cumulative microcredits
|
|
91
114
|
* const maxMicrocredits = 100000;
|
|
92
|
-
* const records = networkClient.findUnspentRecords(startHeight, undefined,
|
|
115
|
+
* const records = networkClient.findUnspentRecords(startHeight, undefined, ["credits.aleo"], undefined, maxMicrocredits);
|
|
93
116
|
*/
|
|
94
|
-
findUnspentRecords(startHeight: number, endHeight: number | undefined,
|
|
117
|
+
findUnspentRecords(startHeight: number, endHeight: number | undefined, programs?: string[], amounts?: number[] | undefined, maxMicrocredits?: number | undefined, nonces?: string[] | undefined, privateKey?: string | PrivateKey | undefined): Promise<Array<RecordPlaintext>>;
|
|
95
118
|
/**
|
|
96
119
|
* Returns the contents of the block at the specified block height.
|
|
97
120
|
*
|
|
@@ -129,7 +152,7 @@ declare class AleoNetworkClient {
|
|
|
129
152
|
* @param {Program | string} program
|
|
130
153
|
* @returns {TransactionJSON}
|
|
131
154
|
*/
|
|
132
|
-
|
|
155
|
+
getDeploymentTransactionObjectForProgram(program: Program | string): Promise<Transaction>;
|
|
133
156
|
/**
|
|
134
157
|
* Returns the contents of the latest block.
|
|
135
158
|
*
|
|
@@ -224,7 +247,15 @@ declare class AleoNetworkClient {
|
|
|
224
247
|
* @param {string} programId - The program ID to get the mappings of (e.g. "credits.aleo")
|
|
225
248
|
* @example
|
|
226
249
|
* const mappings = networkClient.getProgramMappingNames("credits.aleo");
|
|
227
|
-
* const expectedMappings = [
|
|
250
|
+
* const expectedMappings = [
|
|
251
|
+
* "committee",
|
|
252
|
+
* "delegated",
|
|
253
|
+
* "metadata",
|
|
254
|
+
* "bonded",
|
|
255
|
+
* "unbonding",
|
|
256
|
+
* "account",
|
|
257
|
+
* "withdraw"
|
|
258
|
+
* ];
|
|
228
259
|
* assert.deepStrictEqual(mappings, expectedMappings);
|
|
229
260
|
*/
|
|
230
261
|
getProgramMappingNames(programId: string): Promise<Array<string>>;
|
|
@@ -354,5 +385,12 @@ declare class AleoNetworkClient {
|
|
|
354
385
|
* @param {string} solution The string representation of the solution desired to be submitted to the network.
|
|
355
386
|
*/
|
|
356
387
|
submitSolution(solution: string): Promise<string>;
|
|
388
|
+
/**
|
|
389
|
+
* Await a transaction to be confirmed on the Aleo network.
|
|
390
|
+
*
|
|
391
|
+
* @param {string} solution The string representation of the solution desired to be submitted to the network.
|
|
392
|
+
*/
|
|
393
|
+
waitForTransactionConfirmation(transactionId: string, checkInterval?: number, // Poll every 2 seconds
|
|
394
|
+
timeout?: number): Promise<Transaction>;
|
|
357
395
|
}
|
|
358
396
|
export { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports };
|
package/dist/testnet/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
4
|
-
export { Address, Ciphertext, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Plaintext, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.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-B2GtLTAh.js';
|
|
4
|
+
export { Address, Ciphertext, ComputeKey, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Plaintext, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
|
|
5
5
|
import 'core-js/proposals/json-parse-with-source.js';
|
|
6
6
|
import 'node:crypto';
|
|
7
7
|
import 'node:fs';
|
|
@@ -41,7 +41,8 @@ async function post(url, options) {
|
|
|
41
41
|
* const localNetworkClient = new AleoNetworkClient("http://localhost:3030");
|
|
42
42
|
*
|
|
43
43
|
* // Connection to a public beacon node
|
|
44
|
-
* const
|
|
44
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
45
|
+
* const publicnetworkClient = new AleoNetworkClient("http://localhost:3030", undefined, account);
|
|
45
46
|
*/
|
|
46
47
|
class AleoNetworkClient {
|
|
47
48
|
host;
|
|
@@ -55,7 +56,7 @@ class AleoNetworkClient {
|
|
|
55
56
|
else {
|
|
56
57
|
this.headers = {
|
|
57
58
|
// This is replaced by the actual version by a Rollup plugin
|
|
58
|
-
"X-Aleo-SDK-Version": "0.8.
|
|
59
|
+
"X-Aleo-SDK-Version": "0.8.4",
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -121,29 +122,28 @@ class AleoNetworkClient {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
/**
|
|
124
|
-
*
|
|
125
|
+
* Attempt to find records in the Aleo blockchain.
|
|
126
|
+
*
|
|
125
127
|
* @param {number} startHeight - The height at which to start searching for unspent records
|
|
126
128
|
* @param {number} endHeight - The height at which to stop searching for unspent records
|
|
127
|
-
* @param {
|
|
129
|
+
* @param {boolean} unspent - Whether to search for unspent records only
|
|
130
|
+
* @param {string[]} programs - The program(s) to search for unspent records in
|
|
128
131
|
* @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
|
|
129
132
|
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
130
133
|
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
134
|
+
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
131
135
|
*
|
|
132
136
|
* @example
|
|
133
|
-
* // Find all unspent records
|
|
134
|
-
* const privateKey = "[PRIVATE_KEY]";
|
|
135
|
-
* const records = networkClient.findUnspentRecords(0, undefined, privateKey);
|
|
136
|
-
*
|
|
137
137
|
* // Find specific amounts
|
|
138
138
|
* const startHeight = 500000;
|
|
139
139
|
* const amounts = [600000, 1000000];
|
|
140
|
-
* const records = networkClient.
|
|
140
|
+
* const records = networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"] amounts);
|
|
141
141
|
*
|
|
142
142
|
* // Find specific amounts with a maximum number of cumulative microcredits
|
|
143
143
|
* const maxMicrocredits = 100000;
|
|
144
|
-
* const records = networkClient.
|
|
144
|
+
* const records = networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"] undefined, maxMicrocredits);
|
|
145
145
|
*/
|
|
146
|
-
async
|
|
146
|
+
async findRecords(startHeight, endHeight, unspent = false, programs, amounts, maxMicrocredits, nonces, privateKey) {
|
|
147
147
|
nonces = nonces || [];
|
|
148
148
|
// Ensure start height is not negative
|
|
149
149
|
if (startHeight < 0) {
|
|
@@ -222,9 +222,11 @@ class AleoNetworkClient {
|
|
|
222
222
|
if (transaction.execution && !(typeof transaction.execution.transitions == "undefined")) {
|
|
223
223
|
for (let k = 0; k < transaction.execution.transitions.length; k++) {
|
|
224
224
|
const transition = transaction.execution.transitions[k];
|
|
225
|
-
// Only search for unspent records in
|
|
226
|
-
if (
|
|
227
|
-
|
|
225
|
+
// Only search for unspent records in the specified programs.
|
|
226
|
+
if (!(typeof programs === "undefined")) {
|
|
227
|
+
if (!programs.includes(transition.program)) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
228
230
|
}
|
|
229
231
|
if (!(typeof transition.outputs == "undefined")) {
|
|
230
232
|
for (let l = 0; l < transition.outputs.length; l++) {
|
|
@@ -242,15 +244,35 @@ class AleoNetworkClient {
|
|
|
242
244
|
if (nonces.includes(nonce)) {
|
|
243
245
|
continue;
|
|
244
246
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
if (unspent) {
|
|
248
|
+
// Otherwise record the nonce that has been found
|
|
249
|
+
const serialNumber = recordPlaintext.serialNumberString(resolvedPrivateKey, "credits.aleo", "credits");
|
|
250
|
+
// Attempt to see if the serial number is spent
|
|
251
|
+
try {
|
|
252
|
+
await this.getTransitionId(serialNumber);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.log("Found unspent record!");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Add the record to the list of records if the user did not specify amounts.
|
|
260
|
+
if (!amounts) {
|
|
261
|
+
records.push(recordPlaintext);
|
|
262
|
+
// If the user specified a maximum number of microcredits, check if the search has found enough
|
|
263
|
+
if (typeof maxMicrocredits === "number") {
|
|
264
|
+
totalRecordValue += recordPlaintext.microcredits();
|
|
265
|
+
// Exit if the search has found the amount specified
|
|
266
|
+
if (totalRecordValue >= BigInt(maxMicrocredits)) {
|
|
267
|
+
return records;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
250
270
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
271
|
+
// If the user specified a list of amounts, check if the search has found them
|
|
272
|
+
if (!(typeof amounts === "undefined") && amounts.length > 0) {
|
|
273
|
+
let amounts_found = 0;
|
|
274
|
+
if (recordPlaintext.microcredits() > amounts[amounts_found]) {
|
|
275
|
+
amounts_found += 1;
|
|
254
276
|
records.push(recordPlaintext);
|
|
255
277
|
// If the user specified a maximum number of microcredits, check if the search has found enough
|
|
256
278
|
if (typeof maxMicrocredits === "number") {
|
|
@@ -260,24 +282,8 @@ class AleoNetworkClient {
|
|
|
260
282
|
return records;
|
|
261
283
|
}
|
|
262
284
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (!(typeof amounts === "undefined") && amounts.length > 0) {
|
|
266
|
-
let amounts_found = 0;
|
|
267
|
-
if (recordPlaintext.microcredits() > amounts[amounts_found]) {
|
|
268
|
-
amounts_found += 1;
|
|
269
|
-
records.push(recordPlaintext);
|
|
270
|
-
// If the user specified a maximum number of microcredits, check if the search has found enough
|
|
271
|
-
if (typeof maxMicrocredits === "number") {
|
|
272
|
-
totalRecordValue += recordPlaintext.microcredits();
|
|
273
|
-
// Exit if the search has found the amount specified
|
|
274
|
-
if (totalRecordValue >= BigInt(maxMicrocredits)) {
|
|
275
|
-
return records;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (records.length >= amounts.length) {
|
|
279
|
-
return records;
|
|
280
|
-
}
|
|
285
|
+
if (records.length >= amounts.length) {
|
|
286
|
+
return records;
|
|
281
287
|
}
|
|
282
288
|
}
|
|
283
289
|
}
|
|
@@ -308,6 +314,31 @@ class AleoNetworkClient {
|
|
|
308
314
|
}
|
|
309
315
|
return records;
|
|
310
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Attempts to find unspent records in the Aleo blockchain.
|
|
319
|
+
*
|
|
320
|
+
* @param {number} startHeight - The height at which to start searching for unspent records
|
|
321
|
+
* @param {number} endHeight - The height at which to stop searching for unspent records
|
|
322
|
+
* @param {string[]} programs - The program(s) to search for unspent records in
|
|
323
|
+
* @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
|
|
324
|
+
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
325
|
+
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
326
|
+
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* // Find specific amounts
|
|
330
|
+
* const startHeight = 500000;
|
|
331
|
+
* const endHeight = 550000;
|
|
332
|
+
* const amounts = [600000, 1000000];
|
|
333
|
+
* const records = networkClient.findUnspentRecords(startHeight, endHeight, ["credits.aleo"], amounts);
|
|
334
|
+
*
|
|
335
|
+
* // Find specific amounts with a maximum number of cumulative microcredits
|
|
336
|
+
* const maxMicrocredits = 100000;
|
|
337
|
+
* const records = networkClient.findUnspentRecords(startHeight, undefined, ["credits.aleo"], undefined, maxMicrocredits);
|
|
338
|
+
*/
|
|
339
|
+
async findUnspentRecords(startHeight, endHeight, programs, amounts, maxMicrocredits, nonces, privateKey) {
|
|
340
|
+
return await this.findRecords(startHeight, endHeight, true, programs, amounts, maxMicrocredits, nonces, privateKey);
|
|
341
|
+
}
|
|
311
342
|
/**
|
|
312
343
|
* Returns the contents of the block at the specified block height.
|
|
313
344
|
*
|
|
@@ -380,7 +411,7 @@ class AleoNetworkClient {
|
|
|
380
411
|
* @param {Program | string} program
|
|
381
412
|
* @returns {TransactionJSON}
|
|
382
413
|
*/
|
|
383
|
-
async
|
|
414
|
+
async getDeploymentTransactionObjectForProgram(program) {
|
|
384
415
|
try {
|
|
385
416
|
const transaction_id = await this.getDeploymentTransactionIDForProgram(program);
|
|
386
417
|
return await this.getTransactionObject(transaction_id);
|
|
@@ -557,7 +588,15 @@ class AleoNetworkClient {
|
|
|
557
588
|
* @param {string} programId - The program ID to get the mappings of (e.g. "credits.aleo")
|
|
558
589
|
* @example
|
|
559
590
|
* const mappings = networkClient.getProgramMappingNames("credits.aleo");
|
|
560
|
-
* const expectedMappings = [
|
|
591
|
+
* const expectedMappings = [
|
|
592
|
+
* "committee",
|
|
593
|
+
* "delegated",
|
|
594
|
+
* "metadata",
|
|
595
|
+
* "bonded",
|
|
596
|
+
* "unbonding",
|
|
597
|
+
* "account",
|
|
598
|
+
* "withdraw"
|
|
599
|
+
* ];
|
|
561
600
|
* assert.deepStrictEqual(mappings, expectedMappings);
|
|
562
601
|
*/
|
|
563
602
|
async getProgramMappingNames(programId) {
|
|
@@ -793,6 +832,32 @@ class AleoNetworkClient {
|
|
|
793
832
|
throw new Error(`Error posting transaction: No response received: ${error.message}`);
|
|
794
833
|
}
|
|
795
834
|
}
|
|
835
|
+
/**
|
|
836
|
+
* Await a transaction to be confirmed on the Aleo network.
|
|
837
|
+
*
|
|
838
|
+
* @param {string} solution The string representation of the solution desired to be submitted to the network.
|
|
839
|
+
*/
|
|
840
|
+
async waitForTransactionConfirmation(transactionId, checkInterval = 2000, // Poll every 2 seconds
|
|
841
|
+
timeout = 45000 // Timeout after 45 seconds
|
|
842
|
+
) {
|
|
843
|
+
const startTime = Date.now();
|
|
844
|
+
return new Promise((resolve, reject) => {
|
|
845
|
+
const interval = setInterval(async () => {
|
|
846
|
+
try {
|
|
847
|
+
// Replace with actual Aleo transaction lookup API
|
|
848
|
+
const transaction = await this.getTransactionObject(transactionId);
|
|
849
|
+
resolve(transaction);
|
|
850
|
+
if (Date.now() - startTime > timeout) {
|
|
851
|
+
clearInterval(interval);
|
|
852
|
+
reject(new Error("Transaction confirmation timed out"));
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
catch (error) {
|
|
856
|
+
console.error("Error checking transaction:", error);
|
|
857
|
+
}
|
|
858
|
+
}, checkInterval);
|
|
859
|
+
});
|
|
860
|
+
}
|
|
796
861
|
}
|
|
797
862
|
|
|
798
863
|
const KEY_STORE = Metadata.baseUrl();
|
|
@@ -2366,4 +2431,4 @@ function validateTransferType(transferType) {
|
|
|
2366
2431
|
}
|
|
2367
2432
|
|
|
2368
2433
|
export { AleoKeyProvider as A, CREDITS_PROGRAM_KEYS as C, KEY_STORE as K, ProgramManager as P, VALID_TRANSFER_TYPES as V, AleoKeyProviderParams as a, AleoNetworkClient as b, PRIVATE_TRANSFER as c, PRIVATE_TO_PUBLIC_TRANSFER as d, PRIVATE_TRANSFER_TYPES as e, PUBLIC_TRANSFER as f, PUBLIC_TRANSFER_AS_SIGNER as g, PUBLIC_TO_PRIVATE_TRANSFER as h, logAndThrow as l };
|
|
2369
|
-
//# sourceMappingURL=program-manager-
|
|
2434
|
+
//# sourceMappingURL=program-manager-B2GtLTAh.js.map
|