@provablehq/sdk 0.11.9 → 0.11.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.
- package/dist/mainnet/account.d.cts +3 -3
- package/dist/mainnet/account.d.ts +3 -3
- package/dist/mainnet/api-auth.d.cts +14 -9
- package/dist/mainnet/api-auth.d.ts +14 -9
- package/dist/mainnet/browser.cjs +545 -191
- package/dist/mainnet/browser.cjs.map +1 -1
- package/dist/mainnet/browser.d.cts +1 -1
- package/dist/mainnet/browser.d.ts +1 -1
- package/dist/mainnet/browser.js +545 -192
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/keys/provider/interface.d.cts +4 -4
- package/dist/mainnet/keys/provider/interface.d.ts +4 -4
- package/dist/mainnet/keys/provider/memory.d.cts +6 -6
- package/dist/mainnet/keys/provider/memory.d.ts +6 -6
- package/dist/mainnet/keys/provider/offline.d.cts +1 -1
- package/dist/mainnet/keys/provider/offline.d.ts +1 -1
- package/dist/mainnet/network-client.d.cts +40 -38
- package/dist/mainnet/network-client.d.ts +40 -38
- package/dist/mainnet/node.cjs +1 -0
- package/dist/mainnet/node.cjs.map +1 -1
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/program-manager.d.cts +132 -35
- package/dist/mainnet/program-manager.d.ts +132 -35
- package/dist/mainnet/record-provider.d.cts +7 -7
- package/dist/mainnet/record-provider.d.ts +7 -7
- package/dist/mainnet/record-scanner.d.cts +3 -3
- package/dist/mainnet/record-scanner.d.ts +3 -3
- package/dist/testnet/account.d.cts +3 -3
- package/dist/testnet/account.d.ts +3 -3
- package/dist/testnet/api-auth.d.cts +14 -9
- package/dist/testnet/api-auth.d.ts +14 -9
- package/dist/testnet/browser.cjs +545 -191
- package/dist/testnet/browser.cjs.map +1 -1
- package/dist/testnet/browser.d.cts +1 -1
- package/dist/testnet/browser.d.ts +1 -1
- package/dist/testnet/browser.js +545 -192
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/keys/provider/interface.d.cts +4 -4
- package/dist/testnet/keys/provider/interface.d.ts +4 -4
- package/dist/testnet/keys/provider/memory.d.cts +6 -6
- package/dist/testnet/keys/provider/memory.d.ts +6 -6
- package/dist/testnet/keys/provider/offline.d.cts +1 -1
- package/dist/testnet/keys/provider/offline.d.ts +1 -1
- package/dist/testnet/network-client.d.cts +40 -38
- package/dist/testnet/network-client.d.ts +40 -38
- package/dist/testnet/node.cjs +1 -0
- package/dist/testnet/node.cjs.map +1 -1
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/program-manager.d.cts +132 -35
- package/dist/testnet/program-manager.d.ts +132 -35
- package/dist/testnet/record-provider.d.cts +7 -7
- package/dist/testnet/record-provider.d.ts +7 -7
- package/dist/testnet/record-scanner.d.cts +3 -3
- package/dist/testnet/record-scanner.d.ts +3 -3
- package/package.json +2 -2
package/dist/mainnet/browser.js
CHANGED
|
@@ -851,7 +851,7 @@ class Account {
|
|
|
851
851
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/testnet.js";
|
|
852
852
|
*
|
|
853
853
|
* // Create a connection to the Aleo network and an account
|
|
854
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
854
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
855
855
|
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
856
856
|
*
|
|
857
857
|
* // Get the record ciphertexts from a transaction.
|
|
@@ -881,7 +881,7 @@ class Account {
|
|
|
881
881
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/testnet.js";
|
|
882
882
|
*
|
|
883
883
|
* // Create a connection to the Aleo network and an account
|
|
884
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
884
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
885
885
|
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
886
886
|
*
|
|
887
887
|
* // Get the record ciphertexts from a transaction.
|
|
@@ -955,7 +955,7 @@ class Account {
|
|
|
955
955
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/testnet.js";
|
|
956
956
|
*
|
|
957
957
|
* // Create a connection to the Aleo network and an account
|
|
958
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
958
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
959
959
|
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
960
960
|
*
|
|
961
961
|
* // Get the record ciphertexts from a transaction and check ownership of them.
|
|
@@ -1540,10 +1540,12 @@ const DEFAULT_API_KEY_HEADER = "X-API-Key";
|
|
|
1540
1540
|
/**
|
|
1541
1541
|
* Normalize legacy auth options into an explicit {@link ApiAuthConfig}.
|
|
1542
1542
|
*
|
|
1543
|
-
* Rules
|
|
1543
|
+
* Rules:
|
|
1544
1544
|
* - An explicit `auth` wins. Combining it with legacy fields throws — the caller's intent
|
|
1545
1545
|
* is ambiguous and guessing hides misconfiguration.
|
|
1546
|
-
* - A string `apiKey`
|
|
1546
|
+
* - A string `apiKey` on its own selects `api-key` mode with the default header: nothing can
|
|
1547
|
+
* mint a JWT without a `consumerId`, so a lone key is a provisioned edge key.
|
|
1548
|
+
* - A string `apiKey` with a `consumerId`, or a bare `jwtData`, selects `jwt` mode.
|
|
1547
1549
|
* - An `{ header, value }` apiKey selects `api-key` mode with that header. Combining it with
|
|
1548
1550
|
* a `consumerId` throws: keyed auth has no consumer and the pair would silently pick one.
|
|
1549
1551
|
* - Nothing configured selects `none`.
|
|
@@ -1564,6 +1566,11 @@ function normalizeAuthConfig(options) {
|
|
|
1564
1566
|
validateKeyed(config);
|
|
1565
1567
|
return config;
|
|
1566
1568
|
}
|
|
1569
|
+
if (typeof options.apiKey === "string" && options.apiKey !== "" && options.consumerId === undefined && options.jwtData === undefined) {
|
|
1570
|
+
// Nothing can mint a JWT without a consumerId, so a lone key is a provisioned
|
|
1571
|
+
// gateway key (edge.provable.com) and is sent verbatim.
|
|
1572
|
+
return { mode: "api-key", value: options.apiKey };
|
|
1573
|
+
}
|
|
1567
1574
|
if (options.apiKey !== undefined || options.consumerId !== undefined || options.jwtData !== undefined) {
|
|
1568
1575
|
return { mode: "jwt", apiKey: options.apiKey, consumerId: options.consumerId, jwtData: options.jwtData };
|
|
1569
1576
|
}
|
|
@@ -1715,7 +1722,7 @@ const HEADERS = new Set([
|
|
|
1715
1722
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
1716
1723
|
* const apiKey = process.env.apiKey;
|
|
1717
1724
|
* const consumerId = process.env.consumerId;
|
|
1718
|
-
* const publicNetworkClient = new AleoNetworkClient("https://
|
|
1725
|
+
* const publicNetworkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined, account);
|
|
1719
1726
|
*/
|
|
1720
1727
|
class AleoNetworkClient {
|
|
1721
1728
|
host;
|
|
@@ -1734,6 +1741,9 @@ class AleoNetworkClient {
|
|
|
1734
1741
|
// The consumer the cached jwtData was minted for, so the cache is never
|
|
1735
1742
|
// reused for a different identity on a shared client.
|
|
1736
1743
|
jwtConsumerId;
|
|
1744
|
+
// The origin the cached jwtData was minted at, so a token is never reused
|
|
1745
|
+
// for a proving request routed to a different gateway.
|
|
1746
|
+
jwtMintOrigin;
|
|
1737
1747
|
proverUri;
|
|
1738
1748
|
recordScannerUri;
|
|
1739
1749
|
constructor(host, options) {
|
|
@@ -1753,7 +1763,7 @@ class AleoNetworkClient {
|
|
|
1753
1763
|
else {
|
|
1754
1764
|
this.headers = {
|
|
1755
1765
|
// This is replaced by the actual version by a Rollup plugin
|
|
1756
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1766
|
+
"X-Aleo-SDK-Version": "0.11.10",
|
|
1757
1767
|
"X-Aleo-environment": environment(),
|
|
1758
1768
|
};
|
|
1759
1769
|
}
|
|
@@ -1775,7 +1785,7 @@ class AleoNetworkClient {
|
|
|
1775
1785
|
else {
|
|
1776
1786
|
this.headers = {
|
|
1777
1787
|
// This is replaced by the actual version by a Rollup plugin
|
|
1778
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1788
|
+
"X-Aleo-SDK-Version": "0.11.10",
|
|
1779
1789
|
"X-Aleo-environment": environment(),
|
|
1780
1790
|
};
|
|
1781
1791
|
}
|
|
@@ -1787,7 +1797,7 @@ class AleoNetworkClient {
|
|
|
1787
1797
|
* @example
|
|
1788
1798
|
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1789
1799
|
*
|
|
1790
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1800
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
1791
1801
|
* const account = new Account();
|
|
1792
1802
|
* networkClient.setAccount(account);
|
|
1793
1803
|
*/
|
|
@@ -1815,7 +1825,7 @@ class AleoNetworkClient {
|
|
|
1815
1825
|
* const networkClient = new AleoNetworkClient("http://0.0.0.0:3030", undefined);
|
|
1816
1826
|
*
|
|
1817
1827
|
* // Set the host to a public node.
|
|
1818
|
-
* networkClient.setHost("https://
|
|
1828
|
+
* networkClient.setHost("https://edge.provable.com/api/v2");
|
|
1819
1829
|
*/
|
|
1820
1830
|
setHost(host) {
|
|
1821
1831
|
this.host = host + "/mainnet";
|
|
@@ -1829,7 +1839,7 @@ class AleoNetworkClient {
|
|
|
1829
1839
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1830
1840
|
*
|
|
1831
1841
|
* // Create a networkClient that connects to the provable explorer api.
|
|
1832
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1842
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
1833
1843
|
*
|
|
1834
1844
|
* // Set the prover uri.
|
|
1835
1845
|
* networkClient.setProverUri("https://prover.provable.prove");
|
|
@@ -1846,7 +1856,7 @@ class AleoNetworkClient {
|
|
|
1846
1856
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1847
1857
|
*
|
|
1848
1858
|
* // Create a networkClient that connects to the provable explorer api.
|
|
1849
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1859
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
1850
1860
|
*
|
|
1851
1861
|
* // Set the record scanner uri.
|
|
1852
1862
|
* networkClient.setRecordScannerUri("https://scanner.provable.scan");
|
|
@@ -1974,7 +1984,7 @@ class AleoNetworkClient {
|
|
|
1974
1984
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
1975
1985
|
*
|
|
1976
1986
|
* // Create a network client.
|
|
1977
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1987
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
1978
1988
|
* networkClient.setAccount(account);
|
|
1979
1989
|
*
|
|
1980
1990
|
* // Find specific amounts
|
|
@@ -2197,7 +2207,7 @@ class AleoNetworkClient {
|
|
|
2197
2207
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
2198
2208
|
*
|
|
2199
2209
|
* // Create a network client and set an account to search for records with.
|
|
2200
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2210
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2201
2211
|
* networkClient.setAccount(account);
|
|
2202
2212
|
*
|
|
2203
2213
|
* // Find specific amounts
|
|
@@ -2253,7 +2263,7 @@ class AleoNetworkClient {
|
|
|
2253
2263
|
* @example
|
|
2254
2264
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2255
2265
|
*
|
|
2256
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2266
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2257
2267
|
* const block = networkClient.getBlockByHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
2258
2268
|
*/
|
|
2259
2269
|
async getBlockByHash(blockHash) {
|
|
@@ -2311,7 +2321,7 @@ class AleoNetworkClient {
|
|
|
2311
2321
|
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
2312
2322
|
*
|
|
2313
2323
|
* // Get the transaction ID of the deployment transaction for a program.
|
|
2314
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2324
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2315
2325
|
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
2316
2326
|
*
|
|
2317
2327
|
* // Get the transaction data for the deployment transaction.
|
|
@@ -2346,7 +2356,7 @@ class AleoNetworkClient {
|
|
|
2346
2356
|
* import { AleoNetworkClient, DeploymentJSON } from "@provablehq/sdk/testnet.js";
|
|
2347
2357
|
*
|
|
2348
2358
|
* // Get the transaction ID of the deployment transaction for a program.
|
|
2349
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2359
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2350
2360
|
* const transaction = networkClient.getDeploymentTransactionForProgram("hello_hello.aleo");
|
|
2351
2361
|
*
|
|
2352
2362
|
* // Get the verifying keys for each function in the deployment.
|
|
@@ -2379,7 +2389,7 @@ class AleoNetworkClient {
|
|
|
2379
2389
|
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
2380
2390
|
*
|
|
2381
2391
|
* // Get the transaction ID of the deployment transaction for a program.
|
|
2382
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2392
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2383
2393
|
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
2384
2394
|
*
|
|
2385
2395
|
* // Get the transaction data for the deployment transaction.
|
|
@@ -2410,7 +2420,7 @@ class AleoNetworkClient {
|
|
|
2410
2420
|
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
2411
2421
|
*
|
|
2412
2422
|
* // Create a network client.
|
|
2413
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2423
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2414
2424
|
*
|
|
2415
2425
|
* const latestHeight = networkClient.getLatestBlock();
|
|
2416
2426
|
*/
|
|
@@ -2435,10 +2445,10 @@ class AleoNetworkClient {
|
|
|
2435
2445
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2436
2446
|
*
|
|
2437
2447
|
* // Create a network client.
|
|
2438
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2448
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2439
2449
|
*
|
|
2440
2450
|
* // Create a network client and get the latest committee.
|
|
2441
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2451
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2442
2452
|
* const latestCommittee = await networkClient.getLatestCommittee();
|
|
2443
2453
|
*/
|
|
2444
2454
|
async getLatestCommittee() {
|
|
@@ -2463,10 +2473,10 @@ class AleoNetworkClient {
|
|
|
2463
2473
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2464
2474
|
*
|
|
2465
2475
|
* // Create a network client.
|
|
2466
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2476
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2467
2477
|
*
|
|
2468
2478
|
* // Create a network client and get the committee for a specific block.
|
|
2469
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2479
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2470
2480
|
* const committee = await networkClient.getCommitteeByBlockHeight(1234);
|
|
2471
2481
|
*/
|
|
2472
2482
|
async getCommitteeByBlockHeight(blockHeight) {
|
|
@@ -2490,7 +2500,7 @@ class AleoNetworkClient {
|
|
|
2490
2500
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2491
2501
|
*
|
|
2492
2502
|
* // Create a network client.
|
|
2493
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2503
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2494
2504
|
*
|
|
2495
2505
|
* const latestHeight = networkClient.getLatestHeight();
|
|
2496
2506
|
*/
|
|
@@ -2534,7 +2544,7 @@ class AleoNetworkClient {
|
|
|
2534
2544
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2535
2545
|
*
|
|
2536
2546
|
* // Create a network client.
|
|
2537
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2547
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2538
2548
|
*
|
|
2539
2549
|
* // Get the latest block hash.
|
|
2540
2550
|
* const latestHash = networkClient.getLatestBlockHash();
|
|
@@ -2562,7 +2572,7 @@ class AleoNetworkClient {
|
|
|
2562
2572
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2563
2573
|
*
|
|
2564
2574
|
* // Create a network client.
|
|
2565
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2575
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2566
2576
|
*
|
|
2567
2577
|
* // Get the source code of a program.)
|
|
2568
2578
|
* @returns {Promise<string>} Source code of the program
|
|
@@ -2571,7 +2581,7 @@ class AleoNetworkClient {
|
|
|
2571
2581
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2572
2582
|
*
|
|
2573
2583
|
* // Create a network client.
|
|
2574
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2584
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2575
2585
|
*
|
|
2576
2586
|
* const program = networkClient.getProgram("hello_hello.aleo");
|
|
2577
2587
|
* 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"
|
|
@@ -2604,7 +2614,7 @@ class AleoNetworkClient {
|
|
|
2604
2614
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2605
2615
|
*
|
|
2606
2616
|
* // Create a network client.
|
|
2607
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2617
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2608
2618
|
*
|
|
2609
2619
|
* const programVersion = networkClient.getLatestProgramEdition("hello_hello.aleo");
|
|
2610
2620
|
* assert.equal(programVersion, 1);
|
|
@@ -2629,7 +2639,7 @@ class AleoNetworkClient {
|
|
|
2629
2639
|
* @returns {{ program_id: string, edition: number, amendment_count: number }}
|
|
2630
2640
|
*
|
|
2631
2641
|
* @example
|
|
2632
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2642
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
2633
2643
|
* const info = await networkClient.getProgramAmendmentCount("hello_hello.aleo");
|
|
2634
2644
|
* console.log(info.edition, info.amendment_count);
|
|
2635
2645
|
*/
|
|
@@ -2657,7 +2667,7 @@ class AleoNetworkClient {
|
|
|
2657
2667
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2658
2668
|
*
|
|
2659
2669
|
* // Create a network client.
|
|
2660
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2670
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2661
2671
|
*
|
|
2662
2672
|
* const programID = "hello_hello.aleo";
|
|
2663
2673
|
* 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"
|
|
@@ -2697,7 +2707,7 @@ class AleoNetworkClient {
|
|
|
2697
2707
|
* }
|
|
2698
2708
|
*
|
|
2699
2709
|
* // Create a network client.
|
|
2700
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2710
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2701
2711
|
*
|
|
2702
2712
|
* // Imports can be fetched using the program ID, source code, or program object
|
|
2703
2713
|
* let programImports = await networkClient.getProgramImports("double_test.aleo");
|
|
@@ -2767,7 +2777,7 @@ class AleoNetworkClient {
|
|
|
2767
2777
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2768
2778
|
*
|
|
2769
2779
|
* // Create a network client.
|
|
2770
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2780
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2771
2781
|
*
|
|
2772
2782
|
* const programImportsNames = networkClient.getProgramImports("wrapped_credits.aleo");
|
|
2773
2783
|
* const expectedImportsNames = ["credits.aleo"];
|
|
@@ -2798,7 +2808,7 @@ class AleoNetworkClient {
|
|
|
2798
2808
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2799
2809
|
*
|
|
2800
2810
|
* // Create a network client.
|
|
2801
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2811
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2802
2812
|
*
|
|
2803
2813
|
* const mappings = networkClient.getProgramMappingNames("credits.aleo");
|
|
2804
2814
|
* const expectedMappings = [
|
|
@@ -2836,7 +2846,7 @@ class AleoNetworkClient {
|
|
|
2836
2846
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2837
2847
|
*
|
|
2838
2848
|
* // Create a network client.
|
|
2839
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2849
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2840
2850
|
*
|
|
2841
2851
|
* // Get public balance of an account
|
|
2842
2852
|
* const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
@@ -2868,7 +2878,7 @@ class AleoNetworkClient {
|
|
|
2868
2878
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2869
2879
|
*
|
|
2870
2880
|
* // Create a network client.
|
|
2871
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2881
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2872
2882
|
*
|
|
2873
2883
|
* // Get the bond state as an account.
|
|
2874
2884
|
* const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
@@ -2914,7 +2924,7 @@ class AleoNetworkClient {
|
|
|
2914
2924
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2915
2925
|
*
|
|
2916
2926
|
* // Create a network client.
|
|
2917
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2927
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2918
2928
|
*
|
|
2919
2929
|
* // Get the balance of an account from either an address object or address string.
|
|
2920
2930
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
@@ -2945,7 +2955,7 @@ class AleoNetworkClient {
|
|
|
2945
2955
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2946
2956
|
*
|
|
2947
2957
|
* // Create a network client.
|
|
2948
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2958
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2949
2959
|
*
|
|
2950
2960
|
* // Get the latest state root.
|
|
2951
2961
|
* const stateRoot = networkClient.getStateRoot();
|
|
@@ -2972,7 +2982,7 @@ class AleoNetworkClient {
|
|
|
2972
2982
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2973
2983
|
*
|
|
2974
2984
|
* // Create a network client.
|
|
2975
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2985
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2976
2986
|
*
|
|
2977
2987
|
* const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
2978
2988
|
*/
|
|
@@ -2998,7 +3008,7 @@ class AleoNetworkClient {
|
|
|
2998
3008
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2999
3009
|
*
|
|
3000
3010
|
* // Create a network client.
|
|
3001
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3011
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3002
3012
|
*
|
|
3003
3013
|
* const transaction = networkClient.getConfirmedTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
3004
3014
|
* assert.equal(transaction.status, "confirmed");
|
|
@@ -3063,7 +3073,7 @@ class AleoNetworkClient {
|
|
|
3063
3073
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
3064
3074
|
*
|
|
3065
3075
|
* // Create a network client.
|
|
3066
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3076
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3067
3077
|
*
|
|
3068
3078
|
* const transactions = networkClient.getTransactions(654);
|
|
3069
3079
|
*/
|
|
@@ -3089,7 +3099,7 @@ class AleoNetworkClient {
|
|
|
3089
3099
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
3090
3100
|
*
|
|
3091
3101
|
* // Create a network client.
|
|
3092
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3102
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3093
3103
|
*
|
|
3094
3104
|
* const transactions = networkClient.getTransactionsByBlockHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
3095
3105
|
*/
|
|
@@ -3116,7 +3126,7 @@ class AleoNetworkClient {
|
|
|
3116
3126
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
3117
3127
|
*
|
|
3118
3128
|
* // Create a network client.
|
|
3119
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3129
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3120
3130
|
*
|
|
3121
3131
|
* // Get the current transactions in the mempool.
|
|
3122
3132
|
* const transactions = networkClient.getTransactionsInMempool();
|
|
@@ -3277,17 +3287,34 @@ class AleoNetworkClient {
|
|
|
3277
3287
|
if (options.auth && (options.apiKey !== undefined || options.consumerId !== undefined || options.jwtData !== undefined)) {
|
|
3278
3288
|
throw new Error("Pass either `auth` or the legacy apiKey/consumerId/jwtData options, not both");
|
|
3279
3289
|
}
|
|
3290
|
+
// Mint the JWT at the origin the proving request actually lands on, not the
|
|
3291
|
+
// client's main host: a caller can route proving to a different gateway via
|
|
3292
|
+
// setProverUri or a per-request `url`, and the JWT is validated there.
|
|
3293
|
+
let mintOrigin = this.baseUrl;
|
|
3294
|
+
try {
|
|
3295
|
+
mintOrigin = new URL(proverUri).origin;
|
|
3296
|
+
}
|
|
3297
|
+
catch {
|
|
3298
|
+
// proverUri may carry the unsubstituted mainnet placeholder in tests;
|
|
3299
|
+
// fall back to the client host origin.
|
|
3300
|
+
}
|
|
3301
|
+
// A token assigned directly to `jwtData` carries no mint scope: the caller
|
|
3302
|
+
// injected it (an external session owns minting) and it is honored as-is.
|
|
3303
|
+
// A token this client minted is scoped to its consumer and origin below.
|
|
3304
|
+
const injectedJwt = this.jwtMintOrigin === undefined ? this.jwtData : undefined;
|
|
3280
3305
|
const config = options.auth ?? this.auth ?? normalizeAuthConfig({
|
|
3281
3306
|
apiKey: options.apiKey ?? this.apiKey,
|
|
3282
3307
|
consumerId: options.consumerId ?? this.consumerId,
|
|
3283
|
-
jwtData: options.jwtData ??
|
|
3308
|
+
jwtData: options.jwtData ?? injectedJwt,
|
|
3284
3309
|
});
|
|
3285
|
-
const auth = new ApiAuth(config,
|
|
3286
|
-
//
|
|
3287
|
-
//
|
|
3288
|
-
// consumer that minted it
|
|
3289
|
-
// client never
|
|
3290
|
-
|
|
3310
|
+
const auth = new ApiAuth(config, mintOrigin, this.transport, this.method("refreshJwt"));
|
|
3311
|
+
// Reuse the cached client token until the refresh window instead of
|
|
3312
|
+
// minting on every request, but only when this submission targets the
|
|
3313
|
+
// same consumer AND the same gateway origin that minted it — so a shared
|
|
3314
|
+
// client never rides another identity's token or sends one gateway's
|
|
3315
|
+
// token to a different gateway. A per-request jwtData in the config wins.
|
|
3316
|
+
if (config.mode === "jwt" && !config.jwtData && this.jwtData
|
|
3317
|
+
&& config.consumerId === this.jwtConsumerId && mintOrigin === this.jwtMintOrigin) {
|
|
3291
3318
|
auth.setJwtData(this.jwtData);
|
|
3292
3319
|
}
|
|
3293
3320
|
// Resolves the auth headers, which refreshes the JWT when it is stale. Runs before
|
|
@@ -3296,7 +3323,12 @@ class AleoNetworkClient {
|
|
|
3296
3323
|
const jwtData = auth.getJwtData();
|
|
3297
3324
|
if (config.mode === "jwt" && jwtData) {
|
|
3298
3325
|
this.jwtData = jwtData;
|
|
3299
|
-
this.
|
|
3326
|
+
// Only a token this client minted gets a scope. An injected token that
|
|
3327
|
+
// passed through unchanged stays unscoped so later calls keep honoring it.
|
|
3328
|
+
if (jwtData !== config.jwtData) {
|
|
3329
|
+
this.jwtConsumerId = config.consumerId;
|
|
3330
|
+
this.jwtMintOrigin = mintOrigin;
|
|
3331
|
+
}
|
|
3300
3332
|
options.jwtData = jwtData;
|
|
3301
3333
|
}
|
|
3302
3334
|
// Create the necessary headers to hit the provable api.
|
|
@@ -3387,7 +3419,7 @@ class AleoNetworkClient {
|
|
|
3387
3419
|
* import { AleoNetworkClient, Account, ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
3388
3420
|
*
|
|
3389
3421
|
* // Create a network client and program manager.
|
|
3390
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3422
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3391
3423
|
* const programManager = new ProgramManager(networkClient);
|
|
3392
3424
|
*
|
|
3393
3425
|
* // Set the account for the program manager.
|
|
@@ -3635,12 +3667,12 @@ class AleoKeyProvider {
|
|
|
3635
3667
|
*
|
|
3636
3668
|
* @example
|
|
3637
3669
|
* // Create a new object which implements the KeyProvider interface
|
|
3638
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3670
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
3639
3671
|
* const keyProvider = new AleoKeyProvider();
|
|
3640
3672
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3641
3673
|
*
|
|
3642
3674
|
* // Initialize a program manager with the key provider to automatically fetch keys for value transfers
|
|
3643
|
-
* const programManager = new ProgramManager("https://
|
|
3675
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
3644
3676
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3645
3677
|
*
|
|
3646
3678
|
* // Keys can also be fetched manually using the key provider
|
|
@@ -3687,12 +3719,12 @@ class AleoKeyProvider {
|
|
|
3687
3719
|
*
|
|
3688
3720
|
* @example
|
|
3689
3721
|
* // Create a new AleoKeyProvider object
|
|
3690
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3722
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
3691
3723
|
* const keyProvider = new AleoKeyProvider();
|
|
3692
3724
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3693
3725
|
*
|
|
3694
3726
|
* // Initialize a program manager with the key provider to automatically fetch keys for value transfers
|
|
3695
|
-
* const programManager = new ProgramManager("https://
|
|
3727
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
3696
3728
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3697
3729
|
*
|
|
3698
3730
|
* // Keys can also be fetched manually
|
|
@@ -3810,12 +3842,12 @@ class AleoKeyProvider {
|
|
|
3810
3842
|
*
|
|
3811
3843
|
* @example
|
|
3812
3844
|
* // Create a new AleoKeyProvider
|
|
3813
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3845
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
3814
3846
|
* const keyProvider = new AleoKeyProvider();
|
|
3815
3847
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3816
3848
|
*
|
|
3817
3849
|
* // Initialize a program manager with the key provider to automatically fetch keys for value transfers
|
|
3818
|
-
* const programManager = new ProgramManager("https://
|
|
3850
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
3819
3851
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3820
3852
|
*
|
|
3821
3853
|
* // Keys can also be fetched manually
|
|
@@ -4160,7 +4192,7 @@ class OfflineSearchParams {
|
|
|
4160
4192
|
* const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction("hello_hello.aleo", "hello", 1, false, ["5u32", "5u32"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);
|
|
4161
4193
|
*
|
|
4162
4194
|
* // Broadcast the transaction later on a machine with internet access
|
|
4163
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4195
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4164
4196
|
* const txId = await networkClient.broadcastTransaction(offlineExecuteTx);
|
|
4165
4197
|
*/
|
|
4166
4198
|
class OfflineKeyProvider {
|
|
@@ -4620,7 +4652,7 @@ class NetworkRecordProvider {
|
|
|
4620
4652
|
*
|
|
4621
4653
|
* @example
|
|
4622
4654
|
* // Create a new NetworkRecordProvider
|
|
4623
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4655
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4624
4656
|
* const keyProvider = new AleoKeyProvider();
|
|
4625
4657
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
4626
4658
|
*
|
|
@@ -4633,7 +4665,7 @@ class NetworkRecordProvider {
|
|
|
4633
4665
|
*
|
|
4634
4666
|
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
4635
4667
|
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
4636
|
-
* const programManager = new ProgramManager("https://
|
|
4668
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
4637
4669
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
4638
4670
|
*
|
|
4639
4671
|
* */
|
|
@@ -4681,7 +4713,7 @@ class NetworkRecordProvider {
|
|
|
4681
4713
|
*
|
|
4682
4714
|
* @example
|
|
4683
4715
|
* // Create a new NetworkRecordProvider
|
|
4684
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4716
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4685
4717
|
* const keyProvider = new AleoKeyProvider();
|
|
4686
4718
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
4687
4719
|
*
|
|
@@ -4694,7 +4726,7 @@ class NetworkRecordProvider {
|
|
|
4694
4726
|
*
|
|
4695
4727
|
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
4696
4728
|
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
4697
|
-
* const programManager = new ProgramManager("https://
|
|
4729
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
4698
4730
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
4699
4731
|
*/
|
|
4700
4732
|
async findCreditsRecord(microcredits, searchParameters) {
|
|
@@ -4790,7 +4822,7 @@ class NetworkRecordProvider {
|
|
|
4790
4822
|
* const params = new BlockHeightSearch(89995, 99995);
|
|
4791
4823
|
*
|
|
4792
4824
|
* // Create a new NetworkRecordProvider
|
|
4793
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4825
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4794
4826
|
* const keyProvider = new AleoKeyProvider();
|
|
4795
4827
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
4796
4828
|
*
|
|
@@ -4981,7 +5013,9 @@ class RecordScanner {
|
|
|
4981
5013
|
* @param {RecordScannerJWTData | undefined} jwtData The JWT data to use, or undefined to clear.
|
|
4982
5014
|
*/
|
|
4983
5015
|
setJwtData(jwtData) {
|
|
4984
|
-
|
|
5016
|
+
// Rebuild rather than store: with a lone legacy apiKey the mode is api-key
|
|
5017
|
+
// until a JWT exists, and a JWT is only sent from jwt mode.
|
|
5018
|
+
this.auth = this.buildAuth(jwtData);
|
|
4985
5019
|
}
|
|
4986
5020
|
/**
|
|
4987
5021
|
* Set whether /owned should automatically re-register on 422 (when a view key for the UUID is in viewKeys or account) and retry once.
|
|
@@ -5944,33 +5978,129 @@ function generateHookData(recipientAddress, secretNonce) {
|
|
|
5944
5978
|
return hookData;
|
|
5945
5979
|
}
|
|
5946
5980
|
|
|
5947
|
-
const
|
|
5948
|
-
|
|
5949
|
-
|
|
5981
|
+
const preparedContextBuilders = new WeakMap();
|
|
5982
|
+
const preparedProcessPrograms = new WeakMap();
|
|
5983
|
+
const preparedProgramImports = new WeakMap();
|
|
5984
|
+
const preparedContextQueues = new WeakMap();
|
|
5985
|
+
const CREDITS_PROGRAM_ID = "credits.aleo";
|
|
5986
|
+
let canonicalCreditsProgramSource;
|
|
5987
|
+
function normalizeProgramSource(program) {
|
|
5988
|
+
return program instanceof Program ? program.toString() : program;
|
|
5989
|
+
}
|
|
5990
|
+
function getCanonicalCreditsProgramSource() {
|
|
5991
|
+
if (canonicalCreditsProgramSource === undefined) {
|
|
5992
|
+
const creditsProgram = Program.getCreditsProgram();
|
|
5993
|
+
try {
|
|
5994
|
+
canonicalCreditsProgramSource = creditsProgram.toString();
|
|
5995
|
+
}
|
|
5996
|
+
finally {
|
|
5997
|
+
creditsProgram.free();
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
return canonicalCreditsProgramSource;
|
|
6001
|
+
}
|
|
6002
|
+
function isCanonicalCreditsProgramSource(source) {
|
|
6003
|
+
if (source instanceof Program) {
|
|
6004
|
+
return source.toString() === getCanonicalCreditsProgramSource();
|
|
6005
|
+
}
|
|
6006
|
+
// API responses may format the same program differently (for example,
|
|
6007
|
+
// numeric separators), so compare snarkVM's canonical serialization.
|
|
6008
|
+
let parsed;
|
|
6009
|
+
try {
|
|
6010
|
+
parsed = Program.fromString(source);
|
|
6011
|
+
return parsed.toString() === getCanonicalCreditsProgramSource();
|
|
6012
|
+
}
|
|
6013
|
+
catch {
|
|
6014
|
+
return false;
|
|
6015
|
+
}
|
|
6016
|
+
finally {
|
|
6017
|
+
parsed?.free();
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
function preparedProcessHasCompatibleImport(programs, name, source) {
|
|
6021
|
+
// Every snarkVM process already contains credits.aleo, and the imports
|
|
6022
|
+
// builder intentionally does not retain that built-in in its metadata.
|
|
6023
|
+
if (name === CREDITS_PROGRAM_ID) {
|
|
6024
|
+
return isCanonicalCreditsProgramSource(source);
|
|
6025
|
+
}
|
|
6026
|
+
return programs.get(name)?.programSource === normalizeProgramSource(source);
|
|
6027
|
+
}
|
|
6028
|
+
function preparedProcessSupports(preparedProcess, options) {
|
|
6029
|
+
const programs = preparedProcessPrograms.get(preparedProcess);
|
|
6030
|
+
const builder = preparedContextBuilders.get(preparedProcess);
|
|
6031
|
+
if (!programs || !builder)
|
|
6032
|
+
return false;
|
|
6033
|
+
const program = programs.get(options.programName);
|
|
6034
|
+
if (!program)
|
|
6035
|
+
return false;
|
|
6036
|
+
if (options.functionName !== undefined
|
|
6037
|
+
&& !program.functions.includes(options.functionName)) {
|
|
6038
|
+
return false;
|
|
6039
|
+
}
|
|
6040
|
+
if (options.programSource !== undefined
|
|
6041
|
+
&& normalizeProgramSource(options.programSource) !== program.programSource) {
|
|
6042
|
+
return false;
|
|
6043
|
+
}
|
|
6044
|
+
if (options.edition !== undefined && options.edition !== program.edition) {
|
|
6045
|
+
return false;
|
|
6046
|
+
}
|
|
6047
|
+
if (options.programImports) {
|
|
6048
|
+
for (const [name, source] of Object.entries(options.programImports)) {
|
|
6049
|
+
if (!preparedProcessHasCompatibleImport(programs, name, source)) {
|
|
6050
|
+
return false;
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
}
|
|
6054
|
+
return true;
|
|
6055
|
+
}
|
|
6056
|
+
function selectedPreparedContext(options) {
|
|
6057
|
+
if (options.preparedProgram && options.preparedProcess) {
|
|
6058
|
+
throw new Error("Specify either preparedProgram or preparedProcess, not both");
|
|
6059
|
+
}
|
|
6060
|
+
return options.preparedProcess ?? options.preparedProgram;
|
|
6061
|
+
}
|
|
6062
|
+
/**
|
|
6063
|
+
* Serialize WASM calls that borrow a prepared context's snarkVM process.
|
|
6064
|
+
*
|
|
6065
|
+
* WASM builder clones are reference-counted handles to one mutable snarkVM
|
|
6066
|
+
* process guarded by a RefCell. Overlapping borrows would panic and abort the
|
|
6067
|
+
* WASM module, so calls sharing a context are queued behind one another at the
|
|
6068
|
+
* WASM boundary. Only the WASM call itself is queued: network resolution and
|
|
6069
|
+
* fee record lookup still run concurrently across calls.
|
|
6070
|
+
*
|
|
6071
|
+
* The entry points that accept a prepared context currently complete their
|
|
6072
|
+
* borrow without yielding, so the queue never waits in practice. It exists to
|
|
6073
|
+
* turn a future borrow-across-await into a delayed call rather than a panic.
|
|
6074
|
+
*/
|
|
6075
|
+
function withPreparedContextWasm(preparedContext, call) {
|
|
6076
|
+
if (!preparedContext)
|
|
6077
|
+
return call();
|
|
6078
|
+
const previous = preparedContextQueues.get(preparedContext) ?? Promise.resolve();
|
|
6079
|
+
const next = previous.then(call, call);
|
|
6080
|
+
// Keep the queue alive regardless of how this call settles so one failure
|
|
6081
|
+
// does not block later calls on the same context. Normalize both outcomes
|
|
6082
|
+
// so the queue does not retain a successful WASM result.
|
|
6083
|
+
const tail = next.then(() => undefined, () => undefined);
|
|
6084
|
+
preparedContextQueues.set(preparedContext, tail);
|
|
6085
|
+
return next;
|
|
6086
|
+
}
|
|
6087
|
+
function clonePreparedContextBuilder(preparedContext) {
|
|
6088
|
+
const builder = preparedContextBuilders.get(preparedContext);
|
|
5950
6089
|
if (!builder) {
|
|
5951
|
-
throw new Error(
|
|
6090
|
+
throw new Error(preparedContext instanceof PreparedProcess
|
|
6091
|
+
? "Prepared process has already been freed"
|
|
6092
|
+
: "Prepared program has already been freed");
|
|
5952
6093
|
}
|
|
5953
6094
|
// The WASM clone is a cheap shared Rc handle, not a deep copy. Mutations
|
|
5954
6095
|
// made while authorizing intentionally remain cached in the prepared context.
|
|
5955
6096
|
return builder.clone();
|
|
5956
6097
|
}
|
|
5957
|
-
function programImportsFromBuilder(builder, entryProgramName) {
|
|
5958
|
-
const imports = {};
|
|
5959
|
-
for (const name of Array.from(builder.programNames())) {
|
|
5960
|
-
if (name === entryProgramName)
|
|
5961
|
-
continue;
|
|
5962
|
-
const source = builder.getProgram(name);
|
|
5963
|
-
if (source)
|
|
5964
|
-
imports[name] = source;
|
|
5965
|
-
}
|
|
5966
|
-
return imports;
|
|
5967
|
-
}
|
|
5968
6098
|
/**
|
|
5969
6099
|
* A reusable program context created by {@link ProgramManager.prepareProgram}.
|
|
5970
6100
|
*
|
|
5971
|
-
* The context is scoped to one program function.
|
|
5972
|
-
*
|
|
5973
|
-
* is no longer needed.
|
|
6101
|
+
* The context is scoped to one program function. Concurrent calls sharing it
|
|
6102
|
+
* are serialized at the WASM boundary. The caller owns the context and should
|
|
6103
|
+
* call {@link free} when it is no longer needed.
|
|
5974
6104
|
*/
|
|
5975
6105
|
class PreparedProgram {
|
|
5976
6106
|
programName;
|
|
@@ -5990,8 +6120,45 @@ class PreparedProgram {
|
|
|
5990
6120
|
* Release the prepared snarkVM process. This method is idempotent.
|
|
5991
6121
|
*/
|
|
5992
6122
|
free() {
|
|
5993
|
-
|
|
5994
|
-
|
|
6123
|
+
preparedContextBuilders.get(this)?.free();
|
|
6124
|
+
preparedContextBuilders.delete(this);
|
|
6125
|
+
preparedProgramImports.delete(this);
|
|
6126
|
+
}
|
|
6127
|
+
}
|
|
6128
|
+
/**
|
|
6129
|
+
* A reusable snarkVM process created by {@link ProgramManager.prepareProcess}.
|
|
6130
|
+
*
|
|
6131
|
+
* Unlike {@link PreparedProgram}, a prepared process can authorize any
|
|
6132
|
+
* function in any loaded program. Extra loaded programs remain idle when a
|
|
6133
|
+
* call only needs a subset. Concurrent calls sharing the process are
|
|
6134
|
+
* serialized at the WASM boundary.
|
|
6135
|
+
*/
|
|
6136
|
+
class PreparedProcess {
|
|
6137
|
+
programs;
|
|
6138
|
+
/** Instances are normally created through {@link ProgramManager.prepareProcess}. */
|
|
6139
|
+
constructor(programs) {
|
|
6140
|
+
this.programs = Object.freeze(programs.map((program) => Object.freeze({
|
|
6141
|
+
...program,
|
|
6142
|
+
functions: Object.freeze([...program.functions]),
|
|
6143
|
+
})));
|
|
6144
|
+
}
|
|
6145
|
+
/** Names of all programs loaded into this process. */
|
|
6146
|
+
get programNames() {
|
|
6147
|
+
return this.programs.map(({ programName }) => programName);
|
|
6148
|
+
}
|
|
6149
|
+
/**
|
|
6150
|
+
* Check whether the process can serve a call without network resolution or
|
|
6151
|
+
* process rebuilding. Caller-provided imports may be a subset of the
|
|
6152
|
+
* programs loaded into the process.
|
|
6153
|
+
*/
|
|
6154
|
+
supports(options) {
|
|
6155
|
+
return preparedProcessSupports(this, options);
|
|
6156
|
+
}
|
|
6157
|
+
/** Release the prepared snarkVM process. This method is idempotent. */
|
|
6158
|
+
free() {
|
|
6159
|
+
preparedContextBuilders.get(this)?.free();
|
|
6160
|
+
preparedContextBuilders.delete(this);
|
|
6161
|
+
preparedProcessPrograms.delete(this);
|
|
5995
6162
|
}
|
|
5996
6163
|
}
|
|
5997
6164
|
/**
|
|
@@ -6012,7 +6179,7 @@ class ProgramManager {
|
|
|
6012
6179
|
* @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface
|
|
6013
6180
|
*/
|
|
6014
6181
|
constructor(host, keyProvider, recordProvider, networkClientOptions, keyStore) {
|
|
6015
|
-
this.host = host ? host : "https://
|
|
6182
|
+
this.host = host ? host : "https://edge.provable.com/api/v2";
|
|
6016
6183
|
this.networkClient = new AleoNetworkClient(this.host, networkClientOptions);
|
|
6017
6184
|
this.keyProvider = keyProvider ? keyProvider : new AleoKeyProvider({ transport: networkClientOptions?.transport });
|
|
6018
6185
|
this.recordProvider = recordProvider;
|
|
@@ -6143,11 +6310,16 @@ class ProgramManager {
|
|
|
6143
6310
|
program = program.toString();
|
|
6144
6311
|
}
|
|
6145
6312
|
const parsedProgram = Program.fromString(program);
|
|
6146
|
-
|
|
6147
|
-
|
|
6313
|
+
try {
|
|
6314
|
+
if (parsedProgram.id() !== options.programName) {
|
|
6315
|
+
throw new Error(`Program source ID '${parsedProgram.id()}' does not match requested program '${options.programName}'`);
|
|
6316
|
+
}
|
|
6317
|
+
if (!parsedProgram.getFunctions().includes(options.functionName)) {
|
|
6318
|
+
throw new Error(`Function '${options.functionName}' does not exist in program '${options.programName}'`);
|
|
6319
|
+
}
|
|
6148
6320
|
}
|
|
6149
|
-
|
|
6150
|
-
|
|
6321
|
+
finally {
|
|
6322
|
+
parsedProgram.free();
|
|
6151
6323
|
}
|
|
6152
6324
|
const edition = options.edition
|
|
6153
6325
|
?? (await this.resolveEditionAndAmendment(options.programName)).edition;
|
|
@@ -6155,10 +6327,171 @@ class ProgramManager {
|
|
|
6155
6327
|
// Add the entry program as well as its imports so the snarkVM process is
|
|
6156
6328
|
// fully initialized before an authorization is requested.
|
|
6157
6329
|
builder.addProgram(options.programName, program, edition);
|
|
6330
|
+
// Snapshot the import sources once so later validation is answered from
|
|
6331
|
+
// JavaScript and never borrows the shared WASM process.
|
|
6332
|
+
const importSources = new Map();
|
|
6333
|
+
for (const name of Array.from(builder.programNames())) {
|
|
6334
|
+
if (name === options.programName)
|
|
6335
|
+
continue;
|
|
6336
|
+
const source = builder.getProgram(name);
|
|
6337
|
+
if (source !== undefined)
|
|
6338
|
+
importSources.set(name, source);
|
|
6339
|
+
}
|
|
6158
6340
|
const preparedProgram = new PreparedProgram(options.programName, options.functionName, program, edition);
|
|
6159
|
-
|
|
6341
|
+
preparedContextBuilders.set(preparedProgram, builder);
|
|
6342
|
+
preparedProgramImports.set(preparedProgram, importSources);
|
|
6160
6343
|
return preparedProgram;
|
|
6161
6344
|
}
|
|
6345
|
+
/**
|
|
6346
|
+
* Prepare one reusable snarkVM process for multiple programs and functions.
|
|
6347
|
+
*
|
|
6348
|
+
* Sources, editions, and transitive imports are resolved once. Every
|
|
6349
|
+
* loaded program can later be used as an entry program, and an invocation
|
|
6350
|
+
* may supply any matching subset of the preloaded imports.
|
|
6351
|
+
*
|
|
6352
|
+
* @example
|
|
6353
|
+
* const prepared = await programManager.prepareProcess({
|
|
6354
|
+
* programs: [
|
|
6355
|
+
* { programName: "wallet_router.aleo" },
|
|
6356
|
+
* { programName: "token_registry.aleo" },
|
|
6357
|
+
* ],
|
|
6358
|
+
* programImports: dynamicDispatchTargets,
|
|
6359
|
+
* });
|
|
6360
|
+
* try {
|
|
6361
|
+
* const authorization = await programManager.buildAuthorizationUnchecked({
|
|
6362
|
+
* programName: "wallet_router.aleo",
|
|
6363
|
+
* functionName: "transfer",
|
|
6364
|
+
* inputs,
|
|
6365
|
+
* preparedProcess: prepared,
|
|
6366
|
+
* });
|
|
6367
|
+
* } finally {
|
|
6368
|
+
* prepared.free();
|
|
6369
|
+
* }
|
|
6370
|
+
*/
|
|
6371
|
+
async prepareProcess(options) {
|
|
6372
|
+
if (!Array.isArray(options.programs) || options.programs.length === 0) {
|
|
6373
|
+
throw new Error("At least one program is required to prepare a process");
|
|
6374
|
+
}
|
|
6375
|
+
const requestedNames = new Set();
|
|
6376
|
+
for (const program of options.programs) {
|
|
6377
|
+
if (requestedNames.has(program.programName)) {
|
|
6378
|
+
throw new Error(`Program '${program.programName}' was requested more than once`);
|
|
6379
|
+
}
|
|
6380
|
+
requestedNames.add(program.programName);
|
|
6381
|
+
}
|
|
6382
|
+
const requestedPrograms = await Promise.all(options.programs.map(async (requested) => {
|
|
6383
|
+
let source = requested.programSource;
|
|
6384
|
+
if (source === undefined) {
|
|
6385
|
+
try {
|
|
6386
|
+
source = await this.networkClient.getProgram(requested.programName);
|
|
6387
|
+
}
|
|
6388
|
+
catch (e) {
|
|
6389
|
+
logAndThrow(`Error finding ${requested.programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`);
|
|
6390
|
+
}
|
|
6391
|
+
}
|
|
6392
|
+
const programSource = normalizeProgramSource(source);
|
|
6393
|
+
const edition = requested.edition
|
|
6394
|
+
?? (await this.resolveEditionAndAmendment(requested.programName)).edition;
|
|
6395
|
+
return { programName: requested.programName, programSource, edition };
|
|
6396
|
+
}));
|
|
6397
|
+
const sources = new Map();
|
|
6398
|
+
const editions = new Map();
|
|
6399
|
+
const mergeSource = (name, source) => {
|
|
6400
|
+
const existing = sources.get(name);
|
|
6401
|
+
if (existing !== undefined && existing !== source) {
|
|
6402
|
+
throw new Error(`Conflicting sources were supplied for program '${name}'`);
|
|
6403
|
+
}
|
|
6404
|
+
sources.set(name, source);
|
|
6405
|
+
};
|
|
6406
|
+
for (const program of requestedPrograms) {
|
|
6407
|
+
mergeSource(program.programName, program.programSource);
|
|
6408
|
+
editions.set(program.programName, program.edition);
|
|
6409
|
+
}
|
|
6410
|
+
// Treat every explicitly requested program as already known while
|
|
6411
|
+
// resolving imports for its siblings. Otherwise, a requested program
|
|
6412
|
+
// that statically imports another requested program would fetch that
|
|
6413
|
+
// sibling from the network again and could conflict with the source
|
|
6414
|
+
// supplied by the caller.
|
|
6415
|
+
const knownProgramSources = {
|
|
6416
|
+
...Object.fromEntries(requestedPrograms.map((program) => [
|
|
6417
|
+
program.programName,
|
|
6418
|
+
program.programSource,
|
|
6419
|
+
])),
|
|
6420
|
+
...(options.programImports ?? {}),
|
|
6421
|
+
};
|
|
6422
|
+
const collectedImports = await Promise.all(requestedPrograms.map((program) => this.collectProgramImports(program.programSource, knownProgramSources, true)));
|
|
6423
|
+
for (const imports of collectedImports) {
|
|
6424
|
+
for (const [name, source] of imports)
|
|
6425
|
+
mergeSource(name, source);
|
|
6426
|
+
}
|
|
6427
|
+
const functions = new Map();
|
|
6428
|
+
const staticImports = new Map();
|
|
6429
|
+
for (const [name, source] of sources) {
|
|
6430
|
+
const parsed = Program.fromString(source);
|
|
6431
|
+
try {
|
|
6432
|
+
if (parsed.id() !== name) {
|
|
6433
|
+
throw new Error(`Program source ID '${parsed.id()}' does not match supplied program name '${name}'`);
|
|
6434
|
+
}
|
|
6435
|
+
functions.set(name, Object.freeze(Array.from(parsed.getFunctions())));
|
|
6436
|
+
staticImports.set(name, Object.freeze(Array.from(parsed.getImports())));
|
|
6437
|
+
}
|
|
6438
|
+
finally {
|
|
6439
|
+
parsed.free();
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
for (const [name, imports] of staticImports) {
|
|
6443
|
+
for (const importedName of imports) {
|
|
6444
|
+
if (importedName !== CREDITS_PROGRAM_ID && !sources.has(importedName)) {
|
|
6445
|
+
throw new Error(`Missing import '${importedName}' required by program '${name}'`);
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
await Promise.all(Array.from(sources.keys()).map(async (name) => {
|
|
6450
|
+
if (!editions.has(name)) {
|
|
6451
|
+
editions.set(name, (await this.resolveEditionAndAmendment(name)).edition);
|
|
6452
|
+
}
|
|
6453
|
+
}));
|
|
6454
|
+
const sortedNames = [];
|
|
6455
|
+
const visited = new Set();
|
|
6456
|
+
const visiting = new Set();
|
|
6457
|
+
const visit = (name) => {
|
|
6458
|
+
if (visited.has(name))
|
|
6459
|
+
return;
|
|
6460
|
+
if (visiting.has(name)) {
|
|
6461
|
+
throw new Error(`Cyclic program imports include '${name}'`);
|
|
6462
|
+
}
|
|
6463
|
+
visiting.add(name);
|
|
6464
|
+
for (const dependency of staticImports.get(name) ?? []) {
|
|
6465
|
+
if (sources.has(dependency))
|
|
6466
|
+
visit(dependency);
|
|
6467
|
+
}
|
|
6468
|
+
visiting.delete(name);
|
|
6469
|
+
visited.add(name);
|
|
6470
|
+
sortedNames.push(name);
|
|
6471
|
+
};
|
|
6472
|
+
for (const name of sources.keys())
|
|
6473
|
+
visit(name);
|
|
6474
|
+
const builder = new ProgramImports();
|
|
6475
|
+
try {
|
|
6476
|
+
for (const name of sortedNames) {
|
|
6477
|
+
builder.addProgram(name, sources.get(name), editions.get(name));
|
|
6478
|
+
}
|
|
6479
|
+
}
|
|
6480
|
+
catch (e) {
|
|
6481
|
+
builder.free();
|
|
6482
|
+
throw e;
|
|
6483
|
+
}
|
|
6484
|
+
const processPrograms = sortedNames.map((name) => ({
|
|
6485
|
+
programName: name,
|
|
6486
|
+
programSource: sources.get(name),
|
|
6487
|
+
edition: editions.get(name),
|
|
6488
|
+
functions: functions.get(name),
|
|
6489
|
+
}));
|
|
6490
|
+
const preparedProcess = new PreparedProcess(processPrograms);
|
|
6491
|
+
preparedContextBuilders.set(preparedProcess, builder);
|
|
6492
|
+
preparedProcessPrograms.set(preparedProcess, new Map(preparedProcess.programs.map((program) => [program.programName, program])));
|
|
6493
|
+
return preparedProcess;
|
|
6494
|
+
}
|
|
6162
6495
|
validatePreparedProgram(preparedProgram, options) {
|
|
6163
6496
|
if (preparedProgram.programName !== options.programName
|
|
6164
6497
|
|| preparedProgram.functionName !== options.functionName) {
|
|
@@ -6176,18 +6509,65 @@ class ProgramManager {
|
|
|
6176
6509
|
throw new Error("Prepared program edition does not match the supplied edition");
|
|
6177
6510
|
}
|
|
6178
6511
|
if (options.programImports) {
|
|
6179
|
-
const
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6512
|
+
const importSources = preparedProgramImports.get(preparedProgram);
|
|
6513
|
+
if (!importSources || !preparedContextBuilders.has(preparedProgram)) {
|
|
6514
|
+
throw new Error("Prepared program has already been freed");
|
|
6515
|
+
}
|
|
6516
|
+
for (const [name, source] of Object.entries(options.programImports)) {
|
|
6517
|
+
if (importSources.get(name) !== normalizeProgramSource(source)) {
|
|
6518
|
+
throw new Error(`Prepared program import '${name}' does not match the supplied import`);
|
|
6185
6519
|
}
|
|
6186
6520
|
}
|
|
6187
|
-
|
|
6188
|
-
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
validatePreparedProcess(preparedProcess, options) {
|
|
6524
|
+
const programs = preparedProcessPrograms.get(preparedProcess);
|
|
6525
|
+
if (!programs || !preparedContextBuilders.has(preparedProcess)) {
|
|
6526
|
+
throw new Error("Prepared process has already been freed");
|
|
6527
|
+
}
|
|
6528
|
+
const program = programs.get(options.programName);
|
|
6529
|
+
if (!program) {
|
|
6530
|
+
throw new Error(`Prepared process does not contain program '${options.programName}'`);
|
|
6531
|
+
}
|
|
6532
|
+
if (!program.functions.includes(options.functionName)) {
|
|
6533
|
+
throw new Error(`Prepared process does not contain function '${options.programName}/${options.functionName}'`);
|
|
6534
|
+
}
|
|
6535
|
+
if (options.programSource !== undefined
|
|
6536
|
+
&& normalizeProgramSource(options.programSource) !== program.programSource) {
|
|
6537
|
+
throw new Error("Prepared process source does not match the supplied program source");
|
|
6538
|
+
}
|
|
6539
|
+
if (options.edition !== undefined && options.edition !== program.edition) {
|
|
6540
|
+
throw new Error("Prepared process edition does not match the supplied edition");
|
|
6541
|
+
}
|
|
6542
|
+
if (options.programImports) {
|
|
6543
|
+
for (const [name, source] of Object.entries(options.programImports)) {
|
|
6544
|
+
if (!preparedProcessHasCompatibleImport(programs, name, source)) {
|
|
6545
|
+
throw new Error(`Prepared process import '${name}' does not match a loaded program`);
|
|
6546
|
+
}
|
|
6189
6547
|
}
|
|
6190
6548
|
}
|
|
6549
|
+
return program;
|
|
6550
|
+
}
|
|
6551
|
+
preparedCallContext(options) {
|
|
6552
|
+
const context = selectedPreparedContext(options);
|
|
6553
|
+
if (!context)
|
|
6554
|
+
return undefined;
|
|
6555
|
+
if (context instanceof PreparedProcess) {
|
|
6556
|
+
const program = this.validatePreparedProcess(context, options);
|
|
6557
|
+
return {
|
|
6558
|
+
context,
|
|
6559
|
+
programName: program.programName,
|
|
6560
|
+
programSource: program.programSource,
|
|
6561
|
+
edition: program.edition,
|
|
6562
|
+
};
|
|
6563
|
+
}
|
|
6564
|
+
this.validatePreparedProgram(context, options);
|
|
6565
|
+
return {
|
|
6566
|
+
context,
|
|
6567
|
+
programName: context.programName,
|
|
6568
|
+
programSource: context.programSource,
|
|
6569
|
+
edition: context.edition,
|
|
6570
|
+
};
|
|
6191
6571
|
}
|
|
6192
6572
|
/**
|
|
6193
6573
|
* Collect static imports declared by the entry program together with any
|
|
@@ -6516,7 +6896,7 @@ class ProgramManager {
|
|
|
6516
6896
|
* import { ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
6517
6897
|
*
|
|
6518
6898
|
* // Create a ProgramManager
|
|
6519
|
-
* const programManager = new ProgramManager("https://
|
|
6899
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2");
|
|
6520
6900
|
*
|
|
6521
6901
|
* // Set the value of the `Accept-Language` header to `en-US`
|
|
6522
6902
|
* programManager.setHeader('Accept-Language', 'en-US');
|
|
@@ -6537,7 +6917,7 @@ class ProgramManager {
|
|
|
6537
6917
|
* keyProvider.useCache(true);
|
|
6538
6918
|
*
|
|
6539
6919
|
* // Create a ProgramManager
|
|
6540
|
-
* const programManager = new ProgramManager("https://
|
|
6920
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
6541
6921
|
*
|
|
6542
6922
|
* // Set the inclusion keys.
|
|
6543
6923
|
* programManager.setInclusionProver();
|
|
@@ -6571,7 +6951,7 @@ class ProgramManager {
|
|
|
6571
6951
|
* import { ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
6572
6952
|
*
|
|
6573
6953
|
* // Create a ProgramManager
|
|
6574
|
-
* const programManager = new ProgramManager("https://
|
|
6954
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2");
|
|
6575
6955
|
*
|
|
6576
6956
|
* // Remove the default `X-Aleo-SDK-Version` header
|
|
6577
6957
|
* programManager.removeHeader('X-Aleo-SDK-Version');
|
|
@@ -6601,7 +6981,7 @@ class ProgramManager {
|
|
|
6601
6981
|
*
|
|
6602
6982
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
6603
6983
|
* 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";
|
|
6604
|
-
* const programManager = new ProgramManager("https://
|
|
6984
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6605
6985
|
* programManager.setAccount(Account);
|
|
6606
6986
|
*
|
|
6607
6987
|
* // Define a fee in credits
|
|
@@ -6713,7 +7093,7 @@ class ProgramManager {
|
|
|
6713
7093
|
*
|
|
6714
7094
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
6715
7095
|
* 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";
|
|
6716
|
-
* const programManager = new ProgramManager("https://
|
|
7096
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6717
7097
|
* programManager.setAccount(Account);
|
|
6718
7098
|
*
|
|
6719
7099
|
* // Define a fee in credits
|
|
@@ -6831,7 +7211,7 @@ class ProgramManager {
|
|
|
6831
7211
|
*
|
|
6832
7212
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
6833
7213
|
* 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";
|
|
6834
|
-
* const programManager = new ProgramManager("https://
|
|
7214
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6835
7215
|
*
|
|
6836
7216
|
* // Define a fee in credits
|
|
6837
7217
|
* const priorityFee = 0.0;
|
|
@@ -6879,7 +7259,7 @@ class ProgramManager {
|
|
|
6879
7259
|
* keyProvider.useCache(true);
|
|
6880
7260
|
*
|
|
6881
7261
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
6882
|
-
* const programManager = new ProgramManager("https://
|
|
7262
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6883
7263
|
*
|
|
6884
7264
|
* // Build and execute the transaction
|
|
6885
7265
|
* const tx = await programManager.buildExecutionTransaction({
|
|
@@ -7036,7 +7416,7 @@ class ProgramManager {
|
|
|
7036
7416
|
* keyProvider.useCache(true);
|
|
7037
7417
|
*
|
|
7038
7418
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
7039
|
-
* const programManager = new ProgramManager("https://
|
|
7419
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
7040
7420
|
*
|
|
7041
7421
|
* // Build the `Authorization`.
|
|
7042
7422
|
* const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
@@ -7174,7 +7554,7 @@ class ProgramManager {
|
|
|
7174
7554
|
* keyProvider.useCache(true);
|
|
7175
7555
|
*
|
|
7176
7556
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7177
|
-
* const programManager = new ProgramManager("https://
|
|
7557
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7178
7558
|
*
|
|
7179
7559
|
* // Build the `Authorization`.
|
|
7180
7560
|
* const authorization = await programManager.buildAuthorization({
|
|
@@ -7189,15 +7569,12 @@ class ProgramManager {
|
|
|
7189
7569
|
async buildAuthorization(options) {
|
|
7190
7570
|
// Destructure the options object to access the parameters.
|
|
7191
7571
|
const { functionName, inputs, } = options;
|
|
7192
|
-
const
|
|
7193
|
-
if (preparedProgram) {
|
|
7194
|
-
this.validatePreparedProgram(preparedProgram, options);
|
|
7195
|
-
}
|
|
7572
|
+
const preparedCall = this.preparedCallContext(options);
|
|
7196
7573
|
const privateKey = options.privateKey;
|
|
7197
|
-
let program =
|
|
7198
|
-
let programName =
|
|
7574
|
+
let program = preparedCall?.programSource ?? options.programSource;
|
|
7575
|
+
let programName = preparedCall?.programName ?? options.programName;
|
|
7199
7576
|
const imports = options.programImports;
|
|
7200
|
-
let edition =
|
|
7577
|
+
let edition = preparedCall?.edition ?? options.edition;
|
|
7201
7578
|
// Ensure the function exists on the network.
|
|
7202
7579
|
if (program === undefined) {
|
|
7203
7580
|
try {
|
|
@@ -7223,7 +7600,7 @@ class ProgramManager {
|
|
|
7223
7600
|
if (typeof executionPrivateKey === "undefined") {
|
|
7224
7601
|
throw "No private key provided and no private key set in the ProgramManager";
|
|
7225
7602
|
}
|
|
7226
|
-
if (!
|
|
7603
|
+
if (!preparedCall) {
|
|
7227
7604
|
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7228
7605
|
edition = edition ?? resolved.edition;
|
|
7229
7606
|
}
|
|
@@ -7231,13 +7608,13 @@ class ProgramManager {
|
|
|
7231
7608
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7232
7609
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7233
7610
|
// authorizations don't synthesize keys).
|
|
7234
|
-
const builder =
|
|
7235
|
-
?
|
|
7611
|
+
const builder = preparedCall
|
|
7612
|
+
? clonePreparedContextBuilder(preparedCall.context)
|
|
7236
7613
|
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7237
|
-
const
|
|
7238
|
-
const hasImports = !builder.isEmpty();
|
|
7614
|
+
const hasPreparedContext = preparedCall !== undefined;
|
|
7615
|
+
const hasImports = !hasPreparedContext && !builder.isEmpty();
|
|
7239
7616
|
// Build and return an `Authorization` for the desired function.
|
|
7240
|
-
const authorization = await ProgramManager$1.authorize(executionPrivateKey, program, functionName, preparedInputs,
|
|
7617
|
+
const authorization = await withPreparedContextWasm(preparedCall?.context, () => ProgramManager$1.authorize(executionPrivateKey, program, functionName, preparedInputs, hasPreparedContext || hasImports ? undefined : imports, edition, hasPreparedContext ? builder : hasImports ? builder.clone() : undefined));
|
|
7241
7618
|
return authorization;
|
|
7242
7619
|
}
|
|
7243
7620
|
/**
|
|
@@ -7256,7 +7633,7 @@ class ProgramManager {
|
|
|
7256
7633
|
* keyProvider.useCache(true);
|
|
7257
7634
|
*
|
|
7258
7635
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7259
|
-
* const programManager = new ProgramManager("https://
|
|
7636
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7260
7637
|
*
|
|
7261
7638
|
* // Build the unchecked `Authorization`.
|
|
7262
7639
|
* const authorization = await programManager.buildAuthorizationUnchecked({
|
|
@@ -7271,15 +7648,12 @@ class ProgramManager {
|
|
|
7271
7648
|
async buildAuthorizationUnchecked(options) {
|
|
7272
7649
|
// Destructure the options object to access the parameters.
|
|
7273
7650
|
const { functionName, inputs, } = options;
|
|
7274
|
-
const
|
|
7275
|
-
if (preparedProgram) {
|
|
7276
|
-
this.validatePreparedProgram(preparedProgram, options);
|
|
7277
|
-
}
|
|
7651
|
+
const preparedCall = this.preparedCallContext(options);
|
|
7278
7652
|
const privateKey = options.privateKey;
|
|
7279
|
-
let program =
|
|
7280
|
-
let programName =
|
|
7653
|
+
let program = preparedCall?.programSource ?? options.programSource;
|
|
7654
|
+
let programName = preparedCall?.programName ?? options.programName;
|
|
7281
7655
|
const imports = options.programImports;
|
|
7282
|
-
let edition =
|
|
7656
|
+
let edition = preparedCall?.edition ?? options.edition;
|
|
7283
7657
|
// Ensure the function exists on the network.
|
|
7284
7658
|
if (program === undefined) {
|
|
7285
7659
|
try {
|
|
@@ -7305,7 +7679,7 @@ class ProgramManager {
|
|
|
7305
7679
|
if (typeof executionPrivateKey === "undefined") {
|
|
7306
7680
|
throw "No private key provided and no private key set in the ProgramManager";
|
|
7307
7681
|
}
|
|
7308
|
-
if (!
|
|
7682
|
+
if (!preparedCall) {
|
|
7309
7683
|
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7310
7684
|
edition = edition ?? resolved.edition;
|
|
7311
7685
|
}
|
|
@@ -7313,13 +7687,13 @@ class ProgramManager {
|
|
|
7313
7687
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7314
7688
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7315
7689
|
// authorizations don't synthesize keys).
|
|
7316
|
-
const builder =
|
|
7317
|
-
?
|
|
7690
|
+
const builder = preparedCall
|
|
7691
|
+
? clonePreparedContextBuilder(preparedCall.context)
|
|
7318
7692
|
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7319
|
-
const
|
|
7320
|
-
const hasImports = !builder.isEmpty();
|
|
7693
|
+
const hasPreparedContext = preparedCall !== undefined;
|
|
7694
|
+
const hasImports = !hasPreparedContext && !builder.isEmpty();
|
|
7321
7695
|
// Build and return an `Authorization` for the desired function.
|
|
7322
|
-
const authorization = await ProgramManager$1.buildAuthorizationUnchecked(executionPrivateKey, program, functionName, preparedInputs,
|
|
7696
|
+
const authorization = await withPreparedContextWasm(preparedCall?.context, () => ProgramManager$1.buildAuthorizationUnchecked(executionPrivateKey, program, functionName, preparedInputs, hasPreparedContext || hasImports ? undefined : imports, edition, hasPreparedContext ? builder : hasImports ? builder.clone() : undefined));
|
|
7323
7697
|
return authorization;
|
|
7324
7698
|
}
|
|
7325
7699
|
/**
|
|
@@ -7338,7 +7712,7 @@ class ProgramManager {
|
|
|
7338
7712
|
* keyProvider.useCache(true);
|
|
7339
7713
|
*
|
|
7340
7714
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7341
|
-
* const programManager = new ProgramManager("https://
|
|
7715
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7342
7716
|
*
|
|
7343
7717
|
* // Build the proving request.
|
|
7344
7718
|
* const provingRequest = await programManager.provingRequest({
|
|
@@ -7356,18 +7730,15 @@ class ProgramManager {
|
|
|
7356
7730
|
async provingRequest(options) {
|
|
7357
7731
|
// Destructure the options object to access the parameters.
|
|
7358
7732
|
const { functionName, priorityFee, privateFee, inputs, recordSearchParams, broadcast = false, unchecked = false, } = options;
|
|
7359
|
-
const
|
|
7360
|
-
if (preparedProgram) {
|
|
7361
|
-
this.validatePreparedProgram(preparedProgram, options);
|
|
7362
|
-
}
|
|
7733
|
+
const preparedCall = this.preparedCallContext(options);
|
|
7363
7734
|
const baseFee = options.baseFee ? options.baseFee : 0;
|
|
7364
7735
|
const privateKey = options.privateKey;
|
|
7365
7736
|
const useFeeMaster = options.useFeeMaster ? options.useFeeMaster : false;
|
|
7366
|
-
let program =
|
|
7367
|
-
let programName =
|
|
7737
|
+
let program = preparedCall?.programSource ?? options.programSource;
|
|
7738
|
+
let programName = preparedCall?.programName ?? options.programName;
|
|
7368
7739
|
let feeRecord = options.feeRecord;
|
|
7369
7740
|
let imports = options.programImports;
|
|
7370
|
-
let edition =
|
|
7741
|
+
let edition = preparedCall?.edition ?? options.edition;
|
|
7371
7742
|
if (!inputs && !options.executionRequest) {
|
|
7372
7743
|
throw new Error("Either function inputs or an execution request must be provided to form a proving request");
|
|
7373
7744
|
}
|
|
@@ -7387,7 +7758,7 @@ class ProgramManager {
|
|
|
7387
7758
|
if (programName === undefined) {
|
|
7388
7759
|
programName = Program.fromString(program).id();
|
|
7389
7760
|
}
|
|
7390
|
-
if (!
|
|
7761
|
+
if (!preparedCall) {
|
|
7391
7762
|
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7392
7763
|
edition = edition ?? resolved.edition;
|
|
7393
7764
|
}
|
|
@@ -7399,8 +7770,8 @@ class ProgramManager {
|
|
|
7399
7770
|
executionPrivateKey = this.account.privateKey();
|
|
7400
7771
|
}
|
|
7401
7772
|
// Resolve the program imports if they exist.
|
|
7402
|
-
const numberOfImports =
|
|
7403
|
-
if (!
|
|
7773
|
+
const numberOfImports = ProgramManager.getImportNames(program).length;
|
|
7774
|
+
if (!preparedCall && numberOfImports > 0 && !imports) {
|
|
7404
7775
|
try {
|
|
7405
7776
|
imports = (await this.networkClient.getProgramImports(programName));
|
|
7406
7777
|
}
|
|
@@ -7410,33 +7781,19 @@ class ProgramManager {
|
|
|
7410
7781
|
}
|
|
7411
7782
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7412
7783
|
// proving requests don't synthesize keys).
|
|
7413
|
-
const builder =
|
|
7414
|
-
?
|
|
7784
|
+
const builder = preparedCall
|
|
7785
|
+
? clonePreparedContextBuilder(preparedCall.context)
|
|
7415
7786
|
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7416
|
-
const
|
|
7417
|
-
const hasImports = !builder.isEmpty();
|
|
7418
|
-
|
|
7419
|
-
// both the private-fee estimate below and the Rust-side fee estimator
|
|
7420
|
-
// (estimate_fee_for_authorization uses the legacy imports Object to
|
|
7421
|
-
// avoid a RefCell double-borrow — see proving_request.rs) see all
|
|
7422
|
-
// transitive imports, not just the caller's partial set. Use
|
|
7423
|
-
// programNames + getProgram to avoid serializing key bytes (toObject
|
|
7424
|
-
// would serialize all proving/verifying keys, which can be tens of
|
|
7425
|
-
// MB). The prepared executionRequest path skips the copy: it passes
|
|
7426
|
-
// the process builder directly and never estimates fees, so the
|
|
7427
|
-
// imports Object goes unused there.
|
|
7428
|
-
const importsObjectUnused = hasPreparedProcess
|
|
7429
|
-
&& options.executionRequest instanceof ExecutionRequest;
|
|
7430
|
-
if ((hasPreparedProcess || hasImports) && !importsObjectUnused) {
|
|
7431
|
-
imports = programImportsFromBuilder(builder, programName);
|
|
7432
|
-
}
|
|
7787
|
+
const hasPreparedContext = preparedCall !== undefined;
|
|
7788
|
+
const hasImports = !hasPreparedContext && !builder.isEmpty();
|
|
7789
|
+
const hasProcessBuilder = hasPreparedContext || hasImports;
|
|
7433
7790
|
// Get the fee record from the account if it is not provided in the parameters
|
|
7434
7791
|
try {
|
|
7435
7792
|
if (privateFee && !useFeeMaster && !options.executionRequest) {
|
|
7436
7793
|
let fee = priorityFee;
|
|
7437
7794
|
// If a fee record wasn't provided, estimate the fee that needs to be paid.
|
|
7438
7795
|
if (!feeRecord) {
|
|
7439
|
-
const baseFee = Number(await
|
|
7796
|
+
const baseFee = Number(await withPreparedContextWasm(preparedCall?.context, async () => ProgramManager$1.estimateExecutionFee(program, functionName, hasProcessBuilder ? undefined : imports, edition, hasProcessBuilder ? builder.clone() : undefined)));
|
|
7440
7797
|
fee = baseFee + priorityFee;
|
|
7441
7798
|
}
|
|
7442
7799
|
// Get a credits.aleo record for the fee.
|
|
@@ -7451,10 +7808,7 @@ class ProgramManager {
|
|
|
7451
7808
|
logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
|
|
7452
7809
|
}
|
|
7453
7810
|
if (options.executionRequest instanceof ExecutionRequest) {
|
|
7454
|
-
return await ProgramManager$1.buildProvingRequestFromExecutionRequest(options.executionRequest, program, unchecked, broadcast, edition,
|
|
7455
|
-
// The prepared process supersedes the legacy imports Object;
|
|
7456
|
-
// without one, imports is kept for fee estimation in Rust.
|
|
7457
|
-
hasPreparedProcess ? undefined : imports, executionPrivateKey, hasPreparedProcess ? builder : hasImports ? builder.clone() : undefined);
|
|
7811
|
+
return await withPreparedContextWasm(preparedCall?.context, () => ProgramManager$1.buildProvingRequestFromExecutionRequest(options.executionRequest, program, unchecked, broadcast, edition, hasProcessBuilder ? undefined : imports, executionPrivateKey, hasPreparedContext ? builder : hasImports ? builder.clone() : undefined));
|
|
7458
7812
|
}
|
|
7459
7813
|
else {
|
|
7460
7814
|
// Ensure the private key exists.
|
|
@@ -7468,8 +7822,7 @@ class ProgramManager {
|
|
|
7468
7822
|
// Auto-convert bare string inputs to field elements where the function expects field type.
|
|
7469
7823
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7470
7824
|
// Build and return the `ProvingRequest`.
|
|
7471
|
-
return await ProgramManager$1.buildProvingRequest(executionPrivateKey, program, functionName, preparedInputs, baseFee, priorityFee, feeRecord, imports,
|
|
7472
|
-
broadcast, unchecked, edition, useFeeMaster, hasPreparedProcess ? builder : hasImports ? builder.clone() : undefined);
|
|
7825
|
+
return await withPreparedContextWasm(preparedCall?.context, () => ProgramManager$1.buildProvingRequest(executionPrivateKey, program, functionName, preparedInputs, baseFee, priorityFee, feeRecord, hasProcessBuilder ? undefined : imports, broadcast, unchecked, edition, useFeeMaster, hasPreparedContext ? builder : hasImports ? builder.clone() : undefined));
|
|
7473
7826
|
}
|
|
7474
7827
|
}
|
|
7475
7828
|
/**
|
|
@@ -7488,7 +7841,7 @@ class ProgramManager {
|
|
|
7488
7841
|
* keyProvider.useCache(true);
|
|
7489
7842
|
*
|
|
7490
7843
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7491
|
-
* const programManager = new ProgramManager("https://
|
|
7844
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7492
7845
|
*
|
|
7493
7846
|
* // Build a credits.aleo/fee_public `Authorization`.
|
|
7494
7847
|
* const feePublicAuthorization = await programManager.buildFeeAuthorization({
|
|
@@ -7535,7 +7888,7 @@ class ProgramManager {
|
|
|
7535
7888
|
* keyProvider.useCache(true);
|
|
7536
7889
|
*
|
|
7537
7890
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7538
|
-
* const programManager = new ProgramManager("https://
|
|
7891
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7539
7892
|
*
|
|
7540
7893
|
* // Build and execute the transaction
|
|
7541
7894
|
* const tx_id = await programManager.execute({
|
|
@@ -7710,7 +8063,7 @@ class ProgramManager {
|
|
|
7710
8063
|
* keyProvider.useCache(true);
|
|
7711
8064
|
*
|
|
7712
8065
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7713
|
-
* const programManager = new ProgramManager("https://
|
|
8066
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7714
8067
|
* const record_1 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
|
|
7715
8068
|
* const record_2 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 1540945439182663264862696551825005342995406165131907382295858612069623286213group.public}"
|
|
7716
8069
|
* const tx_id = await programManager.join(record_1, record_2, 0.05, false);
|
|
@@ -7817,7 +8170,7 @@ class ProgramManager {
|
|
|
7817
8170
|
* keyProvider.useCache(true);
|
|
7818
8171
|
*
|
|
7819
8172
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7820
|
-
* const programManager = new ProgramManager("https://
|
|
8173
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7821
8174
|
* const record = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
|
|
7822
8175
|
* const tx_id = await programManager.split(25000000, record);
|
|
7823
8176
|
*
|
|
@@ -7928,7 +8281,7 @@ class ProgramManager {
|
|
|
7928
8281
|
* keyProvider.useCache(true);
|
|
7929
8282
|
*
|
|
7930
8283
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7931
|
-
* const programManager = new ProgramManager("https://
|
|
8284
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7932
8285
|
* const tx = await programManager.buildTransferTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
|
|
7933
8286
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
7934
8287
|
*
|
|
@@ -8017,7 +8370,7 @@ class ProgramManager {
|
|
|
8017
8370
|
* keyProvider.useCache(true);
|
|
8018
8371
|
*
|
|
8019
8372
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
8020
|
-
* const programManager = new ProgramManager("https://
|
|
8373
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
8021
8374
|
* const tx = await programManager.buildTransferPublicTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
|
|
8022
8375
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
8023
8376
|
*
|
|
@@ -8050,7 +8403,7 @@ class ProgramManager {
|
|
|
8050
8403
|
* keyProvider.useCache(true);
|
|
8051
8404
|
*
|
|
8052
8405
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
8053
|
-
* const programManager = new ProgramManager("https://
|
|
8406
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
8054
8407
|
* const tx = await programManager.buildTransferPublicAsSignerTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
|
|
8055
8408
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
8056
8409
|
*
|
|
@@ -8088,7 +8441,7 @@ class ProgramManager {
|
|
|
8088
8441
|
* keyProvider.useCache(true);
|
|
8089
8442
|
*
|
|
8090
8443
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
8091
|
-
* const programManager = new ProgramManager("https://
|
|
8444
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
8092
8445
|
* const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
|
|
8093
8446
|
*
|
|
8094
8447
|
* // Verify the transaction was successful
|
|
@@ -8133,7 +8486,7 @@ class ProgramManager {
|
|
|
8133
8486
|
* keyProvider.useCache(true);
|
|
8134
8487
|
*
|
|
8135
8488
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8136
|
-
* const programManager = new ProgramManager("https://
|
|
8489
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8137
8490
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8138
8491
|
*
|
|
8139
8492
|
* // Create the bonding transaction object for later submission
|
|
@@ -8189,7 +8542,7 @@ class ProgramManager {
|
|
|
8189
8542
|
* keyProvider.useCache(true);
|
|
8190
8543
|
*
|
|
8191
8544
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8192
|
-
* const programManager = new ProgramManager("https://
|
|
8545
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8193
8546
|
*
|
|
8194
8547
|
* // Create the bonding transaction
|
|
8195
8548
|
* tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
|
|
@@ -8237,7 +8590,7 @@ class ProgramManager {
|
|
|
8237
8590
|
* keyProvider.useCache(true);
|
|
8238
8591
|
*
|
|
8239
8592
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8240
|
-
* const programManager = new ProgramManager("https://
|
|
8593
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8241
8594
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8242
8595
|
*
|
|
8243
8596
|
* // Create the bond validator transaction object for later use.
|
|
@@ -8296,7 +8649,7 @@ class ProgramManager {
|
|
|
8296
8649
|
* keyProvider.useCache(true);
|
|
8297
8650
|
*
|
|
8298
8651
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8299
|
-
* const programManager = new ProgramManager("https://
|
|
8652
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8300
8653
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8301
8654
|
*
|
|
8302
8655
|
* // Create the bonding transaction
|
|
@@ -8343,7 +8696,7 @@ class ProgramManager {
|
|
|
8343
8696
|
* keyProvider.useCache(true);
|
|
8344
8697
|
*
|
|
8345
8698
|
* // Create a new ProgramManager with the key that will be used to unbond credits.
|
|
8346
|
-
* const programManager = new ProgramManager("https://
|
|
8699
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8347
8700
|
* const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
|
|
8348
8701
|
*
|
|
8349
8702
|
* // The transaction can be submitted later to the network using the network client.
|
|
@@ -8396,7 +8749,7 @@ class ProgramManager {
|
|
|
8396
8749
|
* keyProvider.useCache(true);
|
|
8397
8750
|
*
|
|
8398
8751
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8399
|
-
* const programManager = new ProgramManager("https://
|
|
8752
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8400
8753
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8401
8754
|
*
|
|
8402
8755
|
* // Create the unbond_public transaction and send it to the network
|
|
@@ -8442,7 +8795,7 @@ class ProgramManager {
|
|
|
8442
8795
|
* keyProvider.useCache(true);
|
|
8443
8796
|
*
|
|
8444
8797
|
* // Create a new ProgramManager with the key that will be used to claim unbonded credits.
|
|
8445
|
-
* const programManager = new ProgramManager("https://
|
|
8798
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8446
8799
|
*
|
|
8447
8800
|
* // Create the claim_unbond_public transaction object for later use.
|
|
8448
8801
|
* const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
|
|
@@ -8492,7 +8845,7 @@ class ProgramManager {
|
|
|
8492
8845
|
* keyProvider.useCache(true);
|
|
8493
8846
|
*
|
|
8494
8847
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8495
|
-
* const programManager = new ProgramManager("https://
|
|
8848
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8496
8849
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8497
8850
|
*
|
|
8498
8851
|
* // Create the claim_unbond_public transaction
|
|
@@ -8546,7 +8899,7 @@ class ProgramManager {
|
|
|
8546
8899
|
* keyProvider.useCache(true);
|
|
8547
8900
|
*
|
|
8548
8901
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8549
|
-
* const programManager = new ProgramManager("https://
|
|
8902
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8550
8903
|
*
|
|
8551
8904
|
* // Create the set_validator_state transaction
|
|
8552
8905
|
* const tx = await programManager.buildSetValidatorStateTransaction(true);
|
|
@@ -8602,7 +8955,7 @@ class ProgramManager {
|
|
|
8602
8955
|
* keyProvider.useCache(true);
|
|
8603
8956
|
*
|
|
8604
8957
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8605
|
-
* const programManager = new ProgramManager("https://
|
|
8958
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8606
8959
|
*
|
|
8607
8960
|
* // Create the set_validator_state transaction
|
|
8608
8961
|
* const tx_id = await programManager.setValidatorState(true);
|
|
@@ -8724,7 +9077,7 @@ class ProgramManager {
|
|
|
8724
9077
|
* keyProvider.useCache(true);
|
|
8725
9078
|
*
|
|
8726
9079
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
8727
|
-
* const programManager = new ProgramManager("https://
|
|
9080
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
8728
9081
|
*
|
|
8729
9082
|
* // Build the `Authorization`.
|
|
8730
9083
|
* const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
@@ -8781,7 +9134,7 @@ class ProgramManager {
|
|
|
8781
9134
|
* import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
|
|
8782
9135
|
*
|
|
8783
9136
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
8784
|
-
* const programManager = new ProgramManager("https://
|
|
9137
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
8785
9138
|
*
|
|
8786
9139
|
* // Get the base fee in microcredits.
|
|
8787
9140
|
* const baseFeeMicrocredits = await programManager.estimateExecutionFee({programName: "credits.aleo"});
|
|
@@ -9519,5 +9872,5 @@ async function initializeWasm() {
|
|
|
9519
9872
|
logger.warn("initializeWasm is deprecated, you no longer need to use it");
|
|
9520
9873
|
}
|
|
9521
9874
|
|
|
9522
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, ApiAuth, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DEFAULT_API_KEY_HEADER, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PreparedProgram, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptSerializedProvingRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, normalizeAuthConfig, programChecksum, provingKeyLocator, serializeProvingRequest, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
9875
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, ApiAuth, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DEFAULT_API_KEY_HEADER, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PreparedProcess, PreparedProgram, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptSerializedProvingRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, normalizeAuthConfig, programChecksum, provingKeyLocator, serializeProvingRequest, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
9523
9876
|
//# sourceMappingURL=browser.js.map
|