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

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 (134) hide show
  1. package/README.md +26 -0
  2. package/build/chains/networks_dev.json +116 -25
  3. package/build/chains/networks_prod-bu.json +116 -8
  4. package/build/chains/networks_prod-dz.json +216 -13
  5. package/build/chains/networks_stg-bu.json +36 -9
  6. package/build/chains/networks_stg-dz.json +82 -22
  7. package/build/chains/networks_stg-sh.json +534 -0
  8. package/build/chains/networks_stg-yb.json +435 -0
  9. package/build/chains/stg-sh.json +93 -0
  10. package/build/contracts/Escrow.d.ts +1 -1
  11. package/build/contracts/Escrow.d.ts.map +1 -1
  12. package/build/contracts/Escrow.js +2 -2
  13. package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/IERC1363.d.ts +232 -0
  14. package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/IERC1363.d.ts.map +1 -0
  15. package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/IERC1363.js +2 -0
  16. package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/index.d.ts +1 -0
  17. package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/index.d.ts.map +1 -1
  18. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/index.d.ts +2 -0
  19. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/index.d.ts.map +1 -1
  20. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.d.ts +21 -0
  21. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.d.ts.map +1 -0
  22. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.js +2 -0
  23. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/index.d.ts +2 -0
  24. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/index.d.ts.map +1 -0
  25. package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/index.js +2 -0
  26. package/build/contracts/typechain-types/contracts/escrow/Escrow.d.ts +5 -3
  27. package/build/contracts/typechain-types/contracts/escrow/Escrow.d.ts.map +1 -1
  28. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1363__factory.d.ts +290 -0
  29. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1363__factory.d.ts.map +1 -0
  30. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1363__factory.js +390 -0
  31. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/index.d.ts +1 -0
  32. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/index.d.ts.map +1 -1
  33. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/index.js +3 -1
  34. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.d.ts +1 -0
  35. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.d.ts.map +1 -1
  36. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.js +2 -1
  37. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/SafeERC20__factory.d.ts +47 -0
  38. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/SafeERC20__factory.d.ts.map +1 -0
  39. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/SafeERC20__factory.js +71 -0
  40. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/index.d.ts +2 -0
  41. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/index.d.ts.map +1 -0
  42. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/index.js +8 -0
  43. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.d.ts +1 -1
  44. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.d.ts.map +1 -1
  45. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.js +1 -1
  46. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.d.ts +1 -1
  47. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.d.ts.map +1 -1
  48. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.js +1 -1
  49. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.d.ts +1 -1
  50. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.d.ts.map +1 -1
  51. package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.js +1 -1
  52. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.d.ts +1 -1
  53. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.d.ts.map +1 -1
  54. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.js +1 -1
  55. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowErrors__factory.d.ts +1 -1
  56. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowErrors__factory.d.ts.map +1 -1
  57. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowErrors__factory.js +1 -1
  58. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.d.ts +1 -1
  59. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.d.ts.map +1 -1
  60. package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.js +1 -1
  61. package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.d.ts +13 -1
  62. package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.d.ts.map +1 -1
  63. package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.js +17 -1
  64. package/build/contracts/typechain-types/factories/contracts/escrow/TokensWhitelist__factory.d.ts +1 -1
  65. package/build/contracts/typechain-types/factories/contracts/escrow/TokensWhitelist__factory.d.ts.map +1 -1
  66. package/build/contracts/typechain-types/factories/contracts/escrow/TokensWhitelist__factory.js +1 -1
  67. package/build/contracts/typechain-types/index.d.ts +4 -0
  68. package/build/contracts/typechain-types/index.d.ts.map +1 -1
  69. package/build/contracts/typechain-types/index.js +5 -1
  70. package/build/errors/AdminErrors.d.ts +5 -9
  71. package/build/errors/AdminErrors.d.ts.map +1 -1
  72. package/build/errors/AdminErrors.js +49 -24
  73. package/build/errors/AlchemyErrors.d.ts +14 -18
  74. package/build/errors/AlchemyErrors.d.ts.map +1 -1
  75. package/build/errors/AlchemyErrors.js +76 -49
  76. package/build/errors/BalanceErrors.d.ts +3 -7
  77. package/build/errors/BalanceErrors.d.ts.map +1 -1
  78. package/build/errors/BalanceErrors.js +47 -26
  79. package/build/errors/DatabaseErrors.d.ts +5 -9
  80. package/build/errors/DatabaseErrors.d.ts.map +1 -1
  81. package/build/errors/DatabaseErrors.js +49 -28
  82. package/build/errors/TransactionsErrors.d.ts +15 -20
  83. package/build/errors/TransactionsErrors.d.ts.map +1 -1
  84. package/build/errors/TransactionsErrors.js +81 -66
  85. package/build/errors/VoltageErrors.d.ts +8 -13
  86. package/build/errors/VoltageErrors.d.ts.map +1 -1
  87. package/build/errors/VoltageErrors.js +58 -45
  88. package/build/errors/WalletErrors.d.ts +6 -12
  89. package/build/errors/WalletErrors.d.ts.map +1 -1
  90. package/build/errors/WalletErrors.js +48 -37
  91. package/build/errors/errors.d.ts +169 -27
  92. package/build/errors/errors.d.ts.map +1 -1
  93. package/build/errors/errors.js +292 -66
  94. package/build/errors/index.d.ts +37 -36
  95. package/build/errors/index.d.ts.map +1 -1
  96. package/build/index.d.ts +1 -0
  97. package/build/index.d.ts.map +1 -1
  98. package/build/index.js +4 -2
  99. package/build/interfaces.d.ts +5 -1
  100. package/build/interfaces.d.ts.map +1 -1
  101. package/build/interfaces.js +1 -0
  102. package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
  103. package/build/services/AlchemyWebhookAddressManager.js +3 -1
  104. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
  105. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
  106. package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
  107. package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
  108. package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
  109. package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
  110. package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts +1 -1
  111. package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts.map +1 -1
  112. package/build/services/solana/escrow/SolanaEscrowAdmin.js +8 -4
  113. package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts.map +1 -1
  114. package/build/services/solana/escrow/services/EscrowAdminUtility.js +5 -2
  115. package/build/services/solana/escrow/services/SolanaTokenProgramCache.d.ts +9 -0
  116. package/build/services/solana/escrow/services/SolanaTokenProgramCache.d.ts.map +1 -0
  117. package/build/services/solana/escrow/services/SolanaTokenProgramCache.js +38 -0
  118. package/build/services/types/bo_withdrawal.d.ts +17 -0
  119. package/build/services/types/bo_withdrawal.d.ts.map +1 -0
  120. package/build/services/types/bo_withdrawal.js +9 -0
  121. package/build/services/types/chain_manager.d.ts +7 -0
  122. package/build/services/types/chain_manager.d.ts.map +1 -1
  123. package/build/services/types/index.d.ts +1 -0
  124. package/build/services/types/index.d.ts.map +1 -1
  125. package/build/services/types/index.js +1 -0
  126. package/build/utils/Logger.d.ts.map +1 -1
  127. package/build/utils/Logger.js +13 -2
  128. package/build/utils/RpcLimiter.d.ts +1 -0
  129. package/build/utils/RpcLimiter.d.ts.map +1 -1
  130. package/build/utils/RpcLimiter.js +1 -0
  131. package/build/utils/solana.d.ts +2 -1
  132. package/build/utils/solana.d.ts.map +1 -1
  133. package/build/utils/solana.js +28 -3
  134. package/package.json +1 -1
@@ -1,79 +1,106 @@
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 AlchemyErrors extends errors_1.default {
8
38
  constructor() {
9
- /** Error Definition */
10
- // public RequirePaymentId() { return "'paymentId' is required" };
11
39
  super(...arguments);
12
- /** Handler methods */
13
- // Return status code, error, and message
14
40
  this.handle_alchemy_error = (error, source_method) => {
15
- let status = this.get_error_code(error.message);
16
- const result = {
41
+ const status = this.get_error_code(error.message);
42
+ return {
17
43
  status_code: status.code,
44
+ source_method,
18
45
  response: {
19
46
  status: false,
20
- 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,
21
49
  data: {},
22
50
  error: status.error
23
51
  }
24
52
  };
25
- return Object.assign(Object.assign({}, result), { source_method });
26
53
  };
27
- // Get the status code and error message
28
54
  this.get_error_code = (message) => {
29
- // Try base codes
30
- let response = this.get_error_code_base(message);
31
- if (response) {
32
- return response;
33
- }
34
- // Try custom class error codes
35
- if (message.includes("User Id associated with payment ID"))
36
- return this.codes[400];
37
- if (message.includes("Failed to delete all webhooks"))
38
- return this.codes[500];
39
- if (message.includes("TypeORM database repository"))
40
- return this.codes[500];
41
- if (message.includes("No webhooks found in"))
42
- return this.codes[500];
43
- if (message.includes("Failed to get addresses for webhook id"))
44
- return this.codes[500];
45
- if (message.includes("AlchemyActionError:"))
46
- return this.codes[500];
47
- if (message.includes("Unsupported alchemy network for chain"))
48
- return this.codes[500];
49
- return {
50
- code: 500,
51
- error: "Internal Server Error"
52
- };
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("Failed to subscribe to the invoice"))
59
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.INVOICE_SUBSCRIBER_ERROR });
60
+ if (message.includes("amount is below the minimum required"))
61
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.REQUIRE_MIN_AMOUNT });
62
+ if (message.includes("Invoice not found or expired"))
63
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.PAYMENT_ID_NOT_FOUND });
64
+ if (message.includes("already been paid"))
65
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.ALREADY_PAID_INVOICE });
66
+ if (message.includes("Payment could not be processed"))
67
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.PAYMENT_FAILED });
68
+ if (message.includes("webhook operation failed"))
69
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_WEBHOOK_ACTION });
70
+ if (message.includes("database repository is not initialized"))
71
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.ORM_REPO_NOT_INITIALIZED });
72
+ if (message.includes("No webhooks found for this subscription"))
73
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.NO_WEBHOOKS });
74
+ if (message.includes("Failed to retrieve webhook addresses"))
75
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_GET_WEBHOOK_ADDRESSES });
76
+ if (message.includes("not supported by Alchemy"))
77
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_ALCHEMY_NETWORK });
78
+ if (message.includes("Failed to initialize webhooks"))
79
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.FAILED_INITIALIZE_WEBHOOKS });
80
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
53
81
  };
54
82
  }
55
- InvoiceSubscriberError(r_hash) { return `Failed to subscribe to invoice ${r_hash}`; }
83
+ InvoiceSubscriberError(_) { return errors_1.ErrorMessages.INVOICE_SUBSCRIBER_ERROR; }
56
84
  ;
57
- RequireMinAmount(min_amount) { return `Amount must be greater than ${min_amount} satoshis."`; }
85
+ RequireMinAmount(_) { return errors_1.ErrorMessages.REQUIRE_MIN_AMOUNT; }
58
86
  ;
59
- PaymentIdNotFound(paymentId) { return `User Id associated with payment ID ${paymentId} not found. Please request a new invoice.`; }
87
+ PaymentIdNotFound(_) { return errors_1.ErrorMessages.PAYMENT_ID_NOT_FOUND; }
60
88
  ;
61
- AlreadyPaidInvoice() { return "Invoice is already paid"; }
89
+ AlreadyPaidInvoice(_) { return errors_1.ErrorMessages.ALREADY_PAID_INVOICE; }
62
90
  ;
63
- PaymentFailed(reason) { return `Payment failed: ${reason}`; }
91
+ PaymentFailed(_) { return errors_1.ErrorMessages.PAYMENT_FAILED; }
64
92
  ;
65
- // public FailedWebhookDeleteAll(success_count: number, expected_success_count: number) { return `Failed to delete all webhooks. Deleted ${success_count} out of ${expected_success_count}` };
66
- FailedWebhookAction(action_type, success_count, expected_success_count) { return `AlchemyActionError: Failed to ${action_type}. Success count: ${success_count} out of ${expected_success_count}`; }
93
+ FailedWebhookAction(_, __, ___) { return errors_1.ErrorMessages.FAILED_WEBHOOK_ACTION; }
67
94
  ;
68
- NotInitializedOrmRepo(repo_name) { return `TypeORM database repository '${repo_name}' not initialized.`; }
95
+ NotInitializedOrmRepo(_) { return errors_1.ErrorMessages.ORM_REPO_NOT_INITIALIZED; }
69
96
  ;
70
- NoWebhooks(subscription) { return `No webhooks found in ${subscription} subscription.`; }
97
+ NoWebhooks(_) { return errors_1.ErrorMessages.NO_WEBHOOKS; }
71
98
  ;
72
- FailedGetWebhookAddresses(subscription, webhook_id) { return `Failed to get addresses for webhook id ${webhook_id} in ${subscription} subscription`; }
99
+ FailedGetWebhookAddresses(_, __) { return errors_1.ErrorMessages.FAILED_GET_WEBHOOK_ADDRESSES; }
73
100
  ;
74
- UnsupportedAlchemyNetwork(chainId) { return `Unsupported alchemy network for chain ${chainId}`; }
101
+ UnsupportedAlchemyNetwork(_) { return errors_1.ErrorMessages.UNSUPPORTED_ALCHEMY_NETWORK; }
75
102
  ;
76
- FailedInitializeWebhooks(subscription) { return `Failed to initialize webhooks on subscription ${subscription}`; }
103
+ FailedInitializeWebhooks(_) { return errors_1.ErrorMessages.FAILED_INITIALIZE_WEBHOOKS; }
77
104
  ;
78
105
  }
79
106
  exports.default = AlchemyErrors;
@@ -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"}