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.mjs CHANGED
@@ -6140,18 +6140,20 @@ var RpcChannel = class {
6140
6140
  }
6141
6141
  async fetchEndpoint(method, params) {
6142
6142
  try {
6143
+ let error;
6144
+ let result;
6143
6145
  if (this.batchClient) {
6144
- const { error: error2, result: result2 } = await this.batchClient.fetch(
6145
- method,
6146
- params,
6147
- this.requestId += 1
6148
- );
6149
- this.errorHandler(method, params, error2);
6150
- return result2;
6146
+ ({ error, result } = await this.batchClient.fetch(method, params, this.requestId += 1));
6147
+ } else {
6148
+ const rawResult = await this.fetch(method, params, this.requestId += 1);
6149
+ ({ error, result } = await rawResult.json());
6151
6150
  }
6152
- const rawResult = await this.fetch(method, params, this.requestId += 1);
6153
- const { error, result } = await rawResult.json();
6154
6151
  this.errorHandler(method, params, error);
6152
+ if (result === void 0) {
6153
+ throw new LibraryError(
6154
+ `RPC: '${method}' returned an empty response (no result and no error). The node reply is malformed or not a valid JSON-RPC response.`
6155
+ );
6156
+ }
6155
6157
  return result;
6156
6158
  } catch (error) {
6157
6159
  this.errorHandler(method, params, error?.response?.data, error);
@@ -6695,18 +6697,20 @@ var RpcChannel2 = class {
6695
6697
  }
6696
6698
  async fetchEndpoint(method, params) {
6697
6699
  try {
6700
+ let error;
6701
+ let result;
6698
6702
  if (this.batchClient) {
6699
- const { error: error2, result: result2 } = await this.batchClient.fetch(
6700
- method,
6701
- params,
6702
- this.requestId += 1
6703
- );
6704
- this.errorHandler(method, params, error2);
6705
- return result2;
6703
+ ({ error, result } = await this.batchClient.fetch(method, params, this.requestId += 1));
6704
+ } else {
6705
+ const rawResult = await this.fetch(method, params, this.requestId += 1);
6706
+ ({ error, result } = await rawResult.json());
6706
6707
  }
6707
- const rawResult = await this.fetch(method, params, this.requestId += 1);
6708
- const { error, result } = await rawResult.json();
6709
6708
  this.errorHandler(method, params, error);
6709
+ if (result === void 0) {
6710
+ throw new LibraryError(
6711
+ `RPC: '${method}' returned an empty response (no result and no error). The node reply is malformed or not a valid JSON-RPC response.`
6712
+ );
6713
+ }
6710
6714
  return result;
6711
6715
  } catch (error) {
6712
6716
  this.errorHandler(method, params, error?.response?.data, error);