@ercworldio/blockchain-shared 1.0.1-dev.9 → 1.0.2-dev.1

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.
Files changed (48) hide show
  1. package/README.md +26 -0
  2. package/build/chains/networks_dev.json +50 -8
  3. package/build/chains/networks_prod-bu.json +98 -7
  4. package/build/chains/networks_prod-dz.json +194 -12
  5. package/build/chains/networks_stg-bu.json +14 -7
  6. package/build/chains/networks_stg-dz.json +60 -20
  7. package/build/errors/AdminErrors.d.ts +5 -9
  8. package/build/errors/AdminErrors.d.ts.map +1 -1
  9. package/build/errors/AdminErrors.js +49 -24
  10. package/build/errors/AlchemyErrors.d.ts +14 -18
  11. package/build/errors/AlchemyErrors.d.ts.map +1 -1
  12. package/build/errors/AlchemyErrors.js +76 -49
  13. package/build/errors/BalanceErrors.d.ts +3 -7
  14. package/build/errors/BalanceErrors.d.ts.map +1 -1
  15. package/build/errors/BalanceErrors.js +47 -26
  16. package/build/errors/DatabaseErrors.d.ts +5 -9
  17. package/build/errors/DatabaseErrors.d.ts.map +1 -1
  18. package/build/errors/DatabaseErrors.js +49 -28
  19. package/build/errors/TransactionsErrors.d.ts +15 -20
  20. package/build/errors/TransactionsErrors.d.ts.map +1 -1
  21. package/build/errors/TransactionsErrors.js +81 -66
  22. package/build/errors/VoltageErrors.d.ts +8 -13
  23. package/build/errors/VoltageErrors.d.ts.map +1 -1
  24. package/build/errors/VoltageErrors.js +58 -45
  25. package/build/errors/WalletErrors.d.ts +6 -12
  26. package/build/errors/WalletErrors.d.ts.map +1 -1
  27. package/build/errors/WalletErrors.js +48 -37
  28. package/build/errors/errors.d.ts +137 -27
  29. package/build/errors/errors.d.ts.map +1 -1
  30. package/build/errors/errors.js +230 -66
  31. package/build/errors/index.d.ts +37 -36
  32. package/build/errors/index.d.ts.map +1 -1
  33. package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
  34. package/build/services/AlchemyWebhookAddressManager.js +3 -1
  35. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
  36. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
  37. package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
  38. package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
  39. package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
  40. package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
  41. package/build/services/types/chain_manager.d.ts +6 -0
  42. package/build/services/types/chain_manager.d.ts.map +1 -1
  43. package/build/utils/Logger.d.ts.map +1 -1
  44. package/build/utils/Logger.js +13 -2
  45. package/build/utils/solana.d.ts +2 -1
  46. package/build/utils/solana.d.ts.map +1 -1
  47. package/build/utils/solana.js +28 -3
  48. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import BaseErrors from "./errors";
1
+ import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
2
2
  interface ErrorHandlerResponse {
3
3
  status_code: number;
4
4
  response: ResponseObject;
@@ -7,17 +7,13 @@ interface ErrorHandlerResponse {
7
7
  interface ResponseObject {
8
8
  status: boolean;
9
9
  message: string;
10
+ error_code: ErrorCode | null;
10
11
  data: any;
11
12
  error: string;
12
13
  }
13
14
  declare class BalanceErrors extends BaseErrors {
14
- /** Error Definition */
15
- /** Handler methods */
16
15
  handle_balance_error: (error: any, source_method: string) => ErrorHandlerResponse;
17
- get_error_code: (message: string) => {
18
- code: number;
19
- error: string;
20
- };
16
+ get_error_code: (message: string) => ErrorCodeEntry;
21
17
  }
22
18
  export default BalanceErrors;
23
19
  //# sourceMappingURL=BalanceErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BalanceErrors.d.ts","sourceRoot":"","sources":["../../src/errors/BalanceErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,UAAU,CAAC;AAElC,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,aAAc,SAAQ,UAAU;IAClC,uBAAuB;IAEvB,sBAAsB;IAGf,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAYvC;CACJ;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"BalanceErrors.d.ts","sourceRoot":"","sources":["../../src/errors/BalanceErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAE,MAAM,UAAU,CAAC;AAE7E,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,aAAc,SAAQ,UAAU;IAC3B,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAQxD;CACJ;AAED,eAAe,aAAa,CAAC"}
@@ -1,44 +1,65 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const errors_1 = __importDefault(require("./errors"));
36
+ const errors_1 = __importStar(require("./errors"));
7
37
  class BalanceErrors extends errors_1.default {
8
38
  constructor() {
9
- /** Error Definition */
10
39
  super(...arguments);
11
- /** Handler methods */
12
- // Return status code, error, and message
13
40
  this.handle_balance_error = (error, source_method) => {
14
- let status = this.get_error_code(error.message);
15
- const result = {
41
+ const status = this.get_error_code(error.message);
42
+ return {
16
43
  status_code: status.code,
44
+ source_method,
17
45
  response: {
18
46
  status: false,
19
- message: status.code == 500 && !error.message ? "Unexpected error occured. Please try again later." : error.message,
47
+ message: status.code === 500 && !error.message ? "An unexpected error occurred. Please try again later." : error.message,
48
+ error_code: status.error_code,
20
49
  data: {},
21
50
  error: status.error
22
51
  }
23
52
  };
24
- return Object.assign(Object.assign({}, result), { source_method });
25
53
  };
26
- // Get the status code and error message
27
54
  this.get_error_code = (message) => {
28
- // Try base codes
29
- let response = this.get_error_code_base(message);
30
- if (response) {
31
- return response;
32
- }
33
- // Try custom class error codes
34
- if (message.includes("Server currently unavailable. Please try again later"))
35
- return this.codes[500];
36
- if (message.includes("Failed to get transactions count from db for chain"))
37
- return this.codes[500];
38
- return {
39
- code: 500,
40
- error: "Internal Server Error"
41
- };
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("Service is temporarily unavailable"))
59
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.SERVER_UNAVAILABLE });
60
+ if (message.includes("Failed to retrieve transaction count"))
61
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_GET_TRANSACTIONS });
62
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
42
63
  };
43
64
  }
44
65
  }
@@ -1,4 +1,4 @@
1
- import BaseErrors from "./errors";
1
+ import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
2
2
  interface ErrorHandlerResponse {
3
3
  status_code: number;
4
4
  response: ResponseObject;
@@ -7,19 +7,15 @@ interface ErrorHandlerResponse {
7
7
  interface ResponseObject {
8
8
  status: boolean;
9
9
  message: string;
10
+ error_code: ErrorCode | null;
10
11
  data: any;
11
12
  error: string;
12
13
  }
13
14
  declare class DatabaseErrors extends BaseErrors {
14
- /** Error Definition */
15
- ServerUnavailable(): string;
16
- FailedGetTransactions(chainId: string, address: string): string;
17
- /** Handler methods */
15
+ ServerUnavailable(_?: any): "Service is temporarily unavailable. Please try again later";
16
+ FailedGetTransactions(_?: any, __?: any): "Failed to retrieve transaction count. Please try again later";
18
17
  handle_database_error: (error: any, source_method: string) => ErrorHandlerResponse;
19
- get_error_code: (message: string) => {
20
- code: number;
21
- error: string;
22
- };
18
+ get_error_code: (message: string) => ErrorCodeEntry;
23
19
  }
24
20
  export default DatabaseErrors;
25
21
  //# sourceMappingURL=DatabaseErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseErrors.d.ts","sourceRoot":"","sources":["../../src/errors/DatabaseErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,UAAU,CAAC;AAElC,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,cAAe,SAAQ,UAAU;IACnC,uBAAuB;IAChB,iBAAiB;IACjB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAE7D,sBAAsB;IAGf,qBAAqB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAavF;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAYvC;CACJ;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"DatabaseErrors.d.ts","sourceRoot":"","sources":["../../src/errors/DatabaseErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAiB,MAAM,UAAU,CAAC;AAE5F,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,cAAe,SAAQ,UAAU;IAC5B,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,qBAAqB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG;IAEvC,qBAAqB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAavF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAQxD;CACJ;AAED,eAAe,cAAc,CAAC"}
@@ -1,49 +1,70 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const errors_1 = __importDefault(require("./errors"));
36
+ const errors_1 = __importStar(require("./errors"));
7
37
  class DatabaseErrors extends errors_1.default {
8
38
  constructor() {
9
39
  super(...arguments);
10
- /** Handler methods */
11
- // Return status code, error, and message
12
40
  this.handle_database_error = (error, source_method) => {
13
- let status = this.get_error_code(error.message);
14
- const result = {
41
+ const status = this.get_error_code(error.message);
42
+ return {
15
43
  status_code: status.code,
44
+ source_method,
16
45
  response: {
17
46
  status: false,
18
- message: status.code == 500 && !error.message ? "Unexpected error occured. Please try again later." : error.message,
47
+ message: status.code === 500 && !error.message ? "An unexpected error occurred. Please try again later." : error.message,
48
+ error_code: status.error_code,
19
49
  data: {},
20
50
  error: status.error
21
51
  }
22
52
  };
23
- return Object.assign(Object.assign({}, result), { source_method });
24
53
  };
25
- // Get the status code and error message
26
54
  this.get_error_code = (message) => {
27
- // Try base codes
28
- let response = this.get_error_code_base(message);
29
- if (response) {
30
- return response;
31
- }
32
- // Try custom class error codes
33
- if (message.includes("Server currently unavailable. Please try again later"))
34
- return this.codes[500];
35
- if (message.includes("Failed to get transactions count from db for chain"))
36
- return this.codes[500];
37
- return {
38
- code: 500,
39
- error: "Internal Server Error"
40
- };
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("Service is temporarily unavailable"))
59
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.SERVER_UNAVAILABLE });
60
+ if (message.includes("Failed to retrieve transaction count"))
61
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_GET_TRANSACTIONS });
62
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
41
63
  };
42
64
  }
43
- /** Error Definition */
44
- ServerUnavailable() { return `Server currently unavailable. Please try again later`; }
65
+ ServerUnavailable(_) { return errors_1.ErrorMessages.SERVER_UNAVAILABLE; }
45
66
  ;
46
- FailedGetTransactions(chainId, address) { return `Failed to get transactions count from db for chain ${chainId} and address ${address}`; }
67
+ FailedGetTransactions(_, __) { return errors_1.ErrorMessages.FAILED_GET_TRANSACTIONS; }
47
68
  ;
48
69
  }
49
70
  exports.default = DatabaseErrors;
@@ -1,5 +1,5 @@
1
1
  import { RequestStatus } from "../services/types/claim";
2
- import BaseErrors from "./errors";
2
+ import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
3
3
  interface ErrorHandlerResponse {
4
4
  status_code: number;
5
5
  response: ResponseObject;
@@ -8,30 +8,25 @@ interface ErrorHandlerResponse {
8
8
  interface ResponseObject {
9
9
  status: boolean;
10
10
  message: string;
11
+ error_code: ErrorCode | null;
11
12
  data: any;
12
13
  error: string;
13
14
  }
14
15
  declare class TransactionsErrors extends BaseErrors {
15
- /** Error Definition */
16
- AddressExists(): string;
17
- RequestNotApproved(status: RequestStatus): string;
18
- ReceiverRequired(): string;
19
- UnexpectedReceiver(): string;
20
- DuplicateClaimJob(request_id: number): string;
21
- InvalidAddress(): string;
22
- RequestFulfilled(): string;
23
- NotExistWithdrawRequest(): string;
24
- UnsupportedNetwork(suggested_networks: string): string;
25
- UnsupportedAddress(network: string): string;
26
- UnexpectedAddressFormat(current_network: string, expected_network: string): string;
27
- EmptyPayload(action: string): string;
28
- OnlyStablecoinWithdrawal(): string;
29
- /** Handler methods */
16
+ RequestNotApproved(_?: RequestStatus): "Withdrawal request has not been approved";
17
+ ReceiverRequired(_?: any): "Receiver address is missing. Please contact support";
18
+ UnexpectedReceiver(_?: any): "Please use the wallet address associated with your deposit";
19
+ DuplicateClaimJob(_?: any): "A claim for this request is already in progress. Please check back in a few minutes";
20
+ InvalidAddress(_?: any): "The wallet address provided is invalid";
21
+ RequestFulfilled(_?: any): "This request has already been fulfilled";
22
+ NotExistWithdrawRequest(_?: any): "Withdrawal request not found";
23
+ UnsupportedNetwork(_?: any): "The selected network is not supported";
24
+ UnsupportedAddress(_?: any, __?: any): "The address format is not compatible with the selected network";
25
+ UnexpectedAddressFormat(_?: any, __?: any): "The address does not match the expected format for the selected network";
26
+ EmptyPayload(_?: any): "Request payload cannot be empty";
27
+ OnlyStablecoinWithdrawal(_?: any): "This network only supports stablecoin withdrawals";
30
28
  handle_transactions_error: (error: any, source_method: string) => ErrorHandlerResponse;
31
- get_error_code: (message: string) => {
32
- code: number;
33
- error: string;
34
- };
29
+ get_error_code: (message: string) => ErrorCodeEntry;
35
30
  }
36
31
  export default TransactionsErrors;
37
32
  //# sourceMappingURL=TransactionsErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionsErrors.d.ts","sourceRoot":"","sources":["../../src/errors/TransactionsErrors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,UAAU,MAAM,UAAU,CAAC;AAElC,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,kBAAmB,SAAQ,UAAU;IACvC,uBAAuB;IAEhB,aAAa;IACb,kBAAkB,CAAC,MAAM,EAAE,aAAa;IAMxC,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB,CAAC,UAAU,EAAE,MAAM;IACpC,cAAc;IACd,gBAAgB;IAChB,uBAAuB;IACvB,kBAAkB,CAAC,kBAAkB,EAAE,MAAM;IAC7C,kBAAkB,CAAC,OAAO,EAAE,MAAM;IAClC,uBAAuB,CAAC,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IACzE,YAAY,CAAC,MAAM,EAAE,MAAM;IAC3B,wBAAwB;IAE/B,sBAAsB;IAGf,yBAAyB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAa3F;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAuBvC;CACJ;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"TransactionsErrors.d.ts","sourceRoot":"","sources":["../../src/errors/TransactionsErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAiB,MAAM,UAAU,CAAC;AAE5F,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,kBAAmB,SAAQ,UAAU;IAChC,kBAAkB,CAAC,CAAC,CAAC,EAAE,aAAa;IACpC,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC1B,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG;IACtB,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,uBAAuB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC/B,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC1B,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG;IACpC,uBAAuB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG;IACzC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG;IACpB,wBAAwB,CAAC,CAAC,CAAC,EAAE,GAAG;IAEhC,yBAAyB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAa3F;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAkBxD;CACJ;AAED,eAAe,kBAAkB,CAAC"}
@@ -1,95 +1,110 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const errors_1 = __importDefault(require("./errors"));
36
+ const errors_1 = __importStar(require("./errors"));
7
37
  class TransactionsErrors extends errors_1.default {
8
38
  constructor() {
9
- /** Error Definition */
10
39
  super(...arguments);
11
- /** Handler methods */
12
- // Return status code, error, and message
13
40
  this.handle_transactions_error = (error, source_method) => {
14
- let status = this.get_error_code(error.message);
15
- const result = {
41
+ const status = this.get_error_code(error.message);
42
+ return {
16
43
  status_code: status.code,
44
+ source_method,
17
45
  response: {
18
46
  status: false,
19
- message: status.code == 500 && !error.message ? "Unexpected error occured. Please try again later." : error.message,
47
+ message: status.code === 500 && !error.message ? "An unexpected error occurred. Please try again later." : error.message,
48
+ error_code: status.error_code,
20
49
  data: {},
21
50
  error: status.error
22
51
  }
23
52
  };
24
- return Object.assign(Object.assign({}, result), { source_method });
25
53
  };
26
- // Get the status code and error message
27
54
  this.get_error_code = (message) => {
28
- // Try base codes
29
- let response = this.get_error_code_base(message);
30
- if (response) {
31
- return response;
32
- }
33
- // Try custom class error codes
34
- if (message.includes("AlchemyActionError:"))
35
- return this.codes[500];
36
- if (message.includes("Withdraw request"))
37
- return this.codes[409];
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("Withdrawal request has not been approved"))
59
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.REQUEST_NOT_APPROVED });
38
60
  if (message.includes("Receiver address is missing"))
39
- return this.codes[400];
40
- if (message.includes("Claim request is already in progress. Check back in a few minutes."))
41
- return this.codes[409];
42
- if (message.includes("Please use the same wallet address you used to make your deposit"))
43
- return this.codes[400];
44
- if (message.includes("Invalid wallet address."))
45
- return this.codes[400];
46
- if (message.includes("Request is already fulfilled."))
47
- return this.codes[409];
48
- if (message.includes("Withdraw request does not exist"))
49
- return this.codes[400];
50
- if (message.includes('The entered address is invalid.'))
51
- return this.codes[400];
52
- if (message.includes('The address you provided looks like a'))
53
- return this.codes[400];
54
- if (message.includes(`Payload cannot be empty for`))
55
- return this.codes[500];
56
- if (message.includes(`This network only supports stablecoin withdrawal.`))
57
- return this.codes[400];
58
- return {
59
- code: 500,
60
- error: "Internal Server Error"
61
- };
61
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.RECEIVER_REQUIRED });
62
+ if (message.includes("wallet address associated with your deposit"))
63
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNEXPECTED_RECEIVER });
64
+ if (message.includes("claim for this request is already in progress"))
65
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.DUPLICATE_CLAIM_JOB });
66
+ if (message.includes("wallet address provided is invalid"))
67
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.INVALID_ADDRESS });
68
+ if (message.includes("already been fulfilled"))
69
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.REQUEST_FULFILLED });
70
+ if (message.includes("Withdrawal request not found"))
71
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.WITHDRAW_REQUEST_NOT_FOUND });
72
+ if (message.includes("selected network is not supported"))
73
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_NETWORK });
74
+ if (message.includes("address format is not compatible"))
75
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_ADDRESS });
76
+ if (message.includes("does not match the expected format"))
77
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ADDRESS_FORMAT });
78
+ if (message.includes("payload cannot be empty"))
79
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.EMPTY_PAYLOAD });
80
+ if (message.includes("only supports stablecoin withdrawals"))
81
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.ONLY_STABLECOIN_WITHDRAWAL });
82
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
62
83
  };
63
84
  }
64
- AddressExists() { return "Deposit address already exists for user id"; }
85
+ RequestNotApproved(_) { return errors_1.ErrorMessages.REQUEST_NOT_APPROVED; }
65
86
  ;
66
- RequestNotApproved(status) {
67
- if (status === "pending" || status === "declined" || status === "canceled")
68
- return `Withdraw request is ${status}`;
69
- else if (status === "successful" || status === "transferred")
70
- return "Withdraw request already fulfilled";
71
- else if (status === "hold")
72
- return "Withdraw request is on hold";
73
- return `Withdraw request is in "${status}" status`;
74
- }
75
- ReceiverRequired() { return "Receiver address is missing. Please contact support."; }
87
+ ReceiverRequired(_) { return errors_1.ErrorMessages.RECEIVER_REQUIRED; }
88
+ ;
89
+ UnexpectedReceiver(_) { return errors_1.ErrorMessages.UNEXPECTED_RECEIVER; }
90
+ ;
91
+ DuplicateClaimJob(_) { return errors_1.ErrorMessages.DUPLICATE_CLAIM_JOB; }
92
+ ;
93
+ InvalidAddress(_) { return errors_1.ErrorMessages.INVALID_WALLET_ADDRESS; }
76
94
  ;
77
- UnexpectedReceiver() { return `Please use the same wallet address you used to make your deposit. To continue using this address, use it to deposit funds to your account.`; }
95
+ RequestFulfilled(_) { return errors_1.ErrorMessages.REQUEST_FULFILLED; }
78
96
  ;
79
- DuplicateClaimJob(request_id) { return `Claim request is already in progress. Check back in a few minutes.`; }
97
+ NotExistWithdrawRequest(_) { return errors_1.ErrorMessages.WITHDRAW_REQUEST_NOT_FOUND; }
80
98
  ;
81
- InvalidAddress() { return `Invalid wallet address.`; }
99
+ UnsupportedNetwork(_) { return errors_1.ErrorMessages.UNSUPPORTED_NETWORK; }
82
100
  ;
83
- RequestFulfilled() { return `Request is already fulfilled.`; }
101
+ UnsupportedAddress(_, __) { return errors_1.ErrorMessages.UNSUPPORTED_ADDRESS; }
84
102
  ;
85
- NotExistWithdrawRequest() { return `Withdraw request does not exist`; }
103
+ UnexpectedAddressFormat(_, __) { return errors_1.ErrorMessages.UNEXPECTED_ADDRESS_FORMAT; }
86
104
  ;
87
- UnsupportedNetwork(suggested_networks) { return `Selected network is not supported. Please choose ${suggested_networks}`; }
105
+ EmptyPayload(_) { return errors_1.ErrorMessages.EMPTY_PAYLOAD; }
88
106
  ;
89
- UnsupportedAddress(network) { return `The entered address is invalid. Please enter a ${network} compatible address format or change the network to ${network}.`; }
90
- UnexpectedAddressFormat(current_network, expected_network) { return `The address you provided looks like a ${expected_network} address. Either enter a valid ${current_network} address, or change the network to ${expected_network}`; }
91
- EmptyPayload(action) { return `Payload cannot be empty for ${action}`; }
92
- OnlyStablecoinWithdrawal() { return `This network only supports stablecoin withdrawal.`; }
107
+ OnlyStablecoinWithdrawal(_) { return errors_1.ErrorMessages.ONLY_STABLECOIN_WITHDRAWAL; }
93
108
  ;
94
109
  }
95
110
  exports.default = TransactionsErrors;
@@ -1,4 +1,4 @@
1
- import BaseErrors from "./errors";
1
+ import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
2
2
  interface ErrorHandlerResponse {
3
3
  status_code: number;
4
4
  response: ResponseObject;
@@ -7,23 +7,18 @@ interface ErrorHandlerResponse {
7
7
  interface ResponseObject {
8
8
  status: boolean;
9
9
  message: string;
10
+ error_code: ErrorCode | null;
10
11
  data: any;
11
12
  error: string;
12
13
  }
13
14
  declare class VoltageErrors extends BaseErrors {
14
- /** Error Definition */
15
- NotApprovedPaymentRequest(): string;
16
- InvoiceSubscriberError(r_hash: string): string;
17
- RequireMinAmount(min_amount: number): string;
18
- PaymentIdNotFound(paymentId: string): string;
19
- AlreadyPaidInvoice(): string;
20
- PaymentFailed(reason: string): string;
21
- /** Handler methods */
15
+ InvoiceSubscriberError(_?: any): "Failed to subscribe to the invoice. Please try again";
16
+ RequireMinAmount(_?: any): "The amount is below the minimum required";
17
+ PaymentIdNotFound(_?: any): "Invoice not found or expired. Please request a new one";
18
+ AlreadyPaidInvoice(_?: any): "This invoice has already been paid";
19
+ PaymentFailed(_?: any): "Payment could not be processed. Please try again";
22
20
  handle_voltage_error: (error: any, source_method: string) => ErrorHandlerResponse;
23
- get_error_code: (message: string) => {
24
- code: number;
25
- error: string;
26
- };
21
+ get_error_code: (message: string) => ErrorCodeEntry;
27
22
  }
28
23
  export default VoltageErrors;
29
24
  //# sourceMappingURL=VoltageErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VoltageErrors.d.ts","sourceRoot":"","sources":["../../src/errors/VoltageErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,UAAU,CAAC;AAElC,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,aAAc,SAAQ,UAAU;IAClC,uBAAuB;IAChB,yBAAyB;IACzB,sBAAsB,CAAC,MAAM,EAAE,MAAM;IACrC,gBAAgB,CAAC,UAAU,EAAE,MAAM;IACnC,iBAAiB,CAAC,SAAS,EAAE,MAAM;IACnC,kBAAkB;IAClB,aAAa,CAAC,MAAM,EAAE,MAAM;IAEnC,sBAAsB;IAGf,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAsBvC;CACJ;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"VoltageErrors.d.ts","sourceRoot":"","sources":["../../src/errors/VoltageErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAiB,MAAM,UAAU,CAAC;AAE5F,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,aAAc,SAAQ,UAAU;IAC3B,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC9B,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC1B,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IAErB,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAWxD;CACJ;AAED,eAAe,aAAa,CAAC"}