starknet 10.3.1 → 10.3.3

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
@@ -1362,7 +1362,7 @@ var CairoFelt252 = class _CairoFelt252 {
1362
1362
  return addHexPrefix(this.toBigInt().toString(16));
1363
1363
  }
1364
1364
  toApiRequest() {
1365
- return addCompiledFlag([this.toHexString()]);
1365
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1366
1366
  }
1367
1367
  static assertRange(val) {
1368
1368
  assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
@@ -1992,7 +1992,7 @@ var CairoBytes31 = class _CairoBytes31 {
1992
1992
  throw new Error("Invalid input type for CairoBytes31. Expected string, Buffer, or Uint8Array");
1993
1993
  }
1994
1994
  toApiRequest() {
1995
- return addCompiledFlag([this.toHexString()]);
1995
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1996
1996
  }
1997
1997
  toBigInt() {
1998
1998
  return uint8ArrayToBigInt(this.data);
@@ -2197,7 +2197,7 @@ var CairoUint32 = class _CairoUint32 {
2197
2197
  return BigInt(data);
2198
2198
  }
2199
2199
  toApiRequest() {
2200
- return addCompiledFlag([this.toHexString()]);
2200
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2201
2201
  }
2202
2202
  toBigInt() {
2203
2203
  return this.data;
@@ -2317,7 +2317,7 @@ var CairoByteArray = class _CairoByteArray {
2317
2317
  toApiRequest() {
2318
2318
  this.assertInitialized();
2319
2319
  return addCompiledFlag([
2320
- addHexPrefix(this.data.length.toString(16)),
2320
+ this.data.length.toString(),
2321
2321
  ...this.data.flatMap((bytes31) => bytes31.toApiRequest()),
2322
2322
  ...this.pending_word.toApiRequest(),
2323
2323
  ...this.pending_word_len.toApiRequest()
@@ -2470,7 +2470,7 @@ var CairoUint8 = class _CairoUint8 {
2470
2470
  return BigInt(data);
2471
2471
  }
2472
2472
  toApiRequest() {
2473
- return addCompiledFlag([this.toHexString()]);
2473
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2474
2474
  }
2475
2475
  toBigInt() {
2476
2476
  return this.data;
@@ -2528,7 +2528,7 @@ var CairoUint16 = class _CairoUint16 {
2528
2528
  return BigInt(data);
2529
2529
  }
2530
2530
  toApiRequest() {
2531
- return addCompiledFlag([this.toHexString()]);
2531
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2532
2532
  }
2533
2533
  toBigInt() {
2534
2534
  return this.data;
@@ -2586,7 +2586,7 @@ var CairoUint64 = class _CairoUint64 {
2586
2586
  return BigInt(data);
2587
2587
  }
2588
2588
  toApiRequest() {
2589
- return addCompiledFlag([this.toHexString()]);
2589
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2590
2590
  }
2591
2591
  toBigInt() {
2592
2592
  return this.data;
@@ -2644,7 +2644,7 @@ var CairoUint96 = class _CairoUint96 {
2644
2644
  return BigInt(data);
2645
2645
  }
2646
2646
  toApiRequest() {
2647
- return addCompiledFlag([this.toHexString()]);
2647
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2648
2648
  }
2649
2649
  toBigInt() {
2650
2650
  return this.data;
@@ -2702,7 +2702,7 @@ var CairoUint128 = class _CairoUint128 {
2702
2702
  return BigInt(data);
2703
2703
  }
2704
2704
  toApiRequest() {
2705
- return addCompiledFlag([this.toHexString()]);
2705
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2706
2706
  }
2707
2707
  toBigInt() {
2708
2708
  return this.data;
@@ -2760,7 +2760,7 @@ var CairoInt8 = class _CairoInt8 {
2760
2760
  return BigInt(data);
2761
2761
  }
2762
2762
  toApiRequest() {
2763
- return addCompiledFlag([this.toHexString()]);
2763
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2764
2764
  }
2765
2765
  toBigInt() {
2766
2766
  return this.data;
@@ -2832,7 +2832,7 @@ var CairoInt16 = class _CairoInt16 {
2832
2832
  return BigInt(data);
2833
2833
  }
2834
2834
  toApiRequest() {
2835
- return addCompiledFlag([this.toHexString()]);
2835
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2836
2836
  }
2837
2837
  toBigInt() {
2838
2838
  return this.data;
@@ -2904,7 +2904,7 @@ var CairoInt32 = class _CairoInt32 {
2904
2904
  return BigInt(data);
2905
2905
  }
2906
2906
  toApiRequest() {
2907
- return addCompiledFlag([this.toHexString()]);
2907
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2908
2908
  }
2909
2909
  toBigInt() {
2910
2910
  return this.data;
@@ -2976,7 +2976,7 @@ var CairoInt64 = class _CairoInt64 {
2976
2976
  return BigInt(data);
2977
2977
  }
2978
2978
  toApiRequest() {
2979
- return addCompiledFlag([this.toHexString()]);
2979
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2980
2980
  }
2981
2981
  toBigInt() {
2982
2982
  return this.data;
@@ -3048,7 +3048,7 @@ var CairoInt128 = class _CairoInt128 {
3048
3048
  return BigInt(data);
3049
3049
  }
3050
3050
  toApiRequest() {
3051
- return addCompiledFlag([this.toHexString()]);
3051
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
3052
3052
  }
3053
3053
  toBigInt() {
3054
3054
  return this.data;
@@ -3212,7 +3212,7 @@ var fastParsingStrategy = {
3212
3212
  return new CairoByteArray(val).toApiRequest();
3213
3213
  },
3214
3214
  [CairoFelt252.abiSelector]: (val) => {
3215
- return felt(val);
3215
+ return new CairoFelt252(val).toApiRequest();
3216
3216
  },
3217
3217
  [CairoUint256.abiSelector]: (val) => {
3218
3218
  return new CairoUint256(val).toApiRequest();
@@ -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);