starknet 10.3.1 → 10.3.2

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/index.js CHANGED
@@ -6321,18 +6321,20 @@ var RpcChannel = class {
6321
6321
  }
6322
6322
  async fetchEndpoint(method, params) {
6323
6323
  try {
6324
+ let error;
6325
+ let result;
6324
6326
  if (this.batchClient) {
6325
- const { error: error2, result: result2 } = await this.batchClient.fetch(
6326
- method,
6327
- params,
6328
- this.requestId += 1
6329
- );
6330
- this.errorHandler(method, params, error2);
6331
- return result2;
6327
+ ({ error, result } = await this.batchClient.fetch(method, params, this.requestId += 1));
6328
+ } else {
6329
+ const rawResult = await this.fetch(method, params, this.requestId += 1);
6330
+ ({ error, result } = await rawResult.json());
6332
6331
  }
6333
- const rawResult = await this.fetch(method, params, this.requestId += 1);
6334
- const { error, result } = await rawResult.json();
6335
6332
  this.errorHandler(method, params, error);
6333
+ if (result === void 0) {
6334
+ throw new LibraryError(
6335
+ `RPC: '${method}' returned an empty response (no result and no error). The node reply is malformed or not a valid JSON-RPC response.`
6336
+ );
6337
+ }
6336
6338
  return result;
6337
6339
  } catch (error) {
6338
6340
  this.errorHandler(method, params, error?.response?.data, error);
@@ -6876,18 +6878,20 @@ var RpcChannel2 = class {
6876
6878
  }
6877
6879
  async fetchEndpoint(method, params) {
6878
6880
  try {
6881
+ let error;
6882
+ let result;
6879
6883
  if (this.batchClient) {
6880
- const { error: error2, result: result2 } = await this.batchClient.fetch(
6881
- method,
6882
- params,
6883
- this.requestId += 1
6884
- );
6885
- this.errorHandler(method, params, error2);
6886
- return result2;
6884
+ ({ error, result } = await this.batchClient.fetch(method, params, this.requestId += 1));
6885
+ } else {
6886
+ const rawResult = await this.fetch(method, params, this.requestId += 1);
6887
+ ({ error, result } = await rawResult.json());
6887
6888
  }
6888
- const rawResult = await this.fetch(method, params, this.requestId += 1);
6889
- const { error, result } = await rawResult.json();
6890
6889
  this.errorHandler(method, params, error);
6890
+ if (result === void 0) {
6891
+ throw new LibraryError(
6892
+ `RPC: '${method}' returned an empty response (no result and no error). The node reply is malformed or not a valid JSON-RPC response.`
6893
+ );
6894
+ }
6891
6895
  return result;
6892
6896
  } catch (error) {
6893
6897
  this.errorHandler(method, params, error?.response?.data, error);