@provablehq/sdk 0.9.7 → 0.10.0-rc
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.
|
@@ -34,6 +34,7 @@ declare class AleoNetworkClient {
|
|
|
34
34
|
ctx: {
|
|
35
35
|
[key: string]: string;
|
|
36
36
|
};
|
|
37
|
+
debugMode: boolean;
|
|
37
38
|
readonly network: string;
|
|
38
39
|
constructor(host: string, options?: AleoNetworkClientOptions);
|
|
39
40
|
/**
|
|
@@ -71,6 +72,21 @@ declare class AleoNetworkClient {
|
|
|
71
72
|
* networkClient.setHost("http://api.explorer.provable.com/v1");
|
|
72
73
|
*/
|
|
73
74
|
setHost(host: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Set debug mode for the networkClient. When this mode is enabled, if Aleo network nodes report failures after
|
|
77
|
+
* calling the `submitTransaction` method, nodes will report debug information as to why the transaction failed.
|
|
78
|
+
*
|
|
79
|
+
* @param {boolean} debugMode Set debug mode for the networkClient.
|
|
80
|
+
* @example
|
|
81
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
82
|
+
*
|
|
83
|
+
* // Create a networkClient
|
|
84
|
+
* const networkClient = new AleoNetworkClient();
|
|
85
|
+
*
|
|
86
|
+
* // Set debug mode to true
|
|
87
|
+
* networkClient.setDebugMode(true);
|
|
88
|
+
**/
|
|
89
|
+
setDebugMode(debugMode: boolean): void;
|
|
74
90
|
/**
|
|
75
91
|
* Set a header in the `AleoNetworkClient`s header map
|
|
76
92
|
*
|
package/dist/testnet/browser.js
CHANGED
|
@@ -478,18 +478,20 @@ class AleoNetworkClient {
|
|
|
478
478
|
headers;
|
|
479
479
|
account;
|
|
480
480
|
ctx;
|
|
481
|
+
debugMode;
|
|
481
482
|
network;
|
|
482
483
|
constructor(host, options) {
|
|
483
484
|
this.host = host + "/testnet";
|
|
484
485
|
this.network = "testnet";
|
|
485
486
|
this.ctx = {};
|
|
487
|
+
this.debugMode = true;
|
|
486
488
|
if (options && options.headers) {
|
|
487
489
|
this.headers = options.headers;
|
|
488
490
|
}
|
|
489
491
|
else {
|
|
490
492
|
this.headers = {
|
|
491
493
|
// This is replaced by the actual version by a Rollup plugin
|
|
492
|
-
"X-Aleo-SDK-Version": "0.
|
|
494
|
+
"X-Aleo-SDK-Version": "0.10.0-rc",
|
|
493
495
|
"X-Aleo-environment": environment(),
|
|
494
496
|
};
|
|
495
497
|
}
|
|
@@ -535,6 +537,23 @@ class AleoNetworkClient {
|
|
|
535
537
|
setHost(host) {
|
|
536
538
|
this.host = host + "/testnet";
|
|
537
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Set debug mode for the networkClient. When this mode is enabled, if Aleo network nodes report failures after
|
|
542
|
+
* calling the `submitTransaction` method, nodes will report debug information as to why the transaction failed.
|
|
543
|
+
*
|
|
544
|
+
* @param {boolean} debugMode Set debug mode for the networkClient.
|
|
545
|
+
* @example
|
|
546
|
+
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
|
|
547
|
+
*
|
|
548
|
+
* // Create a networkClient
|
|
549
|
+
* const networkClient = new AleoNetworkClient();
|
|
550
|
+
*
|
|
551
|
+
* // Set debug mode to true
|
|
552
|
+
* networkClient.setDebugMode(true);
|
|
553
|
+
**/
|
|
554
|
+
setDebugMode(debugMode) {
|
|
555
|
+
this.debugMode = debugMode;
|
|
556
|
+
}
|
|
538
557
|
/**
|
|
539
558
|
* Set a header in the `AleoNetworkClient`s header map
|
|
540
559
|
*
|
|
@@ -1773,7 +1792,8 @@ class AleoNetworkClient {
|
|
|
1773
1792
|
? transaction.toString()
|
|
1774
1793
|
: transaction;
|
|
1775
1794
|
try {
|
|
1776
|
-
const
|
|
1795
|
+
const endpoint = this.debugMode ? "transaction/broadcast?debug=true" : "transaction/broadcast";
|
|
1796
|
+
const response = await retryWithBackoff(() => this._sendPost(`${this.host}/${endpoint}`, {
|
|
1777
1797
|
body: transactionString,
|
|
1778
1798
|
headers: Object.assign({}, { ...this.headers, "X-ALEO-METHOD": "submitTransaction" }, {
|
|
1779
1799
|
"Content-Type": "application/json",
|
|
@@ -3490,11 +3510,12 @@ class ProgramManager {
|
|
|
3490
3510
|
*/
|
|
3491
3511
|
async buildExecutionTransaction(options) {
|
|
3492
3512
|
// Destructure the options object to access the parameters
|
|
3493
|
-
const {
|
|
3513
|
+
const { functionName, priorityFee, privateFee, inputs, recordSearchParams, keySearchParams, privateKey, offlineQuery, } = options;
|
|
3494
3514
|
let feeRecord = options.feeRecord;
|
|
3495
3515
|
let provingKey = options.provingKey;
|
|
3496
3516
|
let verifyingKey = options.verifyingKey;
|
|
3497
3517
|
let program = options.program;
|
|
3518
|
+
let programName = options.programName;
|
|
3498
3519
|
let imports = options.imports;
|
|
3499
3520
|
let edition = options.edition;
|
|
3500
3521
|
// Ensure the function exists on the network
|
|
@@ -3509,6 +3530,10 @@ class ProgramManager {
|
|
|
3509
3530
|
else if (program instanceof Program) {
|
|
3510
3531
|
program = program.toString();
|
|
3511
3532
|
}
|
|
3533
|
+
// Get the program name if it is not provided in the parameters.
|
|
3534
|
+
if (programName === undefined) {
|
|
3535
|
+
programName = Program.fromString(program).id();
|
|
3536
|
+
}
|
|
3512
3537
|
if (edition == undefined) {
|
|
3513
3538
|
try {
|
|
3514
3539
|
edition = await this.networkClient.getLatestProgramEdition(programName);
|
|
@@ -3599,9 +3624,10 @@ class ProgramManager {
|
|
|
3599
3624
|
*/
|
|
3600
3625
|
async buildAuthorization(options) {
|
|
3601
3626
|
// Destructure the options object to access the parameters.
|
|
3602
|
-
const {
|
|
3627
|
+
const { functionName, inputs, } = options;
|
|
3603
3628
|
const privateKey = options.privateKey;
|
|
3604
3629
|
let program = options.programSource;
|
|
3630
|
+
let programName = options.programName;
|
|
3605
3631
|
let imports = options.programImports;
|
|
3606
3632
|
let edition = options.edition;
|
|
3607
3633
|
// Ensure the function exists on the network.
|
|
@@ -3616,6 +3642,10 @@ class ProgramManager {
|
|
|
3616
3642
|
else if (program instanceof Program) {
|
|
3617
3643
|
program = program.toString();
|
|
3618
3644
|
}
|
|
3645
|
+
// Get the program name if it is not provided in the parameters.
|
|
3646
|
+
if (programName === undefined) {
|
|
3647
|
+
programName = Program.fromString(program).id();
|
|
3648
|
+
}
|
|
3619
3649
|
// Get the private key from the account if it is not provided in the parameters.
|
|
3620
3650
|
let executionPrivateKey = privateKey;
|
|
3621
3651
|
if (typeof privateKey === "undefined" &&
|
|
@@ -3677,9 +3707,10 @@ class ProgramManager {
|
|
|
3677
3707
|
*/
|
|
3678
3708
|
async buildAuthorizationUnchecked(options) {
|
|
3679
3709
|
// Destructure the options object to access the parameters.
|
|
3680
|
-
const {
|
|
3710
|
+
const { functionName, inputs, } = options;
|
|
3681
3711
|
const privateKey = options.privateKey;
|
|
3682
3712
|
let program = options.programSource;
|
|
3713
|
+
let programName = options.programName;
|
|
3683
3714
|
let imports = options.programImports;
|
|
3684
3715
|
let edition = options.edition;
|
|
3685
3716
|
// Ensure the function exists on the network.
|
|
@@ -3694,6 +3725,10 @@ class ProgramManager {
|
|
|
3694
3725
|
else if (program instanceof Program) {
|
|
3695
3726
|
program = program.toString();
|
|
3696
3727
|
}
|
|
3728
|
+
// Get the program name if it is not provided in the parameters.
|
|
3729
|
+
if (programName === undefined) {
|
|
3730
|
+
programName = Program.fromString(program).id();
|
|
3731
|
+
}
|
|
3697
3732
|
// Get the private key from the account if it is not provided in the parameters.
|
|
3698
3733
|
let executionPrivateKey = privateKey;
|
|
3699
3734
|
if (typeof privateKey === "undefined" &&
|
|
@@ -3759,9 +3794,10 @@ class ProgramManager {
|
|
|
3759
3794
|
*/
|
|
3760
3795
|
async provingRequest(options) {
|
|
3761
3796
|
// Destructure the options object to access the parameters.
|
|
3762
|
-
const {
|
|
3797
|
+
const { functionName, baseFee, priorityFee, privateFee, inputs, recordSearchParams, broadcast = false, unchecked = false, } = options;
|
|
3763
3798
|
const privateKey = options.privateKey;
|
|
3764
3799
|
let program = options.programSource;
|
|
3800
|
+
let programName = options.programName;
|
|
3765
3801
|
let feeRecord = options.feeRecord;
|
|
3766
3802
|
let imports = options.programImports;
|
|
3767
3803
|
let edition = options.edition;
|
|
@@ -3777,6 +3813,10 @@ class ProgramManager {
|
|
|
3777
3813
|
else if (program instanceof Program) {
|
|
3778
3814
|
program = program.toString();
|
|
3779
3815
|
}
|
|
3816
|
+
// Get the program name if it is not provided in the parameters.
|
|
3817
|
+
if (programName === undefined) {
|
|
3818
|
+
programName = Program.fromString(program).id();
|
|
3819
|
+
}
|
|
3780
3820
|
if (edition == undefined) {
|
|
3781
3821
|
try {
|
|
3782
3822
|
edition = await this.networkClient.getLatestProgramEdition(programName);
|