@provablehq/sdk 0.6.13 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/dist/{account.d.ts → mainnet/account.d.ts} +3 -3
- package/dist/{index.d.ts → mainnet/browser.d.ts} +5 -4
- package/dist/mainnet/browser.js +3127 -0
- package/dist/mainnet/browser.js.map +1 -0
- package/dist/{function-key-provider.d.ts → mainnet/function-key-provider.d.ts} +57 -57
- package/dist/{network-client.d.ts → mainnet/network-client.d.ts} +26 -26
- package/dist/{node-polyfill.d.ts → mainnet/node-polyfill.d.ts} +1 -0
- package/dist/{node-polyfill.js → mainnet/node-polyfill.js} +1 -0
- package/dist/mainnet/node-polyfill.js.map +1 -0
- package/dist/mainnet/node.d.ts +2 -0
- package/dist/{node.js → mainnet/node.js} +3 -2
- package/dist/{node.js.map → mainnet/node.js.map} +1 -1
- package/dist/{offline-key-provider.d.ts → mainnet/offline-key-provider.d.ts} +22 -22
- package/dist/mainnet/polyfill/shared.d.ts +1 -0
- package/dist/{program-manager.d.ts → mainnet/program-manager.d.ts} +59 -59
- package/dist/{record-provider.d.ts → mainnet/record-provider.d.ts} +22 -22
- package/dist/{utils.d.ts → mainnet/utils.d.ts} +1 -0
- package/dist/{worker.d.ts → mainnet/worker.d.ts} +2 -1
- package/dist/mainnet/worker.js +78 -0
- package/dist/mainnet/worker.js.map +1 -0
- package/dist/testnet/account.d.ts +137 -0
- package/dist/testnet/browser.d.ts +53 -0
- package/dist/{index.js → testnet/browser.js} +197 -186
- package/dist/testnet/browser.js.map +1 -0
- package/dist/testnet/function-key-provider.d.ts +348 -0
- package/dist/testnet/managed-worker.d.ts +3 -0
- package/dist/testnet/models/block.d.ts +21 -0
- package/dist/testnet/models/confirmed_transaction.d.ts +6 -0
- package/dist/testnet/models/execution.d.ts +5 -0
- package/dist/testnet/models/input.d.ts +10 -0
- package/dist/testnet/models/output.d.ts +6 -0
- package/dist/testnet/models/transactionModel.d.ts +6 -0
- package/dist/testnet/models/transition.d.ts +13 -0
- package/dist/testnet/network-client.d.ts +267 -0
- package/dist/testnet/node-polyfill.d.ts +5 -0
- package/dist/testnet/node-polyfill.js +303 -0
- package/dist/testnet/node-polyfill.js.map +1 -0
- package/dist/testnet/node.d.ts +2 -0
- package/dist/testnet/node.js +12 -0
- package/dist/testnet/node.js.map +1 -0
- package/dist/testnet/offline-key-provider.d.ts +347 -0
- package/dist/testnet/polyfill/crypto.d.ts +1 -0
- package/dist/testnet/polyfill/fetch.d.ts +1 -0
- package/dist/testnet/polyfill/shared.d.ts +1 -0
- package/dist/testnet/polyfill/worker.d.ts +1 -0
- package/dist/testnet/polyfill/xmlhttprequest.d.ts +1 -0
- package/dist/testnet/program-manager.d.ts +636 -0
- package/dist/testnet/record-provider.d.ts +236 -0
- package/dist/testnet/utils.d.ts +3 -0
- package/dist/testnet/worker.d.ts +9 -0
- package/dist/testnet/worker.js +78 -0
- package/dist/testnet/worker.js.map +1 -0
- package/package.json +23 -13
- package/dist/index.js.map +0 -1
- package/dist/node-polyfill.js.map +0 -1
- package/dist/node.d.ts +0 -2
- package/dist/worker.js +0 -74
- package/dist/worker.js.map +0 -1
- /package/dist/{managed-worker.d.ts → mainnet/managed-worker.d.ts} +0 -0
- /package/dist/{models → mainnet/models}/block.d.ts +0 -0
- /package/dist/{models → mainnet/models}/confirmed_transaction.d.ts +0 -0
- /package/dist/{models → mainnet/models}/execution.d.ts +0 -0
- /package/dist/{models → mainnet/models}/input.d.ts +0 -0
- /package/dist/{models → mainnet/models}/output.d.ts +0 -0
- /package/dist/{models → mainnet/models}/transactionModel.d.ts +0 -0
- /package/dist/{models → mainnet/models}/transition.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/crypto.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/fetch.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/worker.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/xmlhttprequest.d.ts +0 -0
package/README.md
CHANGED
|
@@ -275,7 +275,7 @@ import { Account, AleoNetworkClient, NetworkRecordProvider, ProgramManager, Aleo
|
|
|
275
275
|
const account = new Account();
|
|
276
276
|
|
|
277
277
|
// Create a network client to connect to the Aleo network
|
|
278
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
278
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
279
279
|
|
|
280
280
|
// Create a key provider that will be used to find public proving & verifying keys for Aleo programs
|
|
281
281
|
const keyProvider = new AleoKeyProvider();
|
|
@@ -285,7 +285,7 @@ keyProvider.useCache = true;
|
|
|
285
285
|
const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
286
286
|
|
|
287
287
|
// Initialize a program manager to talk to the Aleo network with the configured key and record providers
|
|
288
|
-
const programManager = new ProgramManager("https://api.explorer.
|
|
288
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
289
289
|
|
|
290
290
|
// Set the account for the program manager
|
|
291
291
|
programManager.setAccount(account);
|
|
@@ -367,7 +367,7 @@ const keyProvider = new AleoKeyProvider();
|
|
|
367
367
|
keyProvider.useCache(true);
|
|
368
368
|
|
|
369
369
|
// Create a record provider that will be used to find records and transaction data for Aleo programs
|
|
370
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
370
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
371
371
|
|
|
372
372
|
// Use existing account with funds
|
|
373
373
|
const account = new Account({
|
|
@@ -377,7 +377,7 @@ const account = new Account({
|
|
|
377
377
|
const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
378
378
|
|
|
379
379
|
// Initialize a program manager to talk to the Aleo network with the configured key and record providers
|
|
380
|
-
const programManager = new ProgramManager("https://api.explorer.
|
|
380
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
381
381
|
programManager.setAccount(account)
|
|
382
382
|
|
|
383
383
|
// Define an Aleo program to deploy
|
|
@@ -429,7 +429,7 @@ A full example of this implementation can be found [here](https://github.com/Pro
|
|
|
429
429
|
|
|
430
430
|
Aleo Credits are used to access blockspace and computational resources on the network, with users paying Credits to submit transactions and have them processed.
|
|
431
431
|
|
|
432
|
-
Aleo credits are defined in the [credits.aleo](https://explorer.
|
|
432
|
+
Aleo credits are defined in the [credits.aleo](https://explorer.provable.com/program/credits.aleo) program. This program is
|
|
433
433
|
deployed to the Aleo network and defines data structures representing Aleo credits and the functions used to manage them.
|
|
434
434
|
|
|
435
435
|
There are two ways to hold Aleo credits:
|
|
@@ -544,13 +544,13 @@ import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNe
|
|
|
544
544
|
|
|
545
545
|
// Create a new NetworkClient, KeyProvider, and RecordProvider
|
|
546
546
|
const account = Account.from_string({privateKey: "user1PrivateKey"});
|
|
547
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
547
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
548
548
|
const keyProvider = new AleoKeyProvider();
|
|
549
549
|
const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
550
550
|
|
|
551
551
|
// Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
552
552
|
const USER_1_ADDRESS = "user1Address";
|
|
553
|
-
const programManager = new ProgramManager("https://api.explorer.
|
|
553
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
554
554
|
programManager.setAccount(account);
|
|
555
555
|
|
|
556
556
|
// Send a private transfer to yourself
|
|
@@ -585,7 +585,7 @@ assert(public_balance === 0);
|
|
|
585
585
|
As shown above, a public balance of any address can be checked with `getMappingValue` function of the `NetworkClient`.
|
|
586
586
|
|
|
587
587
|
```typescript
|
|
588
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
588
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
589
589
|
const USER_1_ADDRESS = "user1Address";
|
|
590
590
|
const public_balance = networkClient.getMappingValue("credits.aleo", USER_1_ADDRESS);
|
|
591
591
|
```
|
|
@@ -674,13 +674,13 @@ import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNe
|
|
|
674
674
|
|
|
675
675
|
// Create a new NetworkClient, KeyProvider, and RecordProvider
|
|
676
676
|
const account = Account.from_string({privateKey: "user1PrivateKey"});
|
|
677
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
677
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
678
678
|
const keyProvider = new AleoKeyProvider();
|
|
679
679
|
const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
680
680
|
|
|
681
681
|
// Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
682
682
|
const USER_2_ADDRESS = "user2Address";
|
|
683
|
-
const programManager = new ProgramManager("https://api.explorer.
|
|
683
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
684
684
|
programManager.setAccount(account);
|
|
685
685
|
|
|
686
686
|
/// Send private transfer to User 2
|
|
@@ -695,12 +695,12 @@ import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNe
|
|
|
695
695
|
|
|
696
696
|
// Create a new NetworkClient, KeyProvider, and RecordProvider
|
|
697
697
|
const account = Account.from_string({privateKey: "user2PrivateKey"});
|
|
698
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
698
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
699
699
|
const keyProvider = new AleoKeyProvider();
|
|
700
700
|
const recordProvider_User2 = new NetworkRecordProvider(account, networkClient);
|
|
701
701
|
|
|
702
702
|
// Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
703
|
-
const programManager = new ProgramManager("https://api.explorer.
|
|
703
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
704
704
|
programManager.setAccount(account);
|
|
705
705
|
|
|
706
706
|
// Fetch the transaction from the network that user 1 sent
|
|
@@ -863,7 +863,7 @@ read the value of a specific key within a mapping.
|
|
|
863
863
|
```typescript
|
|
864
864
|
import { AleoNetworkClient } from '@provablehq/sdk';
|
|
865
865
|
|
|
866
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
866
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
867
867
|
const creditsMappings = networkClient.getMappings("credits.aleo");
|
|
868
868
|
assert(creditsMappings === ["account"]);
|
|
869
869
|
|
|
@@ -903,20 +903,20 @@ by the Aleo network. All that the user of the SDK must do is ensure that the inp
|
|
|
903
903
|
If function inputs are invalid, the network will return an error, but the fee paid for the transaction will still be
|
|
904
904
|
consumed. Therefore, it is important to ensure that the inputs to a function are valid before executing it.
|
|
905
905
|
|
|
906
|
-
A simple example of a mapping update can be shown by simply executing
|
|
906
|
+
A simple example of a mapping update can be shown by simply executing `transfer_public` as shown below.
|
|
907
907
|
|
|
908
908
|
```typescript
|
|
909
909
|
import { Account, ProgramManager, AleoKeyProvider, NetworkRecordProvider, AleoNetworkClient } from '@provablehq/sdk';
|
|
910
910
|
|
|
911
911
|
// Create a new NetworkClient, KeyProvider, and RecordProvider
|
|
912
912
|
const account = Account.from_string({privateKey: "user1PrivateKey"});
|
|
913
|
-
const networkClient = new AleoNetworkClient("https://api.explorer.
|
|
913
|
+
const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
914
914
|
const keyProvider = new AleoKeyProvider();
|
|
915
915
|
const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
916
916
|
|
|
917
917
|
// Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
918
918
|
const RECIPIENT_ADDRESS = "user1Address";
|
|
919
|
-
const programManager = new ProgramManager("https://api.explorer.
|
|
919
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
|
|
920
920
|
programManager.setAccount(account);
|
|
921
921
|
|
|
922
922
|
// Update or initialize a public balance
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext } from "./
|
|
1
|
+
import { Address, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext } from "./browser";
|
|
2
2
|
interface AccountParam {
|
|
3
3
|
privateKey?: string;
|
|
4
4
|
seed?: Uint8Array;
|
|
@@ -41,7 +41,7 @@ export declare class Account {
|
|
|
41
41
|
* Attempts to create an account from a private key ciphertext
|
|
42
42
|
* @param {PrivateKeyCiphertext | string} ciphertext
|
|
43
43
|
* @param {string} password
|
|
44
|
-
* @returns {PrivateKey
|
|
44
|
+
* @returns {PrivateKey}
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* const ciphertext = PrivateKey.newEncrypted("password");
|
|
@@ -90,7 +90,7 @@ export declare class Account {
|
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* // Create a connection to the Aleo network and an account
|
|
93
|
-
* const connection = new
|
|
93
|
+
* const connection = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
94
94
|
* const account = Account.fromCiphertext("ciphertext", "password");
|
|
95
95
|
*
|
|
96
96
|
* // Get a record from the network
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./polyfill/shared";
|
|
2
|
+
import { VerifyingKey } from "@provablehq/wasm/mainnet.js";
|
|
2
3
|
declare const KEY_STORE: string;
|
|
3
4
|
interface Key {
|
|
4
5
|
name: string;
|
|
@@ -23,7 +24,7 @@ declare const CREDITS_PROGRAM_KEYS: {
|
|
|
23
24
|
transfer_public_as_signer: Key;
|
|
24
25
|
transfer_public_to_private: Key;
|
|
25
26
|
unbond_public: Key;
|
|
26
|
-
getKey: (key: string) => Key
|
|
27
|
+
getKey: (key: string) => Key;
|
|
27
28
|
};
|
|
28
29
|
declare const PRIVATE_TRANSFER_TYPES: Set<string>;
|
|
29
30
|
declare const VALID_TRANSFER_TYPES: Set<string>;
|
|
@@ -32,7 +33,7 @@ declare const PRIVATE_TO_PUBLIC_TRANSFER: Set<string>;
|
|
|
32
33
|
declare const PUBLIC_TRANSFER: Set<string>;
|
|
33
34
|
declare const PUBLIC_TRANSFER_AS_SIGNER: Set<string>;
|
|
34
35
|
declare const PUBLIC_TO_PRIVATE_TRANSFER: Set<string>;
|
|
35
|
-
declare function logAndThrow(message: string):
|
|
36
|
+
declare function logAndThrow(message: string): never;
|
|
36
37
|
import { Account } from "./account";
|
|
37
38
|
import { AleoNetworkClient, ProgramImports } from "./network-client";
|
|
38
39
|
import { Block } from "./models/block";
|
|
@@ -47,6 +48,6 @@ import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchP
|
|
|
47
48
|
declare function initializeWasm(): Promise<void>;
|
|
48
49
|
export { createAleoWorker } from "./managed-worker";
|
|
49
50
|
export { ProgramManager } from "./program-manager";
|
|
50
|
-
export { Address, Execution as FunctionExecution, ExecutionResponse, Field, OfflineQuery, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Transaction, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm";
|
|
51
|
+
export { Address, Execution as FunctionExecution, ExecutionResponse, Field, OfflineQuery, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Transaction, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
|
|
51
52
|
export { initializeWasm };
|
|
52
53
|
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, Block, BlockHeightSearch, CachedKeyPair, Execution, FunctionKeyPair, FunctionKeyProvider, Input, Key, KeySearchParams, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, Output, RecordProvider, RecordSearchParams, TransactionModel, Transition, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, logAndThrow, };
|