starknet 4.19.0 → 4.19.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
@@ -33,6 +33,7 @@ __export(src_exports, {
33
33
  ContractInterface: () => ContractInterface,
34
34
  GatewayError: () => GatewayError,
35
35
  HttpError: () => HttpError,
36
+ LibraryError: () => LibraryError,
36
37
  Provider: () => Provider,
37
38
  ProviderInterface: () => ProviderInterface,
38
39
  RpcProvider: () => RpcProvider,
@@ -2652,6 +2653,23 @@ var RPCResponseParser = class {
2652
2653
  }
2653
2654
  };
2654
2655
 
2656
+ // src/provider/errors.ts
2657
+ var import_ts_custom_error = require("ts-custom-error");
2658
+ var LibraryError = class extends import_ts_custom_error.CustomError {
2659
+ };
2660
+ var GatewayError = class extends LibraryError {
2661
+ constructor(message, errorCode) {
2662
+ super(message);
2663
+ this.errorCode = errorCode;
2664
+ }
2665
+ };
2666
+ var HttpError = class extends LibraryError {
2667
+ constructor(message, errorCode) {
2668
+ super(message);
2669
+ this.errorCode = errorCode;
2670
+ }
2671
+ };
2672
+
2655
2673
  // src/provider/utils.ts
2656
2674
  var import_bn2 = require("bn.js");
2657
2675
  var validBlockTags = ["latest", "pending"];
@@ -2728,7 +2746,7 @@ var RpcProvider = class {
2728
2746
  errorHandler(error) {
2729
2747
  if (error) {
2730
2748
  const { code, message } = error;
2731
- throw new Error(`${code}: ${message}`);
2749
+ throw new LibraryError(`${code}: ${message}`);
2732
2750
  }
2733
2751
  }
2734
2752
  async fetchEndpoint(method, params) {
@@ -3136,21 +3154,6 @@ function buildUrl(baseUrl, defaultPath, urlOrPath) {
3136
3154
  return isUrl(urlOrPath) ? urlOrPath : (0, import_url_join.default)(baseUrl, urlOrPath ?? defaultPath);
3137
3155
  }
3138
3156
 
3139
- // src/provider/errors.ts
3140
- var import_ts_custom_error = require("ts-custom-error");
3141
- var GatewayError = class extends import_ts_custom_error.CustomError {
3142
- constructor(message, errorCode) {
3143
- super(message);
3144
- this.errorCode = errorCode;
3145
- }
3146
- };
3147
- var HttpError = class extends import_ts_custom_error.CustomError {
3148
- constructor(message, errorCode) {
3149
- super(message);
3150
- this.errorCode = errorCode;
3151
- }
3152
- };
3153
-
3154
3157
  // src/provider/sequencer.ts
3155
3158
  function isEmptyQueryObject(obj) {
3156
3159
  return obj === void 0 || Object.keys(obj).length === 0 || Object.keys(obj).length === 1 && Object.entries(obj).every(([k, v]) => k === "blockIdentifier" && v === null);
@@ -3317,9 +3320,11 @@ var SequencerProvider = class {
3317
3320
  }
3318
3321
  async getTransaction(txHash) {
3319
3322
  const txHashHex = toHex(toBN(txHash));
3320
- return this.fetchEndpoint("get_transaction", { transactionHash: txHashHex }).then(
3321
- (value) => this.responseParser.parseGetTransactionResponse(value)
3322
- );
3323
+ return this.fetchEndpoint("get_transaction", { transactionHash: txHashHex }).then((result) => {
3324
+ if (Object.values(result).length === 1)
3325
+ throw new LibraryError(result.status);
3326
+ return this.responseParser.parseGetTransactionResponse(result);
3327
+ });
3323
3328
  }
3324
3329
  async getTransactionReceipt(txHash) {
3325
3330
  const txHashHex = toHex(toBN(txHash));
@@ -5070,6 +5075,7 @@ function validateChecksumAddress(address) {
5070
5075
  ContractInterface,
5071
5076
  GatewayError,
5072
5077
  HttpError,
5078
+ LibraryError,
5073
5079
  Provider,
5074
5080
  ProviderInterface,
5075
5081
  RpcProvider,