@provablehq/sdk 0.10.0-rc → 0.10.1
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.d.ts +8 -0
- package/dist/dynamic/browser.js +8 -0
- package/dist/dynamic/node.d.ts +8 -0
- package/dist/dynamic/node.js +8 -0
- package/dist/mainnet/account.d.ts +61 -6
- package/dist/mainnet/browser.d.ts +41 -8
- package/dist/mainnet/browser.js +3758 -571
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/constants.d.ts +6 -0
- package/dist/mainnet/external-signing.d.ts +76 -0
- package/dist/mainnet/integrations/sealance/merkle-tree.d.ts +192 -0
- package/dist/mainnet/keys/keystore/error.d.ts +24 -0
- package/dist/mainnet/keys/keystore/file.d.ts +177 -0
- package/dist/mainnet/keys/keystore/interface.d.ts +161 -0
- package/dist/mainnet/keys/provider/interface.d.ts +170 -0
- package/dist/mainnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
- package/dist/mainnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
- package/dist/mainnet/keys/verifier/interface.d.ts +70 -0
- package/dist/mainnet/keys/verifier/memory.d.ts +37 -0
- package/dist/mainnet/models/cryptoBoxPubkey.d.ts +4 -0
- package/dist/mainnet/models/encryptedProvingRequest.d.ts +4 -0
- package/dist/mainnet/models/external-signing.d.ts +123 -0
- package/dist/mainnet/models/functionInput.d.ts +7 -0
- package/dist/mainnet/models/input/inputJSON.d.ts +1 -0
- package/dist/mainnet/models/input/inputObject.d.ts +1 -0
- package/dist/mainnet/models/keyPair.d.ts +4 -0
- package/dist/mainnet/models/output/outputJSON.d.ts +1 -0
- package/dist/mainnet/models/output/outputObject.d.ts +1 -0
- package/dist/mainnet/models/provingResponse.d.ts +48 -2
- package/dist/mainnet/models/record-provider/encryptedRecord.d.ts +58 -0
- package/dist/mainnet/models/record-provider/ownedRecord.d.ts +60 -0
- package/dist/mainnet/models/record-provider/recordSearchParams.d.ts +19 -0
- package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
- package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
- package/dist/mainnet/models/record-scanner/error.d.ts +47 -0
- package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +22 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +35 -0
- package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
- package/dist/mainnet/models/record-scanner/registrationRequest.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResult.d.ts +9 -0
- package/dist/mainnet/models/record-scanner/revokeResult.d.ts +17 -0
- package/dist/mainnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
- package/dist/mainnet/models/record-scanner/statusResponse.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/statusResult.d.ts +13 -0
- package/dist/mainnet/models/record-scanner/tagsResult.d.ts +12 -0
- package/dist/mainnet/network-client.d.ts +129 -46
- package/dist/mainnet/node-polyfill.js +2 -49
- package/dist/mainnet/node-polyfill.js.map +1 -1
- package/dist/mainnet/node.d.ts +1 -0
- package/dist/mainnet/node.js +376 -4
- package/dist/mainnet/node.js.map +1 -1
- package/dist/mainnet/program-manager.d.ts +556 -58
- package/dist/mainnet/record-provider.d.ts +113 -75
- package/dist/mainnet/record-scanner.d.ts +368 -0
- package/dist/mainnet/security.d.ts +62 -0
- package/dist/mainnet/utils.d.ts +1 -0
- package/dist/mainnet/wasm.d.ts +1 -1
- package/dist/testnet/account.d.ts +61 -6
- package/dist/testnet/browser.d.ts +41 -8
- package/dist/testnet/browser.js +3758 -571
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/constants.d.ts +6 -0
- package/dist/testnet/external-signing.d.ts +76 -0
- package/dist/testnet/integrations/sealance/merkle-tree.d.ts +192 -0
- package/dist/testnet/keys/keystore/error.d.ts +24 -0
- package/dist/testnet/keys/keystore/file.d.ts +177 -0
- package/dist/testnet/keys/keystore/interface.d.ts +161 -0
- package/dist/testnet/keys/provider/interface.d.ts +170 -0
- package/dist/testnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
- package/dist/testnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
- package/dist/testnet/keys/verifier/interface.d.ts +70 -0
- package/dist/testnet/keys/verifier/memory.d.ts +37 -0
- package/dist/testnet/models/cryptoBoxPubkey.d.ts +4 -0
- package/dist/testnet/models/encryptedProvingRequest.d.ts +4 -0
- package/dist/testnet/models/external-signing.d.ts +123 -0
- package/dist/testnet/models/functionInput.d.ts +7 -0
- package/dist/testnet/models/input/inputJSON.d.ts +1 -0
- package/dist/testnet/models/input/inputObject.d.ts +1 -0
- package/dist/testnet/models/keyPair.d.ts +4 -0
- package/dist/testnet/models/output/outputJSON.d.ts +1 -0
- package/dist/testnet/models/output/outputObject.d.ts +1 -0
- package/dist/testnet/models/provingResponse.d.ts +48 -2
- package/dist/testnet/models/record-provider/encryptedRecord.d.ts +58 -0
- package/dist/testnet/models/record-provider/ownedRecord.d.ts +60 -0
- package/dist/testnet/models/record-provider/recordSearchParams.d.ts +19 -0
- package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
- package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
- package/dist/testnet/models/record-scanner/error.d.ts +47 -0
- package/dist/testnet/models/record-scanner/ownedFilter.d.ts +22 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.ts +35 -0
- package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
- package/dist/testnet/models/record-scanner/registrationRequest.d.ts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.ts +13 -0
- package/dist/testnet/models/record-scanner/registrationResult.d.ts +9 -0
- package/dist/testnet/models/record-scanner/revokeResult.d.ts +17 -0
- package/dist/testnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
- package/dist/testnet/models/record-scanner/statusResponse.d.ts +13 -0
- package/dist/testnet/models/record-scanner/statusResult.d.ts +13 -0
- package/dist/testnet/models/record-scanner/tagsResult.d.ts +12 -0
- package/dist/testnet/network-client.d.ts +129 -46
- package/dist/testnet/node-polyfill.js +2 -49
- package/dist/testnet/node-polyfill.js.map +1 -1
- package/dist/testnet/node.d.ts +1 -0
- package/dist/testnet/node.js +376 -4
- package/dist/testnet/node.js.map +1 -1
- package/dist/testnet/program-manager.d.ts +556 -58
- package/dist/testnet/record-provider.d.ts +113 -75
- package/dist/testnet/record-scanner.d.ts +368 -0
- package/dist/testnet/security.d.ts +62 -0
- package/dist/testnet/utils.d.ts +1 -0
- package/dist/testnet/wasm.d.ts +1 -1
- package/package.json +11 -6
|
@@ -1,27 +1,50 @@
|
|
|
1
1
|
import { Account } from "./account.js";
|
|
2
2
|
import { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from "./network-client.js";
|
|
3
3
|
import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
|
|
4
|
-
import { RecordProvider
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { RecordProvider } from "./record-provider.js";
|
|
5
|
+
import { RecordSearchParams } from "./models/record-provider/recordSearchParams.js";
|
|
6
|
+
import { FunctionKeyProvider, KeySearchParams } from "./keys/provider/interface.js";
|
|
7
|
+
import { FunctionKeyPair } from "./models/keyPair.js";
|
|
8
|
+
import { Authorization, ExecutionRequest, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
|
|
9
|
+
import { ExternalSigningOptions } from "./models/external-signing.js";
|
|
10
|
+
/**
|
|
11
|
+
* Represents the options for deploying and upgrading a transaction in the Aleo network.
|
|
12
|
+
* This interface is used to specify the parameters required for building and submitting an deployment transaction.
|
|
13
|
+
*
|
|
14
|
+
* @property {string} program - The program source code to be deployed.
|
|
15
|
+
* @property {number} priorityFee - The priority fee to be paid for the transaction.
|
|
16
|
+
* @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
|
|
17
|
+
* @property {RecordSearchParams} [recordSearchParams] - Parameters for searching for a record to pay the execution transaction fee.
|
|
18
|
+
* @property {string | RecordPlaintext} [feeRecord] - Fee record to use for the transaction.
|
|
19
|
+
* @property {PrivateKey} [privateKey] - Private key to use for the transaction.
|
|
20
|
+
*/
|
|
21
|
+
interface DeployOptions {
|
|
22
|
+
program: string;
|
|
23
|
+
priorityFee: number;
|
|
24
|
+
privateFee: boolean;
|
|
25
|
+
recordSearchParams?: RecordSearchParams;
|
|
26
|
+
feeRecord?: string | RecordPlaintext;
|
|
27
|
+
privateKey?: PrivateKey;
|
|
28
|
+
}
|
|
7
29
|
/**
|
|
8
30
|
* Represents the options for executing a transaction in the Aleo network.
|
|
9
31
|
* This interface is used to specify the parameters required for building and submitting an execution transaction.
|
|
10
32
|
*
|
|
11
33
|
* @property {string} programName - The name of the program containing the function to be executed.
|
|
12
34
|
* @property {string} functionName - The name of the function to execute within the program.
|
|
13
|
-
* @property {number} priorityFee - The
|
|
35
|
+
* @property {number} priorityFee - The priority fee to be paid for the transaction.
|
|
14
36
|
* @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
|
|
15
37
|
* @property {string[]} inputs - The inputs to the function being executed.
|
|
16
|
-
* @property {RecordSearchParams} [recordSearchParams] -
|
|
17
|
-
* @property {KeySearchParams} [keySearchParams] -
|
|
18
|
-
* @property {string | RecordPlaintext} [feeRecord] -
|
|
19
|
-
* @property {ProvingKey} [provingKey] -
|
|
20
|
-
* @property {VerifyingKey} [verifyingKey] -
|
|
21
|
-
* @property {PrivateKey} [privateKey] -
|
|
22
|
-
* @property {OfflineQuery} [offlineQuery] -
|
|
23
|
-
* @property {string | Program} [program] -
|
|
24
|
-
* @property {ProgramImports} [imports] -
|
|
38
|
+
* @property {RecordSearchParams} [recordSearchParams] - Parameters for searching for a record to pay the execution transaction fee.
|
|
39
|
+
* @property {KeySearchParams} [keySearchParams] - Parameters for finding the matching proving & verifying keys for the function.
|
|
40
|
+
* @property {string | RecordPlaintext} [feeRecord] - Fee record to use for the transaction.
|
|
41
|
+
* @property {ProvingKey} [provingKey] - Proving key to use for the transaction.
|
|
42
|
+
* @property {VerifyingKey} [verifyingKey] - Verifying key to use for the transaction.
|
|
43
|
+
* @property {PrivateKey} [privateKey] - Private key to use for the transaction.
|
|
44
|
+
* @property {OfflineQuery} [offlineQuery] - Offline query if creating transactions in an offline environment.
|
|
45
|
+
* @property {string | Program} [program] - Program source code to use for the transaction.
|
|
46
|
+
* @property {ProgramImports} [imports] - Programs that the program being executed imports.
|
|
47
|
+
* @property {number} [edition] - Edition of the program to execute the function in.
|
|
25
48
|
*/
|
|
26
49
|
interface ExecuteOptions {
|
|
27
50
|
programName: string;
|
|
@@ -43,12 +66,13 @@ interface ExecuteOptions {
|
|
|
43
66
|
/**
|
|
44
67
|
* Options for building an Authorization for a function.
|
|
45
68
|
*
|
|
46
|
-
* @property
|
|
47
|
-
* @property
|
|
48
|
-
* @property
|
|
49
|
-
* @property
|
|
50
|
-
* @property
|
|
51
|
-
* @property
|
|
69
|
+
* @property {string} programName Name of the program containing the function to build the authorization for.
|
|
70
|
+
* @property {string} functionName Name of the function name to build the authorization for.
|
|
71
|
+
* @property {string[]} inputs The inputs to the function.
|
|
72
|
+
* @property {string | Program} [programSource] The optional source code for the program to build an execution for.
|
|
73
|
+
* @property {PrivateKey} [privateKey] Optional private key to use to build the authorization.
|
|
74
|
+
* @property {ProgramImports} [programImports] The other programs the program imports.
|
|
75
|
+
* @property {edition} [edition]
|
|
52
76
|
*/
|
|
53
77
|
interface AuthorizationOptions {
|
|
54
78
|
programName: string;
|
|
@@ -62,11 +86,11 @@ interface AuthorizationOptions {
|
|
|
62
86
|
/**
|
|
63
87
|
* Options for executing a fee authorization.
|
|
64
88
|
*
|
|
65
|
-
* @property
|
|
66
|
-
* @property
|
|
67
|
-
* @property
|
|
68
|
-
* @property
|
|
69
|
-
* @property
|
|
89
|
+
* @property {string} deploymentOrExecutionId The id of a previously built Execution or Authorization.
|
|
90
|
+
* @property {number} baseFeeCredits The number of Aleo Credits to pay for the base fee.
|
|
91
|
+
* @property {number} [priorityFeeCredits] The number of Aleo Credits to pay for the priority fee.
|
|
92
|
+
* @property {PrivateKey} [privateKey] Optional private key to specify for the authorization.
|
|
93
|
+
* @property {RecordPlaintext} [feeRecord] A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
|
|
70
94
|
*/
|
|
71
95
|
interface FeeAuthorizationOptions {
|
|
72
96
|
deploymentOrExecutionId: string;
|
|
@@ -75,13 +99,36 @@ interface FeeAuthorizationOptions {
|
|
|
75
99
|
privateKey?: PrivateKey;
|
|
76
100
|
feeRecord?: RecordPlaintext;
|
|
77
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Represents the options for executing a transaction on the Aleo Network from an authorization.
|
|
104
|
+
*
|
|
105
|
+
* @property {string} programName - The name of the program containing the function to be executed.
|
|
106
|
+
* @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.
|
|
107
|
+
* @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.
|
|
108
|
+
* @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.
|
|
109
|
+
* @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.
|
|
110
|
+
* @property {string | Program} [program] - Optional program source code to use for the transaction.
|
|
111
|
+
* @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
|
|
112
|
+
*/
|
|
113
|
+
interface ExecuteAuthorizationOptions {
|
|
114
|
+
programName: string;
|
|
115
|
+
authorization: Authorization;
|
|
116
|
+
feeAuthorization?: Authorization;
|
|
117
|
+
keySearchParams?: KeySearchParams;
|
|
118
|
+
provingKey?: ProvingKey;
|
|
119
|
+
verifyingKey?: VerifyingKey;
|
|
120
|
+
offlineQuery?: OfflineQuery;
|
|
121
|
+
program?: string | Program;
|
|
122
|
+
imports?: ProgramImports;
|
|
123
|
+
}
|
|
78
124
|
/**
|
|
79
125
|
* Represents the options for executing a transaction in the Aleo network.
|
|
80
126
|
* This interface is used to specify the parameters required for building and submitting an execution transaction.
|
|
81
127
|
*
|
|
82
128
|
* @property {string} programName - The name of the program containing the function to be executed.
|
|
83
129
|
* @property {string} functionName - The name of the function to execute within the program.
|
|
84
|
-
* @property {number} baseFee - The base fee to be paid for the transaction.
|
|
130
|
+
* @property {number} [baseFee] - The base fee to be paid for the transaction.
|
|
131
|
+
* @deprecated Base fee is now estimated automatically; this option is ignored and will be removed in a future version.
|
|
85
132
|
* @property {number} priorityFee - The optional priority fee to be paid for the transaction.
|
|
86
133
|
* @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
|
|
87
134
|
* @property {string[]} inputs - The inputs to the function being executed.
|
|
@@ -92,14 +139,17 @@ interface FeeAuthorizationOptions {
|
|
|
92
139
|
* @property {string} uri - The URI send the ProvingRequest to.
|
|
93
140
|
* @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
|
|
94
141
|
* @property {boolean} broadcast - Whether to broadcast the Transaction generated by the remove prover to the Aleo network.
|
|
142
|
+
* @property {boolean} unchecked - Whether to execute the transaction without checking the validity of the authorization (faster but may fail).
|
|
143
|
+
* @property {number} [edition] - Edition of the program to execute the function in.
|
|
144
|
+
* @property {boolean} [useFeeMaster] - Whether to use the FeeMaster account to execute the transaction.
|
|
95
145
|
*/
|
|
96
146
|
interface ProvingRequestOptions {
|
|
97
147
|
programName: string;
|
|
98
148
|
functionName: string;
|
|
99
|
-
baseFee: number;
|
|
100
149
|
priorityFee: number;
|
|
101
150
|
privateFee: boolean;
|
|
102
|
-
inputs
|
|
151
|
+
inputs?: string[];
|
|
152
|
+
baseFee?: number;
|
|
103
153
|
recordSearchParams?: RecordSearchParams;
|
|
104
154
|
feeRecord?: string | RecordPlaintext;
|
|
105
155
|
privateKey?: PrivateKey;
|
|
@@ -108,6 +158,50 @@ interface ProvingRequestOptions {
|
|
|
108
158
|
broadcast?: boolean;
|
|
109
159
|
unchecked?: boolean;
|
|
110
160
|
edition?: number;
|
|
161
|
+
useFeeMaster?: boolean;
|
|
162
|
+
executionRequest?: ExecutionRequest;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Fee estimate options.
|
|
166
|
+
*
|
|
167
|
+
* @property {string} programName - The name of the program containing the function to estimate the fee for.
|
|
168
|
+
* @property {string} functionName - The name of the function to execute within the program to estimate the fee for.
|
|
169
|
+
* @property {string} [program] - Program source code to use for the fee estimate.
|
|
170
|
+
* @property {ProgramImports} [imports] - Programs that the program imports.
|
|
171
|
+
* @property {number} [edition] - Edition of the program to estimate the fee for.
|
|
172
|
+
* @property {Authorization} authorization - An authorization to estimate the fee for.
|
|
173
|
+
*/
|
|
174
|
+
interface FeeEstimateOptions {
|
|
175
|
+
programName: string;
|
|
176
|
+
functionName?: string;
|
|
177
|
+
program?: string | Program;
|
|
178
|
+
imports?: ProgramImports;
|
|
179
|
+
edition?: number;
|
|
180
|
+
authorization?: Authorization;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Options for verifying a single Aleo zkSnark proof.
|
|
184
|
+
*
|
|
185
|
+
* @property {string} verifyingKey - The verifying key string for the circuit
|
|
186
|
+
* @property {string[]} inputs - Array of public input strings — either field elements (e.g. "1field") or Aleo types (e.g. "1u32", "{ x: 1u8 }")
|
|
187
|
+
* @property {string} proof - The proof string to verify
|
|
188
|
+
*/
|
|
189
|
+
interface VerificationOptions {
|
|
190
|
+
verifyingKey: string;
|
|
191
|
+
inputs: string[];
|
|
192
|
+
proof: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Options for verifying a batch Aleo zkSnark proof.
|
|
196
|
+
*
|
|
197
|
+
* @property {string[]} verifyingKeys - Array of verifying key strings, one per circuit
|
|
198
|
+
* @property {string[][][]} inputs - 3D array of input strings [circuit_idx][instance_idx][input_idx]
|
|
199
|
+
* @property {string} proof - The batch proof string to verify
|
|
200
|
+
*/
|
|
201
|
+
interface BatchVerificationOptions {
|
|
202
|
+
verifyingKeys: string[];
|
|
203
|
+
inputs: string[][][];
|
|
204
|
+
proof: string;
|
|
111
205
|
}
|
|
112
206
|
/**
|
|
113
207
|
* The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
|
|
@@ -118,6 +212,7 @@ declare class ProgramManager {
|
|
|
118
212
|
host: string;
|
|
119
213
|
networkClient: AleoNetworkClient;
|
|
120
214
|
recordProvider: RecordProvider | undefined;
|
|
215
|
+
inclusionKeysLoaded: boolean;
|
|
121
216
|
/** Create a new instance of the ProgramManager
|
|
122
217
|
*
|
|
123
218
|
* @param { string | undefined } host A host uri running the official Aleo API
|
|
@@ -163,12 +258,31 @@ declare class ProgramManager {
|
|
|
163
258
|
* import { ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
164
259
|
*
|
|
165
260
|
* // Create a ProgramManager
|
|
166
|
-
* const programManager = new ProgramManager("https://api.
|
|
261
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2");
|
|
167
262
|
*
|
|
168
263
|
* // Set the value of the `Accept-Language` header to `en-US`
|
|
169
264
|
* programManager.setHeader('Accept-Language', 'en-US');
|
|
170
265
|
*/
|
|
171
266
|
setHeader(headerName: string, value: string): void;
|
|
267
|
+
/**
|
|
268
|
+
* Set the inclusion prover into the wasm memory. This should be done prior to any execution of a function with a
|
|
269
|
+
* private record.
|
|
270
|
+
*
|
|
271
|
+
* @param {ProvingKey} [provingKey]
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* import { ProgramManager, AleoKeyProvider } from "@provablehq/sdk/mainnet.js";
|
|
275
|
+
*
|
|
276
|
+
* const keyProvider = new AleoKeyProvider();
|
|
277
|
+
* keyProvider.useCache(true);
|
|
278
|
+
*
|
|
279
|
+
* // Create a ProgramManager
|
|
280
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
|
|
281
|
+
*
|
|
282
|
+
* // Set the inclusion keys.
|
|
283
|
+
* programManager.setInclusionProver();
|
|
284
|
+
*/
|
|
285
|
+
setInclusionProver(provingKey?: ProvingKey): Promise<void>;
|
|
172
286
|
/**
|
|
173
287
|
* Remove a header from the `AleoNetworkClient`s header map
|
|
174
288
|
*
|
|
@@ -178,7 +292,7 @@ declare class ProgramManager {
|
|
|
178
292
|
* import { ProgramManager } from "@provablehq/sdk/mainnet.js";
|
|
179
293
|
*
|
|
180
294
|
* // Create a ProgramManager
|
|
181
|
-
* const programManager = new ProgramManager("https://api.
|
|
295
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2");
|
|
182
296
|
*
|
|
183
297
|
* // Remove the default `X-Aleo-SDK-Version` header
|
|
184
298
|
* programManager.removeHeader('X-Aleo-SDK-Version');
|
|
@@ -206,7 +320,7 @@ declare class ProgramManager {
|
|
|
206
320
|
*
|
|
207
321
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
208
322
|
* 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";
|
|
209
|
-
* const programManager = new ProgramManager("https://api.
|
|
323
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
210
324
|
* programManager.setAccount(Account);
|
|
211
325
|
*
|
|
212
326
|
* // Define a fee in credits
|
|
@@ -223,6 +337,39 @@ declare class ProgramManager {
|
|
|
223
337
|
* }, 20000);
|
|
224
338
|
*/
|
|
225
339
|
buildDeploymentTransaction(program: string, priorityFee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams, feeRecord?: string | RecordPlaintext, privateKey?: PrivateKey): Promise<Transaction>;
|
|
340
|
+
/**
|
|
341
|
+
* Builds a deployment transaction for submission to the Aleo network that upgrades an existing program.
|
|
342
|
+
*
|
|
343
|
+
* @param {DeployOptions} options The deployment options.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* /// Import the mainnet version of the sdk.
|
|
347
|
+
* import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
348
|
+
*
|
|
349
|
+
* // Create a new NetworkClient, KeyProvider, and RecordProvider
|
|
350
|
+
* const keyProvider = new AleoKeyProvider();
|
|
351
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
352
|
+
* keyProvider.useCache(true);
|
|
353
|
+
*
|
|
354
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
355
|
+
* 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";
|
|
356
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
357
|
+
* programManager.setAccount(Account);
|
|
358
|
+
*
|
|
359
|
+
* // Define a fee in credits
|
|
360
|
+
* const priorityFee = 0.0;
|
|
361
|
+
*
|
|
362
|
+
* // Create the deployment transaction.
|
|
363
|
+
* const tx = await programManager.buildUpgradeTransaction({program: program, priorityFee: fee, privateFee: false});
|
|
364
|
+
* await programManager.networkClient.submitTransaction(tx);
|
|
365
|
+
*
|
|
366
|
+
* // Verify the transaction was successful
|
|
367
|
+
* setTimeout(async () => {
|
|
368
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
369
|
+
* assert(transaction.id() === tx.id());
|
|
370
|
+
* }, 20000);
|
|
371
|
+
*/
|
|
372
|
+
buildUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
|
|
226
373
|
/**
|
|
227
374
|
* Deploy an Aleo program to the Aleo network
|
|
228
375
|
*
|
|
@@ -245,7 +392,7 @@ declare class ProgramManager {
|
|
|
245
392
|
*
|
|
246
393
|
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
247
394
|
* 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";
|
|
248
|
-
* const programManager = new ProgramManager("https://api.
|
|
395
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
249
396
|
*
|
|
250
397
|
* // Define a fee in credits
|
|
251
398
|
* const priorityFee = 0.0;
|
|
@@ -276,7 +423,7 @@ declare class ProgramManager {
|
|
|
276
423
|
* keyProvider.useCache(true);
|
|
277
424
|
*
|
|
278
425
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
279
|
-
* const programManager = new ProgramManager("https://api.
|
|
426
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
280
427
|
*
|
|
281
428
|
* // Build and execute the transaction
|
|
282
429
|
* const tx = await programManager.buildExecutionTransaction({
|
|
@@ -298,6 +445,77 @@ declare class ProgramManager {
|
|
|
298
445
|
* }, 10000);
|
|
299
446
|
*/
|
|
300
447
|
buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
|
|
448
|
+
/**
|
|
449
|
+
* Builds an execution transaction for submission to the Aleo network from an Authorization and Fee Authorization.
|
|
450
|
+
* This method is helpful if signing and authorization needs to be done in a secure environment separate from where
|
|
451
|
+
* transactions are built.
|
|
452
|
+
*
|
|
453
|
+
* @param {ExecuteAuthorizationOptions} options - The options for executing the authorizations.
|
|
454
|
+
* @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
|
|
458
|
+
*
|
|
459
|
+
* await initThreadPool();
|
|
460
|
+
*
|
|
461
|
+
* // Create a new KeyProvider.
|
|
462
|
+
* const keyProvider = new AleoKeyProvider();
|
|
463
|
+
* keyProvider.useCache(true);
|
|
464
|
+
*
|
|
465
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
466
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
|
|
467
|
+
*
|
|
468
|
+
* // Build the `Authorization`.
|
|
469
|
+
* const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
470
|
+
* const authorization = await programManager.buildAuthorization({
|
|
471
|
+
* programName: "credits.aleo",
|
|
472
|
+
* functionName: "transfer_public",
|
|
473
|
+
* privateKey,
|
|
474
|
+
* inputs: [
|
|
475
|
+
* "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
|
|
476
|
+
* "10000000u64",
|
|
477
|
+
* ],
|
|
478
|
+
* });
|
|
479
|
+
*
|
|
480
|
+
* console.log("Getting execution id");
|
|
481
|
+
*
|
|
482
|
+
* // Derive the execution ID and base fee.
|
|
483
|
+
* const executionId = authorization.toExecutionId().toString();
|
|
484
|
+
*
|
|
485
|
+
* console.log("Estimating fee");
|
|
486
|
+
*
|
|
487
|
+
* // Get the base fee in microcredits.
|
|
488
|
+
* const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization(authorization, "credits.aleo");
|
|
489
|
+
* const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
|
|
490
|
+
*
|
|
491
|
+
* console.log("Building fee authorization");
|
|
492
|
+
*
|
|
493
|
+
* // Build a credits.aleo/fee_public `Authorization`.
|
|
494
|
+
* const feeAuthorization = await programManager.buildFeeAuthorization({
|
|
495
|
+
* deploymentOrExecutionId: executionId,
|
|
496
|
+
* baseFeeCredits,
|
|
497
|
+
* privateKey
|
|
498
|
+
* });
|
|
499
|
+
*
|
|
500
|
+
* console.log("Executing authorizations");
|
|
501
|
+
*
|
|
502
|
+
* // Build and execute the transaction.
|
|
503
|
+
* const tx = await programManager.buildTransactionFromAuthorization({
|
|
504
|
+
* programName: "credits.aleo",
|
|
505
|
+
* authorization,
|
|
506
|
+
* feeAuthorization,
|
|
507
|
+
* });
|
|
508
|
+
*
|
|
509
|
+
* // Submit the transaction to the network.
|
|
510
|
+
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
511
|
+
*
|
|
512
|
+
* // Verify the transaction was successful.
|
|
513
|
+
* setTimeout(async () => {
|
|
514
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
515
|
+
* console.log(transaction);
|
|
516
|
+
* }, 10000);
|
|
517
|
+
*/
|
|
518
|
+
buildTransactionFromAuthorization(options: ExecuteAuthorizationOptions): Promise<Transaction>;
|
|
301
519
|
/**
|
|
302
520
|
* Builds a SnarkVM `Authorization` for a specific function.
|
|
303
521
|
*
|
|
@@ -314,7 +532,7 @@ declare class ProgramManager {
|
|
|
314
532
|
* keyProvider.useCache(true);
|
|
315
533
|
*
|
|
316
534
|
* // Initialize a ProgramManager with the key and record providers.
|
|
317
|
-
* const programManager = new ProgramManager("https://api.
|
|
535
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
318
536
|
*
|
|
319
537
|
* // Build the `Authorization`.
|
|
320
538
|
* const authorization = await programManager.buildAuthorization({
|
|
@@ -343,7 +561,7 @@ declare class ProgramManager {
|
|
|
343
561
|
* keyProvider.useCache(true);
|
|
344
562
|
*
|
|
345
563
|
* // Initialize a ProgramManager with the key and record providers.
|
|
346
|
-
* const programManager = new ProgramManager("https://api.
|
|
564
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
347
565
|
*
|
|
348
566
|
* // Build the unchecked `Authorization`.
|
|
349
567
|
* const authorization = await programManager.buildAuthorizationUnchecked({
|
|
@@ -357,7 +575,7 @@ declare class ProgramManager {
|
|
|
357
575
|
*/
|
|
358
576
|
buildAuthorizationUnchecked(options: AuthorizationOptions): Promise<Authorization>;
|
|
359
577
|
/**
|
|
360
|
-
* Builds a `ProvingRequest` for submission to a prover for execution.
|
|
578
|
+
* Builds a `ProvingRequest` for submission to a prover for execution. If building a proving request with an ExecutionRequest, a private key must be explicitly provided.
|
|
361
579
|
*
|
|
362
580
|
* @param {ProvingRequestOptions} options - The options for building the proving request
|
|
363
581
|
* @returns {Promise<ProvingRequest>} - A promise that resolves to the transaction or an error.
|
|
@@ -372,13 +590,12 @@ declare class ProgramManager {
|
|
|
372
590
|
* keyProvider.useCache(true);
|
|
373
591
|
*
|
|
374
592
|
* // Initialize a ProgramManager with the key and record providers.
|
|
375
|
-
* const programManager = new ProgramManager("https://api.
|
|
593
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
376
594
|
*
|
|
377
595
|
* // Build the proving request.
|
|
378
596
|
* const provingRequest = await programManager.provingRequest({
|
|
379
597
|
* programName: "credits.aleo",
|
|
380
598
|
* functionName: "transfer_public",
|
|
381
|
-
* baseFee: 100000,
|
|
382
599
|
* priorityFee: 0,
|
|
383
600
|
* privateFee: false,
|
|
384
601
|
* inputs: [
|
|
@@ -405,17 +622,17 @@ declare class ProgramManager {
|
|
|
405
622
|
* keyProvider.useCache(true);
|
|
406
623
|
*
|
|
407
624
|
* // Initialize a ProgramManager with the key and record providers.
|
|
408
|
-
* const programManager = new ProgramManager("https://api.
|
|
625
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
409
626
|
*
|
|
410
627
|
* // Build a credits.aleo/fee_public `Authorization`.
|
|
411
|
-
* const feePublicAuthorization = await programManager.
|
|
628
|
+
* const feePublicAuthorization = await programManager.buildFeeAuthorization({
|
|
412
629
|
* deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
|
|
413
630
|
* baseFeeCredits: 0.1,
|
|
414
631
|
* });
|
|
415
632
|
*
|
|
416
633
|
* // Build a credits.aleo/fee_private `Authorization`.
|
|
417
634
|
* const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
|
|
418
|
-
* const feePrivateAuthorization = await programManager.
|
|
635
|
+
* const feePrivateAuthorization = await programManager.buildFeeAuthorization({
|
|
419
636
|
* deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
|
|
420
637
|
* baseFeeCredits: 0.1,
|
|
421
638
|
* feeRecord: record,
|
|
@@ -438,7 +655,7 @@ declare class ProgramManager {
|
|
|
438
655
|
* keyProvider.useCache(true);
|
|
439
656
|
*
|
|
440
657
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
441
|
-
* const programManager = new ProgramManager("https://api.
|
|
658
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
442
659
|
*
|
|
443
660
|
* // Build and execute the transaction
|
|
444
661
|
* const tx_id = await programManager.execute({
|
|
@@ -457,6 +674,24 @@ declare class ProgramManager {
|
|
|
457
674
|
* }, 10000);
|
|
458
675
|
*/
|
|
459
676
|
execute(options: ExecuteOptions): Promise<string>;
|
|
677
|
+
/**
|
|
678
|
+
* Prepares user-provided inputs for a function call by auto-converting bare
|
|
679
|
+
* string identifiers to field elements where the function signature expects
|
|
680
|
+
* a `field` type. This lets callers of dynamic-dispatch programs pass
|
|
681
|
+
* human-readable strings (e.g. `"my_program"`) instead of requiring
|
|
682
|
+
* `stringToField("my_program").toString()`.
|
|
683
|
+
*
|
|
684
|
+
* Inputs that already look like a numeric field literal (matching
|
|
685
|
+
* `/^\d+field$/` after trimming whitespace) are left untouched. Non-field
|
|
686
|
+
* inputs are returned as-is. If introspection fails for any reason the
|
|
687
|
+
* original inputs are returned unchanged.
|
|
688
|
+
*
|
|
689
|
+
* @param {string | Program} programSource - The program source code or Program object
|
|
690
|
+
* @param {string} functionName - The function to inspect
|
|
691
|
+
* @param {string[]} inputs - The raw user-provided inputs
|
|
692
|
+
* @returns {string[]} The (possibly converted) inputs
|
|
693
|
+
*/
|
|
694
|
+
prepareInputs(programSource: string | Program, functionName: string, inputs: string[]): string[];
|
|
460
695
|
/**
|
|
461
696
|
* Run an Aleo program in offline mode
|
|
462
697
|
*
|
|
@@ -513,7 +748,7 @@ declare class ProgramManager {
|
|
|
513
748
|
* keyProvider.useCache(true);
|
|
514
749
|
*
|
|
515
750
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
516
|
-
* const programManager = new ProgramManager("https://api.
|
|
751
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
517
752
|
* const record_1 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
|
|
518
753
|
* const record_2 = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 1540945439182663264862696551825005342995406165131907382295858612069623286213group.public}"
|
|
519
754
|
* const tx_id = await programManager.join(record_1, record_2, 0.05, false);
|
|
@@ -544,7 +779,7 @@ declare class ProgramManager {
|
|
|
544
779
|
* keyProvider.useCache(true);
|
|
545
780
|
*
|
|
546
781
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
547
|
-
* const programManager = new ProgramManager("https://api.
|
|
782
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
548
783
|
* const record = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
|
|
549
784
|
* const tx_id = await programManager.split(25000000, record);
|
|
550
785
|
*
|
|
@@ -591,7 +826,7 @@ declare class ProgramManager {
|
|
|
591
826
|
* keyProvider.useCache(true);
|
|
592
827
|
*
|
|
593
828
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
594
|
-
* const programManager = new ProgramManager("https://api.
|
|
829
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
595
830
|
* const tx = await programManager.buildTransferTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
|
|
596
831
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
597
832
|
*
|
|
@@ -622,7 +857,7 @@ declare class ProgramManager {
|
|
|
622
857
|
* keyProvider.useCache(true);
|
|
623
858
|
*
|
|
624
859
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
625
|
-
* const programManager = new ProgramManager("https://api.
|
|
860
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
626
861
|
* const tx = await programManager.buildTransferPublicTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
|
|
627
862
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
628
863
|
*
|
|
@@ -653,7 +888,7 @@ declare class ProgramManager {
|
|
|
653
888
|
* keyProvider.useCache(true);
|
|
654
889
|
*
|
|
655
890
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
656
|
-
* const programManager = new ProgramManager("https://api.
|
|
891
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
657
892
|
* const tx = await programManager.buildTransferPublicAsSignerTransaction(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", 0.2);
|
|
658
893
|
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
659
894
|
*
|
|
@@ -689,7 +924,7 @@ declare class ProgramManager {
|
|
|
689
924
|
* keyProvider.useCache(true);
|
|
690
925
|
*
|
|
691
926
|
* // Initialize a program manager with the key provider to automatically fetch keys for executions
|
|
692
|
-
* const programManager = new ProgramManager("https://api.
|
|
927
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
|
|
693
928
|
* const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "public", 0.2, false);
|
|
694
929
|
*
|
|
695
930
|
* // Verify the transaction was successful
|
|
@@ -717,7 +952,7 @@ declare class ProgramManager {
|
|
|
717
952
|
* keyProvider.useCache(true);
|
|
718
953
|
*
|
|
719
954
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
720
|
-
* const programManager = new ProgramManager("https://api.
|
|
955
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
721
956
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
722
957
|
*
|
|
723
958
|
* // Create the bonding transaction object for later submission
|
|
@@ -751,7 +986,7 @@ declare class ProgramManager {
|
|
|
751
986
|
* keyProvider.useCache(true);
|
|
752
987
|
*
|
|
753
988
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
754
|
-
* const programManager = new ProgramManager("https://api.
|
|
989
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
755
990
|
*
|
|
756
991
|
* // Create the bonding transaction
|
|
757
992
|
* tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
|
|
@@ -782,7 +1017,7 @@ declare class ProgramManager {
|
|
|
782
1017
|
* keyProvider.useCache(true);
|
|
783
1018
|
*
|
|
784
1019
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
785
|
-
* const programManager = new ProgramManager("https://api.
|
|
1020
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
786
1021
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
787
1022
|
*
|
|
788
1023
|
* // Create the bond validator transaction object for later use.
|
|
@@ -817,7 +1052,7 @@ declare class ProgramManager {
|
|
|
817
1052
|
* keyProvider.useCache(true);
|
|
818
1053
|
*
|
|
819
1054
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
820
|
-
* const programManager = new ProgramManager("https://api.
|
|
1055
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
821
1056
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
822
1057
|
*
|
|
823
1058
|
* // Create the bonding transaction
|
|
@@ -847,7 +1082,7 @@ declare class ProgramManager {
|
|
|
847
1082
|
* keyProvider.useCache(true);
|
|
848
1083
|
*
|
|
849
1084
|
* // Create a new ProgramManager with the key that will be used to unbond credits.
|
|
850
|
-
* const programManager = new ProgramManager("https://api.
|
|
1085
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
851
1086
|
* const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
|
|
852
1087
|
*
|
|
853
1088
|
* // The transaction can be submitted later to the network using the network client.
|
|
@@ -882,7 +1117,7 @@ declare class ProgramManager {
|
|
|
882
1117
|
* keyProvider.useCache(true);
|
|
883
1118
|
*
|
|
884
1119
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
885
|
-
* const programManager = new ProgramManager("https://api.
|
|
1120
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
886
1121
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
887
1122
|
*
|
|
888
1123
|
* // Create the unbond_public transaction and send it to the network
|
|
@@ -911,7 +1146,7 @@ declare class ProgramManager {
|
|
|
911
1146
|
* keyProvider.useCache(true);
|
|
912
1147
|
*
|
|
913
1148
|
* // Create a new ProgramManager with the key that will be used to claim unbonded credits.
|
|
914
|
-
* const programManager = new ProgramManager("https://api.
|
|
1149
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
915
1150
|
*
|
|
916
1151
|
* // Create the claim_unbond_public transaction object for later use.
|
|
917
1152
|
* const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
|
|
@@ -943,7 +1178,7 @@ declare class ProgramManager {
|
|
|
943
1178
|
* keyProvider.useCache(true);
|
|
944
1179
|
*
|
|
945
1180
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
946
|
-
* const programManager = new ProgramManager("https://api.
|
|
1181
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
947
1182
|
* programManager.setAccount(new Account("YourPrivateKey"));
|
|
948
1183
|
*
|
|
949
1184
|
* // Create the claim_unbond_public transaction
|
|
@@ -980,7 +1215,7 @@ declare class ProgramManager {
|
|
|
980
1215
|
* keyProvider.useCache(true);
|
|
981
1216
|
*
|
|
982
1217
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
983
|
-
* const programManager = new ProgramManager("https://api.
|
|
1218
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
984
1219
|
*
|
|
985
1220
|
* // Create the set_validator_state transaction
|
|
986
1221
|
* const tx = await programManager.buildSetValidatorStateTransaction(true);
|
|
@@ -1019,7 +1254,7 @@ declare class ProgramManager {
|
|
|
1019
1254
|
* keyProvider.useCache(true);
|
|
1020
1255
|
*
|
|
1021
1256
|
* // Create a new ProgramManager with the key that will be used to bond credits
|
|
1022
|
-
* const programManager = new ProgramManager("https://api.
|
|
1257
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, undefined);
|
|
1023
1258
|
*
|
|
1024
1259
|
* // Create the set_validator_state transaction
|
|
1025
1260
|
* const tx_id = await programManager.setValidatorState(true);
|
|
@@ -1085,6 +1320,269 @@ declare class ProgramManager {
|
|
|
1085
1320
|
* @param {string} program The program source code
|
|
1086
1321
|
*/
|
|
1087
1322
|
verifyProgram(program: string): boolean;
|
|
1323
|
+
/**
|
|
1324
|
+
* Estimate the execution fee for an authorization.
|
|
1325
|
+
*
|
|
1326
|
+
* @param {FeeEstimateOptions} options Options for fee estimate.
|
|
1327
|
+
*
|
|
1328
|
+
* @example
|
|
1329
|
+
* import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
|
|
1330
|
+
*
|
|
1331
|
+
* await initThreadPool();
|
|
1332
|
+
*
|
|
1333
|
+
* // Create a new KeyProvider.
|
|
1334
|
+
* const keyProvider = new AleoKeyProvider();
|
|
1335
|
+
* keyProvider.useCache(true);
|
|
1336
|
+
*
|
|
1337
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
1338
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
|
|
1339
|
+
*
|
|
1340
|
+
* // Build the `Authorization`.
|
|
1341
|
+
* const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
1342
|
+
* const authorization = await programManager.buildAuthorization({
|
|
1343
|
+
* programName: "credits.aleo",
|
|
1344
|
+
* functionName: "transfer_public",
|
|
1345
|
+
* privateKey,
|
|
1346
|
+
* inputs: [
|
|
1347
|
+
* "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
|
|
1348
|
+
* "10000000u64",
|
|
1349
|
+
* ],
|
|
1350
|
+
* });
|
|
1351
|
+
*
|
|
1352
|
+
* console.log("Getting execution id");
|
|
1353
|
+
*
|
|
1354
|
+
* // Derive the execution ID and base fee.
|
|
1355
|
+
* const executionId = authorization.toExecutionId().toString();
|
|
1356
|
+
*
|
|
1357
|
+
* console.log("Estimating fee");
|
|
1358
|
+
*
|
|
1359
|
+
* // Get the base fee in microcredits.
|
|
1360
|
+
* const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({
|
|
1361
|
+
* authorization,
|
|
1362
|
+
* programName: "credits.aleo"
|
|
1363
|
+
* });
|
|
1364
|
+
* const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
|
|
1365
|
+
*
|
|
1366
|
+
* console.log("Building fee authorization");
|
|
1367
|
+
*
|
|
1368
|
+
* // Build a credits.aleo/fee_public `Authorization`.
|
|
1369
|
+
* const feeAuthorization = await programManager.buildFeeAuthorization({
|
|
1370
|
+
* deploymentOrExecutionId: executionId,
|
|
1371
|
+
* baseFeeCredits,
|
|
1372
|
+
* privateKey
|
|
1373
|
+
* });
|
|
1374
|
+
*/
|
|
1375
|
+
estimateFeeForAuthorization(options: FeeEstimateOptions): Promise<bigint>;
|
|
1376
|
+
/**
|
|
1377
|
+
* Estimate the execution fee for an Aleo function.
|
|
1378
|
+
*
|
|
1379
|
+
* @param {FeeEstimateOptions} options Options for the fee estimate.
|
|
1380
|
+
*
|
|
1381
|
+
* @returns {Promise<bigint>} Execution fee in microcredits for the authorization.
|
|
1382
|
+
*
|
|
1383
|
+
* @example
|
|
1384
|
+
* import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
|
|
1385
|
+
*
|
|
1386
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
1387
|
+
* const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider);
|
|
1388
|
+
*
|
|
1389
|
+
* // Get the base fee in microcredits.
|
|
1390
|
+
* const baseFeeMicrocredits = await programManager.estimateExecutionFee({programName: "credits.aleo"});
|
|
1391
|
+
* const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
|
|
1392
|
+
*
|
|
1393
|
+
* console.log("Building fee authorization");
|
|
1394
|
+
*
|
|
1395
|
+
* // Build a credits.aleo/fee_public `Authorization`.
|
|
1396
|
+
* const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({
|
|
1397
|
+
* programName: "credits.aleo",
|
|
1398
|
+
* functionName: "transfer_public",
|
|
1399
|
+
* });
|
|
1400
|
+
* const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
|
|
1401
|
+
*/
|
|
1402
|
+
estimateExecutionFee(options: FeeEstimateOptions): Promise<bigint>;
|
|
1088
1403
|
getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
|
|
1404
|
+
/**
|
|
1405
|
+
* Builds an execution transaction for submission to the a local devnode.
|
|
1406
|
+
* This method skips proof generation and is not meant for use with the mainnet or testnet Aleo networks.
|
|
1407
|
+
* Note: getOrInitConsensusVersionTestHeights must be called prior to using this method for this method to work properly.
|
|
1408
|
+
*
|
|
1409
|
+
* @param {ExecuteOptions} options - The options for the execution transaction.
|
|
1410
|
+
* @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
|
|
1411
|
+
*
|
|
1412
|
+
* @example
|
|
1413
|
+
* /// Import the mainnet version of the sdk.
|
|
1414
|
+
* import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
1415
|
+
*
|
|
1416
|
+
* // Initialize the development consensus heights in order to work with devnode.
|
|
1417
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
|
|
1418
|
+
*
|
|
1419
|
+
* // Create a new NetworkClient and RecordProvider.
|
|
1420
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
1421
|
+
* keyProvider.useCache(true);
|
|
1422
|
+
*
|
|
1423
|
+
* // Initialize a program manager.
|
|
1424
|
+
* const programManager = new ProgramManager("http://localhost:3030", recordProvider);
|
|
1425
|
+
*
|
|
1426
|
+
* // Build and execute the transaction.
|
|
1427
|
+
* const tx = await programManager.buildDevnodeExecutionTransaction({
|
|
1428
|
+
* programName: "hello_hello.aleo",
|
|
1429
|
+
* functionName: "hello_hello",
|
|
1430
|
+
* priorityFee: 0.0,
|
|
1431
|
+
* privateFee: false,
|
|
1432
|
+
* inputs: ["5u32", "5u32"],
|
|
1433
|
+
* });
|
|
1434
|
+
*
|
|
1435
|
+
* // Submit the transaction to the network
|
|
1436
|
+
* await programManager.networkClient.submitTransaction(tx.toString());
|
|
1437
|
+
*
|
|
1438
|
+
* // Verify the transaction was successful
|
|
1439
|
+
* setTimeout(async () => {
|
|
1440
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
1441
|
+
* assert(transaction.id() === tx.id());
|
|
1442
|
+
* }, 10000);
|
|
1443
|
+
*/
|
|
1444
|
+
buildDevnodeExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
|
|
1445
|
+
/**
|
|
1446
|
+
* Builds a deployment transaction with placeholder certificates and verifying keys for each function in the program.
|
|
1447
|
+
* Intended for use with a local devnode.
|
|
1448
|
+
* `getOrInitConsensusVersionTestHeights` must be called with development heights prior to invoking this method for it to work properly.
|
|
1449
|
+
*
|
|
1450
|
+
* @param {DeployOptions} options - The options for the deployment transaction.
|
|
1451
|
+
* @returns {string} The transaction id of the deployed program or a failure message from the network
|
|
1452
|
+
*
|
|
1453
|
+
* @example
|
|
1454
|
+
* /// Import the mainnet version of the sdk.
|
|
1455
|
+
* import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
|
|
1456
|
+
*
|
|
1457
|
+
* // Initialize the development consensus heights in order to work with a local devnode.
|
|
1458
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
|
|
1459
|
+
*
|
|
1460
|
+
* // Create a new NetworkClient, and RecordProvider
|
|
1461
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
1462
|
+
* keyProvider.useCache(true);
|
|
1463
|
+
*
|
|
1464
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
1465
|
+
* 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";
|
|
1466
|
+
* const programManager = new ProgramManager("http://localhost:3030", recordProvider);
|
|
1467
|
+
* programManager.setAccount(Account);
|
|
1468
|
+
*
|
|
1469
|
+
* // Define a fee in credits
|
|
1470
|
+
* const priorityFee = 0.0;
|
|
1471
|
+
*
|
|
1472
|
+
* // Create the deployment transaction.
|
|
1473
|
+
* const tx = await programManager.buildDevnodeDeploymentTransaction({program: program, fee: priorityFee, privateFee: false});
|
|
1474
|
+
* await programManager.networkClient.submitTransaction(tx);
|
|
1475
|
+
*
|
|
1476
|
+
* // Verify the transaction was successful
|
|
1477
|
+
* setTimeout(async () => {
|
|
1478
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
1479
|
+
* assert(transaction.id() === tx.id());
|
|
1480
|
+
* }, 20000);
|
|
1481
|
+
*/
|
|
1482
|
+
buildDevnodeDeploymentTransaction(options: DeployOptions): Promise<Transaction>;
|
|
1483
|
+
/**
|
|
1484
|
+
* Builds an upgrade transaction on a local devnodewith placeholder certificates and verifying keys for each function in the program.
|
|
1485
|
+
* This method is only intended for use with a local devnode.
|
|
1486
|
+
*
|
|
1487
|
+
* @param {DeployOptions} options - The options for the deployment transaction.
|
|
1488
|
+
* @returns {string} The transaction id of the deployed program or a failure message from the network
|
|
1489
|
+
*
|
|
1490
|
+
* @example
|
|
1491
|
+
* /// Import the mainnet version of the sdk.
|
|
1492
|
+
* import { ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
1493
|
+
*
|
|
1494
|
+
* // Create a new NetworkClient, and RecordProvider
|
|
1495
|
+
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
1496
|
+
* keyProvider.useCache(true);
|
|
1497
|
+
*
|
|
1498
|
+
* // Initialize a program manager with the key provider to automatically fetch keys for deployments
|
|
1499
|
+
* 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";
|
|
1500
|
+
* const programManager = new ProgramManager("http://localhost:3030", recordProvider);
|
|
1501
|
+
* programManager.setAccount(Account);
|
|
1502
|
+
*
|
|
1503
|
+
* // Define a fee in credits
|
|
1504
|
+
* const priorityFee = 0.0;
|
|
1505
|
+
*
|
|
1506
|
+
* // Create the deployment transaction.
|
|
1507
|
+
* const tx = await programManager.buildDevnodeUpgradeTransaction({program: program, fee: priorityFee, privateFee: false});
|
|
1508
|
+
* await programManager.networkClient.submitTransaction(tx);
|
|
1509
|
+
*
|
|
1510
|
+
* // Verify the transaction was successful
|
|
1511
|
+
* setTimeout(async () => {
|
|
1512
|
+
* const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
1513
|
+
* assert(transaction.id() === tx.id());
|
|
1514
|
+
* }, 20000);
|
|
1515
|
+
*/
|
|
1516
|
+
buildDevnodeUpgradeTransaction(options: DeployOptions): Promise<Transaction>;
|
|
1089
1517
|
}
|
|
1090
|
-
|
|
1518
|
+
/**
|
|
1519
|
+
* Convert an array of Aleo type strings to field element strings.
|
|
1520
|
+
*
|
|
1521
|
+
* Inputs that are already field elements (e.g. "1field") are passed through directly.
|
|
1522
|
+
* Other Aleo values (e.g. "1u32", records, futures, dynamic records) are parsed via
|
|
1523
|
+
* Value and converted to their field representation.
|
|
1524
|
+
*
|
|
1525
|
+
* @param {string[]} inputs Array of Aleo value strings
|
|
1526
|
+
* @returns {string[]} Array of field element strings
|
|
1527
|
+
*/
|
|
1528
|
+
declare function inputsToFields(inputs: string[]): string[];
|
|
1529
|
+
/**
|
|
1530
|
+
* Verify an Aleo zkSnark proof against a verifying key and public inputs.
|
|
1531
|
+
*
|
|
1532
|
+
* This verifies a proof produced by an Aleo program that may not be deployed on chain.
|
|
1533
|
+
* It directly invokes the Varuna proof verification from snarkVM.
|
|
1534
|
+
*
|
|
1535
|
+
* **Note:** The proof must have been generated with the Fiat-Shamir domain separator
|
|
1536
|
+
* "snark_verify". Proofs generated via snarkVM with a different function name will fail
|
|
1537
|
+
* verification even if the circuit and inputs are correct.
|
|
1538
|
+
*
|
|
1539
|
+
* Inputs can be raw field element strings (e.g. "1field") or Aleo type strings
|
|
1540
|
+
* (e.g. "1u32", "true", "{ x: 1u8, y: 2u8 }"). Non-field inputs are automatically
|
|
1541
|
+
* converted to their field representation via Value.toFields().
|
|
1542
|
+
*
|
|
1543
|
+
* @param {VerificationOptions} options The verification parameters
|
|
1544
|
+
* @returns {boolean} True if the proof is valid, false otherwise
|
|
1545
|
+
*
|
|
1546
|
+
* @example
|
|
1547
|
+
* import { verifyProof } from "@provablehq/sdk/mainnet.js";
|
|
1548
|
+
*
|
|
1549
|
+
* // Using raw field elements:
|
|
1550
|
+
* const isValid = verifyProof({
|
|
1551
|
+
* verifyingKey: "verifier1...",
|
|
1552
|
+
* inputs: ["1field", "2field"],
|
|
1553
|
+
* proof: "proof1...",
|
|
1554
|
+
* });
|
|
1555
|
+
*
|
|
1556
|
+
* // Using Aleo types (automatically converted to fields):
|
|
1557
|
+
* const isValid2 = verifyProof({
|
|
1558
|
+
* verifyingKey: "verifier1...",
|
|
1559
|
+
* inputs: ["1u32", "2u32"],
|
|
1560
|
+
* proof: "proof1...",
|
|
1561
|
+
* });
|
|
1562
|
+
*/
|
|
1563
|
+
declare function verifyProof(options: VerificationOptions): boolean;
|
|
1564
|
+
/**
|
|
1565
|
+
* Verify a batch Aleo zkSnark proof against multiple verifying keys and their corresponding public inputs.
|
|
1566
|
+
*
|
|
1567
|
+
* Each verifying key is paired with one or more sets of public inputs (instances).
|
|
1568
|
+
* Inputs can be raw field element strings or Aleo type strings — non-field inputs
|
|
1569
|
+
* are automatically converted to their field representation.
|
|
1570
|
+
*
|
|
1571
|
+
* **Note:** The proof must have been generated with the Fiat-Shamir domain separator
|
|
1572
|
+
* "snark_verify_batch". Proofs generated with a different function name will fail
|
|
1573
|
+
* verification even if the circuits and inputs are correct.
|
|
1574
|
+
*
|
|
1575
|
+
* @param {BatchVerificationOptions} options The batch verification parameters
|
|
1576
|
+
* @returns {boolean} True if the batch proof is valid, false otherwise
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* import { verifyBatchProof } from "@provablehq/sdk/mainnet.js";
|
|
1580
|
+
*
|
|
1581
|
+
* const isValid = verifyBatchProof({
|
|
1582
|
+
* verifyingKeys: ["verifier1...", "verifier2..."],
|
|
1583
|
+
* inputs: [[["1field", "2field"]], [["3field"]]],
|
|
1584
|
+
* proof: "proof1...",
|
|
1585
|
+
* });
|
|
1586
|
+
*/
|
|
1587
|
+
declare function verifyBatchProof(options: BatchVerificationOptions): boolean;
|
|
1588
|
+
export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions, ExternalSigningOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof };
|