Skip to content

Commit 2b57d16

Browse files
Enable setting verbose transaction errors on the AleoNetworkClient
1 parent 88971e5 commit 2b57d16

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

sdk/src/network-client.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class AleoNetworkClient {
5252
headers: { [key: string]: string };
5353
account: Account | undefined;
5454
ctx: { [key: string]: string };
55-
debugMode: boolean;
55+
verboseErrors: boolean;
5656
readonly network: string;
5757

5858
constructor(host: string, options?: AleoNetworkClientOptions) {
5959
this.host = host + "/%%NETWORK%%";
6060
this.network = "%%NETWORK%%";
6161
this.ctx = {};
62-
this.debugMode = true;
62+
this.verboseErrors = true;
6363

6464
if (options && options.headers) {
6565
this.headers = options.headers;
@@ -117,21 +117,20 @@ class AleoNetworkClient {
117117
}
118118

119119
/**
120-
* Set debug mode for the networkClient. When this mode is enabled, if Aleo network nodes report failures after
121-
* calling the `submitTransaction` method, nodes will report debug information as to why the transaction failed.
120+
* Set verbose errors to true or false for the `AleoNetworkClient`. When set to true, if `submitTransaction` fails, the failure responses will report descriptive information as to why the transaction failed.
122121
*
123-
* @param {boolean} debugMode Set debug mode for the networkClient.
122+
* @param {boolean} verboseErrors Set verbose error mode to true or false for the AleoNetworkClient.
124123
* @example
125124
* import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
126125
*
127126
* // Create a networkClient
128127
* const networkClient = new AleoNetworkClient();
129128
*
130129
* // Set debug mode to true
131-
* networkClient.setDebugMode(true);
130+
* networkClient.setVerboseTransactionErrors(true);
132131
**/
133-
setDebugMode(debugMode: boolean) {
134-
this.debugMode = debugMode;
132+
setVerboseErrors(verboseErrors: boolean) {
133+
this.verboseErrors = verboseErrors;
135134
}
136135

137136
/**
@@ -1571,7 +1570,7 @@ class AleoNetworkClient {
15711570
? transaction.toString()
15721571
: transaction;
15731572
try {
1574-
const endpoint = this.debugMode ? "transaction/broadcast?debug=true" : "transaction/broadcast";
1573+
const endpoint = this.verboseErrors ? "transaction/broadcast?check_transaction=true" : "transaction/broadcast";
15751574
const response = await retryWithBackoff(() =>
15761575
this._sendPost(`${this.host}/${endpoint}`, {
15771576
body: transactionString,

0 commit comments

Comments
 (0)