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.mjs CHANGED
@@ -1181,7 +1181,7 @@ var CairoFelt252 = class _CairoFelt252 {
1181
1181
  return addHexPrefix(this.toBigInt().toString(16));
1182
1182
  }
1183
1183
  toApiRequest() {
1184
- return addCompiledFlag([this.toHexString()]);
1184
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1185
1185
  }
1186
1186
  static assertRange(val) {
1187
1187
  assert(val >= 0n && val < PRIME, `Value ${val} is out of felt252 range [0, ${PRIME})`);
@@ -1811,7 +1811,7 @@ var CairoBytes31 = class _CairoBytes31 {
1811
1811
  throw new Error("Invalid input type for CairoBytes31. Expected string, Buffer, or Uint8Array");
1812
1812
  }
1813
1813
  toApiRequest() {
1814
- return addCompiledFlag([this.toHexString()]);
1814
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
1815
1815
  }
1816
1816
  toBigInt() {
1817
1817
  return uint8ArrayToBigInt(this.data);
@@ -2016,7 +2016,7 @@ var CairoUint32 = class _CairoUint32 {
2016
2016
  return BigInt(data);
2017
2017
  }
2018
2018
  toApiRequest() {
2019
- return addCompiledFlag([this.toHexString()]);
2019
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2020
2020
  }
2021
2021
  toBigInt() {
2022
2022
  return this.data;
@@ -2136,7 +2136,7 @@ var CairoByteArray = class _CairoByteArray {
2136
2136
  toApiRequest() {
2137
2137
  this.assertInitialized();
2138
2138
  return addCompiledFlag([
2139
- addHexPrefix(this.data.length.toString(16)),
2139
+ this.data.length.toString(),
2140
2140
  ...this.data.flatMap((bytes31) => bytes31.toApiRequest()),
2141
2141
  ...this.pending_word.toApiRequest(),
2142
2142
  ...this.pending_word_len.toApiRequest()
@@ -2289,7 +2289,7 @@ var CairoUint8 = class _CairoUint8 {
2289
2289
  return BigInt(data);
2290
2290
  }
2291
2291
  toApiRequest() {
2292
- return addCompiledFlag([this.toHexString()]);
2292
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2293
2293
  }
2294
2294
  toBigInt() {
2295
2295
  return this.data;
@@ -2347,7 +2347,7 @@ var CairoUint16 = class _CairoUint16 {
2347
2347
  return BigInt(data);
2348
2348
  }
2349
2349
  toApiRequest() {
2350
- return addCompiledFlag([this.toHexString()]);
2350
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2351
2351
  }
2352
2352
  toBigInt() {
2353
2353
  return this.data;
@@ -2405,7 +2405,7 @@ var CairoUint64 = class _CairoUint64 {
2405
2405
  return BigInt(data);
2406
2406
  }
2407
2407
  toApiRequest() {
2408
- return addCompiledFlag([this.toHexString()]);
2408
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2409
2409
  }
2410
2410
  toBigInt() {
2411
2411
  return this.data;
@@ -2463,7 +2463,7 @@ var CairoUint96 = class _CairoUint96 {
2463
2463
  return BigInt(data);
2464
2464
  }
2465
2465
  toApiRequest() {
2466
- return addCompiledFlag([this.toHexString()]);
2466
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2467
2467
  }
2468
2468
  toBigInt() {
2469
2469
  return this.data;
@@ -2521,7 +2521,7 @@ var CairoUint128 = class _CairoUint128 {
2521
2521
  return BigInt(data);
2522
2522
  }
2523
2523
  toApiRequest() {
2524
- return addCompiledFlag([this.toHexString()]);
2524
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2525
2525
  }
2526
2526
  toBigInt() {
2527
2527
  return this.data;
@@ -2579,7 +2579,7 @@ var CairoInt8 = class _CairoInt8 {
2579
2579
  return BigInt(data);
2580
2580
  }
2581
2581
  toApiRequest() {
2582
- return addCompiledFlag([this.toHexString()]);
2582
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2583
2583
  }
2584
2584
  toBigInt() {
2585
2585
  return this.data;
@@ -2651,7 +2651,7 @@ var CairoInt16 = class _CairoInt16 {
2651
2651
  return BigInt(data);
2652
2652
  }
2653
2653
  toApiRequest() {
2654
- return addCompiledFlag([this.toHexString()]);
2654
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2655
2655
  }
2656
2656
  toBigInt() {
2657
2657
  return this.data;
@@ -2723,7 +2723,7 @@ var CairoInt32 = class _CairoInt32 {
2723
2723
  return BigInt(data);
2724
2724
  }
2725
2725
  toApiRequest() {
2726
- return addCompiledFlag([this.toHexString()]);
2726
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2727
2727
  }
2728
2728
  toBigInt() {
2729
2729
  return this.data;
@@ -2795,7 +2795,7 @@ var CairoInt64 = class _CairoInt64 {
2795
2795
  return BigInt(data);
2796
2796
  }
2797
2797
  toApiRequest() {
2798
- return addCompiledFlag([this.toHexString()]);
2798
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2799
2799
  }
2800
2800
  toBigInt() {
2801
2801
  return this.data;
@@ -2867,7 +2867,7 @@ var CairoInt128 = class _CairoInt128 {
2867
2867
  return BigInt(data);
2868
2868
  }
2869
2869
  toApiRequest() {
2870
- return addCompiledFlag([this.toHexString()]);
2870
+ return addCompiledFlag([BigInt(this.toHexString()).toString()]);
2871
2871
  }
2872
2872
  toBigInt() {
2873
2873
  return this.data;
@@ -3031,7 +3031,7 @@ var fastParsingStrategy = {
3031
3031
  return new CairoByteArray(val).toApiRequest();
3032
3032
  },
3033
3033
  [CairoFelt252.abiSelector]: (val) => {
3034
- return felt(val);
3034
+ return new CairoFelt252(val).toApiRequest();
3035
3035
  },
3036
3036
  [CairoUint256.abiSelector]: (val) => {
3037
3037
  return new CairoUint256(val).toApiRequest();
@@ -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);