@provablehq/sdk 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dynamic/browser.cjs +12 -0
- package/dist/dynamic/browser.d.cts +8 -0
- package/dist/dynamic/browser.d.ts +2 -2
- package/dist/dynamic/node.cjs +12 -0
- package/dist/dynamic/node.d.cts +8 -0
- package/dist/dynamic/node.d.ts +2 -2
- package/dist/mainnet/account.d.cts +347 -0
- package/dist/mainnet/browser.cjs +8530 -0
- package/dist/mainnet/browser.cjs.map +1 -0
- package/dist/mainnet/browser.d.cts +72 -0
- package/dist/mainnet/browser.d.ts +3 -3
- package/dist/mainnet/browser.js +78 -32
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/constants.d.cts +40 -0
- package/dist/mainnet/external-signing.d.cts +76 -0
- package/dist/mainnet/integrations/sealance/merkle-tree.d.cts +192 -0
- package/dist/mainnet/keys/keystore/error.d.cts +24 -0
- package/dist/mainnet/keys/keystore/file.d.cts +177 -0
- package/dist/mainnet/keys/keystore/interface.d.cts +161 -0
- package/dist/mainnet/keys/provider/interface.d.cts +170 -0
- package/dist/mainnet/keys/provider/memory.d.cts +213 -0
- package/dist/mainnet/keys/provider/memory.d.ts +6 -2
- package/dist/mainnet/keys/provider/offline.d.cts +365 -0
- package/dist/mainnet/keys/verifier/interface.d.cts +70 -0
- package/dist/mainnet/keys/verifier/memory.d.cts +37 -0
- package/dist/mainnet/keys/verifier/memory.d.ts +1 -1
- package/dist/mainnet/models/authorization.d.cts +6 -0
- package/dist/mainnet/models/authorization.d.ts +2 -2
- package/dist/mainnet/models/blockJSON.d.cts +33 -0
- package/dist/mainnet/models/confirmed_transaction.d.cts +9 -0
- package/dist/mainnet/models/cryptoBoxPubkey.d.cts +4 -0
- package/dist/mainnet/models/deployment/deploymentJSON.d.cts +6 -0
- package/dist/mainnet/models/deployment/deploymentObject.d.cts +6 -0
- package/dist/mainnet/models/encryptedProvingRequest.d.cts +4 -0
- package/dist/mainnet/models/execution/executionJSON.d.cts +11 -0
- package/dist/mainnet/models/execution/executionObject.d.cts +11 -0
- package/dist/mainnet/models/external-signing.d.cts +123 -0
- package/dist/mainnet/models/finalizeJSON.d.cts +6 -0
- package/dist/mainnet/models/functionInput.d.cts +7 -0
- package/dist/mainnet/models/functionObject.d.cts +8 -0
- package/dist/mainnet/models/imports.d.cts +7 -0
- package/dist/mainnet/models/input/inputJSON.d.cts +10 -0
- package/dist/mainnet/models/input/inputObject.d.cts +15 -0
- package/dist/mainnet/models/inputID.d.cts +4 -0
- package/dist/mainnet/models/keyPair.d.cts +4 -0
- package/dist/mainnet/models/output/outputJSON.d.cts +7 -0
- package/dist/mainnet/models/output/outputObject.d.cts +18 -0
- package/dist/mainnet/models/owner/ownerJSON.d.cts +4 -0
- package/dist/mainnet/models/owner/ownerObject.d.cts +5 -0
- package/dist/mainnet/models/plaintext/array.d.cts +3 -0
- package/dist/mainnet/models/plaintext/literal.d.cts +1 -0
- package/dist/mainnet/models/plaintext/plaintext.d.cts +5 -0
- package/dist/mainnet/models/plaintext/struct.d.cts +5 -0
- package/dist/mainnet/models/provingRequest.d.cts +6 -0
- package/dist/mainnet/models/provingRequest.d.ts +1 -1
- package/dist/mainnet/models/provingResponse.d.cts +51 -0
- package/dist/mainnet/models/ratification.d.cts +4 -0
- package/dist/mainnet/models/record-provider/encryptedRecord.d.cts +58 -0
- package/dist/mainnet/models/record-provider/ownedRecord.d.cts +60 -0
- package/dist/mainnet/models/record-provider/recordSearchParams.d.cts +19 -0
- package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
- package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
- package/dist/mainnet/models/record-scanner/error.d.cts +47 -0
- package/dist/mainnet/models/record-scanner/error.d.ts +1 -1
- package/dist/mainnet/models/record-scanner/ownedFilter.d.cts +22 -0
- package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +3 -3
- package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.cts +35 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +2 -2
- package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
- package/dist/mainnet/models/record-scanner/registrationRequest.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResult.d.cts +9 -0
- package/dist/mainnet/models/record-scanner/revokeResult.d.cts +17 -0
- package/dist/mainnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
- package/dist/mainnet/models/record-scanner/statusResponse.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/statusResult.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/tagsResult.d.cts +12 -0
- package/dist/mainnet/models/request.d.cts +14 -0
- package/dist/mainnet/models/request.d.ts +1 -1
- package/dist/mainnet/models/solution.d.cts +14 -0
- package/dist/mainnet/models/transaction/transactionJSON.d.cts +11 -0
- package/dist/mainnet/models/transaction/transactionObject.d.cts +14 -0
- package/dist/mainnet/models/transition/transitionJSON.d.cts +13 -0
- package/dist/mainnet/models/transition/transitionObject.d.cts +15 -0
- package/dist/mainnet/network-client.d.cts +850 -0
- package/dist/mainnet/network-client.d.ts +3 -0
- package/dist/mainnet/node-polyfill.cjs +238 -0
- package/dist/mainnet/node-polyfill.cjs.map +1 -0
- package/dist/mainnet/node-polyfill.d.cts +5 -0
- package/dist/mainnet/node-polyfill.js +1 -1
- package/dist/mainnet/node-polyfill.js.map +1 -1
- package/dist/mainnet/node.cjs +686 -0
- package/dist/mainnet/node.cjs.map +1 -0
- package/dist/mainnet/node.d.cts +3 -0
- package/dist/mainnet/node.js +2 -2
- package/dist/mainnet/polyfill/crypto.d.cts +1 -0
- package/dist/mainnet/polyfill/fetch.d.cts +1 -0
- package/dist/mainnet/polyfill/shared.d.cts +1 -0
- package/dist/mainnet/polyfill/worker.d.cts +1 -0
- package/dist/mainnet/polyfill/xmlhttprequest.d.cts +1 -0
- package/dist/mainnet/program-manager.d.cts +1600 -0
- package/dist/mainnet/program-manager.d.ts +13 -1
- package/dist/mainnet/record-provider.d.cts +274 -0
- package/dist/mainnet/record-scanner.d.cts +371 -0
- package/dist/mainnet/record-scanner.d.ts +9 -6
- package/dist/mainnet/security.d.cts +62 -0
- package/dist/mainnet/security.d.ts +5 -5
- package/dist/mainnet/utils.d.cts +23 -0
- package/dist/mainnet/utils.d.ts +10 -2
- package/dist/mainnet/wasm.d.cts +1 -0
- package/dist/testnet/account.d.cts +347 -0
- package/dist/testnet/browser.cjs +8530 -0
- package/dist/testnet/browser.cjs.map +1 -0
- package/dist/testnet/browser.d.cts +72 -0
- package/dist/testnet/browser.d.ts +3 -3
- package/dist/testnet/browser.js +78 -32
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/constants.d.cts +40 -0
- package/dist/testnet/external-signing.d.cts +76 -0
- package/dist/testnet/integrations/sealance/merkle-tree.d.cts +192 -0
- package/dist/testnet/keys/keystore/error.d.cts +24 -0
- package/dist/testnet/keys/keystore/file.d.cts +177 -0
- package/dist/testnet/keys/keystore/interface.d.cts +161 -0
- package/dist/testnet/keys/provider/interface.d.cts +170 -0
- package/dist/testnet/keys/provider/memory.d.cts +213 -0
- package/dist/testnet/keys/provider/memory.d.ts +6 -2
- package/dist/testnet/keys/provider/offline.d.cts +365 -0
- package/dist/testnet/keys/verifier/interface.d.cts +70 -0
- package/dist/testnet/keys/verifier/memory.d.cts +37 -0
- package/dist/testnet/keys/verifier/memory.d.ts +1 -1
- package/dist/testnet/models/authorization.d.cts +6 -0
- package/dist/testnet/models/authorization.d.ts +2 -2
- package/dist/testnet/models/blockJSON.d.cts +33 -0
- package/dist/testnet/models/confirmed_transaction.d.cts +9 -0
- package/dist/testnet/models/cryptoBoxPubkey.d.cts +4 -0
- package/dist/testnet/models/deployment/deploymentJSON.d.cts +6 -0
- package/dist/testnet/models/deployment/deploymentObject.d.cts +6 -0
- package/dist/testnet/models/encryptedProvingRequest.d.cts +4 -0
- package/dist/testnet/models/execution/executionJSON.d.cts +11 -0
- package/dist/testnet/models/execution/executionObject.d.cts +11 -0
- package/dist/testnet/models/external-signing.d.cts +123 -0
- package/dist/testnet/models/finalizeJSON.d.cts +6 -0
- package/dist/testnet/models/functionInput.d.cts +7 -0
- package/dist/testnet/models/functionObject.d.cts +8 -0
- package/dist/testnet/models/imports.d.cts +7 -0
- package/dist/testnet/models/input/inputJSON.d.cts +10 -0
- package/dist/testnet/models/input/inputObject.d.cts +15 -0
- package/dist/testnet/models/inputID.d.cts +4 -0
- package/dist/testnet/models/keyPair.d.cts +4 -0
- package/dist/testnet/models/output/outputJSON.d.cts +7 -0
- package/dist/testnet/models/output/outputObject.d.cts +18 -0
- package/dist/testnet/models/owner/ownerJSON.d.cts +4 -0
- package/dist/testnet/models/owner/ownerObject.d.cts +5 -0
- package/dist/testnet/models/plaintext/array.d.cts +3 -0
- package/dist/testnet/models/plaintext/literal.d.cts +1 -0
- package/dist/testnet/models/plaintext/plaintext.d.cts +5 -0
- package/dist/testnet/models/plaintext/struct.d.cts +5 -0
- package/dist/testnet/models/provingRequest.d.cts +6 -0
- package/dist/testnet/models/provingRequest.d.ts +1 -1
- package/dist/testnet/models/provingResponse.d.cts +51 -0
- package/dist/testnet/models/ratification.d.cts +4 -0
- package/dist/testnet/models/record-provider/encryptedRecord.d.cts +58 -0
- package/dist/testnet/models/record-provider/ownedRecord.d.cts +60 -0
- package/dist/testnet/models/record-provider/recordSearchParams.d.cts +19 -0
- package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
- package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
- package/dist/testnet/models/record-scanner/error.d.cts +47 -0
- package/dist/testnet/models/record-scanner/error.d.ts +1 -1
- package/dist/testnet/models/record-scanner/ownedFilter.d.cts +22 -0
- package/dist/testnet/models/record-scanner/ownedFilter.d.ts +3 -3
- package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.cts +35 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.ts +2 -2
- package/dist/testnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
- package/dist/testnet/models/record-scanner/registrationRequest.d.cts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.cts +13 -0
- package/dist/testnet/models/record-scanner/registrationResult.d.cts +9 -0
- package/dist/testnet/models/record-scanner/revokeResult.d.cts +17 -0
- package/dist/testnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
- package/dist/testnet/models/record-scanner/statusResponse.d.cts +13 -0
- package/dist/testnet/models/record-scanner/statusResult.d.cts +13 -0
- package/dist/testnet/models/record-scanner/tagsResult.d.cts +12 -0
- package/dist/testnet/models/request.d.cts +14 -0
- package/dist/testnet/models/request.d.ts +1 -1
- package/dist/testnet/models/solution.d.cts +14 -0
- package/dist/testnet/models/transaction/transactionJSON.d.cts +11 -0
- package/dist/testnet/models/transaction/transactionObject.d.cts +14 -0
- package/dist/testnet/models/transition/transitionJSON.d.cts +13 -0
- package/dist/testnet/models/transition/transitionObject.d.cts +15 -0
- package/dist/testnet/network-client.d.cts +850 -0
- package/dist/testnet/network-client.d.ts +3 -0
- package/dist/testnet/node-polyfill.cjs +238 -0
- package/dist/testnet/node-polyfill.cjs.map +1 -0
- package/dist/testnet/node-polyfill.d.cts +5 -0
- package/dist/testnet/node-polyfill.js +1 -1
- package/dist/testnet/node-polyfill.js.map +1 -1
- package/dist/testnet/node.cjs +686 -0
- package/dist/testnet/node.cjs.map +1 -0
- package/dist/testnet/node.d.cts +3 -0
- package/dist/testnet/node.js +2 -2
- package/dist/testnet/polyfill/crypto.d.cts +1 -0
- package/dist/testnet/polyfill/fetch.d.cts +1 -0
- package/dist/testnet/polyfill/shared.d.cts +1 -0
- package/dist/testnet/polyfill/worker.d.cts +1 -0
- package/dist/testnet/polyfill/xmlhttprequest.d.cts +1 -0
- package/dist/testnet/program-manager.d.cts +1600 -0
- package/dist/testnet/program-manager.d.ts +13 -1
- package/dist/testnet/record-provider.d.cts +274 -0
- package/dist/testnet/record-scanner.d.cts +371 -0
- package/dist/testnet/record-scanner.d.ts +9 -6
- package/dist/testnet/security.d.cts +62 -0
- package/dist/testnet/security.d.ts +5 -5
- package/dist/testnet/utils.d.cts +23 -0
- package/dist/testnet/utils.d.ts +10 -2
- package/dist/testnet/wasm.d.cts +1 -0
- package/package.json +51 -9
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
import { TransportFunction } from "./utils.js";
|
|
2
|
+
import { Account } from "./account.js";
|
|
3
|
+
import { BlockJSON } from "./models/blockJSON.js";
|
|
4
|
+
import { TransactionJSON } from "./models/transaction/transactionJSON.js";
|
|
5
|
+
import { Address, Plaintext, Program, ProvingRequest, RecordPlaintext, PrivateKey, Transaction } from "./wasm.js";
|
|
6
|
+
import { ConfirmedTransactionJSON } from "./models/confirmed_transaction.js";
|
|
7
|
+
import { ProvingResponse, ProvingResult } from "./models/provingResponse.js";
|
|
8
|
+
type ProgramImports = {
|
|
9
|
+
[key: string]: string | Program;
|
|
10
|
+
};
|
|
11
|
+
interface AleoNetworkClientOptions {
|
|
12
|
+
headers?: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
15
|
+
proverUri?: string;
|
|
16
|
+
recordScannerUri?: string;
|
|
17
|
+
transport?: TransportFunction;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for the JWT data.
|
|
21
|
+
*
|
|
22
|
+
* @property jwt {string} The JWT token string.
|
|
23
|
+
* @property expiration {number} The expiration time of the JWT token in UNIX timestamp format.
|
|
24
|
+
*/
|
|
25
|
+
interface JWTData {
|
|
26
|
+
jwt: string;
|
|
27
|
+
expiration: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for submitting a proving request.
|
|
31
|
+
*
|
|
32
|
+
* @property provingRequest {ProvingRequest | string} The proving request being submitted to the network.
|
|
33
|
+
* @property url {string} The URL of the delegated proving service.
|
|
34
|
+
* @property apiKey {string} The API key used for generating a JWT.
|
|
35
|
+
* @property consumerId {string} The consumer ID associated with the API key.
|
|
36
|
+
* @property jwt {string} An optional JWT token used for authenticating with the proving service.
|
|
37
|
+
*/
|
|
38
|
+
interface DelegatedProvingParams {
|
|
39
|
+
provingRequest: ProvingRequest | string;
|
|
40
|
+
url?: string;
|
|
41
|
+
apiKey?: string;
|
|
42
|
+
consumerId?: string;
|
|
43
|
+
jwtData?: JWTData;
|
|
44
|
+
dpsPrivacy?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
|
|
48
|
+
* allow users to query public information from the Aleo blockchain and submit transactions to the network.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} host
|
|
51
|
+
* @example
|
|
52
|
+
* // Connection to a local node.
|
|
53
|
+
* const localNetworkClient = new AleoNetworkClient("http://0.0.0.0:3030", undefined, account);
|
|
54
|
+
*
|
|
55
|
+
* // Connection to a public beacon node
|
|
56
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
57
|
+
* const apiKey = process.env.apiKey;
|
|
58
|
+
* const consumerId = process.env.consumerId;
|
|
59
|
+
* const publicNetworkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined, account);
|
|
60
|
+
*/
|
|
61
|
+
declare class AleoNetworkClient {
|
|
62
|
+
host: string;
|
|
63
|
+
private readonly baseUrl;
|
|
64
|
+
headers: {
|
|
65
|
+
[key: string]: string;
|
|
66
|
+
};
|
|
67
|
+
account: Account | undefined;
|
|
68
|
+
ctx: {
|
|
69
|
+
[key: string]: string;
|
|
70
|
+
};
|
|
71
|
+
verboseErrors: boolean;
|
|
72
|
+
readonly network: string;
|
|
73
|
+
transport: TransportFunction;
|
|
74
|
+
apiKey?: string;
|
|
75
|
+
consumerId?: string;
|
|
76
|
+
jwtData?: JWTData;
|
|
77
|
+
proverUri?: string;
|
|
78
|
+
recordScannerUri?: string;
|
|
79
|
+
constructor(host: string, options?: AleoNetworkClientOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Set an account to use in networkClient calls
|
|
82
|
+
*
|
|
83
|
+
* @param {Account} account Set an account to use for record scanning functions.
|
|
84
|
+
* @example
|
|
85
|
+
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
86
|
+
*
|
|
87
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
88
|
+
* const account = new Account();
|
|
89
|
+
* networkClient.setAccount(account);
|
|
90
|
+
*/
|
|
91
|
+
setAccount(account: Account): void;
|
|
92
|
+
/**
|
|
93
|
+
* Return the Aleo account used in the networkClient
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const account = networkClient.getAccount();
|
|
97
|
+
*/
|
|
98
|
+
getAccount(): Account | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Set a new host for the networkClient
|
|
101
|
+
*
|
|
102
|
+
* @param {string} host The address of a node hosting the Aleo API
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
106
|
+
*
|
|
107
|
+
* // Create a networkClient that connects to a local node.
|
|
108
|
+
* const networkClient = new AleoNetworkClient("http://0.0.0.0:3030", undefined);
|
|
109
|
+
*
|
|
110
|
+
* // Set the host to a public node.
|
|
111
|
+
* networkClient.setHost("https://api.provable.com/v2");
|
|
112
|
+
*/
|
|
113
|
+
setHost(host: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Set a new uri for a remote prover.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} proverUri The uri of the remote prover.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
121
|
+
*
|
|
122
|
+
* // Create a networkClient that connects to the provable explorer api.
|
|
123
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
124
|
+
*
|
|
125
|
+
* // Set the prover uri.
|
|
126
|
+
* networkClient.setProverUri("https://prover.provable.prove");
|
|
127
|
+
*/
|
|
128
|
+
setProverUri(proverUri: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* Set a new uri for a remote record scanner.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} recordScannerUri The uri of the remote record scanner.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
136
|
+
*
|
|
137
|
+
* // Create a networkClient that connects to the provable explorer api.
|
|
138
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
139
|
+
*
|
|
140
|
+
* // Set the record scanner uri.
|
|
141
|
+
* networkClient.setRecordScannerUri("https://scanner.provable.scan");
|
|
142
|
+
*/
|
|
143
|
+
setRecordScannerUri(recordScannerUri: string): void;
|
|
144
|
+
/**
|
|
145
|
+
* Set verbose errors to true or false for the `AleoNetworkClient`. When set to true, if `submitTransaction` fails, the failure responses will report descriptive information as to why the transaction failed.
|
|
146
|
+
*
|
|
147
|
+
* @param {boolean} verboseErrors Set verbose error mode to true or false for the AleoNetworkClient.
|
|
148
|
+
* @example
|
|
149
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
150
|
+
*
|
|
151
|
+
* // Create a networkClient
|
|
152
|
+
* const networkClient = new AleoNetworkClient();
|
|
153
|
+
*
|
|
154
|
+
* // Set debug mode to true
|
|
155
|
+
* networkClient.setVerboseTransactionErrors(true);
|
|
156
|
+
**/
|
|
157
|
+
setVerboseErrors(verboseErrors: boolean): void;
|
|
158
|
+
/**
|
|
159
|
+
* Set a header in the `AleoNetworkClient`s header map
|
|
160
|
+
*
|
|
161
|
+
* @param {string} headerName The name of the header to set
|
|
162
|
+
* @param {string} value The header value
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
166
|
+
*
|
|
167
|
+
* // Create a networkClient
|
|
168
|
+
* const networkClient = new AleoNetworkClient();
|
|
169
|
+
*
|
|
170
|
+
* // Set the value of the `Accept-Language` header to `en-US`
|
|
171
|
+
* networkClient.setHeader('Accept-Language', 'en-US');
|
|
172
|
+
*/
|
|
173
|
+
setHeader(headerName: string, value: string): void;
|
|
174
|
+
removeHeader(headerName: string): void;
|
|
175
|
+
/**
|
|
176
|
+
* Fetches data from the Aleo network and returns it as a JSON object.
|
|
177
|
+
*
|
|
178
|
+
* @param url The URL to fetch data from.
|
|
179
|
+
*/
|
|
180
|
+
fetchData<Type>(url?: string): Promise<Type>;
|
|
181
|
+
/**
|
|
182
|
+
* Fetches data from the Aleo network and returns it as an unparsed string.
|
|
183
|
+
*
|
|
184
|
+
* This method should be used when it is desired to reconstitute data returned
|
|
185
|
+
* from the network into a WASM object.
|
|
186
|
+
*
|
|
187
|
+
* @param url
|
|
188
|
+
*/
|
|
189
|
+
fetchRaw(url?: string): Promise<string>;
|
|
190
|
+
/**
|
|
191
|
+
* Wrapper around the POST helper to allow mocking in tests. Not meant for use in production.
|
|
192
|
+
*
|
|
193
|
+
* @param url The URL to POST to.
|
|
194
|
+
* @param options The RequestInit options for the POST request.
|
|
195
|
+
* @returns The Response object from the POST request.
|
|
196
|
+
*/
|
|
197
|
+
private _sendPost;
|
|
198
|
+
/**
|
|
199
|
+
* Attempt to find records in the Aleo blockchain.
|
|
200
|
+
*
|
|
201
|
+
* @param {number} startHeight - The height at which to start searching for unspent records
|
|
202
|
+
* @param {number} endHeight - The height at which to stop searching for unspent records
|
|
203
|
+
* @param {boolean} unspent - Whether to search for unspent records only
|
|
204
|
+
* @param {string[]} programs - The program(s) to search for unspent records in
|
|
205
|
+
* @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
|
|
206
|
+
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
207
|
+
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
208
|
+
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
209
|
+
* @returns {Promise<Array<RecordPlaintext>>} An array of records belonging to the account configured in the network client.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
213
|
+
*
|
|
214
|
+
* // Import an account from a ciphertext and password.
|
|
215
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
216
|
+
*
|
|
217
|
+
* // Create a network client.
|
|
218
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
219
|
+
* networkClient.setAccount(account);
|
|
220
|
+
*
|
|
221
|
+
* // Find specific amounts
|
|
222
|
+
* const startHeight = 500000;
|
|
223
|
+
* const amounts = [600000, 1000000];
|
|
224
|
+
* const records = networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"] amounts);
|
|
225
|
+
*
|
|
226
|
+
* // Find specific amounts with a maximum number of cumulative microcredits
|
|
227
|
+
* const maxMicrocredits = 100000;
|
|
228
|
+
* const records = networkClient.findRecords(startHeight, undefined, true, ["credits.aleo"] undefined, maxMicrocredits);
|
|
229
|
+
*/
|
|
230
|
+
findRecords(startHeight: number, endHeight: number | undefined, unspent?: boolean, programs?: string[], amounts?: number[] | undefined, maxMicrocredits?: number | undefined, nonces?: string[] | undefined, privateKey?: string | PrivateKey | undefined): Promise<Array<RecordPlaintext>>;
|
|
231
|
+
/**
|
|
232
|
+
* Attempts to find unspent records in the Aleo blockchain.
|
|
233
|
+
*
|
|
234
|
+
* @param {number} startHeight - The height at which to start searching for unspent records
|
|
235
|
+
* @param {number} endHeight - The height at which to stop searching for unspent records
|
|
236
|
+
* @param {string[]} programs - The program(s) to search for unspent records in
|
|
237
|
+
* @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
|
|
238
|
+
* @param {number} maxMicrocredits - The maximum number of microcredits to search for
|
|
239
|
+
* @param {string[]} nonces - The nonces of already found records to exclude from the search
|
|
240
|
+
* @param {string | PrivateKey} privateKey - An optional private key to use to find unspent records.
|
|
241
|
+
* @returns {Promise<Array<RecordPlaintext>>} An array of unspent records belonging to the account configured in the network client.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* import { Account, AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
245
|
+
*
|
|
246
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
247
|
+
*
|
|
248
|
+
* // Create a network client and set an account to search for records with.
|
|
249
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
250
|
+
* networkClient.setAccount(account);
|
|
251
|
+
*
|
|
252
|
+
* // Find specific amounts
|
|
253
|
+
* const startHeight = 500000;
|
|
254
|
+
* const endHeight = 550000;
|
|
255
|
+
* const amounts = [600000, 1000000];
|
|
256
|
+
* const records = networkClient.findUnspentRecords(startHeight, endHeight, ["credits.aleo"], amounts);
|
|
257
|
+
*
|
|
258
|
+
* // Find specific amounts with a maximum number of cumulative microcredits
|
|
259
|
+
* const maxMicrocredits = 100000;
|
|
260
|
+
* const records = networkClient.findUnspentRecords(startHeight, undefined, ["credits.aleo"], undefined, maxMicrocredits);
|
|
261
|
+
*/
|
|
262
|
+
findUnspentRecords(startHeight: number, endHeight: number | undefined, programs?: string[], amounts?: number[] | undefined, maxMicrocredits?: number | undefined, nonces?: string[] | undefined, privateKey?: string | PrivateKey | undefined): Promise<Array<RecordPlaintext>>;
|
|
263
|
+
/**
|
|
264
|
+
* Returns the contents of the block at the specified block height.
|
|
265
|
+
*
|
|
266
|
+
* @param {number} blockHeight - The height of the block to fetch
|
|
267
|
+
* @returns {Promise<BlockJSON>} A javascript object containing the block at the specified height
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* const block = networkClient.getBlock(1234);
|
|
271
|
+
*/
|
|
272
|
+
getBlock(blockHeight: number): Promise<BlockJSON>;
|
|
273
|
+
/**
|
|
274
|
+
* Returns the contents of the block with the specified hash.
|
|
275
|
+
*
|
|
276
|
+
* @param {string} blockHash The hash of the block to fetch.
|
|
277
|
+
* @returns {Promise<BlockJSON>} A javascript object representation of the block matching the hash.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
281
|
+
*
|
|
282
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
283
|
+
* const block = networkClient.getBlockByHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
284
|
+
*/
|
|
285
|
+
getBlockByHash(blockHash: string): Promise<BlockJSON>;
|
|
286
|
+
/**
|
|
287
|
+
* Returns a range of blocks between the specified block heights. A maximum of 50 blocks can be fetched at a time.
|
|
288
|
+
*
|
|
289
|
+
* @param {number} start Starting block to fetch.
|
|
290
|
+
* @param {number} end Ending block to fetch. This cannot be more than 50 blocks ahead of the start block.
|
|
291
|
+
* @returns {Promise<Array<BlockJSON>>} An array of block objects
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
295
|
+
*
|
|
296
|
+
* // Fetch 50 blocks.
|
|
297
|
+
* const (start, end) = (2050, 2100);
|
|
298
|
+
* const blockRange = networkClient.getBlockRange(start, end);
|
|
299
|
+
*
|
|
300
|
+
* let cursor = start;
|
|
301
|
+
* blockRange.forEach((block) => {
|
|
302
|
+
* assert(block.height == cursor);
|
|
303
|
+
* cursor += 1;
|
|
304
|
+
* }
|
|
305
|
+
*/
|
|
306
|
+
getBlockRange(start: number, end: number): Promise<Array<BlockJSON>>;
|
|
307
|
+
/**
|
|
308
|
+
* Returns the deployment transaction id associated with the specified program.
|
|
309
|
+
*
|
|
310
|
+
* @param {Program | string} program The name of the deployed program OR a wasm Program object.
|
|
311
|
+
* @returns {Promise<string>} The transaction ID of the deployment transaction.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
315
|
+
*
|
|
316
|
+
* // Get the transaction ID of the deployment transaction for a program.
|
|
317
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
318
|
+
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
319
|
+
*
|
|
320
|
+
* // Get the transaction data for the deployment transaction.
|
|
321
|
+
* const transaction = networkClient.getTransactionObject(transactionId);
|
|
322
|
+
*
|
|
323
|
+
* // Get the verifying keys for the functions in the deployed program.
|
|
324
|
+
* const verifyingKeys = transaction.verifyingKeys();
|
|
325
|
+
*/
|
|
326
|
+
getDeploymentTransactionIDForProgram(program: Program | string): Promise<string>;
|
|
327
|
+
/**
|
|
328
|
+
* Returns the deployment transaction associated with a specified program as a JSON object.
|
|
329
|
+
*
|
|
330
|
+
* @param {Program | string} program The name of the deployed program OR a wasm Program object.
|
|
331
|
+
* @returns {Promise<Transaction>} JSON representation of the deployment transaction.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* import { AleoNetworkClient, DeploymentJSON } from "@provablehq/sdk/testnet.js";
|
|
335
|
+
*
|
|
336
|
+
* // Get the transaction ID of the deployment transaction for a program.
|
|
337
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
338
|
+
* const transaction = networkClient.getDeploymentTransactionForProgram("hello_hello.aleo");
|
|
339
|
+
*
|
|
340
|
+
* // Get the verifying keys for each function in the deployment.
|
|
341
|
+
* const deployment = <DeploymentJSON>transaction.deployment;
|
|
342
|
+
* const verifyingKeys = deployment.verifying_keys;
|
|
343
|
+
*/
|
|
344
|
+
getDeploymentTransactionForProgram(program: Program | string): Promise<TransactionJSON>;
|
|
345
|
+
/**
|
|
346
|
+
* Returns the deployment transaction associated with a specified program as a wasm object.
|
|
347
|
+
*
|
|
348
|
+
* @param {Program | string} program The name of the deployed program OR a wasm Program object.
|
|
349
|
+
* @returns {Promise<Transaction>} Wasm object representation of the deployment transaction.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
353
|
+
*
|
|
354
|
+
* // Get the transaction ID of the deployment transaction for a program.
|
|
355
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
356
|
+
* const transactionId = networkClient.getDeploymentTransactionIDForProgram("hello_hello.aleo");
|
|
357
|
+
*
|
|
358
|
+
* // Get the transaction data for the deployment transaction.
|
|
359
|
+
* const transaction = networkClient.getDeploymentTransactionObjectForProgram(transactionId);
|
|
360
|
+
*
|
|
361
|
+
* // Get the verifying keys for the functions in the deployed program.
|
|
362
|
+
* const verifyingKeys = transaction.verifyingKeys();
|
|
363
|
+
*/
|
|
364
|
+
getDeploymentTransactionObjectForProgram(program: Program | string): Promise<Transaction>;
|
|
365
|
+
/**
|
|
366
|
+
* Returns the contents of the latest block as JSON.
|
|
367
|
+
*
|
|
368
|
+
* @returns {Promise<BlockJSON>} A javascript object containing the latest block
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/testnet.js";
|
|
372
|
+
*
|
|
373
|
+
* // Create a network client.
|
|
374
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
375
|
+
*
|
|
376
|
+
* const latestHeight = networkClient.getLatestBlock();
|
|
377
|
+
*/
|
|
378
|
+
getLatestBlock(): Promise<BlockJSON>;
|
|
379
|
+
/**
|
|
380
|
+
* Returns the latest committee.
|
|
381
|
+
*
|
|
382
|
+
* @returns {Promise<object>} A javascript object containing the latest committee
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
386
|
+
*
|
|
387
|
+
* // Create a network client.
|
|
388
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
389
|
+
*
|
|
390
|
+
* // Create a network client and get the latest committee.
|
|
391
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
392
|
+
* const latestCommittee = await networkClient.getLatestCommittee();
|
|
393
|
+
*/
|
|
394
|
+
getLatestCommittee(): Promise<object>;
|
|
395
|
+
/**
|
|
396
|
+
* Returns the committee at the specified block height.
|
|
397
|
+
*
|
|
398
|
+
* @param {number} blockHeight - The height of the block to fetch the committee for
|
|
399
|
+
* @returns {Promise<object>} A javascript object containing the committee
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
403
|
+
*
|
|
404
|
+
* // Create a network client.
|
|
405
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
406
|
+
*
|
|
407
|
+
* // Create a network client and get the committee for a specific block.
|
|
408
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
409
|
+
* const committee = await networkClient.getCommitteeByBlockHeight(1234);
|
|
410
|
+
*/
|
|
411
|
+
getCommitteeByBlockHeight(blockHeight: number): Promise<object>;
|
|
412
|
+
/**
|
|
413
|
+
* Returns the latest block height.
|
|
414
|
+
*
|
|
415
|
+
* @returns {Promise<number>} The latest block height.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
419
|
+
*
|
|
420
|
+
* // Create a network client.
|
|
421
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
422
|
+
*
|
|
423
|
+
* const latestHeight = networkClient.getLatestHeight();
|
|
424
|
+
*/
|
|
425
|
+
getLatestHeight(): Promise<number>;
|
|
426
|
+
/**
|
|
427
|
+
* Returns the latest block hash.
|
|
428
|
+
*
|
|
429
|
+
* @returns {Promise<string>} The latest block hash.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
433
|
+
*
|
|
434
|
+
* // Create a network client.
|
|
435
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
436
|
+
*
|
|
437
|
+
* // Get the latest block hash.
|
|
438
|
+
* const latestHash = networkClient.getLatestBlockHash();
|
|
439
|
+
*/
|
|
440
|
+
getLatestBlockHash(): Promise<string>;
|
|
441
|
+
/**
|
|
442
|
+
* Returns the source code of a program given a program ID.
|
|
443
|
+
*
|
|
444
|
+
* @param {string} programId The program ID of a program deployed to the Aleo Network.
|
|
445
|
+
* @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.
|
|
446
|
+
* @returns {Promise<string>} The source code of the program.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
450
|
+
*
|
|
451
|
+
* // Create a network client.
|
|
452
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
453
|
+
*
|
|
454
|
+
* // Get the source code of a program.)
|
|
455
|
+
* @returns {Promise<string>} Source code of the program
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
459
|
+
*
|
|
460
|
+
* // Create a network client.
|
|
461
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
462
|
+
*
|
|
463
|
+
* const program = networkClient.getProgram("hello_hello.aleo");
|
|
464
|
+
* 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"
|
|
465
|
+
* assert.equal(program, expectedSource);
|
|
466
|
+
*/
|
|
467
|
+
getProgram(programId: string, edition?: number): Promise<string>;
|
|
468
|
+
/**
|
|
469
|
+
* Returns the current program edition deployed on the Aleo network.
|
|
470
|
+
*
|
|
471
|
+
* @param {string} programId The program ID of a program deployed to the Aleo Network.
|
|
472
|
+
* @returns {Promise<number>} The edition of the program.
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
476
|
+
*
|
|
477
|
+
* // Create a network client.
|
|
478
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
479
|
+
*
|
|
480
|
+
* const programVersion = networkClient.getLatestProgramEdition("hello_hello.aleo");
|
|
481
|
+
* assert.equal(programVersion, 1);
|
|
482
|
+
*/
|
|
483
|
+
getLatestProgramEdition(programId: string): Promise<number>;
|
|
484
|
+
/**
|
|
485
|
+
* Returns a program object from a program ID or program source code.
|
|
486
|
+
*
|
|
487
|
+
* @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network.
|
|
488
|
+
* @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.
|
|
489
|
+
* @returns {Promise<Program>} Source code of the program.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
493
|
+
*
|
|
494
|
+
* // Create a network client.
|
|
495
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
496
|
+
*
|
|
497
|
+
* const programID = "hello_hello.aleo";
|
|
498
|
+
* 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"
|
|
499
|
+
*
|
|
500
|
+
* // Get program object from program ID or program source code
|
|
501
|
+
* const programObjectFromID = await networkClient.getProgramObject(programID);
|
|
502
|
+
* const programObjectFromSource = await networkClient.getProgramObject(programSource);
|
|
503
|
+
*
|
|
504
|
+
* // Both program objects should be equal
|
|
505
|
+
* assert(programObjectFromID.to_string() === programObjectFromSource.to_string());
|
|
506
|
+
*/
|
|
507
|
+
getProgramObject(inputProgram: string, edition?: number): Promise<Program>;
|
|
508
|
+
/**
|
|
509
|
+
* Returns an object containing the source code of a program and the source code of all programs it imports
|
|
510
|
+
*
|
|
511
|
+
* @param {Program | string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
|
|
512
|
+
* @returns {Promise<ProgramImports>} Object of the form { "program_id": "program_source", .. } containing program id & source code for all program imports
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
516
|
+
*
|
|
517
|
+
* const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n input r0 as u32.private;\n call multiply_test.aleo/multiply 2u32 r0 into r1;\n output r1 as u32.private;\n"
|
|
518
|
+
* const double_test = Program.fromString(double_test_source);
|
|
519
|
+
* const expectedImports = {
|
|
520
|
+
* "multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n input r0 as u32.public;\n input r1 as u32.private;\n mul r0 r1 into r2;\n output r2 as u32.private;\n"
|
|
521
|
+
* }
|
|
522
|
+
*
|
|
523
|
+
* // Create a network client.
|
|
524
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
525
|
+
*
|
|
526
|
+
* // Imports can be fetched using the program ID, source code, or program object
|
|
527
|
+
* let programImports = await networkClient.getProgramImports("double_test.aleo");
|
|
528
|
+
* assert.deepStrictEqual(programImports, expectedImports);
|
|
529
|
+
*
|
|
530
|
+
* // Using the program source code
|
|
531
|
+
* programImports = await networkClient.getProgramImports(double_test_source);
|
|
532
|
+
* assert.deepStrictEqual(programImports, expectedImports);
|
|
533
|
+
*
|
|
534
|
+
* // Using the program object
|
|
535
|
+
* programImports = await networkClient.getProgramImports(double_test);
|
|
536
|
+
* assert.deepStrictEqual(programImports, expectedImports);
|
|
537
|
+
*/
|
|
538
|
+
getProgramImports(inputProgram: Program | string, imports?: ProgramImports): Promise<ProgramImports>;
|
|
539
|
+
/**
|
|
540
|
+
* Get a list of the program names that a program imports.
|
|
541
|
+
*
|
|
542
|
+
* @param {Program | string} inputProgram - The program id or program source code to get the imports of
|
|
543
|
+
* @returns {string[]} - The list of program names that the program imports
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
547
|
+
*
|
|
548
|
+
* // Create a network client.
|
|
549
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
550
|
+
*
|
|
551
|
+
* const programImportsNames = networkClient.getProgramImports("wrapped_credits.aleo");
|
|
552
|
+
* const expectedImportsNames = ["credits.aleo"];
|
|
553
|
+
* assert.deepStrictEqual(programImportsNames, expectedImportsNames);
|
|
554
|
+
*/
|
|
555
|
+
getProgramImportNames(inputProgram: Program | string): Promise<string[]>;
|
|
556
|
+
/**
|
|
557
|
+
* Returns the names of the mappings of a program.
|
|
558
|
+
*
|
|
559
|
+
* @param {string} programId - The program ID to get the mappings of (e.g. "credits.aleo")
|
|
560
|
+
* @returns {Promise<Array<string>>} - The names of the mappings of the program.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
564
|
+
*
|
|
565
|
+
* // Create a network client.
|
|
566
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
567
|
+
*
|
|
568
|
+
* const mappings = networkClient.getProgramMappingNames("credits.aleo");
|
|
569
|
+
* const expectedMappings = [
|
|
570
|
+
* "committee",
|
|
571
|
+
* "delegated",
|
|
572
|
+
* "metadata",
|
|
573
|
+
* "bonded",
|
|
574
|
+
* "unbonding",
|
|
575
|
+
* "account",
|
|
576
|
+
* "withdraw"
|
|
577
|
+
* ];
|
|
578
|
+
* assert.deepStrictEqual(mappings, expectedMappings);
|
|
579
|
+
*/
|
|
580
|
+
getProgramMappingNames(programId: string): Promise<Array<string>>;
|
|
581
|
+
/**
|
|
582
|
+
* Returns the value of a program's mapping for a specific key.
|
|
583
|
+
*
|
|
584
|
+
* @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
|
|
585
|
+
* @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
|
|
586
|
+
* @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the "account" mapping)
|
|
587
|
+
* @returns {Promise<string>} String representation of the value of the mapping
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
591
|
+
*
|
|
592
|
+
* // Create a network client.
|
|
593
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
594
|
+
*
|
|
595
|
+
* // Get public balance of an account
|
|
596
|
+
* const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
597
|
+
* const expectedValue = "0u64";
|
|
598
|
+
* assert(mappingValue === expectedValue);
|
|
599
|
+
*/
|
|
600
|
+
getProgramMappingValue(programId: string, mappingName: string, key: string | Plaintext): Promise<string>;
|
|
601
|
+
/**
|
|
602
|
+
* Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.
|
|
603
|
+
*
|
|
604
|
+
* @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
|
|
605
|
+
* @param {string} mappingName - The name of the mapping to get the value of (e.g. "bonded")
|
|
606
|
+
* @param {string | Plaintext} key - The key to look up in the mapping (e.g. an address for the "bonded" mapping)
|
|
607
|
+
* @returns {Promise<Plaintext>} String representation of the value of the mapping
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
611
|
+
*
|
|
612
|
+
* // Create a network client.
|
|
613
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
614
|
+
*
|
|
615
|
+
* // Get the bond state as an account.
|
|
616
|
+
* const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
617
|
+
*
|
|
618
|
+
* // Get the two members of the object individually.
|
|
619
|
+
* const validator = unbondedState.getMember("validator");
|
|
620
|
+
* const microcredits = unbondedState.getMember("microcredits");
|
|
621
|
+
*
|
|
622
|
+
* // Ensure the expected values are correct.
|
|
623
|
+
* assert.equal(validator, "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd");
|
|
624
|
+
* assert.equal(microcredits, BigInt("9007199254740991"));
|
|
625
|
+
*
|
|
626
|
+
* // Get a JS object representation of the unbonded state.
|
|
627
|
+
* const unbondedStateObject = unbondedState.toObject();
|
|
628
|
+
*
|
|
629
|
+
* const expectedState = {
|
|
630
|
+
* validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
|
|
631
|
+
* microcredits: BigInt(9007199254740991)
|
|
632
|
+
* };
|
|
633
|
+
* assert.equal(unbondedState, expectedState);
|
|
634
|
+
*/
|
|
635
|
+
getProgramMappingPlaintext(programId: string, mappingName: string, key: string | Plaintext): Promise<Plaintext>;
|
|
636
|
+
/**
|
|
637
|
+
* Returns the public balance of an address from the account mapping in credits.aleo
|
|
638
|
+
*
|
|
639
|
+
* @param {Address | string} address A string or wasm object representing an address.
|
|
640
|
+
* @returns {Promise<number>} The public balance of the address in microcredits.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
644
|
+
*
|
|
645
|
+
* // Create a network client.
|
|
646
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
647
|
+
*
|
|
648
|
+
* // Get the balance of an account from either an address object or address string.
|
|
649
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
650
|
+
* const publicBalance = await networkClient.getPublicBalance(account.address());
|
|
651
|
+
* const publicBalanceFromString = await networkClient.getPublicBalance(account.address().to_string());
|
|
652
|
+
* assert(publicBalance === publicBalanceFromString);
|
|
653
|
+
*/
|
|
654
|
+
getPublicBalance(address: Address | string): Promise<number>;
|
|
655
|
+
/**
|
|
656
|
+
* Returns the latest state/merkle root of the Aleo blockchain.
|
|
657
|
+
*
|
|
658
|
+
* @returns {Promise<string>} A string representing the latest state root of the Aleo blockchain.
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
662
|
+
*
|
|
663
|
+
* // Create a network client.
|
|
664
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
665
|
+
*
|
|
666
|
+
* // Get the latest state root.
|
|
667
|
+
* const stateRoot = networkClient.getStateRoot();
|
|
668
|
+
*/
|
|
669
|
+
getStateRoot(): Promise<string>;
|
|
670
|
+
/**
|
|
671
|
+
* Returns a transaction by its unique identifier.
|
|
672
|
+
*
|
|
673
|
+
* @param {string} transactionId The transaction ID to fetch.
|
|
674
|
+
* @returns {Promise<TransactionJSON>} A json representation of the transaction.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
678
|
+
*
|
|
679
|
+
* // Create a network client.
|
|
680
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
681
|
+
*
|
|
682
|
+
* const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
683
|
+
*/
|
|
684
|
+
getTransaction(transactionId: string): Promise<TransactionJSON>;
|
|
685
|
+
/**
|
|
686
|
+
* Returns a confirmed transaction by its unique identifier.
|
|
687
|
+
*
|
|
688
|
+
* @param {string} transactionId The transaction ID to fetch.
|
|
689
|
+
* @returns {Promise<ConfirmedTransactionJSON>} A json object containing the confirmed transaction.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
693
|
+
*
|
|
694
|
+
* // Create a network client.
|
|
695
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
696
|
+
*
|
|
697
|
+
* const transaction = networkClient.getConfirmedTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
698
|
+
* assert.equal(transaction.status, "confirmed");
|
|
699
|
+
*/
|
|
700
|
+
getConfirmedTransaction(transactionId: string): Promise<ConfirmedTransactionJSON>;
|
|
701
|
+
/**
|
|
702
|
+
* Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,
|
|
703
|
+
* outputs, and records to be searched for and displayed.
|
|
704
|
+
*
|
|
705
|
+
* @param {string} transactionId - The unique identifier of the transaction to fetch
|
|
706
|
+
* @returns {Promise<Transaction>} A wasm object representation of the transaction.
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* const transactionObject = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
|
|
710
|
+
* // Get the transaction inputs as a JS array.
|
|
711
|
+
* const transactionInputs = transactionObject.inputs(true);
|
|
712
|
+
*
|
|
713
|
+
* // Get the transaction outputs as a JS object.
|
|
714
|
+
* const transactionOutputs = transactionObject.outputs(true);
|
|
715
|
+
*
|
|
716
|
+
* // Get any records generated in transitions in the transaction as a JS object.
|
|
717
|
+
* const records = transactionObject.records();
|
|
718
|
+
*
|
|
719
|
+
* // Get the transaction type.
|
|
720
|
+
* const transactionType = transactionObject.transactionType();
|
|
721
|
+
* assert.equal(transactionType, "Execute");
|
|
722
|
+
*
|
|
723
|
+
* // Get a JS representation of all inputs, outputs, and transaction metadata.
|
|
724
|
+
* const transactionSummary = transactionObject.summary();
|
|
725
|
+
*/
|
|
726
|
+
getTransactionObject(transactionId: string): Promise<Transaction>;
|
|
727
|
+
/**
|
|
728
|
+
* Returns the transactions present at the specified block height.
|
|
729
|
+
*
|
|
730
|
+
* @param {number} blockHeight The block height to fetch the confirmed transactions at.
|
|
731
|
+
* @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block height.
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
735
|
+
*
|
|
736
|
+
* // Create a network client.
|
|
737
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
738
|
+
*
|
|
739
|
+
* const transactions = networkClient.getTransactions(654);
|
|
740
|
+
*/
|
|
741
|
+
getTransactions(blockHeight: number): Promise<Array<ConfirmedTransactionJSON>>;
|
|
742
|
+
/**
|
|
743
|
+
* Returns the confirmed transactions present in the block with the specified block hash.
|
|
744
|
+
*
|
|
745
|
+
* @param {string} blockHash The block hash to fetch the confirmed transactions at.
|
|
746
|
+
* @returns {Promise<Array<ConfirmedTransactionJSON>>} An array of confirmed transactions (in JSON format) for the block hash.
|
|
747
|
+
*
|
|
748
|
+
* @example
|
|
749
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
750
|
+
*
|
|
751
|
+
* // Create a network client.
|
|
752
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
753
|
+
*
|
|
754
|
+
* const transactions = networkClient.getTransactionsByBlockHash("ab19dklwl9vp63zu3hwg57wyhvmqf92fx5g8x0t6dr72py8r87pxupqfne5t9");
|
|
755
|
+
*/
|
|
756
|
+
getTransactionsByBlockHash(blockHash: string): Promise<Array<ConfirmedTransactionJSON>>;
|
|
757
|
+
/**
|
|
758
|
+
* Returns the transactions in the memory pool. This method requires access to a validator's REST API.
|
|
759
|
+
*
|
|
760
|
+
* @returns {Promise<Array<TransactionJSON>>} An array of transactions (in JSON format) currently in the mempool.
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/mainnet.js";
|
|
764
|
+
*
|
|
765
|
+
* // Create a network client.
|
|
766
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
767
|
+
*
|
|
768
|
+
* // Get the current transactions in the mempool.
|
|
769
|
+
* const transactions = networkClient.getTransactionsInMempool();
|
|
770
|
+
*/
|
|
771
|
+
getTransactionsInMempool(): Promise<Array<TransactionJSON>>;
|
|
772
|
+
/**
|
|
773
|
+
* Returns the transition ID of the transition corresponding to the ID of the input or output.
|
|
774
|
+
* @param {string} inputOrOutputID - The unique identifier of the input or output to find the transition ID for
|
|
775
|
+
* @returns {Promise<string>} - The transition ID of the input or output ID.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* const transitionId = networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");
|
|
779
|
+
*/
|
|
780
|
+
getTransitionId(inputOrOutputID: string): Promise<string>;
|
|
781
|
+
/**
|
|
782
|
+
* Submit an execute or deployment transaction to the Aleo network.
|
|
783
|
+
*
|
|
784
|
+
* @param {Transaction | string} transaction - The transaction to submit, either as a Transaction object or string representation
|
|
785
|
+
* @returns {Promise<string>} - The transaction id of the submitted transaction or the resulting error
|
|
786
|
+
*/
|
|
787
|
+
submitTransaction(transaction: Transaction | string): Promise<string>;
|
|
788
|
+
/**
|
|
789
|
+
* Submit a solution to the Aleo network.
|
|
790
|
+
*
|
|
791
|
+
* @param {string} solution - The string representation of the solution to submit
|
|
792
|
+
* @returns {Promise<string>} The solution id of the submitted solution or the resulting error.
|
|
793
|
+
*/
|
|
794
|
+
submitSolution(solution: string): Promise<string>;
|
|
795
|
+
/**
|
|
796
|
+
* Refreshes the JWT by making a POST request to /jwts/{consumer_id}
|
|
797
|
+
*
|
|
798
|
+
* @param {string} apiKey - The API key for authentication.
|
|
799
|
+
* @param {string} consumerId - The consumer ID associated with the API key.
|
|
800
|
+
* @returns {Promise<JwtData>} The JWT token and expiration time
|
|
801
|
+
*/
|
|
802
|
+
private refreshJwt;
|
|
803
|
+
/**
|
|
804
|
+
* Parses a /prove or /prove/encrypted response. Returns a result object (never throws for 200/400/500/503).
|
|
805
|
+
*/
|
|
806
|
+
private handleProvingResponse;
|
|
807
|
+
/**
|
|
808
|
+
* Submit a `ProvingRequest` to a remote proving service for delegated proving. If the broadcast flag of the `ProvingRequest` is set to `true` the remote service will attempt to broadcast the result `Transaction` on behalf of the requestor. Throws on HTTP 400, 500, 503 (and retries on 500/503). Callers should {@link submitProvingRequestSafe} to handle proving request failures without throwing.
|
|
809
|
+
*
|
|
810
|
+
* @param {DelegatedProvingParams} options - The optional parameters required to submit a proving request.
|
|
811
|
+
* @returns {Promise<ProvingResponse>} The ProvingResponse containing the transaction result and the result of the broadcast if the `broadcast` flag was set to `true`.
|
|
812
|
+
*/
|
|
813
|
+
submitProvingRequest(options: DelegatedProvingParams): Promise<ProvingResponse>;
|
|
814
|
+
/**
|
|
815
|
+
* Submit a proving request and return a result object instead of throwing. This method is usable when callers want to handle HTTP status (400, 500, 503) yourself. Retries on 500/503 and returns on 200 or 400.
|
|
816
|
+
*
|
|
817
|
+
* @param {DelegatedProvingParams} options - The optional parameters required to submit a proving request.
|
|
818
|
+
* @returns {Promise<ProvingResult>} `{ ok: true, data }` on success (200), or `{ ok: false, status, error }` on 400/500/503. Check `result.ok` and then either `result.data` or `result.status` / `result.error.message`.
|
|
819
|
+
*/
|
|
820
|
+
submitProvingRequestSafe(options: DelegatedProvingParams): Promise<ProvingResult>;
|
|
821
|
+
/**
|
|
822
|
+
* Await a submitted transaction to be confirmed or rejected on the Aleo network.
|
|
823
|
+
*
|
|
824
|
+
* @param {string} transactionId - The transaction ID to wait for confirmation
|
|
825
|
+
* @param {number} checkInterval - The interval in milliseconds to check for confirmation (default: 2000)
|
|
826
|
+
* @param {number} timeout - The maximum time in milliseconds to wait for confirmation (default: 45000)
|
|
827
|
+
* @returns {Promise<Transaction>} The confirmed transaction object that returns if the transaction is confirmed.
|
|
828
|
+
*
|
|
829
|
+
* @example
|
|
830
|
+
* import { AleoNetworkClient, Account, ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
831
|
+
*
|
|
832
|
+
* // Create a network client and program manager.
|
|
833
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2", undefined);
|
|
834
|
+
* const programManager = new ProgramManager(networkClient);
|
|
835
|
+
*
|
|
836
|
+
* // Set the account for the program manager.
|
|
837
|
+
* programManager.setAccount(Account.fromCiphertext(process.env.ciphertext, process.env.password));
|
|
838
|
+
*
|
|
839
|
+
* // Build a transfer transaction.
|
|
840
|
+
* const tx = await programManager.buildTransferPublicTransaction(100, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0);
|
|
841
|
+
*
|
|
842
|
+
* // Submit the transaction to the network.
|
|
843
|
+
* const transactionId = await networkClient.submitTransaction(tx);
|
|
844
|
+
*
|
|
845
|
+
* // Wait for the transaction to be confirmed.
|
|
846
|
+
* const transaction = await networkClient.waitForTransactionConfirmation(transactionId);
|
|
847
|
+
*/
|
|
848
|
+
waitForTransactionConfirmation(transactionId: string, checkInterval?: number, timeout?: number): Promise<ConfirmedTransactionJSON>;
|
|
849
|
+
}
|
|
850
|
+
export { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports };
|