@ercworldio/blockchain-shared 1.0.2-dev.1 → 1.0.2-dev.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/build/errors/errors.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare const ErrorMessages: {
|
|
|
15
15
|
readonly INVALID_PAYMENT_TOKEN: "The payment token provided is not recognized";
|
|
16
16
|
readonly UNEXPECTED_PAYMENT_TOKEN: "The selected payment token is not supported on this network";
|
|
17
17
|
readonly NOT_FOUND: "The requested resource was not found";
|
|
18
|
-
readonly CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support";
|
|
19
18
|
readonly UNEXPECTED_ERROR: "An unexpected error occurred. Please try again later";
|
|
20
19
|
readonly DATABASE_NOT_INITIALIZED: "Database connection is not available";
|
|
21
20
|
readonly INVALID_USER_ID: "The provided user ID is invalid";
|
|
@@ -52,6 +51,14 @@ export declare const ErrorMessages: {
|
|
|
52
51
|
readonly UNEXPECTED_ADDRESS_FORMAT: "The address does not match the expected format for the selected network";
|
|
53
52
|
readonly EMPTY_PAYLOAD: "Request payload cannot be empty";
|
|
54
53
|
readonly ONLY_STABLECOIN_WITHDRAWAL: "This network only supports stablecoin withdrawals";
|
|
54
|
+
/** Chain Config Related */
|
|
55
|
+
readonly CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support";
|
|
56
|
+
readonly ALLOWED_RECEIVERS_CONFIG_NOT_SET: "Allowed receiver addresses not configured. Please contact support";
|
|
57
|
+
readonly ACCOUNTING_CONFIG_NOT_SET: "Accounting configuration is missing. Please contact support";
|
|
58
|
+
/** BO Admin Errors */
|
|
59
|
+
readonly ZERO_VALUE_TX: "Withdrawal amount cannot be zero";
|
|
60
|
+
readonly UNSUPPORTED_BLOCKCHAIN: "The selected blockchain is not supported";
|
|
61
|
+
readonly NOT_WHITELISTED: "The provided wallet address is not whitelisted";
|
|
55
62
|
};
|
|
56
63
|
export declare const ErrorCodes: {
|
|
57
64
|
readonly INTERNAL_SERVER: "error.internal_server_error";
|
|
@@ -66,7 +73,6 @@ export declare const ErrorCodes: {
|
|
|
66
73
|
readonly INVALID_PAYMENT_TOKEN: "error.invalid_payment_token";
|
|
67
74
|
readonly UNEXPECTED_PAYMENT_TOKEN: "error.unexpected_payment_token";
|
|
68
75
|
readonly NOT_FOUND: "error.not_found";
|
|
69
|
-
readonly CHAIN_CONFIG_NOT_SET: "error.chain_config_not_set";
|
|
70
76
|
readonly UNEXPECTED_ERROR: "error.unexpected_error";
|
|
71
77
|
readonly DATABASE_NOT_INITIALIZED: "error.database_not_initialized";
|
|
72
78
|
readonly INVALID_USER_ID: "error.invalid_user_id";
|
|
@@ -102,6 +108,12 @@ export declare const ErrorCodes: {
|
|
|
102
108
|
readonly UNEXPECTED_ADDRESS_FORMAT: "error.unexpected_address_format";
|
|
103
109
|
readonly EMPTY_PAYLOAD: "error.empty_payload";
|
|
104
110
|
readonly ONLY_STABLECOIN_WITHDRAWAL: "error.only_stablecoin_withdrawal";
|
|
111
|
+
readonly CHAIN_CONFIG_NOT_SET: "error.chain_config_not_set";
|
|
112
|
+
readonly ACCOUNTING_CONFIG_NOT_SET: "error.accounting_config_not_set";
|
|
113
|
+
readonly ALLOWED_RECEIVERS_CONFIG_NOT_SET: "error.allowed_receivers_config_not_set";
|
|
114
|
+
readonly ZERO_VALUE_TX: "error.zero_value_tx";
|
|
115
|
+
readonly UNSUPPORTED_BLOCKCHAIN: "error.unsupported_blockchain";
|
|
116
|
+
readonly NOT_WHITELISTED: "error.not_whitelisted_wallet_address";
|
|
105
117
|
};
|
|
106
118
|
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
107
119
|
export interface ErrorCodeEntry {
|
|
@@ -166,6 +178,8 @@ declare class BaseErrors {
|
|
|
166
178
|
UnexpectedPaymentToken(_?: any): "The selected payment token is not supported on this network";
|
|
167
179
|
NotFound(_?: any): "The requested resource was not found";
|
|
168
180
|
ChainConfigNotSet(_?: any): "Chain configuration is missing. Please contact support";
|
|
181
|
+
AccountingNotSet(): "Accounting configuration is missing. Please contact support";
|
|
182
|
+
AllowedReceiversNotSet(): "Allowed receiver addresses not configured. Please contact support";
|
|
169
183
|
UnexpectedError(_?: any): "An unexpected error occurred. Please try again later";
|
|
170
184
|
NotInitializedDatabase(_?: any): "Database connection is not available";
|
|
171
185
|
InvalidUserId(_?: any): "The provided user ID is invalid";
|
|
@@ -176,6 +190,9 @@ declare class BaseErrors {
|
|
|
176
190
|
NotApprovedPaymentRequest(_?: any): "Payment request has not been approved";
|
|
177
191
|
RequirePaymentId(_?: any): "Payment ID is required";
|
|
178
192
|
AddressExists(_?: any): "A deposit address already exists for this account";
|
|
193
|
+
UnsupportedBlockchainType(): "The selected blockchain is not supported";
|
|
194
|
+
ZeroValueTx(): "Withdrawal amount cannot be zero";
|
|
195
|
+
NotWhitelisted(): "The provided wallet address is not whitelisted";
|
|
179
196
|
/** Handler methods */
|
|
180
197
|
handle_error: (error: any, source_method: string) => ErrorHandlerResponse;
|
|
181
198
|
get_error_code_base: (message: string) => ErrorCodeEntry | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqFtB,2BAA2B;;;;IAK3B,sBAAsB;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEb,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CA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,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG;IACvB,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC5B,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC3B,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM;IAC/B,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG;IACjC,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,yBAAyB;IACzB,WAAW;IACX,cAAc;IAErB,sBAAsB;IACf,YAAY,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAuB9E;IAEM,mBAAmB,GAAI,SAAS,MAAM,KAAG,cAAc,GAAG,IAAI,CA8BpE;CACJ;AAED,eAAe,UAAU,CAAC"}
|
package/build/errors/errors.js
CHANGED
|
@@ -28,7 +28,6 @@ exports.ErrorMessages = {
|
|
|
28
28
|
UNEXPECTED_PAYMENT_TOKEN: "The selected payment token is not supported on this network",
|
|
29
29
|
// 400
|
|
30
30
|
NOT_FOUND: "The requested resource was not found",
|
|
31
|
-
CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support",
|
|
32
31
|
UNEXPECTED_ERROR: "An unexpected error occurred. Please try again later",
|
|
33
32
|
DATABASE_NOT_INITIALIZED: "Database connection is not available",
|
|
34
33
|
// 400
|
|
@@ -74,8 +73,7 @@ exports.ErrorMessages = {
|
|
|
74
73
|
// 400
|
|
75
74
|
UNEXPECTED_RECEIVER: "Please use the wallet address associated with your deposit",
|
|
76
75
|
// 409
|
|
77
|
-
DUPLICATE_CLAIM_JOB: "A claim for this request is already in progress. Please check back in a few minutes",
|
|
78
|
-
// 400
|
|
76
|
+
DUPLICATE_CLAIM_JOB: "A claim for this request is already in progress. Please check back in a few minutes", // 400
|
|
79
77
|
INVALID_WALLET_ADDRESS: "The wallet address provided is invalid",
|
|
80
78
|
// 409
|
|
81
79
|
REQUEST_FULFILLED: "This request has already been fulfilled",
|
|
@@ -91,6 +89,14 @@ exports.ErrorMessages = {
|
|
|
91
89
|
EMPTY_PAYLOAD: "Request payload cannot be empty",
|
|
92
90
|
// 400
|
|
93
91
|
ONLY_STABLECOIN_WITHDRAWAL: "This network only supports stablecoin withdrawals",
|
|
92
|
+
/** Chain Config Related */
|
|
93
|
+
CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support", // 500
|
|
94
|
+
ALLOWED_RECEIVERS_CONFIG_NOT_SET: "Allowed receiver addresses not configured. Please contact support", //500
|
|
95
|
+
ACCOUNTING_CONFIG_NOT_SET: "Accounting configuration is missing. Please contact support", //500
|
|
96
|
+
/** BO Admin Errors */
|
|
97
|
+
ZERO_VALUE_TX: `Withdrawal amount cannot be zero`, // 400
|
|
98
|
+
UNSUPPORTED_BLOCKCHAIN: `The selected blockchain is not supported`, // 400
|
|
99
|
+
NOT_WHITELISTED: `The provided wallet address is not whitelisted`, // 400
|
|
94
100
|
};
|
|
95
101
|
exports.ErrorCodes = {
|
|
96
102
|
INTERNAL_SERVER: 'error.internal_server_error',
|
|
@@ -105,7 +111,6 @@ exports.ErrorCodes = {
|
|
|
105
111
|
INVALID_PAYMENT_TOKEN: 'error.invalid_payment_token',
|
|
106
112
|
UNEXPECTED_PAYMENT_TOKEN: 'error.unexpected_payment_token',
|
|
107
113
|
NOT_FOUND: 'error.not_found',
|
|
108
|
-
CHAIN_CONFIG_NOT_SET: 'error.chain_config_not_set',
|
|
109
114
|
UNEXPECTED_ERROR: 'error.unexpected_error',
|
|
110
115
|
DATABASE_NOT_INITIALIZED: 'error.database_not_initialized',
|
|
111
116
|
INVALID_USER_ID: 'error.invalid_user_id',
|
|
@@ -146,6 +151,13 @@ exports.ErrorCodes = {
|
|
|
146
151
|
UNEXPECTED_ADDRESS_FORMAT: 'error.unexpected_address_format',
|
|
147
152
|
EMPTY_PAYLOAD: 'error.empty_payload',
|
|
148
153
|
ONLY_STABLECOIN_WITHDRAWAL: 'error.only_stablecoin_withdrawal',
|
|
154
|
+
// Chain/Network Config
|
|
155
|
+
CHAIN_CONFIG_NOT_SET: 'error.chain_config_not_set',
|
|
156
|
+
ACCOUNTING_CONFIG_NOT_SET: 'error.accounting_config_not_set',
|
|
157
|
+
ALLOWED_RECEIVERS_CONFIG_NOT_SET: 'error.allowed_receivers_config_not_set',
|
|
158
|
+
ZERO_VALUE_TX: `error.zero_value_tx`,
|
|
159
|
+
UNSUPPORTED_BLOCKCHAIN: `error.unsupported_blockchain`,
|
|
160
|
+
NOT_WHITELISTED: `error.not_whitelisted_wallet_address`
|
|
149
161
|
};
|
|
150
162
|
class BaseErrors {
|
|
151
163
|
constructor() {
|
|
@@ -229,6 +241,16 @@ class BaseErrors {
|
|
|
229
241
|
return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.PAYMENT_REQUEST_NOT_APPROVED });
|
|
230
242
|
if (message.includes("deposit address already exists"))
|
|
231
243
|
return Object.assign(Object.assign({}, this.codes[409]), { error_code: exports.ErrorCodes.ADDRESS_EXISTS });
|
|
244
|
+
if (message.includes(exports.ErrorMessages.ACCOUNTING_CONFIG_NOT_SET))
|
|
245
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.ACCOUNTING_CONFIG_NOT_SET });
|
|
246
|
+
if (message.includes(exports.ErrorMessages.ALLOWED_RECEIVERS_CONFIG_NOT_SET))
|
|
247
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.ALLOWED_RECEIVERS_CONFIG_NOT_SET });
|
|
248
|
+
if (message.includes(exports.ErrorMessages.NOT_WHITELISTED))
|
|
249
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.NOT_WHITELISTED });
|
|
250
|
+
if (message.includes(exports.ErrorMessages.UNSUPPORTED_BLOCKCHAIN))
|
|
251
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.UNSUPPORTED_BLOCKCHAIN });
|
|
252
|
+
if (message.includes(exports.ErrorMessages.ZERO_VALUE_TX))
|
|
253
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.ZERO_VALUE_TX });
|
|
232
254
|
return null;
|
|
233
255
|
};
|
|
234
256
|
}
|
|
@@ -257,6 +279,10 @@ class BaseErrors {
|
|
|
257
279
|
;
|
|
258
280
|
ChainConfigNotSet(_) { return exports.ErrorMessages.CHAIN_CONFIG_NOT_SET; }
|
|
259
281
|
;
|
|
282
|
+
AccountingNotSet() { return exports.ErrorMessages.ACCOUNTING_CONFIG_NOT_SET; }
|
|
283
|
+
;
|
|
284
|
+
AllowedReceiversNotSet() { return exports.ErrorMessages.ALLOWED_RECEIVERS_CONFIG_NOT_SET; }
|
|
285
|
+
;
|
|
260
286
|
UnexpectedError(_) { return exports.ErrorMessages.UNEXPECTED_ERROR; }
|
|
261
287
|
;
|
|
262
288
|
NotInitializedDatabase(_) { return exports.ErrorMessages.DATABASE_NOT_INITIALIZED; }
|
|
@@ -277,5 +303,11 @@ class BaseErrors {
|
|
|
277
303
|
;
|
|
278
304
|
AddressExists(_) { return exports.ErrorMessages.ADDRESS_EXISTS; }
|
|
279
305
|
;
|
|
306
|
+
UnsupportedBlockchainType() { return exports.ErrorMessages.UNSUPPORTED_BLOCKCHAIN; }
|
|
307
|
+
;
|
|
308
|
+
ZeroValueTx() { return exports.ErrorMessages.ZERO_VALUE_TX; }
|
|
309
|
+
;
|
|
310
|
+
NotWhitelisted() { return exports.ErrorMessages.NOT_WHITELISTED; }
|
|
311
|
+
;
|
|
280
312
|
}
|
|
281
313
|
exports.default = BaseErrors;
|