@ercworldio/blockchain-shared 1.0.1-dev.9 → 1.0.2-dev.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 (47) hide show
  1. package/build/chains/networks_dev.json +28 -7
  2. package/build/chains/networks_prod-bu.json +98 -7
  3. package/build/chains/networks_prod-dz.json +46 -12
  4. package/build/chains/networks_stg-bu.json +14 -7
  5. package/build/chains/networks_stg-dz.json +38 -20
  6. package/build/errors/AdminErrors.d.ts +5 -9
  7. package/build/errors/AdminErrors.d.ts.map +1 -1
  8. package/build/errors/AdminErrors.js +49 -24
  9. package/build/errors/AlchemyErrors.d.ts +14 -18
  10. package/build/errors/AlchemyErrors.d.ts.map +1 -1
  11. package/build/errors/AlchemyErrors.js +76 -49
  12. package/build/errors/BalanceErrors.d.ts +3 -7
  13. package/build/errors/BalanceErrors.d.ts.map +1 -1
  14. package/build/errors/BalanceErrors.js +47 -26
  15. package/build/errors/DatabaseErrors.d.ts +5 -9
  16. package/build/errors/DatabaseErrors.d.ts.map +1 -1
  17. package/build/errors/DatabaseErrors.js +49 -28
  18. package/build/errors/TransactionsErrors.d.ts +15 -20
  19. package/build/errors/TransactionsErrors.d.ts.map +1 -1
  20. package/build/errors/TransactionsErrors.js +81 -66
  21. package/build/errors/VoltageErrors.d.ts +8 -13
  22. package/build/errors/VoltageErrors.d.ts.map +1 -1
  23. package/build/errors/VoltageErrors.js +58 -45
  24. package/build/errors/WalletErrors.d.ts +6 -12
  25. package/build/errors/WalletErrors.d.ts.map +1 -1
  26. package/build/errors/WalletErrors.js +48 -37
  27. package/build/errors/errors.d.ts +137 -27
  28. package/build/errors/errors.d.ts.map +1 -1
  29. package/build/errors/errors.js +230 -66
  30. package/build/errors/index.d.ts +37 -36
  31. package/build/errors/index.d.ts.map +1 -1
  32. package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
  33. package/build/services/AlchemyWebhookAddressManager.js +3 -1
  34. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
  35. package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
  36. package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
  37. package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
  38. package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
  39. package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
  40. package/build/services/types/chain_manager.d.ts +5 -0
  41. package/build/services/types/chain_manager.d.ts.map +1 -1
  42. package/build/utils/Logger.d.ts.map +1 -1
  43. package/build/utils/Logger.js +13 -2
  44. package/build/utils/solana.d.ts +2 -1
  45. package/build/utils/solana.d.ts.map +1 -1
  46. package/build/utils/solana.js +28 -3
  47. package/package.json +1 -1
@@ -1,3 +1,114 @@
1
+ /**
2
+ * Centralized static error message strings.
3
+ * Keys mirror ErrorCodes — subclasses reference these instead of using inline string literals.
4
+ */
5
+ export declare const ErrorMessages: {
6
+ readonly INTERNAL_SERVER: "Internal Server Error";
7
+ readonly UNAUTHORIZED: "You are not authorized to perform this action";
8
+ readonly REQUIRE_PARAMETER: "A required parameter is missing";
9
+ readonly USER_NOT_FOUND: "User not found";
10
+ readonly INVALID_VALUE: "One or more values provided are invalid";
11
+ readonly INVALID_TOKEN_FORMAT: "Invalid authorization format. Expected: Bearer <token>";
12
+ readonly RENEW_NOT_ALLOWED: "Your deposit address is not yet eligible for renewal";
13
+ readonly VALIDATION_ERROR: "Request validation failed";
14
+ readonly UNSUPPORTED_RESOURCE: "The requested resource is not supported";
15
+ readonly INVALID_PAYMENT_TOKEN: "The payment token provided is not recognized";
16
+ readonly UNEXPECTED_PAYMENT_TOKEN: "The selected payment token is not supported on this network";
17
+ readonly NOT_FOUND: "The requested resource was not found";
18
+ readonly CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support";
19
+ readonly UNEXPECTED_ERROR: "An unexpected error occurred. Please try again later";
20
+ readonly DATABASE_NOT_INITIALIZED: "Database connection is not available";
21
+ readonly INVALID_USER_ID: "The provided user ID is invalid";
22
+ readonly NO_PAYMENT_TOKENS: "No payment tokens are configured for this network";
23
+ readonly SERVER_NOT_INITIALIZED: "Server is starting up. Please try again in a moment";
24
+ readonly SERVER_NOT_RESPONDING: "The server is not responding. Please try again later";
25
+ readonly INVALID_ADDRESS: "The provided address is invalid";
26
+ readonly PAYMENT_REQUEST_NOT_APPROVED: "Payment request has not been approved";
27
+ readonly REQUIRE_PAYMENT_ID: "Payment ID is required";
28
+ readonly ADDRESS_EXISTS: "A deposit address already exists for this account";
29
+ readonly UNSUPPORTED_ALCHEMY_NETWORK: "The blockchain network is not supported by Alchemy";
30
+ readonly FAILED_INITIALIZE_WEBHOOKS: "Failed to initialize webhooks. Please try again later";
31
+ readonly SERVER_UNAVAILABLE: "Service is temporarily unavailable. Please try again later";
32
+ readonly FAILED_GET_TRANSACTIONS: "Failed to retrieve transaction count. Please try again later";
33
+ readonly INVOICE_SUBSCRIBER_ERROR: "Failed to subscribe to the invoice. Please try again";
34
+ readonly REQUIRE_MIN_AMOUNT: "The amount is below the minimum required";
35
+ readonly PAYMENT_ID_NOT_FOUND: "Invoice not found or expired. Please request a new one";
36
+ readonly ALREADY_PAID_INVOICE: "This invoice has already been paid";
37
+ readonly PAYMENT_FAILED: "Payment could not be processed. Please try again";
38
+ readonly FAILED_WEBHOOK_ACTION: "A webhook operation failed. Please try again later";
39
+ readonly ORM_REPO_NOT_INITIALIZED: "A required database repository is not initialized";
40
+ readonly NO_WEBHOOKS: "No webhooks found for this subscription";
41
+ readonly FAILED_GET_WEBHOOK_ADDRESSES: "Failed to retrieve webhook addresses. Please try again later";
42
+ readonly PARENT_INDEX_IN_USE: "The selected wallet index is already in use";
43
+ readonly REQUEST_NOT_APPROVED: "Withdrawal request has not been approved";
44
+ readonly RECEIVER_REQUIRED: "Receiver address is missing. Please contact support";
45
+ readonly UNEXPECTED_RECEIVER: "Please use the wallet address associated with your deposit";
46
+ readonly DUPLICATE_CLAIM_JOB: "A claim for this request is already in progress. Please check back in a few minutes";
47
+ readonly INVALID_WALLET_ADDRESS: "The wallet address provided is invalid";
48
+ readonly REQUEST_FULFILLED: "This request has already been fulfilled";
49
+ readonly WITHDRAW_REQUEST_NOT_FOUND: "Withdrawal request not found";
50
+ readonly UNSUPPORTED_NETWORK: "The selected network is not supported";
51
+ readonly UNSUPPORTED_ADDRESS: "The address format is not compatible with the selected network";
52
+ readonly UNEXPECTED_ADDRESS_FORMAT: "The address does not match the expected format for the selected network";
53
+ readonly EMPTY_PAYLOAD: "Request payload cannot be empty";
54
+ readonly ONLY_STABLECOIN_WITHDRAWAL: "This network only supports stablecoin withdrawals";
55
+ };
56
+ export declare const ErrorCodes: {
57
+ readonly INTERNAL_SERVER: "error.internal_server_error";
58
+ readonly UNAUTHORIZED: "error.unauthorized";
59
+ readonly REQUIRE_PARAMETER: "error.require_parameter";
60
+ readonly USER_NOT_FOUND: "error.user_not_found";
61
+ readonly INVALID_VALUE: "error.invalid_value";
62
+ readonly INVALID_TOKEN_FORMAT: "error.invalid_token_format";
63
+ readonly RENEW_NOT_ALLOWED: "error.renew_not_allowed";
64
+ readonly VALIDATION_ERROR: "error.validation_error";
65
+ readonly UNSUPPORTED_RESOURCE: "error.unsupported_resource";
66
+ readonly INVALID_PAYMENT_TOKEN: "error.invalid_payment_token";
67
+ readonly UNEXPECTED_PAYMENT_TOKEN: "error.unexpected_payment_token";
68
+ readonly NOT_FOUND: "error.not_found";
69
+ readonly CHAIN_CONFIG_NOT_SET: "error.chain_config_not_set";
70
+ readonly UNEXPECTED_ERROR: "error.unexpected_error";
71
+ readonly DATABASE_NOT_INITIALIZED: "error.database_not_initialized";
72
+ readonly INVALID_USER_ID: "error.invalid_user_id";
73
+ readonly NO_PAYMENT_TOKENS: "error.no_payment_tokens";
74
+ readonly SERVER_NOT_INITIALIZED: "error.server_not_initialized";
75
+ readonly SERVER_NOT_RESPONDING: "error.server_not_responding";
76
+ readonly INVALID_ADDRESS: "error.invalid_address";
77
+ readonly PAYMENT_REQUEST_NOT_APPROVED: "error.payment_request_not_approved";
78
+ readonly REQUIRE_PAYMENT_ID: "error.require_payment_id";
79
+ readonly ADDRESS_EXISTS: "error.address_exists";
80
+ readonly UNSUPPORTED_ALCHEMY_NETWORK: "error.unsupported_alchemy_network";
81
+ readonly FAILED_INITIALIZE_WEBHOOKS: "error.failed_initialize_webhooks";
82
+ readonly SERVER_UNAVAILABLE: "error.server_unavailable";
83
+ readonly FAILED_GET_TRANSACTIONS: "error.failed_get_transactions";
84
+ readonly ORM_REPO_NOT_INITIALIZED: "error.orm_repo_not_initialized";
85
+ readonly INVOICE_SUBSCRIBER_ERROR: "error.invoice_subscriber_error";
86
+ readonly REQUIRE_MIN_AMOUNT: "error.require_min_amount";
87
+ readonly PAYMENT_ID_NOT_FOUND: "error.payment_id_not_found";
88
+ readonly ALREADY_PAID_INVOICE: "error.already_paid_invoice";
89
+ readonly PAYMENT_FAILED: "error.payment_failed";
90
+ readonly FAILED_WEBHOOK_ACTION: "error.failed_webhook_action";
91
+ readonly NO_WEBHOOKS: "error.no_webhooks";
92
+ readonly FAILED_GET_WEBHOOK_ADDRESSES: "error.failed_get_webhook_addresses";
93
+ readonly PARENT_INDEX_IN_USE: "error.parent_index_in_use";
94
+ readonly REQUEST_NOT_APPROVED: "error.request_not_approved";
95
+ readonly RECEIVER_REQUIRED: "error.receiver_required";
96
+ readonly UNEXPECTED_RECEIVER: "error.unexpected_receiver";
97
+ readonly DUPLICATE_CLAIM_JOB: "error.duplicate_claim_job";
98
+ readonly REQUEST_FULFILLED: "error.request_fulfilled";
99
+ readonly WITHDRAW_REQUEST_NOT_FOUND: "error.withdraw_request_not_found";
100
+ readonly UNSUPPORTED_NETWORK: "error.unsupported_network";
101
+ readonly UNSUPPORTED_ADDRESS: "error.unsupported_address";
102
+ readonly UNEXPECTED_ADDRESS_FORMAT: "error.unexpected_address_format";
103
+ readonly EMPTY_PAYLOAD: "error.empty_payload";
104
+ readonly ONLY_STABLECOIN_WITHDRAWAL: "error.only_stablecoin_withdrawal";
105
+ };
106
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
107
+ export interface ErrorCodeEntry {
108
+ code: number;
109
+ error: string;
110
+ error_code: ErrorCode;
111
+ }
1
112
  interface ErrorHandlerResponse {
2
113
  status_code: number;
3
114
  response: ResponseObject;
@@ -6,6 +117,8 @@ interface ErrorHandlerResponse {
6
117
  interface ResponseObject {
7
118
  status: boolean;
8
119
  message: string;
120
+ /** Static CMS translation key. Null for unrecognised/internal errors. */
121
+ error_code: ErrorCode | null;
9
122
  data: any;
10
123
  error: string;
11
124
  }
@@ -40,35 +153,32 @@ declare class BaseErrors {
40
153
  error: string;
41
154
  };
42
155
  };
43
- /** Error Definition */
44
- Unauthorized(): string;
45
- RequireParameter(key: string): string;
46
- NotFoundUser(): string;
47
- InvalidValue(name: string, context?: string): string;
48
- InvalidTokenFormat(): string;
49
- RenewNotAllowed(remaining_duration_s: number, remaining_threshold_s: number): string;
50
- ValidationError(validation_type: string): string;
51
- UnsupportedResource(target: string): string;
52
- InvalidPaymentToken(token: string): string;
53
- UnexpectedPaymentToken(): string;
54
- NotFound(resource_name: string): string;
55
- ChainConfigNotSet(): string;
56
- UnexpectedError(details?: string): string;
57
- NotInitializedDatabase(): string;
58
- InvalidUserId(id: string): string;
59
- NoPaymentTokens(): string;
60
- NotInitializedServer(): string;
61
- ServerNotResponding(): string;
62
- InvalidAddress(target: string): string;
63
- NotApprovedPaymentRequest(): string;
64
- RequirePaymentId(): string;
65
- AddressExists(): string;
156
+ /** Error definitions — unchanged, backward compatible */
157
+ Unauthorized(_?: any): "You are not authorized to perform this action";
158
+ RequireParameter(_?: any): "A required parameter is missing";
159
+ NotFoundUser(_?: any): "User not found";
160
+ InvalidValue(_?: any, __?: any): "One or more values provided are invalid";
161
+ InvalidTokenFormat(_?: any): "Invalid authorization format. Expected: Bearer <token>";
162
+ RenewNotAllowed(_?: any, __?: any): "Your deposit address is not yet eligible for renewal";
163
+ ValidationError(_?: any): "Request validation failed";
164
+ UnsupportedResource(_?: any): "The requested resource is not supported";
165
+ InvalidPaymentToken(_?: any): "The payment token provided is not recognized";
166
+ UnexpectedPaymentToken(_?: any): "The selected payment token is not supported on this network";
167
+ NotFound(_?: any): "The requested resource was not found";
168
+ ChainConfigNotSet(_?: any): "Chain configuration is missing. Please contact support";
169
+ UnexpectedError(_?: any): "An unexpected error occurred. Please try again later";
170
+ NotInitializedDatabase(_?: any): "Database connection is not available";
171
+ InvalidUserId(_?: any): "The provided user ID is invalid";
172
+ NoPaymentTokens(_?: any): "No payment tokens are configured for this network";
173
+ NotInitializedServer(_?: any): "Server is starting up. Please try again in a moment";
174
+ ServerNotResponding(_?: any): "The server is not responding. Please try again later";
175
+ InvalidAddress(_?: any): string;
176
+ NotApprovedPaymentRequest(_?: any): "Payment request has not been approved";
177
+ RequirePaymentId(_?: any): "Payment ID is required";
178
+ AddressExists(_?: any): "A deposit address already exists for this account";
66
179
  /** Handler methods */
67
180
  handle_error: (error: any, source_method: string) => ErrorHandlerResponse;
68
- get_error_code_base: (message: string) => {
69
- code: number;
70
- error: string;
71
- } | null;
181
+ get_error_code_base: (message: string) => ErrorCodeEntry | null;
72
182
  }
73
183
  export default BaseErrors;
74
184
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,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,UAAU;IACL,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQX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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;IAE5B,sBAAsB;IACf,YAAY,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAuB9E;IAEM,mBAAmB,GAAI,SAAS,MAAM,KAAG,cAAc,GAAG,IAAI,CAyBpE;CACJ;AAED,eAAe,UAAU,CAAC"}
@@ -1,5 +1,152 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorCodes = exports.ErrorMessages = void 0;
4
+ /**
5
+ * Centralized static error message strings.
6
+ * Keys mirror ErrorCodes — subclasses reference these instead of using inline string literals.
7
+ */
8
+ exports.ErrorMessages = {
9
+ // BaseErrors
10
+ INTERNAL_SERVER: "Internal Server Error",
11
+ UNAUTHORIZED: "You are not authorized to perform this action",
12
+ // 400
13
+ REQUIRE_PARAMETER: "A required parameter is missing",
14
+ USER_NOT_FOUND: "User not found",
15
+ // 400
16
+ INVALID_VALUE: "One or more values provided are invalid",
17
+ // 400
18
+ INVALID_TOKEN_FORMAT: "Invalid authorization format. Expected: Bearer <token>",
19
+ // 400
20
+ RENEW_NOT_ALLOWED: "Your deposit address is not yet eligible for renewal",
21
+ // 400
22
+ VALIDATION_ERROR: "Request validation failed",
23
+ // 400
24
+ UNSUPPORTED_RESOURCE: "The requested resource is not supported",
25
+ // 400
26
+ INVALID_PAYMENT_TOKEN: "The payment token provided is not recognized",
27
+ // 400
28
+ UNEXPECTED_PAYMENT_TOKEN: "The selected payment token is not supported on this network",
29
+ // 400
30
+ NOT_FOUND: "The requested resource was not found",
31
+ CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support",
32
+ UNEXPECTED_ERROR: "An unexpected error occurred. Please try again later",
33
+ DATABASE_NOT_INITIALIZED: "Database connection is not available",
34
+ // 400
35
+ INVALID_USER_ID: "The provided user ID is invalid",
36
+ NO_PAYMENT_TOKENS: "No payment tokens are configured for this network",
37
+ SERVER_NOT_INITIALIZED: "Server is starting up. Please try again in a moment",
38
+ // 400
39
+ SERVER_NOT_RESPONDING: "The server is not responding. Please try again later",
40
+ // 400
41
+ INVALID_ADDRESS: "The provided address is invalid",
42
+ PAYMENT_REQUEST_NOT_APPROVED: "Payment request has not been approved",
43
+ // 400
44
+ REQUIRE_PAYMENT_ID: "Payment ID is required",
45
+ // 409
46
+ ADDRESS_EXISTS: "A deposit address already exists for this account",
47
+ // Admin / webhook
48
+ UNSUPPORTED_ALCHEMY_NETWORK: "The blockchain network is not supported by Alchemy",
49
+ FAILED_INITIALIZE_WEBHOOKS: "Failed to initialize webhooks. Please try again later",
50
+ // Database
51
+ SERVER_UNAVAILABLE: "Service is temporarily unavailable. Please try again later",
52
+ FAILED_GET_TRANSACTIONS: "Failed to retrieve transaction count. Please try again later",
53
+ // Alchemy / Voltage shared
54
+ INVOICE_SUBSCRIBER_ERROR: "Failed to subscribe to the invoice. Please try again",
55
+ // 400
56
+ REQUIRE_MIN_AMOUNT: "The amount is below the minimum required",
57
+ // 400
58
+ PAYMENT_ID_NOT_FOUND: "Invoice not found or expired. Please request a new one",
59
+ // 409
60
+ ALREADY_PAID_INVOICE: "This invoice has already been paid",
61
+ PAYMENT_FAILED: "Payment could not be processed. Please try again",
62
+ FAILED_WEBHOOK_ACTION: "A webhook operation failed. Please try again later",
63
+ ORM_REPO_NOT_INITIALIZED: "A required database repository is not initialized",
64
+ NO_WEBHOOKS: "No webhooks found for this subscription",
65
+ FAILED_GET_WEBHOOK_ADDRESSES: "Failed to retrieve webhook addresses. Please try again later",
66
+ // Wallet
67
+ // 409
68
+ PARENT_INDEX_IN_USE: "The selected wallet index is already in use",
69
+ // Transactions
70
+ // 409
71
+ REQUEST_NOT_APPROVED: "Withdrawal request has not been approved",
72
+ // 400
73
+ RECEIVER_REQUIRED: "Receiver address is missing. Please contact support",
74
+ // 400
75
+ UNEXPECTED_RECEIVER: "Please use the wallet address associated with your deposit",
76
+ // 409
77
+ DUPLICATE_CLAIM_JOB: "A claim for this request is already in progress. Please check back in a few minutes",
78
+ // 400
79
+ INVALID_WALLET_ADDRESS: "The wallet address provided is invalid",
80
+ // 409
81
+ REQUEST_FULFILLED: "This request has already been fulfilled",
82
+ // 400
83
+ WITHDRAW_REQUEST_NOT_FOUND: "Withdrawal request not found",
84
+ // 400
85
+ UNSUPPORTED_NETWORK: "The selected network is not supported",
86
+ // 400
87
+ UNSUPPORTED_ADDRESS: "The address format is not compatible with the selected network",
88
+ // 400
89
+ UNEXPECTED_ADDRESS_FORMAT: "The address does not match the expected format for the selected network",
90
+ // 400
91
+ EMPTY_PAYLOAD: "Request payload cannot be empty",
92
+ // 400
93
+ ONLY_STABLECOIN_WITHDRAWAL: "This network only supports stablecoin withdrawals",
94
+ };
95
+ exports.ErrorCodes = {
96
+ INTERNAL_SERVER: 'error.internal_server_error',
97
+ UNAUTHORIZED: 'error.unauthorized',
98
+ REQUIRE_PARAMETER: 'error.require_parameter',
99
+ USER_NOT_FOUND: 'error.user_not_found',
100
+ INVALID_VALUE: 'error.invalid_value',
101
+ INVALID_TOKEN_FORMAT: 'error.invalid_token_format',
102
+ RENEW_NOT_ALLOWED: 'error.renew_not_allowed',
103
+ VALIDATION_ERROR: 'error.validation_error',
104
+ UNSUPPORTED_RESOURCE: 'error.unsupported_resource',
105
+ INVALID_PAYMENT_TOKEN: 'error.invalid_payment_token',
106
+ UNEXPECTED_PAYMENT_TOKEN: 'error.unexpected_payment_token',
107
+ NOT_FOUND: 'error.not_found',
108
+ CHAIN_CONFIG_NOT_SET: 'error.chain_config_not_set',
109
+ UNEXPECTED_ERROR: 'error.unexpected_error',
110
+ DATABASE_NOT_INITIALIZED: 'error.database_not_initialized',
111
+ INVALID_USER_ID: 'error.invalid_user_id',
112
+ NO_PAYMENT_TOKENS: 'error.no_payment_tokens',
113
+ SERVER_NOT_INITIALIZED: 'error.server_not_initialized',
114
+ SERVER_NOT_RESPONDING: 'error.server_not_responding',
115
+ INVALID_ADDRESS: 'error.invalid_address',
116
+ PAYMENT_REQUEST_NOT_APPROVED: 'error.payment_request_not_approved',
117
+ REQUIRE_PAYMENT_ID: 'error.require_payment_id',
118
+ ADDRESS_EXISTS: 'error.address_exists',
119
+ // Admin / webhook
120
+ UNSUPPORTED_ALCHEMY_NETWORK: 'error.unsupported_alchemy_network',
121
+ FAILED_INITIALIZE_WEBHOOKS: 'error.failed_initialize_webhooks',
122
+ // Database
123
+ SERVER_UNAVAILABLE: 'error.server_unavailable',
124
+ FAILED_GET_TRANSACTIONS: 'error.failed_get_transactions',
125
+ ORM_REPO_NOT_INITIALIZED: 'error.orm_repo_not_initialized',
126
+ // Alchemy / Voltage shared
127
+ INVOICE_SUBSCRIBER_ERROR: 'error.invoice_subscriber_error',
128
+ REQUIRE_MIN_AMOUNT: 'error.require_min_amount',
129
+ PAYMENT_ID_NOT_FOUND: 'error.payment_id_not_found',
130
+ ALREADY_PAID_INVOICE: 'error.already_paid_invoice',
131
+ PAYMENT_FAILED: 'error.payment_failed',
132
+ FAILED_WEBHOOK_ACTION: 'error.failed_webhook_action',
133
+ NO_WEBHOOKS: 'error.no_webhooks',
134
+ FAILED_GET_WEBHOOK_ADDRESSES: 'error.failed_get_webhook_addresses',
135
+ // Wallet
136
+ PARENT_INDEX_IN_USE: 'error.parent_index_in_use',
137
+ // Transactions
138
+ REQUEST_NOT_APPROVED: 'error.request_not_approved',
139
+ RECEIVER_REQUIRED: 'error.receiver_required',
140
+ UNEXPECTED_RECEIVER: 'error.unexpected_receiver',
141
+ DUPLICATE_CLAIM_JOB: 'error.duplicate_claim_job',
142
+ REQUEST_FULFILLED: 'error.request_fulfilled',
143
+ WITHDRAW_REQUEST_NOT_FOUND: 'error.withdraw_request_not_found',
144
+ UNSUPPORTED_NETWORK: 'error.unsupported_network',
145
+ UNSUPPORTED_ADDRESS: 'error.unsupported_address',
146
+ UNEXPECTED_ADDRESS_FORMAT: 'error.unexpected_address_format',
147
+ EMPTY_PAYLOAD: 'error.empty_payload',
148
+ ONLY_STABLECOIN_WITHDRAWAL: 'error.only_stablecoin_withdrawal',
149
+ };
3
150
  class BaseErrors {
4
151
  constructor() {
5
152
  this.codes = {
@@ -12,106 +159,123 @@ class BaseErrors {
12
159
  503: { code: 503, error: "Service Unavailable" }
13
160
  };
14
161
  /** Handler methods */
15
- // Return status code, error, and message
16
162
  this.handle_error = (error, source_method) => {
17
163
  const result = {
18
164
  status_code: 500,
165
+ source_method,
19
166
  response: {
20
167
  status: false,
21
168
  message: "Unexpected error occured. Please try again later.",
169
+ error_code: null,
22
170
  data: {},
23
171
  error: "Internal Server Error"
24
172
  }
25
173
  };
26
- let status = this.get_error_code_base(error.message);
174
+ const status = this.get_error_code_base(error.message);
27
175
  if (!status)
28
- return Object.assign(Object.assign({}, result), { source_method });
176
+ return result;
29
177
  result.status_code = status.code;
30
- result.response.message = status.code == 500 && !error.message ? "Unexpected error occured. Please try again later." : error.message;
178
+ result.response.message = status.code === 500 && !error.message
179
+ ? "Unexpected error occured. Please try again later."
180
+ : error.message;
31
181
  result.response.error = status.error;
32
- return Object.assign(Object.assign({}, result), { source_method });
182
+ result.response.error_code = status.error_code;
183
+ return result;
33
184
  };
34
- // Get the status code and error message
35
185
  this.get_error_code_base = (message) => {
36
- if (message.includes("is required"))
37
- return this.codes[400];
38
- if (message.includes("Unauthorized"))
39
- return this.codes[401];
40
- if (message.includes("User not found"))
41
- return this.codes[403];
186
+ if (message.includes("not authorized"))
187
+ return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.UNAUTHORIZED });
42
188
  if (message.includes("jwt expired"))
43
- return this.codes[401];
44
- if (message.includes("Token format is invalid. Use Bearer"))
45
- return this.codes[400];
46
- if (message.includes("You can only renew your deposit address when"))
47
- return this.codes[400];
48
- if (message.includes("Unsupported "))
49
- return this.codes[400];
50
- if (message.includes('Invalid payment token'))
51
- return this.codes[400];
52
- if (message.includes('not found'))
53
- return this.codes[400];
54
- if (message.includes('Payment tokens not found for specified network'))
55
- return this.codes[502];
56
- if (message.includes('The selected payment token is not supported by this network'))
57
- return this.codes[400];
58
- if (message.includes('Server bootstrapping in progress. Try again later.'))
59
- return this.codes[503];
60
- if (message.includes('server is not responding.'))
61
- return this.codes[400];
62
- if (message.includes('address is invalid'))
63
- return this.codes[400];
64
- if (message.includes("Invalid value for"))
65
- return this.codes[400];
66
- if (message.includes("Payment request not approved"))
67
- return this.codes[401];
68
- if (message.includes("'paymentId' is required"))
69
- return this.codes[400];
70
- if (message.includes("Deposit address already exists for user id"))
71
- return this.codes[409];
72
- if (message.includes("Chain configuration is not set"))
73
- return this.codes[500];
189
+ return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.UNAUTHORIZED });
190
+ if (message.includes("required parameter is missing"))
191
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.REQUIRE_PARAMETER });
192
+ if (message.includes("Payment ID is required"))
193
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.REQUIRE_PAYMENT_ID });
194
+ if (message.includes("User not found"))
195
+ return Object.assign(Object.assign({}, this.codes[403]), { error_code: exports.ErrorCodes.USER_NOT_FOUND });
196
+ if (message.includes("values provided are invalid"))
197
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_VALUE });
198
+ if (message.includes("Invalid authorization format"))
199
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_TOKEN_FORMAT });
200
+ if (message.includes("not yet eligible for renewal"))
201
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.RENEW_NOT_ALLOWED });
202
+ if (message.includes("Request validation failed"))
203
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.VALIDATION_ERROR });
204
+ if (message.includes("resource is not supported"))
205
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.UNSUPPORTED_RESOURCE });
206
+ if (message.includes("payment token provided is not recognized"))
207
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_PAYMENT_TOKEN });
208
+ if (message.includes("not supported on this network"))
209
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.UNEXPECTED_PAYMENT_TOKEN });
210
+ if (message.includes("resource was not found"))
211
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.NOT_FOUND });
212
+ if (message.includes("Chain configuration is missing"))
213
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.CHAIN_CONFIG_NOT_SET });
214
+ if (message.includes("unexpected error occurred"))
215
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.UNEXPECTED_ERROR });
216
+ if (message.includes("Database connection is not available"))
217
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.DATABASE_NOT_INITIALIZED });
218
+ if (message.includes("user ID is invalid"))
219
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_USER_ID });
220
+ if (message.includes("No payment tokens are configured"))
221
+ return Object.assign(Object.assign({}, this.codes[502]), { error_code: exports.ErrorCodes.NO_PAYMENT_TOKENS });
222
+ if (message.includes("Server is starting up"))
223
+ return Object.assign(Object.assign({}, this.codes[503]), { error_code: exports.ErrorCodes.SERVER_NOT_INITIALIZED });
224
+ if (message.includes("server is not responding"))
225
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.SERVER_NOT_RESPONDING });
226
+ if (message.includes("provided address is invalid"))
227
+ return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_ADDRESS });
228
+ if (message.includes("Payment request has not been approved"))
229
+ return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.PAYMENT_REQUEST_NOT_APPROVED });
230
+ if (message.includes("deposit address already exists"))
231
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: exports.ErrorCodes.ADDRESS_EXISTS });
74
232
  return null;
75
233
  };
76
234
  }
77
- /** Error Definition */
78
- Unauthorized() { return "Unauthorized"; }
235
+ /** Error definitions — unchanged, backward compatible */
236
+ Unauthorized(_) { return exports.ErrorMessages.UNAUTHORIZED; }
237
+ ;
238
+ RequireParameter(_) { return exports.ErrorMessages.REQUIRE_PARAMETER; }
239
+ ;
240
+ NotFoundUser(_) { return exports.ErrorMessages.USER_NOT_FOUND; }
241
+ ;
242
+ InvalidValue(_, __) { return exports.ErrorMessages.INVALID_VALUE; }
243
+ ;
244
+ InvalidTokenFormat(_) { return exports.ErrorMessages.INVALID_TOKEN_FORMAT; }
245
+ ;
246
+ RenewNotAllowed(_, __) { return exports.ErrorMessages.RENEW_NOT_ALLOWED; }
247
+ ;
248
+ ValidationError(_) { return exports.ErrorMessages.VALIDATION_ERROR; }
79
249
  ;
80
- RequireParameter(key) { return `${key} is required`; }
250
+ UnsupportedResource(_) { return exports.ErrorMessages.UNSUPPORTED_RESOURCE; }
81
251
  ;
82
- NotFoundUser() { return `User not found`; }
252
+ InvalidPaymentToken(_) { return exports.ErrorMessages.INVALID_PAYMENT_TOKEN; }
83
253
  ;
84
- InvalidValue(name, context) { return `Invalid value for ${name}${context ? `: ${context}` : ""}`; }
254
+ UnexpectedPaymentToken(_) { return exports.ErrorMessages.UNEXPECTED_PAYMENT_TOKEN; }
85
255
  ;
86
- InvalidTokenFormat() { return "Token format is invalid. Use Bearer {token}"; }
256
+ NotFound(_) { return exports.ErrorMessages.NOT_FOUND; }
87
257
  ;
88
- RenewNotAllowed(remaining_duration_s, remaining_threshold_s) { return `You can only renew your deposit address when it has less than ${remaining_threshold_s / 60} minutes remaining before expiry.`; }
89
- ValidationError(validation_type) { return `Failed while validating ${validation_type}`; }
258
+ ChainConfigNotSet(_) { return exports.ErrorMessages.CHAIN_CONFIG_NOT_SET; }
90
259
  ;
91
- UnsupportedResource(target) { return `Unsupported ${target}`; }
260
+ UnexpectedError(_) { return exports.ErrorMessages.UNEXPECTED_ERROR; }
92
261
  ;
93
- InvalidPaymentToken(token) { return `Invalid payment token ${token}`; }
262
+ NotInitializedDatabase(_) { return exports.ErrorMessages.DATABASE_NOT_INITIALIZED; }
94
263
  ;
95
- UnexpectedPaymentToken() { return `The selected payment token is not supported by this network.`; }
96
- NotFound(resource_name) { return `${resource_name} not found`; }
264
+ InvalidUserId(_) { return exports.ErrorMessages.INVALID_USER_ID; }
97
265
  ;
98
- ChainConfigNotSet() { return `Chain configuration is not set. Ensure the config file is created and exists in storage service.`; }
266
+ NoPaymentTokens(_) { return exports.ErrorMessages.NO_PAYMENT_TOKENS; }
99
267
  ;
100
- UnexpectedError(details) { return `Unexpected error occured${details ? ":" : "."} ${details ? details : ""}`; }
101
- NotInitializedDatabase() { return "Database driver is not initialized."; }
268
+ NotInitializedServer(_) { return exports.ErrorMessages.SERVER_NOT_INITIALIZED; }
102
269
  ;
103
- InvalidUserId(id) { return `Invalid user id: ${id}`; }
270
+ ServerNotResponding(_) { return exports.ErrorMessages.SERVER_NOT_RESPONDING; }
104
271
  ;
105
- NoPaymentTokens() { return `Payment tokens not found for specified network.`; }
272
+ InvalidAddress(_) { return exports.ErrorMessages.INVALID_ADDRESS; }
106
273
  ;
107
- NotInitializedServer() { return `Server bootstrapping in progress. Try again later.`; }
108
- ServerNotResponding() { return `The provided server is not responding. Please ensure the server is accepting HTTP requests.`; }
109
- InvalidAddress(target) { return `The provided ${target} address is invalid`; }
110
- NotApprovedPaymentRequest() { return "Payment request not approved"; }
274
+ NotApprovedPaymentRequest(_) { return exports.ErrorMessages.PAYMENT_REQUEST_NOT_APPROVED; }
111
275
  ;
112
- RequirePaymentId() { return "'paymentId' is required"; }
276
+ RequirePaymentId(_) { return exports.ErrorMessages.REQUIRE_PAYMENT_ID; }
113
277
  ;
114
- AddressExists() { return "Deposit address already exists for user id"; }
278
+ AddressExists(_) { return exports.ErrorMessages.ADDRESS_EXISTS; }
115
279
  ;
116
280
  }
117
281
  exports.default = BaseErrors;