starknet 3.15.5 → 3.15.6
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/CHANGELOG.md +6 -0
- package/dist/provider/default.js +12 -3
- package/dist/provider/errors.d.ts +9 -0
- package/dist/provider/errors.js +40 -0
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/index.js +2 -3
- package/dist/provider/utils.d.ts +0 -5
- package/dist/provider/utils.js +1 -27
- package/package.json +1 -1
- package/provider/default.js +11 -3
- package/provider/errors.d.ts +9 -0
- package/provider/errors.js +50 -0
- package/provider/index.d.ts +1 -1
- package/provider/index.js +2 -8
- package/provider/utils.d.ts +0 -6
- package/provider/utils.js +1 -38
- package/src/provider/default.ts +11 -3
- package/src/provider/errors.ts +14 -0
- package/src/provider/index.ts +1 -1
- package/src/provider/utils.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [3.15.6](https://github.com/0xs34n/starknet.js/compare/v3.15.5...v3.15.6) (2022-06-28)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- throw http error when parsing fails ([898574f](https://github.com/0xs34n/starknet.js/commit/898574f0087bf653b5d74bbe3dc52a0cb6efc432))
|
|
6
|
+
|
|
1
7
|
## [3.15.5](https://github.com/0xs34n/starknet.js/compare/v3.15.4...v3.15.5) (2022-06-27)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
package/dist/provider/default.js
CHANGED
|
@@ -73,6 +73,7 @@ var hash_1 = require("../utils/hash");
|
|
|
73
73
|
var json_1 = require("../utils/json");
|
|
74
74
|
var number_1 = require("../utils/number");
|
|
75
75
|
var stark_1 = require("../utils/stark");
|
|
76
|
+
var errors_1 = require("./errors");
|
|
76
77
|
var interface_1 = require("./interface");
|
|
77
78
|
var utils_1 = require("./utils");
|
|
78
79
|
function wait(delay) {
|
|
@@ -206,9 +207,16 @@ var Provider = /** @class */ (function () {
|
|
|
206
207
|
case 3:
|
|
207
208
|
textResponse = _c.sent();
|
|
208
209
|
if (!res.ok) {
|
|
209
|
-
responseBody =
|
|
210
|
+
responseBody = void 0;
|
|
211
|
+
try {
|
|
212
|
+
responseBody = (0, json_1.parse)(textResponse);
|
|
213
|
+
}
|
|
214
|
+
catch (_d) {
|
|
215
|
+
// if error parsing fails, return an http error
|
|
216
|
+
throw new errors_1.HttpError(res.statusText, res.status);
|
|
217
|
+
}
|
|
210
218
|
errorCode = responseBody.code || (responseBody === null || responseBody === void 0 ? void 0 : responseBody.status_code);
|
|
211
|
-
throw new
|
|
219
|
+
throw new errors_1.GatewayError(responseBody.message, errorCode); // Caught locally, and re-thrown for the user
|
|
212
220
|
}
|
|
213
221
|
if (endpoint === 'estimate_fee') {
|
|
214
222
|
return [2 /*return*/, (0, json_1.parseAlwaysAsBig)(textResponse, function (_, v) {
|
|
@@ -221,7 +229,8 @@ var Provider = /** @class */ (function () {
|
|
|
221
229
|
return [2 /*return*/, (0, json_1.parse)(textResponse)];
|
|
222
230
|
case 4:
|
|
223
231
|
err_1 = _c.sent();
|
|
224
|
-
|
|
232
|
+
// rethrow custom errors
|
|
233
|
+
if (err_1 instanceof errors_1.GatewayError || err_1 instanceof errors_1.HttpError) {
|
|
225
234
|
throw err_1;
|
|
226
235
|
}
|
|
227
236
|
if (err_1 instanceof Error) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CustomError } from 'ts-custom-error';
|
|
2
|
+
export declare class GatewayError extends CustomError {
|
|
3
|
+
errorCode: string;
|
|
4
|
+
constructor(message: string, errorCode: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class HttpError extends CustomError {
|
|
7
|
+
errorCode: number;
|
|
8
|
+
constructor(message: string, errorCode: number);
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.HttpError = exports.GatewayError = void 0;
|
|
19
|
+
/* eslint-disable max-classes-per-file */
|
|
20
|
+
var ts_custom_error_1 = require("ts-custom-error");
|
|
21
|
+
var GatewayError = /** @class */ (function (_super) {
|
|
22
|
+
__extends(GatewayError, _super);
|
|
23
|
+
function GatewayError(message, errorCode) {
|
|
24
|
+
var _this = _super.call(this, message) || this;
|
|
25
|
+
_this.errorCode = errorCode;
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
return GatewayError;
|
|
29
|
+
}(ts_custom_error_1.CustomError));
|
|
30
|
+
exports.GatewayError = GatewayError;
|
|
31
|
+
var HttpError = /** @class */ (function (_super) {
|
|
32
|
+
__extends(HttpError, _super);
|
|
33
|
+
function HttpError(message, errorCode) {
|
|
34
|
+
var _this = _super.call(this, message) || this;
|
|
35
|
+
_this.errorCode = errorCode;
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
return HttpError;
|
|
39
|
+
}(ts_custom_error_1.CustomError));
|
|
40
|
+
exports.HttpError = HttpError;
|
package/dist/provider/index.d.ts
CHANGED
package/dist/provider/index.js
CHANGED
|
@@ -14,10 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.defaultProvider =
|
|
17
|
+
exports.defaultProvider = void 0;
|
|
18
18
|
var default_1 = require("./default");
|
|
19
19
|
__exportStar(require("./default"), exports);
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "GatewayError", { enumerable: true, get: function () { return utils_1.GatewayError; } });
|
|
20
|
+
__exportStar(require("./errors"), exports);
|
|
22
21
|
__exportStar(require("./interface"), exports);
|
|
23
22
|
exports.defaultProvider = new default_1.Provider();
|
package/dist/provider/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CustomError } from 'ts-custom-error';
|
|
2
1
|
import type { BlockNumber } from '../types';
|
|
3
2
|
import { BigNumberish } from '../utils/number';
|
|
4
3
|
/**
|
|
@@ -40,8 +39,4 @@ export declare function getBlockIdentifier(blockIdentifier: BlockIdentifier): Bl
|
|
|
40
39
|
* @returns block identifier for API request
|
|
41
40
|
*/
|
|
42
41
|
export declare function getFormattedBlockIdentifier(blockIdentifier?: BlockIdentifier): string;
|
|
43
|
-
export declare class GatewayError extends CustomError {
|
|
44
|
-
errorCode: string;
|
|
45
|
-
constructor(message: string, errorCode: string);
|
|
46
|
-
}
|
|
47
42
|
export {};
|
package/dist/provider/utils.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
var ts_custom_error_1 = require("ts-custom-error");
|
|
3
|
+
exports.getFormattedBlockIdentifier = exports.getBlockIdentifier = exports.txIdentifier = exports.formatHash = void 0;
|
|
20
4
|
var number_1 = require("../utils/number");
|
|
21
5
|
/**
|
|
22
6
|
*
|
|
@@ -93,13 +77,3 @@ function getFormattedBlockIdentifier(blockIdentifier) {
|
|
|
93
77
|
return "blockHash=".concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
|
|
94
78
|
}
|
|
95
79
|
exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
|
|
96
|
-
var GatewayError = /** @class */ (function (_super) {
|
|
97
|
-
__extends(GatewayError, _super);
|
|
98
|
-
function GatewayError(message, errorCode) {
|
|
99
|
-
var _this = _super.call(this, message) || this;
|
|
100
|
-
_this.errorCode = errorCode;
|
|
101
|
-
return _this;
|
|
102
|
-
}
|
|
103
|
-
return GatewayError;
|
|
104
|
-
}(ts_custom_error_1.CustomError));
|
|
105
|
-
exports.GatewayError = GatewayError;
|
package/package.json
CHANGED
package/provider/default.js
CHANGED
|
@@ -179,6 +179,7 @@ var hash_1 = require('../utils/hash');
|
|
|
179
179
|
var json_1 = require('../utils/json');
|
|
180
180
|
var number_1 = require('../utils/number');
|
|
181
181
|
var stark_1 = require('../utils/stark');
|
|
182
|
+
var errors_1 = require('./errors');
|
|
182
183
|
var interface_1 = require('./interface');
|
|
183
184
|
var utils_1 = require('./utils');
|
|
184
185
|
function wait(delay) {
|
|
@@ -333,13 +334,19 @@ var Provider = /** @class */ (function () {
|
|
|
333
334
|
case 3:
|
|
334
335
|
textResponse = _c.sent();
|
|
335
336
|
if (!res.ok) {
|
|
336
|
-
responseBody =
|
|
337
|
+
responseBody = void 0;
|
|
338
|
+
try {
|
|
339
|
+
responseBody = (0, json_1.parse)(textResponse);
|
|
340
|
+
} catch (_d) {
|
|
341
|
+
// if error parsing fails, return an http error
|
|
342
|
+
throw new errors_1.HttpError(res.statusText, res.status);
|
|
343
|
+
}
|
|
337
344
|
errorCode =
|
|
338
345
|
responseBody.code ||
|
|
339
346
|
(responseBody === null || responseBody === void 0
|
|
340
347
|
? void 0
|
|
341
348
|
: responseBody.status_code);
|
|
342
|
-
throw new
|
|
349
|
+
throw new errors_1.GatewayError(responseBody.message, errorCode); // Caught locally, and re-thrown for the user
|
|
343
350
|
}
|
|
344
351
|
if (endpoint === 'estimate_fee') {
|
|
345
352
|
return [
|
|
@@ -355,7 +362,8 @@ var Provider = /** @class */ (function () {
|
|
|
355
362
|
return [2 /*return*/, (0, json_1.parse)(textResponse)];
|
|
356
363
|
case 4:
|
|
357
364
|
err_1 = _c.sent();
|
|
358
|
-
|
|
365
|
+
// rethrow custom errors
|
|
366
|
+
if (err_1 instanceof errors_1.GatewayError || err_1 instanceof errors_1.HttpError) {
|
|
359
367
|
throw err_1;
|
|
360
368
|
}
|
|
361
369
|
if (err_1 instanceof Error) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CustomError } from 'ts-custom-error';
|
|
2
|
+
export declare class GatewayError extends CustomError {
|
|
3
|
+
errorCode: string;
|
|
4
|
+
constructor(message: string, errorCode: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class HttpError extends CustomError {
|
|
7
|
+
errorCode: number;
|
|
8
|
+
constructor(message: string, errorCode: number);
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __extends =
|
|
3
|
+
(this && this.__extends) ||
|
|
4
|
+
(function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics =
|
|
7
|
+
Object.setPrototypeOf ||
|
|
8
|
+
({ __proto__: [] } instanceof Array &&
|
|
9
|
+
function (d, b) {
|
|
10
|
+
d.__proto__ = b;
|
|
11
|
+
}) ||
|
|
12
|
+
function (d, b) {
|
|
13
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
14
|
+
};
|
|
15
|
+
return extendStatics(d, b);
|
|
16
|
+
};
|
|
17
|
+
return function (d, b) {
|
|
18
|
+
if (typeof b !== 'function' && b !== null)
|
|
19
|
+
throw new TypeError('Class extends value ' + String(b) + ' is not a constructor or null');
|
|
20
|
+
extendStatics(d, b);
|
|
21
|
+
function __() {
|
|
22
|
+
this.constructor = d;
|
|
23
|
+
}
|
|
24
|
+
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
28
|
+
exports.HttpError = exports.GatewayError = void 0;
|
|
29
|
+
/* eslint-disable max-classes-per-file */
|
|
30
|
+
var ts_custom_error_1 = require('ts-custom-error');
|
|
31
|
+
var GatewayError = /** @class */ (function (_super) {
|
|
32
|
+
__extends(GatewayError, _super);
|
|
33
|
+
function GatewayError(message, errorCode) {
|
|
34
|
+
var _this = _super.call(this, message) || this;
|
|
35
|
+
_this.errorCode = errorCode;
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
return GatewayError;
|
|
39
|
+
})(ts_custom_error_1.CustomError);
|
|
40
|
+
exports.GatewayError = GatewayError;
|
|
41
|
+
var HttpError = /** @class */ (function (_super) {
|
|
42
|
+
__extends(HttpError, _super);
|
|
43
|
+
function HttpError(message, errorCode) {
|
|
44
|
+
var _this = _super.call(this, message) || this;
|
|
45
|
+
_this.errorCode = errorCode;
|
|
46
|
+
return _this;
|
|
47
|
+
}
|
|
48
|
+
return HttpError;
|
|
49
|
+
})(ts_custom_error_1.CustomError);
|
|
50
|
+
exports.HttpError = HttpError;
|
package/provider/index.d.ts
CHANGED
package/provider/index.js
CHANGED
|
@@ -27,15 +27,9 @@ var __exportStar =
|
|
|
27
27
|
__createBinding(exports, m, p);
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
30
|
-
exports.defaultProvider =
|
|
30
|
+
exports.defaultProvider = void 0;
|
|
31
31
|
var default_1 = require('./default');
|
|
32
32
|
__exportStar(require('./default'), exports);
|
|
33
|
-
|
|
34
|
-
Object.defineProperty(exports, 'GatewayError', {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () {
|
|
37
|
-
return utils_1.GatewayError;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
33
|
+
__exportStar(require('./errors'), exports);
|
|
40
34
|
__exportStar(require('./interface'), exports);
|
|
41
35
|
exports.defaultProvider = new default_1.Provider();
|
package/provider/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CustomError } from 'ts-custom-error';
|
|
2
|
-
|
|
3
1
|
import type { BlockNumber } from '../types';
|
|
4
2
|
import { BigNumberish } from '../utils/number';
|
|
5
3
|
/**
|
|
@@ -43,8 +41,4 @@ export declare function getBlockIdentifier(blockIdentifier: BlockIdentifier): Bl
|
|
|
43
41
|
* @returns block identifier for API request
|
|
44
42
|
*/
|
|
45
43
|
export declare function getFormattedBlockIdentifier(blockIdentifier?: BlockIdentifier): string;
|
|
46
|
-
export declare class GatewayError extends CustomError {
|
|
47
|
-
errorCode: string;
|
|
48
|
-
constructor(message: string, errorCode: string);
|
|
49
|
-
}
|
|
50
44
|
export {};
|
package/provider/utils.js
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
var __extends =
|
|
3
|
-
(this && this.__extends) ||
|
|
4
|
-
(function () {
|
|
5
|
-
var extendStatics = function (d, b) {
|
|
6
|
-
extendStatics =
|
|
7
|
-
Object.setPrototypeOf ||
|
|
8
|
-
({ __proto__: [] } instanceof Array &&
|
|
9
|
-
function (d, b) {
|
|
10
|
-
d.__proto__ = b;
|
|
11
|
-
}) ||
|
|
12
|
-
function (d, b) {
|
|
13
|
-
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
14
|
-
};
|
|
15
|
-
return extendStatics(d, b);
|
|
16
|
-
};
|
|
17
|
-
return function (d, b) {
|
|
18
|
-
if (typeof b !== 'function' && b !== null)
|
|
19
|
-
throw new TypeError('Class extends value ' + String(b) + ' is not a constructor or null');
|
|
20
|
-
extendStatics(d, b);
|
|
21
|
-
function __() {
|
|
22
|
-
this.constructor = d;
|
|
23
|
-
}
|
|
24
|
-
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
25
|
-
};
|
|
26
|
-
})();
|
|
27
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
exports.getFormattedBlockIdentifier =
|
|
3
|
+
exports.getFormattedBlockIdentifier =
|
|
30
4
|
exports.getBlockIdentifier =
|
|
31
5
|
exports.txIdentifier =
|
|
32
6
|
exports.formatHash =
|
|
33
7
|
void 0;
|
|
34
|
-
var ts_custom_error_1 = require('ts-custom-error');
|
|
35
8
|
var number_1 = require('../utils/number');
|
|
36
9
|
/**
|
|
37
10
|
*
|
|
@@ -109,13 +82,3 @@ function getFormattedBlockIdentifier(blockIdentifier) {
|
|
|
109
82
|
return 'blockHash='.concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
|
|
110
83
|
}
|
|
111
84
|
exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
|
|
112
|
-
var GatewayError = /** @class */ (function (_super) {
|
|
113
|
-
__extends(GatewayError, _super);
|
|
114
|
-
function GatewayError(message, errorCode) {
|
|
115
|
-
var _this = _super.call(this, message) || this;
|
|
116
|
-
_this.errorCode = errorCode;
|
|
117
|
-
return _this;
|
|
118
|
-
}
|
|
119
|
-
return GatewayError;
|
|
120
|
-
})(ts_custom_error_1.CustomError);
|
|
121
|
-
exports.GatewayError = GatewayError;
|
package/src/provider/default.ts
CHANGED
|
@@ -23,8 +23,9 @@ import { getSelectorFromName } from '../utils/hash';
|
|
|
23
23
|
import { parse, parseAlwaysAsBig, stringify } from '../utils/json';
|
|
24
24
|
import { BigNumberish, bigNumberishArrayToDecimalStringArray, toBN, toHex } from '../utils/number';
|
|
25
25
|
import { compressProgram, randomAddress } from '../utils/stark';
|
|
26
|
+
import { GatewayError, HttpError } from './errors';
|
|
26
27
|
import { ProviderInterface } from './interface';
|
|
27
|
-
import { BlockIdentifier,
|
|
28
|
+
import { BlockIdentifier, getFormattedBlockIdentifier } from './utils';
|
|
28
29
|
|
|
29
30
|
type NetworkName = 'mainnet-alpha' | 'goerli-alpha';
|
|
30
31
|
|
|
@@ -162,7 +163,13 @@ export class Provider implements ProviderInterface {
|
|
|
162
163
|
const textResponse = await res.text();
|
|
163
164
|
if (!res.ok) {
|
|
164
165
|
// This will allow user to handle contract errors
|
|
165
|
-
|
|
166
|
+
let responseBody: any;
|
|
167
|
+
try {
|
|
168
|
+
responseBody = parse(textResponse);
|
|
169
|
+
} catch {
|
|
170
|
+
// if error parsing fails, return an http error
|
|
171
|
+
throw new HttpError(res.statusText, res.status);
|
|
172
|
+
}
|
|
166
173
|
|
|
167
174
|
const errorCode = responseBody.code || ((responseBody as any)?.status_code as string); // starknet-devnet uses status_code instead of code; They need to fix that
|
|
168
175
|
throw new GatewayError(responseBody.message, errorCode); // Caught locally, and re-thrown for the user
|
|
@@ -178,7 +185,8 @@ export class Provider implements ProviderInterface {
|
|
|
178
185
|
}
|
|
179
186
|
return parse(textResponse) as Endpoints[T]['RESPONSE'];
|
|
180
187
|
} catch (err) {
|
|
181
|
-
|
|
188
|
+
// rethrow custom errors
|
|
189
|
+
if (err instanceof GatewayError || err instanceof HttpError) {
|
|
182
190
|
throw err;
|
|
183
191
|
}
|
|
184
192
|
if (err instanceof Error) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { CustomError } from 'ts-custom-error';
|
|
3
|
+
|
|
4
|
+
export class GatewayError extends CustomError {
|
|
5
|
+
constructor(message: string, public errorCode: string) {
|
|
6
|
+
super(message);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class HttpError extends CustomError {
|
|
11
|
+
constructor(message: string, public errorCode: number) {
|
|
12
|
+
super(message);
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/provider/index.ts
CHANGED
package/src/provider/utils.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CustomError } from 'ts-custom-error';
|
|
2
|
-
|
|
3
1
|
import type { BlockNumber } from '../types';
|
|
4
2
|
import { BigNumberish, toBN, toHex } from '../utils/number';
|
|
5
3
|
|
|
@@ -84,9 +82,3 @@ export function getFormattedBlockIdentifier(blockIdentifier: BlockIdentifier = n
|
|
|
84
82
|
}
|
|
85
83
|
return `blockHash=${toHex(toBN(blockIdentifierObject.data))}`;
|
|
86
84
|
}
|
|
87
|
-
|
|
88
|
-
export class GatewayError extends CustomError {
|
|
89
|
-
constructor(message: string, public errorCode: string) {
|
|
90
|
-
super(message);
|
|
91
|
-
}
|
|
92
|
-
}
|