@provablehq/sdk 0.9.4-offline-rc → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mainnet/browser.d.ts +1 -1
- package/dist/mainnet/browser.js +78 -130
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/function-key-provider.d.ts +0 -18
- package/dist/mainnet/network-client.d.ts +32 -5
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/offline-key-provider.d.ts +0 -14
- package/dist/mainnet/program-manager.d.ts +0 -10
- package/dist/mainnet/wasm.d.ts +1 -1
- package/dist/testnet/browser.d.ts +1 -1
- package/dist/testnet/browser.js +78 -130
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/function-key-provider.d.ts +0 -18
- package/dist/testnet/network-client.d.ts +32 -5
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/offline-key-provider.d.ts +0 -14
- package/dist/testnet/program-manager.d.ts +0 -10
- package/dist/testnet/wasm.d.ts +1 -1
- package/package.json +2 -2
|
@@ -33,7 +33,7 @@ import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchP
|
|
|
33
33
|
declare function initializeWasm(): Promise<void>;
|
|
34
34
|
export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from "./program-manager.js";
|
|
35
35
|
export { logAndThrow } from "./utils.js";
|
|
36
|
-
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, Group, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm.js";
|
|
36
|
+
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, Group, I8, I16, I32, I64, I128, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm.js";
|
|
37
37
|
export { initializeWasm };
|
|
38
38
|
export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, } from "./constants.js";
|
|
39
39
|
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
|
package/dist/mainnet/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'core-js/proposals/json-parse-with-source.js';
|
|
2
2
|
import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, Program, Plaintext, Transaction, Metadata, VerifyingKey, ProvingKey, ProgramManager as ProgramManager$1, RecordPlaintext, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
|
|
3
|
-
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
|
|
3
|
+
export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from
|
|
@@ -489,7 +489,7 @@ class AleoNetworkClient {
|
|
|
489
489
|
else {
|
|
490
490
|
this.headers = {
|
|
491
491
|
// This is replaced by the actual version by a Rollup plugin
|
|
492
|
-
"X-Aleo-SDK-Version": "0.9.
|
|
492
|
+
"X-Aleo-SDK-Version": "0.9.5",
|
|
493
493
|
"X-Aleo-environment": environment(),
|
|
494
494
|
};
|
|
495
495
|
}
|
|
@@ -1186,7 +1186,17 @@ class AleoNetworkClient {
|
|
|
1186
1186
|
/**
|
|
1187
1187
|
* Returns the source code of a program given a program ID.
|
|
1188
1188
|
*
|
|
1189
|
-
* @param {string} programId The program ID of a program deployed to the Aleo Network
|
|
1189
|
+
* @param {string} programId The program ID of a program deployed to the Aleo Network.
|
|
1190
|
+
* @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.
|
|
1191
|
+
* @returns {Promise<string>} The source code of the program.
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1195
|
+
*
|
|
1196
|
+
* // Create a network client.
|
|
1197
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
1198
|
+
*
|
|
1199
|
+
* // Get the source code of a program.)
|
|
1190
1200
|
* @returns {Promise<string>} Source code of the program
|
|
1191
1201
|
*
|
|
1192
1202
|
* @example
|
|
@@ -1199,10 +1209,42 @@ class AleoNetworkClient {
|
|
|
1199
1209
|
* 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"
|
|
1200
1210
|
* assert.equal(program, expectedSource);
|
|
1201
1211
|
*/
|
|
1202
|
-
async getProgram(programId) {
|
|
1212
|
+
async getProgram(programId, edition) {
|
|
1213
|
+
try {
|
|
1214
|
+
this.ctx = { "X-ALEO-METHOD": "getProgramVersion" };
|
|
1215
|
+
if (typeof edition === "number") {
|
|
1216
|
+
return await this.fetchData(`/program/${programId}/${edition}`);
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
return await this.fetchData("/program/" + programId);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
catch (error) {
|
|
1223
|
+
throw new Error(`Error fetching program ${programId}: ${error}`);
|
|
1224
|
+
}
|
|
1225
|
+
finally {
|
|
1226
|
+
this.ctx = {};
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Returns the current program edition deployed on the Aleo network.
|
|
1231
|
+
*
|
|
1232
|
+
* @param {string} programId The program ID of a program deployed to the Aleo Network.
|
|
1233
|
+
* @returns {Promise<number>} The edition of the program.
|
|
1234
|
+
*
|
|
1235
|
+
* @example
|
|
1236
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
1237
|
+
*
|
|
1238
|
+
* // Create a network client.
|
|
1239
|
+
* const networkClient = new AleoNetworkClient("http://api.explorer.provable.com/v1", undefined);
|
|
1240
|
+
*
|
|
1241
|
+
* const programVersion = networkClient.getLatestProgramEdition("hello_hello.aleo");
|
|
1242
|
+
* assert.equal(programVersion, 1);
|
|
1243
|
+
*/
|
|
1244
|
+
async getLatestProgramEdition(programId) {
|
|
1203
1245
|
try {
|
|
1204
|
-
this.ctx = { "X-ALEO-METHOD": "
|
|
1205
|
-
return await this.fetchData("/program/" + programId);
|
|
1246
|
+
this.ctx = { "X-ALEO-METHOD": "getLatestProgramEdition" };
|
|
1247
|
+
return await this.fetchData("/program/" + programId + "/latest_edition");
|
|
1206
1248
|
}
|
|
1207
1249
|
catch (error) {
|
|
1208
1250
|
throw new Error(`Error fetching program ${programId}: ${error}`);
|
|
@@ -1214,8 +1256,9 @@ class AleoNetworkClient {
|
|
|
1214
1256
|
/**
|
|
1215
1257
|
* Returns a program object from a program ID or program source code.
|
|
1216
1258
|
*
|
|
1217
|
-
* @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
|
|
1218
|
-
* @
|
|
1259
|
+
* @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network.
|
|
1260
|
+
* @param {number | undefined} edition The edition of the program to fetch. When this is undefined it will fetch the latest version.
|
|
1261
|
+
* @returns {Promise<Program>} Source code of the program.
|
|
1219
1262
|
*
|
|
1220
1263
|
* @example
|
|
1221
1264
|
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
@@ -1233,18 +1276,13 @@ class AleoNetworkClient {
|
|
|
1233
1276
|
* // Both program objects should be equal
|
|
1234
1277
|
* assert(programObjectFromID.to_string() === programObjectFromSource.to_string());
|
|
1235
1278
|
*/
|
|
1236
|
-
async getProgramObject(inputProgram) {
|
|
1279
|
+
async getProgramObject(inputProgram, edition) {
|
|
1237
1280
|
try {
|
|
1238
1281
|
this.ctx = { "X-ALEO-METHOD": "getProgramObject" };
|
|
1239
|
-
return Program.fromString(inputProgram);
|
|
1282
|
+
return Program.fromString(await this.getProgram(inputProgram, edition));
|
|
1240
1283
|
}
|
|
1241
1284
|
catch (error) {
|
|
1242
|
-
|
|
1243
|
-
return Program.fromString(await this.getProgram(inputProgram));
|
|
1244
|
-
}
|
|
1245
|
-
catch (error) {
|
|
1246
|
-
throw new Error(`${inputProgram} is neither a program name or a valid program: ${error}`);
|
|
1247
|
-
}
|
|
1285
|
+
throw new Error(`${inputProgram} is neither a program name or a valid program: ${error}`);
|
|
1248
1286
|
}
|
|
1249
1287
|
finally {
|
|
1250
1288
|
this.ctx = {};
|
|
@@ -1284,18 +1322,32 @@ class AleoNetworkClient {
|
|
|
1284
1322
|
try {
|
|
1285
1323
|
this.ctx = { "X-ALEO-METHOD": "getProgramImports" };
|
|
1286
1324
|
const imports = {};
|
|
1287
|
-
//
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1325
|
+
// Normalize input to a Program object
|
|
1326
|
+
let program;
|
|
1327
|
+
if (inputProgram instanceof Program) {
|
|
1328
|
+
program = inputProgram;
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
try {
|
|
1332
|
+
program = Program.fromString(inputProgram);
|
|
1333
|
+
}
|
|
1334
|
+
catch {
|
|
1335
|
+
try {
|
|
1336
|
+
program = await this.getProgramObject(inputProgram);
|
|
1337
|
+
}
|
|
1338
|
+
catch (error2) {
|
|
1339
|
+
throw new Error(`${inputProgram} is neither a program name nor a valid program: ${error2}`);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1291
1343
|
// Get the list of programs that the program imports
|
|
1292
1344
|
const importList = program.getImports();
|
|
1293
|
-
// Recursively get any imports that the imported programs have in a depth
|
|
1345
|
+
// Recursively get any imports that the imported programs have in a depth-first search
|
|
1294
1346
|
for (let i = 0; i < importList.length; i++) {
|
|
1295
1347
|
const import_id = importList[i];
|
|
1296
1348
|
if (!imports.hasOwnProperty(import_id)) {
|
|
1297
|
-
const programSource =
|
|
1298
|
-
const nestedImports =
|
|
1349
|
+
const programSource = await this.getProgram(import_id);
|
|
1350
|
+
const nestedImports = await this.getProgramImports(import_id);
|
|
1299
1351
|
for (const key in nestedImports) {
|
|
1300
1352
|
if (!imports.hasOwnProperty(key)) {
|
|
1301
1353
|
imports[key] = nestedImports[key];
|
|
@@ -1374,7 +1426,7 @@ class AleoNetworkClient {
|
|
|
1374
1426
|
return await this.fetchData(`/program/${programId}/mappings`);
|
|
1375
1427
|
}
|
|
1376
1428
|
catch (error) {
|
|
1377
|
-
throw new Error(`Error fetching mappings for program ${programId} - ensure the program exists on chain before trying again`);
|
|
1429
|
+
throw new Error(`Error fetching mappings for program ${programId} - ensure the program exists on chain before trying again: ${error}`);
|
|
1378
1430
|
}
|
|
1379
1431
|
finally {
|
|
1380
1432
|
this.ctx = {};
|
|
@@ -1406,7 +1458,7 @@ class AleoNetworkClient {
|
|
|
1406
1458
|
return await this.fetchData(`/program/${programId}/mapping/${mappingName}/${keyString}`);
|
|
1407
1459
|
}
|
|
1408
1460
|
catch (error) {
|
|
1409
|
-
throw new Error(`Error fetching value for key '${key}' in mapping '${mappingName}' in program '${programId}' - ensure the mapping exists and the key is correct`);
|
|
1461
|
+
throw new Error(`Error fetching value for key '${key}' in mapping '${mappingName}' in program '${programId}' - ensure the mapping exists and the key is correct: ${error}`);
|
|
1410
1462
|
}
|
|
1411
1463
|
finally {
|
|
1412
1464
|
this.ctx = {};
|
|
@@ -2250,22 +2302,6 @@ class AleoKeyProvider {
|
|
|
2250
2302
|
throw new Error("Invalid visibility type");
|
|
2251
2303
|
}
|
|
2252
2304
|
}
|
|
2253
|
-
/**
|
|
2254
|
-
* Returns the proving and verifying keys for the transfer_public function.
|
|
2255
|
-
*
|
|
2256
|
-
* @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function
|
|
2257
|
-
*/
|
|
2258
|
-
async transferPublicKeys() {
|
|
2259
|
-
return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);
|
|
2260
|
-
}
|
|
2261
|
-
/**
|
|
2262
|
-
* Returns the proving and verifying keys for the inclusion proof.
|
|
2263
|
-
*
|
|
2264
|
-
* @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.
|
|
2265
|
-
*/
|
|
2266
|
-
async inclusionKeys() {
|
|
2267
|
-
return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.inclusion);
|
|
2268
|
-
}
|
|
2269
2305
|
/**
|
|
2270
2306
|
* Returns the proving and verifying keys for the join function in the credits.aleo program
|
|
2271
2307
|
*
|
|
@@ -2682,15 +2718,6 @@ class OfflineKeyProvider {
|
|
|
2682
2718
|
return this.functionKeys(OfflineSearchParams.feePublicKeyParams());
|
|
2683
2719
|
}
|
|
2684
2720
|
;
|
|
2685
|
-
/**
|
|
2686
|
-
* Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.
|
|
2687
|
-
*
|
|
2688
|
-
* @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover
|
|
2689
|
-
*/
|
|
2690
|
-
inclusionKeys() {
|
|
2691
|
-
return this.functionKeys(OfflineSearchParams.inclusionKeyParams());
|
|
2692
|
-
}
|
|
2693
|
-
;
|
|
2694
2721
|
/**
|
|
2695
2722
|
* Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
|
|
2696
2723
|
* method for it to work.
|
|
@@ -2823,21 +2850,6 @@ class OfflineKeyProvider {
|
|
|
2823
2850
|
throw new Error("Attempted to insert invalid proving keys for fee_public");
|
|
2824
2851
|
}
|
|
2825
2852
|
}
|
|
2826
|
-
/**
|
|
2827
|
-
* Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs
|
|
2828
|
-
* to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
|
|
2829
|
-
* that the keys match the expected checksum for the inclusion prover.
|
|
2830
|
-
*
|
|
2831
|
-
* @param provingKey
|
|
2832
|
-
*/
|
|
2833
|
-
insertInclusionKeys(provingKey) {
|
|
2834
|
-
if (provingKey.isInclusionProver()) {
|
|
2835
|
-
this.cache.set(CREDITS_PROGRAM_KEYS.inclusion.locator, [provingKey.toBytes(), VerifyingKey.inclusionVerifier().toBytes()]);
|
|
2836
|
-
}
|
|
2837
|
-
else {
|
|
2838
|
-
throw new Error("Attempted to insert invalid proving keys for the inclusion prover");
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
2853
|
/**
|
|
2842
2854
|
* Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
|
|
2843
2855
|
* to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
|
|
@@ -3162,7 +3174,6 @@ class ProgramManager {
|
|
|
3162
3174
|
host;
|
|
3163
3175
|
networkClient;
|
|
3164
3176
|
recordProvider;
|
|
3165
|
-
inclusionKeysLoaded = false;
|
|
3166
3177
|
/** Create a new instance of the ProgramManager
|
|
3167
3178
|
*
|
|
3168
3179
|
* @param { string | undefined } host A host uri running the official Aleo API
|
|
@@ -3513,17 +3524,6 @@ class ProgramManager {
|
|
|
3513
3524
|
logAndThrow(`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`);
|
|
3514
3525
|
}
|
|
3515
3526
|
}
|
|
3516
|
-
if (offlineQuery && !this.inclusionKeysLoaded) {
|
|
3517
|
-
try {
|
|
3518
|
-
const inclusionKeys = await this.keyProvider.inclusionKeys();
|
|
3519
|
-
ProgramManager$1.loadInclusionProver(inclusionKeys[0]);
|
|
3520
|
-
this.inclusionKeysLoaded = true;
|
|
3521
|
-
console.log("Successfully loaded inclusion key");
|
|
3522
|
-
}
|
|
3523
|
-
catch {
|
|
3524
|
-
logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`);
|
|
3525
|
-
}
|
|
3526
|
-
}
|
|
3527
3527
|
// Build an execution transaction
|
|
3528
3528
|
return await ProgramManager$1.buildExecutionTransaction(executionPrivateKey, program, functionName, inputs, priorityFee, feeRecord, this.host, imports, provingKey, verifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
|
|
3529
3529
|
}
|
|
@@ -3985,18 +3985,6 @@ class ProgramManager {
|
|
|
3985
3985
|
catch (e) {
|
|
3986
3986
|
logAndThrow("Records provided are not valid. Please ensure they are valid plaintext records.");
|
|
3987
3987
|
}
|
|
3988
|
-
// Load the inclusion prover offline.
|
|
3989
|
-
if (offlineQuery && !this.inclusionKeysLoaded) {
|
|
3990
|
-
try {
|
|
3991
|
-
const inclusionKeys = await this.keyProvider.inclusionKeys();
|
|
3992
|
-
ProgramManager$1.loadInclusionProver(inclusionKeys[0]);
|
|
3993
|
-
this.inclusionKeysLoaded = true;
|
|
3994
|
-
console.log("Successfully loaded inclusion key");
|
|
3995
|
-
}
|
|
3996
|
-
catch {
|
|
3997
|
-
logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`);
|
|
3998
|
-
}
|
|
3999
|
-
}
|
|
4000
3988
|
// Build an execution transaction and submit it to the network
|
|
4001
3989
|
const tx = await ProgramManager$1.buildJoinTransaction(executionPrivateKey, recordOne, recordTwo, priorityFee, feeRecord, this.host, joinProvingKey, joinVerifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
|
|
4002
3990
|
// Check if the account has sufficient credits to pay for the transaction
|
|
@@ -4061,18 +4049,6 @@ class ProgramManager {
|
|
|
4061
4049
|
catch (e) {
|
|
4062
4050
|
logAndThrow("Record provided is not valid. Please ensure it is a valid plaintext record.");
|
|
4063
4051
|
}
|
|
4064
|
-
// Load the inclusion prover offline.
|
|
4065
|
-
if (offlineQuery && !this.inclusionKeysLoaded) {
|
|
4066
|
-
try {
|
|
4067
|
-
const inclusionKeys = await this.keyProvider.inclusionKeys();
|
|
4068
|
-
ProgramManager$1.loadInclusionProver(inclusionKeys[0]);
|
|
4069
|
-
this.inclusionKeysLoaded = true;
|
|
4070
|
-
console.log("Successfully loaded inclusion key");
|
|
4071
|
-
}
|
|
4072
|
-
catch {
|
|
4073
|
-
logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`);
|
|
4074
|
-
}
|
|
4075
|
-
}
|
|
4076
4052
|
// Build an execution transaction and submit it to the network
|
|
4077
4053
|
const tx = await ProgramManager$1.buildSplitTransaction(executionPrivateKey, splitAmount, amountRecord, this.host, splitProvingKey, splitVerifyingKey, offlineQuery);
|
|
4078
4054
|
return await this.networkClient.submitTransaction(tx);
|
|
@@ -4192,20 +4168,6 @@ class ProgramManager {
|
|
|
4192
4168
|
catch (e) {
|
|
4193
4169
|
logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
|
|
4194
4170
|
}
|
|
4195
|
-
// Load the inclusion prover offline.
|
|
4196
|
-
if (offlineQuery && !this.inclusionKeysLoaded) {
|
|
4197
|
-
const inclusionKeys = await this.keyProvider.inclusionKeys();
|
|
4198
|
-
ProgramManager$1.loadInclusionProver(inclusionKeys[0]);
|
|
4199
|
-
try {
|
|
4200
|
-
const inclusionKeys = await this.keyProvider.inclusionKeys();
|
|
4201
|
-
ProgramManager$1.loadInclusionProver(inclusionKeys[0]);
|
|
4202
|
-
this.inclusionKeysLoaded = true;
|
|
4203
|
-
console.log("Successfully loaded inclusion key");
|
|
4204
|
-
}
|
|
4205
|
-
catch {
|
|
4206
|
-
logAndThrow(`Inclusion key bytes not loaded, please ensure the program manager is initialized with a KeyProvider that includes the inclusion key.`);
|
|
4207
|
-
}
|
|
4208
|
-
}
|
|
4209
4171
|
// Build an execution transaction
|
|
4210
4172
|
return await ProgramManager$1.buildTransferTransaction(executionPrivateKey, amount, recipient, transferType, amountRecord, priorityFee, feeRecord, this.host, transferProvingKey, transferVerifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
|
|
4211
4173
|
}
|
|
@@ -4376,7 +4338,6 @@ class ProgramManager {
|
|
|
4376
4338
|
privateFee,
|
|
4377
4339
|
inputs,
|
|
4378
4340
|
keySearchParams,
|
|
4379
|
-
program,
|
|
4380
4341
|
...additionalOptions,
|
|
4381
4342
|
};
|
|
4382
4343
|
return await this.buildExecutionTransaction(executeOptions);
|
|
@@ -4480,7 +4441,6 @@ class ProgramManager {
|
|
|
4480
4441
|
privateFee,
|
|
4481
4442
|
inputs,
|
|
4482
4443
|
keySearchParams,
|
|
4483
|
-
program,
|
|
4484
4444
|
...additionalOptions,
|
|
4485
4445
|
};
|
|
4486
4446
|
return await this.buildExecutionTransaction(executeOptions);
|
|
@@ -4575,7 +4535,6 @@ class ProgramManager {
|
|
|
4575
4535
|
privateFee,
|
|
4576
4536
|
inputs,
|
|
4577
4537
|
keySearchParams,
|
|
4578
|
-
program,
|
|
4579
4538
|
...additionalOptions,
|
|
4580
4539
|
};
|
|
4581
4540
|
return this.buildExecutionTransaction(executeOptions);
|
|
@@ -4673,7 +4632,6 @@ class ProgramManager {
|
|
|
4673
4632
|
privateFee,
|
|
4674
4633
|
inputs,
|
|
4675
4634
|
keySearchParams,
|
|
4676
|
-
program,
|
|
4677
4635
|
...additionalOptions,
|
|
4678
4636
|
};
|
|
4679
4637
|
// Check if the account has sufficient credits to pay for the transaction
|
|
@@ -4767,7 +4725,7 @@ class ProgramManager {
|
|
|
4767
4725
|
proverUri: CREDITS_PROGRAM_KEYS.set_validator_state.prover,
|
|
4768
4726
|
verifierUri: CREDITS_PROGRAM_KEYS.set_validator_state.verifier,
|
|
4769
4727
|
cacheKey: "credits.aleo/set_validator_state",
|
|
4770
|
-
}),
|
|
4728
|
+
}), ...additionalOptions } = options;
|
|
4771
4729
|
const executeOptions = {
|
|
4772
4730
|
programName,
|
|
4773
4731
|
functionName,
|
|
@@ -4775,7 +4733,6 @@ class ProgramManager {
|
|
|
4775
4733
|
privateFee,
|
|
4776
4734
|
inputs,
|
|
4777
4735
|
keySearchParams,
|
|
4778
|
-
program,
|
|
4779
4736
|
...additionalOptions,
|
|
4780
4737
|
};
|
|
4781
4738
|
return await this.buildExecutionTransaction(executeOptions);
|
|
@@ -4878,15 +4835,6 @@ class ProgramManager {
|
|
|
4878
4835
|
return false;
|
|
4879
4836
|
}
|
|
4880
4837
|
}
|
|
4881
|
-
/**
|
|
4882
|
-
* Set the inclusion key bytes.
|
|
4883
|
-
*
|
|
4884
|
-
* @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)
|
|
4885
|
-
* @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { "programName": "programSourceCode", ... }
|
|
4886
|
-
* @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { "programName": [["functionName", "verifyingKey"], ...], ... }
|
|
4887
|
-
* @returns {boolean} True if the proof is valid, false otherwise
|
|
4888
|
-
*
|
|
4889
|
-
|
|
4890
4838
|
/**
|
|
4891
4839
|
* Create a program object from a program's source code
|
|
4892
4840
|
*
|