@provablehq/sdk 0.11.8 → 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 -7
- package/dist/mainnet/api-auth.d.ts +14 -7
- package/dist/mainnet/browser.cjs +550 -193
- 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 +550 -194
- 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 -7
- package/dist/testnet/api-auth.d.ts +14 -7
- package/dist/testnet/browser.cjs +550 -193
- 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 +550 -194
- 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
|
}
|
|
@@ -1630,11 +1637,14 @@ class ApiAuth {
|
|
|
1630
1637
|
* both a usable token and the material to mint one.
|
|
1631
1638
|
*/
|
|
1632
1639
|
async headers() {
|
|
1633
|
-
if (this.config.mode === "none")
|
|
1634
|
-
return {};
|
|
1635
1640
|
if (this.config.mode === "api-key") {
|
|
1636
1641
|
return { [this.config.header ?? DEFAULT_API_KEY_HEADER]: this.config.value };
|
|
1637
1642
|
}
|
|
1643
|
+
if (this.config.mode === "none") {
|
|
1644
|
+
// A token injected via setJwtData authenticates even without mint
|
|
1645
|
+
// material: an external session owns minting and hands tokens in.
|
|
1646
|
+
return this.jwtData?.jwt ? { Authorization: this.jwtData.jwt } : {};
|
|
1647
|
+
}
|
|
1638
1648
|
const stale = !this.jwtData || Date.now() >= this.jwtData.expiration - FIVE_MINUTES;
|
|
1639
1649
|
if (stale) {
|
|
1640
1650
|
const { apiKey, consumerId } = this.config;
|
|
@@ -1712,7 +1722,7 @@ const HEADERS = new Set([
|
|
|
1712
1722
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
1713
1723
|
* const apiKey = process.env.apiKey;
|
|
1714
1724
|
* const consumerId = process.env.consumerId;
|
|
1715
|
-
* const publicNetworkClient = new AleoNetworkClient("https://
|
|
1725
|
+
* const publicNetworkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined, account);
|
|
1716
1726
|
*/
|
|
1717
1727
|
class AleoNetworkClient {
|
|
1718
1728
|
host;
|
|
@@ -1731,6 +1741,9 @@ class AleoNetworkClient {
|
|
|
1731
1741
|
// The consumer the cached jwtData was minted for, so the cache is never
|
|
1732
1742
|
// reused for a different identity on a shared client.
|
|
1733
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;
|
|
1734
1747
|
proverUri;
|
|
1735
1748
|
recordScannerUri;
|
|
1736
1749
|
constructor(host, options) {
|
|
@@ -1750,7 +1763,7 @@ class AleoNetworkClient {
|
|
|
1750
1763
|
else {
|
|
1751
1764
|
this.headers = {
|
|
1752
1765
|
// This is replaced by the actual version by a Rollup plugin
|
|
1753
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1766
|
+
"X-Aleo-SDK-Version": "0.11.10",
|
|
1754
1767
|
"X-Aleo-environment": environment(),
|
|
1755
1768
|
};
|
|
1756
1769
|
}
|
|
@@ -1772,7 +1785,7 @@ class AleoNetworkClient {
|
|
|
1772
1785
|
else {
|
|
1773
1786
|
this.headers = {
|
|
1774
1787
|
// This is replaced by the actual version by a Rollup plugin
|
|
1775
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1788
|
+
"X-Aleo-SDK-Version": "0.11.10",
|
|
1776
1789
|
"X-Aleo-environment": environment(),
|
|
1777
1790
|
};
|
|
1778
1791
|
}
|
|
@@ -1784,7 +1797,7 @@ class AleoNetworkClient {
|
|
|
1784
1797
|
* @example
|
|
1785
1798
|
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1786
1799
|
*
|
|
1787
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1800
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
1788
1801
|
* const account = new Account();
|
|
1789
1802
|
* networkClient.setAccount(account);
|
|
1790
1803
|
*/
|
|
@@ -1812,7 +1825,7 @@ class AleoNetworkClient {
|
|
|
1812
1825
|
* const networkClient = new AleoNetworkClient("http://0.0.0.0:3030", undefined);
|
|
1813
1826
|
*
|
|
1814
1827
|
* // Set the host to a public node.
|
|
1815
|
-
* networkClient.setHost("https://
|
|
1828
|
+
* networkClient.setHost("https://edge.provable.com/api/v2");
|
|
1816
1829
|
*/
|
|
1817
1830
|
setHost(host) {
|
|
1818
1831
|
this.host = host + "/mainnet";
|
|
@@ -1826,7 +1839,7 @@ class AleoNetworkClient {
|
|
|
1826
1839
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1827
1840
|
*
|
|
1828
1841
|
* // Create a networkClient that connects to the provable explorer api.
|
|
1829
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1842
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
1830
1843
|
*
|
|
1831
1844
|
* // Set the prover uri.
|
|
1832
1845
|
* networkClient.setProverUri("https://prover.provable.prove");
|
|
@@ -1843,7 +1856,7 @@ class AleoNetworkClient {
|
|
|
1843
1856
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1844
1857
|
*
|
|
1845
1858
|
* // Create a networkClient that connects to the provable explorer api.
|
|
1846
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1859
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
1847
1860
|
*
|
|
1848
1861
|
* // Set the record scanner uri.
|
|
1849
1862
|
* networkClient.setRecordScannerUri("https://scanner.provable.scan");
|
|
@@ -1971,7 +1984,7 @@ class AleoNetworkClient {
|
|
|
1971
1984
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
1972
1985
|
*
|
|
1973
1986
|
* // Create a network client.
|
|
1974
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
1987
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
1975
1988
|
* networkClient.setAccount(account);
|
|
1976
1989
|
*
|
|
1977
1990
|
* // Find specific amounts
|
|
@@ -2194,7 +2207,7 @@ class AleoNetworkClient {
|
|
|
2194
2207
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
2195
2208
|
*
|
|
2196
2209
|
* // Create a network client and set an account to search for records with.
|
|
2197
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2210
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2198
2211
|
* networkClient.setAccount(account);
|
|
2199
2212
|
*
|
|
2200
2213
|
* // Find specific amounts
|
|
@@ -2250,7 +2263,7 @@ class AleoNetworkClient {
|
|
|
2250
2263
|
* @example
|
|
2251
2264
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2252
2265
|
*
|
|
2253
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2266
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2254
2267
|
* const block = networkClient.getBlockByHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
2255
2268
|
*/
|
|
2256
2269
|
async getBlockByHash(blockHash) {
|
|
@@ -2308,7 +2321,7 @@ class AleoNetworkClient {
|
|
|
2308
2321
|
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
2309
2322
|
*
|
|
2310
2323
|
* // Get the transaction ID of the deployment transaction for a program.
|
|
2311
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2324
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2312
2325
|
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
2313
2326
|
*
|
|
2314
2327
|
* // Get the transaction data for the deployment transaction.
|
|
@@ -2343,7 +2356,7 @@ class AleoNetworkClient {
|
|
|
2343
2356
|
* import { AleoNetworkClient, DeploymentJSON } from "@provablehq/sdk/testnet.js";
|
|
2344
2357
|
*
|
|
2345
2358
|
* // Get the transaction ID of the deployment transaction for a program.
|
|
2346
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2359
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2347
2360
|
* const transaction = networkClient.getDeploymentTransactionForProgram("hello_hello.aleo");
|
|
2348
2361
|
*
|
|
2349
2362
|
* // Get the verifying keys for each function in the deployment.
|
|
@@ -2376,7 +2389,7 @@ class AleoNetworkClient {
|
|
|
2376
2389
|
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
2377
2390
|
*
|
|
2378
2391
|
* // Get the transaction ID of the deployment transaction for a program.
|
|
2379
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2392
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2380
2393
|
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
2381
2394
|
*
|
|
2382
2395
|
* // Get the transaction data for the deployment transaction.
|
|
@@ -2407,7 +2420,7 @@ class AleoNetworkClient {
|
|
|
2407
2420
|
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
2408
2421
|
*
|
|
2409
2422
|
* // Create a network client.
|
|
2410
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2423
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2411
2424
|
*
|
|
2412
2425
|
* const latestHeight = networkClient.getLatestBlock();
|
|
2413
2426
|
*/
|
|
@@ -2432,10 +2445,10 @@ class AleoNetworkClient {
|
|
|
2432
2445
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2433
2446
|
*
|
|
2434
2447
|
* // Create a network client.
|
|
2435
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2448
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2436
2449
|
*
|
|
2437
2450
|
* // Create a network client and get the latest committee.
|
|
2438
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2451
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2439
2452
|
* const latestCommittee = await networkClient.getLatestCommittee();
|
|
2440
2453
|
*/
|
|
2441
2454
|
async getLatestCommittee() {
|
|
@@ -2460,10 +2473,10 @@ class AleoNetworkClient {
|
|
|
2460
2473
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2461
2474
|
*
|
|
2462
2475
|
* // Create a network client.
|
|
2463
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2476
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2464
2477
|
*
|
|
2465
2478
|
* // Create a network client and get the committee for a specific block.
|
|
2466
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2479
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2467
2480
|
* const committee = await networkClient.getCommitteeByBlockHeight(1234);
|
|
2468
2481
|
*/
|
|
2469
2482
|
async getCommitteeByBlockHeight(blockHeight) {
|
|
@@ -2487,7 +2500,7 @@ class AleoNetworkClient {
|
|
|
2487
2500
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2488
2501
|
*
|
|
2489
2502
|
* // Create a network client.
|
|
2490
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2503
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2491
2504
|
*
|
|
2492
2505
|
* const latestHeight = networkClient.getLatestHeight();
|
|
2493
2506
|
*/
|
|
@@ -2531,7 +2544,7 @@ class AleoNetworkClient {
|
|
|
2531
2544
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2532
2545
|
*
|
|
2533
2546
|
* // Create a network client.
|
|
2534
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2547
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2535
2548
|
*
|
|
2536
2549
|
* // Get the latest block hash.
|
|
2537
2550
|
* const latestHash = networkClient.getLatestBlockHash();
|
|
@@ -2559,7 +2572,7 @@ class AleoNetworkClient {
|
|
|
2559
2572
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2560
2573
|
*
|
|
2561
2574
|
* // Create a network client.
|
|
2562
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2575
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2563
2576
|
*
|
|
2564
2577
|
* // Get the source code of a program.)
|
|
2565
2578
|
* @returns {Promise<string>} Source code of the program
|
|
@@ -2568,7 +2581,7 @@ class AleoNetworkClient {
|
|
|
2568
2581
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2569
2582
|
*
|
|
2570
2583
|
* // Create a network client.
|
|
2571
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2584
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2572
2585
|
*
|
|
2573
2586
|
* const program = networkClient.getProgram("hello_hello.aleo");
|
|
2574
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"
|
|
@@ -2601,7 +2614,7 @@ class AleoNetworkClient {
|
|
|
2601
2614
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2602
2615
|
*
|
|
2603
2616
|
* // Create a network client.
|
|
2604
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2617
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2605
2618
|
*
|
|
2606
2619
|
* const programVersion = networkClient.getLatestProgramEdition("hello_hello.aleo");
|
|
2607
2620
|
* assert.equal(programVersion, 1);
|
|
@@ -2626,7 +2639,7 @@ class AleoNetworkClient {
|
|
|
2626
2639
|
* @returns {{ program_id: string, edition: number, amendment_count: number }}
|
|
2627
2640
|
*
|
|
2628
2641
|
* @example
|
|
2629
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2642
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
2630
2643
|
* const info = await networkClient.getProgramAmendmentCount("hello_hello.aleo");
|
|
2631
2644
|
* console.log(info.edition, info.amendment_count);
|
|
2632
2645
|
*/
|
|
@@ -2654,7 +2667,7 @@ class AleoNetworkClient {
|
|
|
2654
2667
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2655
2668
|
*
|
|
2656
2669
|
* // Create a network client.
|
|
2657
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2670
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2658
2671
|
*
|
|
2659
2672
|
* const programID = "hello_hello.aleo";
|
|
2660
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"
|
|
@@ -2694,7 +2707,7 @@ class AleoNetworkClient {
|
|
|
2694
2707
|
* }
|
|
2695
2708
|
*
|
|
2696
2709
|
* // Create a network client.
|
|
2697
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2710
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2698
2711
|
*
|
|
2699
2712
|
* // Imports can be fetched using the program ID, source code, or program object
|
|
2700
2713
|
* let programImports = await networkClient.getProgramImports("double_test.aleo");
|
|
@@ -2764,7 +2777,7 @@ class AleoNetworkClient {
|
|
|
2764
2777
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2765
2778
|
*
|
|
2766
2779
|
* // Create a network client.
|
|
2767
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2780
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2768
2781
|
*
|
|
2769
2782
|
* const programImportsNames = networkClient.getProgramImports("wrapped_credits.aleo");
|
|
2770
2783
|
* const expectedImportsNames = ["credits.aleo"];
|
|
@@ -2795,7 +2808,7 @@ class AleoNetworkClient {
|
|
|
2795
2808
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2796
2809
|
*
|
|
2797
2810
|
* // Create a network client.
|
|
2798
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2811
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2799
2812
|
*
|
|
2800
2813
|
* const mappings = networkClient.getProgramMappingNames("credits.aleo");
|
|
2801
2814
|
* const expectedMappings = [
|
|
@@ -2833,7 +2846,7 @@ class AleoNetworkClient {
|
|
|
2833
2846
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2834
2847
|
*
|
|
2835
2848
|
* // Create a network client.
|
|
2836
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2849
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2837
2850
|
*
|
|
2838
2851
|
* // Get public balance of an account
|
|
2839
2852
|
* const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
@@ -2865,7 +2878,7 @@ class AleoNetworkClient {
|
|
|
2865
2878
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
2866
2879
|
*
|
|
2867
2880
|
* // Create a network client.
|
|
2868
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2881
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2869
2882
|
*
|
|
2870
2883
|
* // Get the bond state as an account.
|
|
2871
2884
|
* const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
@@ -2911,7 +2924,7 @@ class AleoNetworkClient {
|
|
|
2911
2924
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2912
2925
|
*
|
|
2913
2926
|
* // Create a network client.
|
|
2914
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2927
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2915
2928
|
*
|
|
2916
2929
|
* // Get the balance of an account from either an address object or address string.
|
|
2917
2930
|
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
@@ -2942,7 +2955,7 @@ class AleoNetworkClient {
|
|
|
2942
2955
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2943
2956
|
*
|
|
2944
2957
|
* // Create a network client.
|
|
2945
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2958
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2946
2959
|
*
|
|
2947
2960
|
* // Get the latest state root.
|
|
2948
2961
|
* const stateRoot = networkClient.getStateRoot();
|
|
@@ -2969,7 +2982,7 @@ class AleoNetworkClient {
|
|
|
2969
2982
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2970
2983
|
*
|
|
2971
2984
|
* // Create a network client.
|
|
2972
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
2985
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2973
2986
|
*
|
|
2974
2987
|
* const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
2975
2988
|
*/
|
|
@@ -2995,7 +3008,7 @@ class AleoNetworkClient {
|
|
|
2995
3008
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
2996
3009
|
*
|
|
2997
3010
|
* // Create a network client.
|
|
2998
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3011
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
2999
3012
|
*
|
|
3000
3013
|
* const transaction = networkClient.getConfirmedTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
3001
3014
|
* assert.equal(transaction.status, "confirmed");
|
|
@@ -3060,7 +3073,7 @@ class AleoNetworkClient {
|
|
|
3060
3073
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
3061
3074
|
*
|
|
3062
3075
|
* // Create a network client.
|
|
3063
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3076
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3064
3077
|
*
|
|
3065
3078
|
* const transactions = networkClient.getTransactions(654);
|
|
3066
3079
|
*/
|
|
@@ -3086,7 +3099,7 @@ class AleoNetworkClient {
|
|
|
3086
3099
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
3087
3100
|
*
|
|
3088
3101
|
* // Create a network client.
|
|
3089
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3102
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3090
3103
|
*
|
|
3091
3104
|
* const transactions = networkClient.getTransactionsByBlockHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
3092
3105
|
*/
|
|
@@ -3113,7 +3126,7 @@ class AleoNetworkClient {
|
|
|
3113
3126
|
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
3114
3127
|
*
|
|
3115
3128
|
* // Create a network client.
|
|
3116
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3129
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3117
3130
|
*
|
|
3118
3131
|
* // Get the current transactions in the mempool.
|
|
3119
3132
|
* const transactions = networkClient.getTransactionsInMempool();
|
|
@@ -3274,17 +3287,34 @@ class AleoNetworkClient {
|
|
|
3274
3287
|
if (options.auth && (options.apiKey !== undefined || options.consumerId !== undefined || options.jwtData !== undefined)) {
|
|
3275
3288
|
throw new Error("Pass either `auth` or the legacy apiKey/consumerId/jwtData options, not both");
|
|
3276
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;
|
|
3277
3305
|
const config = options.auth ?? this.auth ?? normalizeAuthConfig({
|
|
3278
3306
|
apiKey: options.apiKey ?? this.apiKey,
|
|
3279
3307
|
consumerId: options.consumerId ?? this.consumerId,
|
|
3280
|
-
jwtData: options.jwtData ??
|
|
3308
|
+
jwtData: options.jwtData ?? injectedJwt,
|
|
3281
3309
|
});
|
|
3282
|
-
const auth = new ApiAuth(config,
|
|
3283
|
-
//
|
|
3284
|
-
//
|
|
3285
|
-
// consumer that minted it
|
|
3286
|
-
// client never
|
|
3287
|
-
|
|
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) {
|
|
3288
3318
|
auth.setJwtData(this.jwtData);
|
|
3289
3319
|
}
|
|
3290
3320
|
// Resolves the auth headers, which refreshes the JWT when it is stale. Runs before
|
|
@@ -3293,7 +3323,12 @@ class AleoNetworkClient {
|
|
|
3293
3323
|
const jwtData = auth.getJwtData();
|
|
3294
3324
|
if (config.mode === "jwt" && jwtData) {
|
|
3295
3325
|
this.jwtData = jwtData;
|
|
3296
|
-
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
|
+
}
|
|
3297
3332
|
options.jwtData = jwtData;
|
|
3298
3333
|
}
|
|
3299
3334
|
// Create the necessary headers to hit the provable api.
|
|
@@ -3384,7 +3419,7 @@ class AleoNetworkClient {
|
|
|
3384
3419
|
* import { AleoNetworkClient, Account, ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
3385
3420
|
*
|
|
3386
3421
|
* // Create a network client and program manager.
|
|
3387
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3422
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2", undefined);
|
|
3388
3423
|
* const programManager = new ProgramManager(networkClient);
|
|
3389
3424
|
*
|
|
3390
3425
|
* // Set the account for the program manager.
|
|
@@ -3632,12 +3667,12 @@ class AleoKeyProvider {
|
|
|
3632
3667
|
*
|
|
3633
3668
|
* @example
|
|
3634
3669
|
* // Create a new object which implements the KeyProvider interface
|
|
3635
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3670
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
3636
3671
|
* const keyProvider = new AleoKeyProvider();
|
|
3637
3672
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3638
3673
|
*
|
|
3639
3674
|
* // Initialize a program manager with the key provider to automatically fetch keys for value transfers
|
|
3640
|
-
* const programManager = new ProgramManager("https://
|
|
3675
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
3641
3676
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3642
3677
|
*
|
|
3643
3678
|
* // Keys can also be fetched manually using the key provider
|
|
@@ -3684,12 +3719,12 @@ class AleoKeyProvider {
|
|
|
3684
3719
|
*
|
|
3685
3720
|
* @example
|
|
3686
3721
|
* // Create a new AleoKeyProvider object
|
|
3687
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3722
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
3688
3723
|
* const keyProvider = new AleoKeyProvider();
|
|
3689
3724
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3690
3725
|
*
|
|
3691
3726
|
* // Initialize a program manager with the key provider to automatically fetch keys for value transfers
|
|
3692
|
-
* const programManager = new ProgramManager("https://
|
|
3727
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
3693
3728
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3694
3729
|
*
|
|
3695
3730
|
* // Keys can also be fetched manually
|
|
@@ -3807,12 +3842,12 @@ class AleoKeyProvider {
|
|
|
3807
3842
|
*
|
|
3808
3843
|
* @example
|
|
3809
3844
|
* // Create a new AleoKeyProvider
|
|
3810
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
3845
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
3811
3846
|
* const keyProvider = new AleoKeyProvider();
|
|
3812
3847
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
3813
3848
|
*
|
|
3814
3849
|
* // Initialize a program manager with the key provider to automatically fetch keys for value transfers
|
|
3815
|
-
* const programManager = new ProgramManager("https://
|
|
3850
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
3816
3851
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
3817
3852
|
*
|
|
3818
3853
|
* // Keys can also be fetched manually
|
|
@@ -4157,7 +4192,7 @@ class OfflineSearchParams {
|
|
|
4157
4192
|
* const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction("hello_hello.aleo", "hello", 1, false, ["5u32", "5u32"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);
|
|
4158
4193
|
*
|
|
4159
4194
|
* // Broadcast the transaction later on a machine with internet access
|
|
4160
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4195
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4161
4196
|
* const txId = await networkClient.broadcastTransaction(offlineExecuteTx);
|
|
4162
4197
|
*/
|
|
4163
4198
|
class OfflineKeyProvider {
|
|
@@ -4617,7 +4652,7 @@ class NetworkRecordProvider {
|
|
|
4617
4652
|
*
|
|
4618
4653
|
* @example
|
|
4619
4654
|
* // Create a new NetworkRecordProvider
|
|
4620
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4655
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4621
4656
|
* const keyProvider = new AleoKeyProvider();
|
|
4622
4657
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
4623
4658
|
*
|
|
@@ -4630,7 +4665,7 @@ class NetworkRecordProvider {
|
|
|
4630
4665
|
*
|
|
4631
4666
|
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
4632
4667
|
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
4633
|
-
* const programManager = new ProgramManager("https://
|
|
4668
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
4634
4669
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
4635
4670
|
*
|
|
4636
4671
|
* */
|
|
@@ -4678,7 +4713,7 @@ class NetworkRecordProvider {
|
|
|
4678
4713
|
*
|
|
4679
4714
|
* @example
|
|
4680
4715
|
* // Create a new NetworkRecordProvider
|
|
4681
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4716
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4682
4717
|
* const keyProvider = new AleoKeyProvider();
|
|
4683
4718
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
4684
4719
|
*
|
|
@@ -4691,7 +4726,7 @@ class NetworkRecordProvider {
|
|
|
4691
4726
|
*
|
|
4692
4727
|
* // When the program manager is initialized with the record provider it will be used to find automatically find
|
|
4693
4728
|
* // fee records and amount records for value transfers so that they do not need to be specified manually
|
|
4694
|
-
* const programManager = new ProgramManager("https://
|
|
4729
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
4695
4730
|
* programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
|
|
4696
4731
|
*/
|
|
4697
4732
|
async findCreditsRecord(microcredits, searchParameters) {
|
|
@@ -4787,7 +4822,7 @@ class NetworkRecordProvider {
|
|
|
4787
4822
|
* const params = new BlockHeightSearch(89995, 99995);
|
|
4788
4823
|
*
|
|
4789
4824
|
* // Create a new NetworkRecordProvider
|
|
4790
|
-
* const networkClient = new AleoNetworkClient("https://
|
|
4825
|
+
* const networkClient = new AleoNetworkClient("https://edge.provable.com/api/v2");
|
|
4791
4826
|
* const keyProvider = new AleoKeyProvider();
|
|
4792
4827
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
4793
4828
|
*
|
|
@@ -4978,7 +5013,9 @@ class RecordScanner {
|
|
|
4978
5013
|
* @param {RecordScannerJWTData | undefined} jwtData The JWT data to use, or undefined to clear.
|
|
4979
5014
|
*/
|
|
4980
5015
|
setJwtData(jwtData) {
|
|
4981
|
-
|
|
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);
|
|
4982
5019
|
}
|
|
4983
5020
|
/**
|
|
4984
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.
|
|
@@ -5941,33 +5978,129 @@ function generateHookData(recipientAddress, secretNonce) {
|
|
|
5941
5978
|
return hookData;
|
|
5942
5979
|
}
|
|
5943
5980
|
|
|
5944
|
-
const
|
|
5945
|
-
|
|
5946
|
-
|
|
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);
|
|
5947
6089
|
if (!builder) {
|
|
5948
|
-
throw new Error(
|
|
6090
|
+
throw new Error(preparedContext instanceof PreparedProcess
|
|
6091
|
+
? "Prepared process has already been freed"
|
|
6092
|
+
: "Prepared program has already been freed");
|
|
5949
6093
|
}
|
|
5950
6094
|
// The WASM clone is a cheap shared Rc handle, not a deep copy. Mutations
|
|
5951
6095
|
// made while authorizing intentionally remain cached in the prepared context.
|
|
5952
6096
|
return builder.clone();
|
|
5953
6097
|
}
|
|
5954
|
-
function programImportsFromBuilder(builder, entryProgramName) {
|
|
5955
|
-
const imports = {};
|
|
5956
|
-
for (const name of Array.from(builder.programNames())) {
|
|
5957
|
-
if (name === entryProgramName)
|
|
5958
|
-
continue;
|
|
5959
|
-
const source = builder.getProgram(name);
|
|
5960
|
-
if (source)
|
|
5961
|
-
imports[name] = source;
|
|
5962
|
-
}
|
|
5963
|
-
return imports;
|
|
5964
|
-
}
|
|
5965
6098
|
/**
|
|
5966
6099
|
* A reusable program context created by {@link ProgramManager.prepareProgram}.
|
|
5967
6100
|
*
|
|
5968
|
-
* The context is scoped to one program function.
|
|
5969
|
-
*
|
|
5970
|
-
* 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.
|
|
5971
6104
|
*/
|
|
5972
6105
|
class PreparedProgram {
|
|
5973
6106
|
programName;
|
|
@@ -5987,8 +6120,45 @@ class PreparedProgram {
|
|
|
5987
6120
|
* Release the prepared snarkVM process. This method is idempotent.
|
|
5988
6121
|
*/
|
|
5989
6122
|
free() {
|
|
5990
|
-
|
|
5991
|
-
|
|
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);
|
|
5992
6162
|
}
|
|
5993
6163
|
}
|
|
5994
6164
|
/**
|
|
@@ -6009,7 +6179,7 @@ class ProgramManager {
|
|
|
6009
6179
|
* @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface
|
|
6010
6180
|
*/
|
|
6011
6181
|
constructor(host, keyProvider, recordProvider, networkClientOptions, keyStore) {
|
|
6012
|
-
this.host = host ? host : "https://
|
|
6182
|
+
this.host = host ? host : "https://edge.provable.com/api/v2";
|
|
6013
6183
|
this.networkClient = new AleoNetworkClient(this.host, networkClientOptions);
|
|
6014
6184
|
this.keyProvider = keyProvider ? keyProvider : new AleoKeyProvider({ transport: networkClientOptions?.transport });
|
|
6015
6185
|
this.recordProvider = recordProvider;
|
|
@@ -6140,11 +6310,16 @@ class ProgramManager {
|
|
|
6140
6310
|
program = program.toString();
|
|
6141
6311
|
}
|
|
6142
6312
|
const parsedProgram = Program.fromString(program);
|
|
6143
|
-
|
|
6144
|
-
|
|
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
|
+
}
|
|
6145
6320
|
}
|
|
6146
|
-
|
|
6147
|
-
|
|
6321
|
+
finally {
|
|
6322
|
+
parsedProgram.free();
|
|
6148
6323
|
}
|
|
6149
6324
|
const edition = options.edition
|
|
6150
6325
|
?? (await this.resolveEditionAndAmendment(options.programName)).edition;
|
|
@@ -6152,10 +6327,171 @@ class ProgramManager {
|
|
|
6152
6327
|
// Add the entry program as well as its imports so the snarkVM process is
|
|
6153
6328
|
// fully initialized before an authorization is requested.
|
|
6154
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
|
+
}
|
|
6155
6340
|
const preparedProgram = new PreparedProgram(options.programName, options.functionName, program, edition);
|
|
6156
|
-
|
|
6341
|
+
preparedContextBuilders.set(preparedProgram, builder);
|
|
6342
|
+
preparedProgramImports.set(preparedProgram, importSources);
|
|
6157
6343
|
return preparedProgram;
|
|
6158
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
|
+
}
|
|
6159
6495
|
validatePreparedProgram(preparedProgram, options) {
|
|
6160
6496
|
if (preparedProgram.programName !== options.programName
|
|
6161
6497
|
|| preparedProgram.functionName !== options.functionName) {
|
|
@@ -6173,18 +6509,65 @@ class ProgramManager {
|
|
|
6173
6509
|
throw new Error("Prepared program edition does not match the supplied edition");
|
|
6174
6510
|
}
|
|
6175
6511
|
if (options.programImports) {
|
|
6176
|
-
const
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
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`);
|
|
6182
6519
|
}
|
|
6183
6520
|
}
|
|
6184
|
-
|
|
6185
|
-
|
|
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
|
+
}
|
|
6186
6547
|
}
|
|
6187
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
|
+
};
|
|
6188
6571
|
}
|
|
6189
6572
|
/**
|
|
6190
6573
|
* Collect static imports declared by the entry program together with any
|
|
@@ -6513,7 +6896,7 @@ class ProgramManager {
|
|
|
6513
6896
|
* import { ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
6514
6897
|
*
|
|
6515
6898
|
* // Create a ProgramManager
|
|
6516
|
-
* const programManager = new ProgramManager("https://
|
|
6899
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2");
|
|
6517
6900
|
*
|
|
6518
6901
|
* // Set the value of the `Accept-Language` header to `en-US`
|
|
6519
6902
|
* programManager.setHeader('Accept-Language', 'en-US');
|
|
@@ -6534,7 +6917,7 @@ class ProgramManager {
|
|
|
6534
6917
|
* keyProvider.useCache(true);
|
|
6535
6918
|
*
|
|
6536
6919
|
* // Create a ProgramManager
|
|
6537
|
-
* const programManager = new ProgramManager("https://
|
|
6920
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
6538
6921
|
*
|
|
6539
6922
|
* // Set the inclusion keys.
|
|
6540
6923
|
* programManager.setInclusionProver();
|
|
@@ -6568,7 +6951,7 @@ class ProgramManager {
|
|
|
6568
6951
|
* import { ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
6569
6952
|
*
|
|
6570
6953
|
* // Create a ProgramManager
|
|
6571
|
-
* const programManager = new ProgramManager("https://
|
|
6954
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2");
|
|
6572
6955
|
*
|
|
6573
6956
|
* // Remove the default `X-Aleo-SDK-Version` header
|
|
6574
6957
|
* programManager.removeHeader('X-Aleo-SDK-Version');
|
|
@@ -6598,7 +6981,7 @@ class ProgramManager {
|
|
|
6598
6981
|
*
|
|
6599
6982
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
6600
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";
|
|
6601
|
-
* const programManager = new ProgramManager("https://
|
|
6984
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6602
6985
|
* programManager.setAccount(Account);
|
|
6603
6986
|
*
|
|
6604
6987
|
* // Define a fee in credits
|
|
@@ -6710,7 +7093,7 @@ class ProgramManager {
|
|
|
6710
7093
|
*
|
|
6711
7094
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
6712
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";
|
|
6713
|
-
* const programManager = new ProgramManager("https://
|
|
7096
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6714
7097
|
* programManager.setAccount(Account);
|
|
6715
7098
|
*
|
|
6716
7099
|
* // Define a fee in credits
|
|
@@ -6828,7 +7211,7 @@ class ProgramManager {
|
|
|
6828
7211
|
*
|
|
6829
7212
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
6830
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";
|
|
6831
|
-
* const programManager = new ProgramManager("https://
|
|
7214
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6832
7215
|
*
|
|
6833
7216
|
* // Define a fee in credits
|
|
6834
7217
|
* const priorityFee = 0.0;
|
|
@@ -6876,7 +7259,7 @@ class ProgramManager {
|
|
|
6876
7259
|
* keyProvider.useCache(true);
|
|
6877
7260
|
*
|
|
6878
7261
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
6879
|
-
* const programManager = new ProgramManager("https://
|
|
7262
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
6880
7263
|
*
|
|
6881
7264
|
* // Build and execute the transaction
|
|
6882
7265
|
* const tx = await programManager.buildExecutionTransaction({
|
|
@@ -7033,7 +7416,7 @@ class ProgramManager {
|
|
|
7033
7416
|
* keyProvider.useCache(true);
|
|
7034
7417
|
*
|
|
7035
7418
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
7036
|
-
* const programManager = new ProgramManager("https://
|
|
7419
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
7037
7420
|
*
|
|
7038
7421
|
* // Build the `Authorization`.
|
|
7039
7422
|
* const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
@@ -7171,7 +7554,7 @@ class ProgramManager {
|
|
|
7171
7554
|
* keyProvider.useCache(true);
|
|
7172
7555
|
*
|
|
7173
7556
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7174
|
-
* const programManager = new ProgramManager("https://
|
|
7557
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7175
7558
|
*
|
|
7176
7559
|
* // Build the `Authorization`.
|
|
7177
7560
|
* const authorization = await programManager.buildAuthorization({
|
|
@@ -7186,15 +7569,12 @@ class ProgramManager {
|
|
|
7186
7569
|
async buildAuthorization(options) {
|
|
7187
7570
|
// Destructure the options object to access the parameters.
|
|
7188
7571
|
const { functionName, inputs, } = options;
|
|
7189
|
-
const
|
|
7190
|
-
if (preparedProgram) {
|
|
7191
|
-
this.validatePreparedProgram(preparedProgram, options);
|
|
7192
|
-
}
|
|
7572
|
+
const preparedCall = this.preparedCallContext(options);
|
|
7193
7573
|
const privateKey = options.privateKey;
|
|
7194
|
-
let program =
|
|
7195
|
-
let programName =
|
|
7574
|
+
let program = preparedCall?.programSource ?? options.programSource;
|
|
7575
|
+
let programName = preparedCall?.programName ?? options.programName;
|
|
7196
7576
|
const imports = options.programImports;
|
|
7197
|
-
let edition =
|
|
7577
|
+
let edition = preparedCall?.edition ?? options.edition;
|
|
7198
7578
|
// Ensure the function exists on the network.
|
|
7199
7579
|
if (program === undefined) {
|
|
7200
7580
|
try {
|
|
@@ -7220,7 +7600,7 @@ class ProgramManager {
|
|
|
7220
7600
|
if (typeof executionPrivateKey === "undefined") {
|
|
7221
7601
|
throw "No private key provided and no private key set in the ProgramManager";
|
|
7222
7602
|
}
|
|
7223
|
-
if (!
|
|
7603
|
+
if (!preparedCall) {
|
|
7224
7604
|
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7225
7605
|
edition = edition ?? resolved.edition;
|
|
7226
7606
|
}
|
|
@@ -7228,13 +7608,13 @@ class ProgramManager {
|
|
|
7228
7608
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7229
7609
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7230
7610
|
// authorizations don't synthesize keys).
|
|
7231
|
-
const builder =
|
|
7232
|
-
?
|
|
7611
|
+
const builder = preparedCall
|
|
7612
|
+
? clonePreparedContextBuilder(preparedCall.context)
|
|
7233
7613
|
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7234
|
-
const
|
|
7235
|
-
const hasImports = !builder.isEmpty();
|
|
7614
|
+
const hasPreparedContext = preparedCall !== undefined;
|
|
7615
|
+
const hasImports = !hasPreparedContext && !builder.isEmpty();
|
|
7236
7616
|
// Build and return an `Authorization` for the desired function.
|
|
7237
|
-
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));
|
|
7238
7618
|
return authorization;
|
|
7239
7619
|
}
|
|
7240
7620
|
/**
|
|
@@ -7253,7 +7633,7 @@ class ProgramManager {
|
|
|
7253
7633
|
* keyProvider.useCache(true);
|
|
7254
7634
|
*
|
|
7255
7635
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7256
|
-
* const programManager = new ProgramManager("https://
|
|
7636
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7257
7637
|
*
|
|
7258
7638
|
* // Build the unchecked `Authorization`.
|
|
7259
7639
|
* const authorization = await programManager.buildAuthorizationUnchecked({
|
|
@@ -7268,15 +7648,12 @@ class ProgramManager {
|
|
|
7268
7648
|
async buildAuthorizationUnchecked(options) {
|
|
7269
7649
|
// Destructure the options object to access the parameters.
|
|
7270
7650
|
const { functionName, inputs, } = options;
|
|
7271
|
-
const
|
|
7272
|
-
if (preparedProgram) {
|
|
7273
|
-
this.validatePreparedProgram(preparedProgram, options);
|
|
7274
|
-
}
|
|
7651
|
+
const preparedCall = this.preparedCallContext(options);
|
|
7275
7652
|
const privateKey = options.privateKey;
|
|
7276
|
-
let program =
|
|
7277
|
-
let programName =
|
|
7653
|
+
let program = preparedCall?.programSource ?? options.programSource;
|
|
7654
|
+
let programName = preparedCall?.programName ?? options.programName;
|
|
7278
7655
|
const imports = options.programImports;
|
|
7279
|
-
let edition =
|
|
7656
|
+
let edition = preparedCall?.edition ?? options.edition;
|
|
7280
7657
|
// Ensure the function exists on the network.
|
|
7281
7658
|
if (program === undefined) {
|
|
7282
7659
|
try {
|
|
@@ -7302,7 +7679,7 @@ class ProgramManager {
|
|
|
7302
7679
|
if (typeof executionPrivateKey === "undefined") {
|
|
7303
7680
|
throw "No private key provided and no private key set in the ProgramManager";
|
|
7304
7681
|
}
|
|
7305
|
-
if (!
|
|
7682
|
+
if (!preparedCall) {
|
|
7306
7683
|
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7307
7684
|
edition = edition ?? resolved.edition;
|
|
7308
7685
|
}
|
|
@@ -7310,13 +7687,13 @@ class ProgramManager {
|
|
|
7310
7687
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7311
7688
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7312
7689
|
// authorizations don't synthesize keys).
|
|
7313
|
-
const builder =
|
|
7314
|
-
?
|
|
7690
|
+
const builder = preparedCall
|
|
7691
|
+
? clonePreparedContextBuilder(preparedCall.context)
|
|
7315
7692
|
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7316
|
-
const
|
|
7317
|
-
const hasImports = !builder.isEmpty();
|
|
7693
|
+
const hasPreparedContext = preparedCall !== undefined;
|
|
7694
|
+
const hasImports = !hasPreparedContext && !builder.isEmpty();
|
|
7318
7695
|
// Build and return an `Authorization` for the desired function.
|
|
7319
|
-
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));
|
|
7320
7697
|
return authorization;
|
|
7321
7698
|
}
|
|
7322
7699
|
/**
|
|
@@ -7335,7 +7712,7 @@ class ProgramManager {
|
|
|
7335
7712
|
* keyProvider.useCache(true);
|
|
7336
7713
|
*
|
|
7337
7714
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7338
|
-
* const programManager = new ProgramManager("https://
|
|
7715
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7339
7716
|
*
|
|
7340
7717
|
* // Build the proving request.
|
|
7341
7718
|
* const provingRequest = await programManager.provingRequest({
|
|
@@ -7353,18 +7730,15 @@ class ProgramManager {
|
|
|
7353
7730
|
async provingRequest(options) {
|
|
7354
7731
|
// Destructure the options object to access the parameters.
|
|
7355
7732
|
const { functionName, priorityFee, privateFee, inputs, recordSearchParams, broadcast = false, unchecked = false, } = options;
|
|
7356
|
-
const
|
|
7357
|
-
if (preparedProgram) {
|
|
7358
|
-
this.validatePreparedProgram(preparedProgram, options);
|
|
7359
|
-
}
|
|
7733
|
+
const preparedCall = this.preparedCallContext(options);
|
|
7360
7734
|
const baseFee = options.baseFee ? options.baseFee : 0;
|
|
7361
7735
|
const privateKey = options.privateKey;
|
|
7362
7736
|
const useFeeMaster = options.useFeeMaster ? options.useFeeMaster : false;
|
|
7363
|
-
let program =
|
|
7364
|
-
let programName =
|
|
7737
|
+
let program = preparedCall?.programSource ?? options.programSource;
|
|
7738
|
+
let programName = preparedCall?.programName ?? options.programName;
|
|
7365
7739
|
let feeRecord = options.feeRecord;
|
|
7366
7740
|
let imports = options.programImports;
|
|
7367
|
-
let edition =
|
|
7741
|
+
let edition = preparedCall?.edition ?? options.edition;
|
|
7368
7742
|
if (!inputs && !options.executionRequest) {
|
|
7369
7743
|
throw new Error("Either function inputs or an execution request must be provided to form a proving request");
|
|
7370
7744
|
}
|
|
@@ -7384,7 +7758,7 @@ class ProgramManager {
|
|
|
7384
7758
|
if (programName === undefined) {
|
|
7385
7759
|
programName = Program.fromString(program).id();
|
|
7386
7760
|
}
|
|
7387
|
-
if (!
|
|
7761
|
+
if (!preparedCall) {
|
|
7388
7762
|
const resolved = await this.resolveEditionAndAmendment(programName, edition);
|
|
7389
7763
|
edition = edition ?? resolved.edition;
|
|
7390
7764
|
}
|
|
@@ -7396,8 +7770,8 @@ class ProgramManager {
|
|
|
7396
7770
|
executionPrivateKey = this.account.privateKey();
|
|
7397
7771
|
}
|
|
7398
7772
|
// Resolve the program imports if they exist.
|
|
7399
|
-
const numberOfImports =
|
|
7400
|
-
if (!
|
|
7773
|
+
const numberOfImports = ProgramManager.getImportNames(program).length;
|
|
7774
|
+
if (!preparedCall && numberOfImports > 0 && !imports) {
|
|
7401
7775
|
try {
|
|
7402
7776
|
imports = (await this.networkClient.getProgramImports(programName));
|
|
7403
7777
|
}
|
|
@@ -7407,33 +7781,19 @@ class ProgramManager {
|
|
|
7407
7781
|
}
|
|
7408
7782
|
// Build ProgramImportsBuilder for import resolution (no key loading —
|
|
7409
7783
|
// proving requests don't synthesize keys).
|
|
7410
|
-
const builder =
|
|
7411
|
-
?
|
|
7784
|
+
const builder = preparedCall
|
|
7785
|
+
? clonePreparedContextBuilder(preparedCall.context)
|
|
7412
7786
|
: (await this.buildProgramImports(program, imports, false, functionName)).builder;
|
|
7413
|
-
const
|
|
7414
|
-
const hasImports = !builder.isEmpty();
|
|
7415
|
-
|
|
7416
|
-
// both the private-fee estimate below and the Rust-side fee estimator
|
|
7417
|
-
// (estimate_fee_for_authorization uses the legacy imports Object to
|
|
7418
|
-
// avoid a RefCell double-borrow — see proving_request.rs) see all
|
|
7419
|
-
// transitive imports, not just the caller's partial set. Use
|
|
7420
|
-
// programNames + getProgram to avoid serializing key bytes (toObject
|
|
7421
|
-
// would serialize all proving/verifying keys, which can be tens of
|
|
7422
|
-
// MB). The prepared executionRequest path skips the copy: it passes
|
|
7423
|
-
// the process builder directly and never estimates fees, so the
|
|
7424
|
-
// imports Object goes unused there.
|
|
7425
|
-
const importsObjectUnused = hasPreparedProcess
|
|
7426
|
-
&& options.executionRequest instanceof ExecutionRequest;
|
|
7427
|
-
if ((hasPreparedProcess || hasImports) && !importsObjectUnused) {
|
|
7428
|
-
imports = programImportsFromBuilder(builder, programName);
|
|
7429
|
-
}
|
|
7787
|
+
const hasPreparedContext = preparedCall !== undefined;
|
|
7788
|
+
const hasImports = !hasPreparedContext && !builder.isEmpty();
|
|
7789
|
+
const hasProcessBuilder = hasPreparedContext || hasImports;
|
|
7430
7790
|
// Get the fee record from the account if it is not provided in the parameters
|
|
7431
7791
|
try {
|
|
7432
7792
|
if (privateFee && !useFeeMaster && !options.executionRequest) {
|
|
7433
7793
|
let fee = priorityFee;
|
|
7434
7794
|
// If a fee record wasn't provided, estimate the fee that needs to be paid.
|
|
7435
7795
|
if (!feeRecord) {
|
|
7436
|
-
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)));
|
|
7437
7797
|
fee = baseFee + priorityFee;
|
|
7438
7798
|
}
|
|
7439
7799
|
// Get a credits.aleo record for the fee.
|
|
@@ -7448,10 +7808,7 @@ class ProgramManager {
|
|
|
7448
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.`);
|
|
7449
7809
|
}
|
|
7450
7810
|
if (options.executionRequest instanceof ExecutionRequest) {
|
|
7451
|
-
return await ProgramManager$1.buildProvingRequestFromExecutionRequest(options.executionRequest, program, unchecked, broadcast, edition,
|
|
7452
|
-
// The prepared process supersedes the legacy imports Object;
|
|
7453
|
-
// without one, imports is kept for fee estimation in Rust.
|
|
7454
|
-
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));
|
|
7455
7812
|
}
|
|
7456
7813
|
else {
|
|
7457
7814
|
// Ensure the private key exists.
|
|
@@ -7465,8 +7822,7 @@ class ProgramManager {
|
|
|
7465
7822
|
// Auto-convert bare string inputs to field elements where the function expects field type.
|
|
7466
7823
|
const preparedInputs = this.prepareInputs(program, functionName, inputs);
|
|
7467
7824
|
// Build and return the `ProvingRequest`.
|
|
7468
|
-
return await ProgramManager$1.buildProvingRequest(executionPrivateKey, program, functionName, preparedInputs, baseFee, priorityFee, feeRecord, imports,
|
|
7469
|
-
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));
|
|
7470
7826
|
}
|
|
7471
7827
|
}
|
|
7472
7828
|
/**
|
|
@@ -7485,7 +7841,7 @@ class ProgramManager {
|
|
|
7485
7841
|
* keyProvider.useCache(true);
|
|
7486
7842
|
*
|
|
7487
7843
|
* // Initialize a ProgramManager with the key and record providers.
|
|
7488
|
-
* const programManager = new ProgramManager("https://
|
|
7844
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7489
7845
|
*
|
|
7490
7846
|
* // Build a credits.aleo/fee_public `Authorization`.
|
|
7491
7847
|
* const feePublicAuthorization = await programManager.buildFeeAuthorization({
|
|
@@ -7532,7 +7888,7 @@ class ProgramManager {
|
|
|
7532
7888
|
* keyProvider.useCache(true);
|
|
7533
7889
|
*
|
|
7534
7890
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7535
|
-
* const programManager = new ProgramManager("https://
|
|
7891
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7536
7892
|
*
|
|
7537
7893
|
* // Build and execute the transaction
|
|
7538
7894
|
* const tx_id = await programManager.execute({
|
|
@@ -7707,7 +8063,7 @@ class ProgramManager {
|
|
|
7707
8063
|
* keyProvider.useCache(true);
|
|
7708
8064
|
*
|
|
7709
8065
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7710
|
-
* const programManager = new ProgramManager("https://
|
|
8066
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7711
8067
|
* const record_1 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
|
|
7712
8068
|
* const record_2 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 1540945439182663264862696551825005342995406165131907382295858612069623286213group.public}"
|
|
7713
8069
|
* const tx_id = await programManager.join(record_1, record_2, 0.05, false);
|
|
@@ -7814,7 +8170,7 @@ class ProgramManager {
|
|
|
7814
8170
|
* keyProvider.useCache(true);
|
|
7815
8171
|
*
|
|
7816
8172
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7817
|
-
* const programManager = new ProgramManager("https://
|
|
8173
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7818
8174
|
* const record = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
|
|
7819
8175
|
* const tx_id = await programManager.split(25000000, record);
|
|
7820
8176
|
*
|
|
@@ -7925,7 +8281,7 @@ class ProgramManager {
|
|
|
7925
8281
|
* keyProvider.useCache(true);
|
|
7926
8282
|
*
|
|
7927
8283
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
7928
|
-
* const programManager = new ProgramManager("https://
|
|
8284
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
7929
8285
|
* const tx = await programManager.buildTransferTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
|
|
7930
8286
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
7931
8287
|
*
|
|
@@ -8014,7 +8370,7 @@ class ProgramManager {
|
|
|
8014
8370
|
* keyProvider.useCache(true);
|
|
8015
8371
|
*
|
|
8016
8372
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
8017
|
-
* const programManager = new ProgramManager("https://
|
|
8373
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
8018
8374
|
* const tx = await programManager.buildTransferPublicTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
|
|
8019
8375
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
8020
8376
|
*
|
|
@@ -8047,7 +8403,7 @@ class ProgramManager {
|
|
|
8047
8403
|
* keyProvider.useCache(true);
|
|
8048
8404
|
*
|
|
8049
8405
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
8050
|
-
* const programManager = new ProgramManager("https://
|
|
8406
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
8051
8407
|
* const tx = await programManager.buildTransferPublicAsSignerTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
|
|
8052
8408
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
8053
8409
|
*
|
|
@@ -8085,7 +8441,7 @@ class ProgramManager {
|
|
|
8085
8441
|
* keyProvider.useCache(true);
|
|
8086
8442
|
*
|
|
8087
8443
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
8088
|
-
* const programManager = new ProgramManager("https://
|
|
8444
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, recordProvider);
|
|
8089
8445
|
* const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
|
|
8090
8446
|
*
|
|
8091
8447
|
* // Verify the transaction was successful
|
|
@@ -8130,7 +8486,7 @@ class ProgramManager {
|
|
|
8130
8486
|
* keyProvider.useCache(true);
|
|
8131
8487
|
*
|
|
8132
8488
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8133
|
-
* const programManager = new ProgramManager("https://
|
|
8489
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8134
8490
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8135
8491
|
*
|
|
8136
8492
|
* // Create the bonding transaction object for later submission
|
|
@@ -8186,7 +8542,7 @@ class ProgramManager {
|
|
|
8186
8542
|
* keyProvider.useCache(true);
|
|
8187
8543
|
*
|
|
8188
8544
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8189
|
-
* const programManager = new ProgramManager("https://
|
|
8545
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8190
8546
|
*
|
|
8191
8547
|
* // Create the bonding transaction
|
|
8192
8548
|
* tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
|
|
@@ -8234,7 +8590,7 @@ class ProgramManager {
|
|
|
8234
8590
|
* keyProvider.useCache(true);
|
|
8235
8591
|
*
|
|
8236
8592
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8237
|
-
* const programManager = new ProgramManager("https://
|
|
8593
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8238
8594
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8239
8595
|
*
|
|
8240
8596
|
* // Create the bond validator transaction object for later use.
|
|
@@ -8293,7 +8649,7 @@ class ProgramManager {
|
|
|
8293
8649
|
* keyProvider.useCache(true);
|
|
8294
8650
|
*
|
|
8295
8651
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8296
|
-
* const programManager = new ProgramManager("https://
|
|
8652
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8297
8653
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8298
8654
|
*
|
|
8299
8655
|
* // Create the bonding transaction
|
|
@@ -8340,7 +8696,7 @@ class ProgramManager {
|
|
|
8340
8696
|
* keyProvider.useCache(true);
|
|
8341
8697
|
*
|
|
8342
8698
|
* // Create a new ProgramManager with the key that will be used to unbond credits.
|
|
8343
|
-
* const programManager = new ProgramManager("https://
|
|
8699
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8344
8700
|
* const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
|
|
8345
8701
|
*
|
|
8346
8702
|
* // The transaction can be submitted later to the network using the network client.
|
|
@@ -8393,7 +8749,7 @@ class ProgramManager {
|
|
|
8393
8749
|
* keyProvider.useCache(true);
|
|
8394
8750
|
*
|
|
8395
8751
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8396
|
-
* const programManager = new ProgramManager("https://
|
|
8752
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8397
8753
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8398
8754
|
*
|
|
8399
8755
|
* // Create the unbond_public transaction and send it to the network
|
|
@@ -8439,7 +8795,7 @@ class ProgramManager {
|
|
|
8439
8795
|
* keyProvider.useCache(true);
|
|
8440
8796
|
*
|
|
8441
8797
|
* // Create a new ProgramManager with the key that will be used to claim unbonded credits.
|
|
8442
|
-
* const programManager = new ProgramManager("https://
|
|
8798
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8443
8799
|
*
|
|
8444
8800
|
* // Create the claim_unbond_public transaction object for later use.
|
|
8445
8801
|
* const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
|
|
@@ -8489,7 +8845,7 @@ class ProgramManager {
|
|
|
8489
8845
|
* keyProvider.useCache(true);
|
|
8490
8846
|
*
|
|
8491
8847
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8492
|
-
* const programManager = new ProgramManager("https://
|
|
8848
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8493
8849
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
8494
8850
|
*
|
|
8495
8851
|
* // Create the claim_unbond_public transaction
|
|
@@ -8543,7 +8899,7 @@ class ProgramManager {
|
|
|
8543
8899
|
* keyProvider.useCache(true);
|
|
8544
8900
|
*
|
|
8545
8901
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8546
|
-
* const programManager = new ProgramManager("https://
|
|
8902
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8547
8903
|
*
|
|
8548
8904
|
* // Create the set_validator_state transaction
|
|
8549
8905
|
* const tx = await programManager.buildSetValidatorStateTransaction(true);
|
|
@@ -8599,7 +8955,7 @@ class ProgramManager {
|
|
|
8599
8955
|
* keyProvider.useCache(true);
|
|
8600
8956
|
*
|
|
8601
8957
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
8602
|
-
* const programManager = new ProgramManager("https://
|
|
8958
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider, undefined);
|
|
8603
8959
|
*
|
|
8604
8960
|
* // Create the set_validator_state transaction
|
|
8605
8961
|
* const tx_id = await programManager.setValidatorState(true);
|
|
@@ -8721,7 +9077,7 @@ class ProgramManager {
|
|
|
8721
9077
|
* keyProvider.useCache(true);
|
|
8722
9078
|
*
|
|
8723
9079
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
8724
|
-
* const programManager = new ProgramManager("https://
|
|
9080
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
8725
9081
|
*
|
|
8726
9082
|
* // Build the `Authorization`.
|
|
8727
9083
|
* const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
@@ -8778,7 +9134,7 @@ class ProgramManager {
|
|
|
8778
9134
|
* import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
|
|
8779
9135
|
*
|
|
8780
9136
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
8781
|
-
* const programManager = new ProgramManager("https://
|
|
9137
|
+
* const programManager = new ProgramManager("https://edge.provable.com/api/v2", keyProvider);
|
|
8782
9138
|
*
|
|
8783
9139
|
* // Get the base fee in microcredits.
|
|
8784
9140
|
* const baseFeeMicrocredits = await programManager.estimateExecutionFee({programName: "credits.aleo"});
|
|
@@ -9516,5 +9872,5 @@ async function initializeWasm() {
|
|
|
9516
9872
|
logger.warn("initializeWasm is deprecated, you no longer need to use it");
|
|
9517
9873
|
}
|
|
9518
9874
|
|
|
9519
|
-
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 };
|
|
9520
9876
|
//# sourceMappingURL=browser.js.map
|