@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,69 +1,82 @@
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 VoltageErrors 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_voltage_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 {
28
- // Try base errors
29
- const response = this.get_error_code_base(message);
30
- if (response) {
31
- return response;
32
- }
33
- // Try custom errors
34
- if (message.includes("User Id associated with payment ID"))
35
- return this.codes[400];
36
- if (message.includes("Payment request not approved"))
37
- return this.codes[401];
38
- if (message.includes("Invoice is already paid"))
39
- return this.codes[403];
40
- if (message.includes("`User Id associated with payment ID`"))
41
- return this.codes[400];
42
- if (message.includes("Amount must be greater than"))
43
- return this.codes[400];
44
- if (message.includes("Failed to subscribe to invoice"))
45
- return this.codes[500];
46
- }
47
- catch (error) {
48
- }
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
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
53
69
  };
54
70
  }
55
- /** Error Definition */
56
- NotApprovedPaymentRequest() { return "Payment request not approved"; }
57
- ;
58
- InvoiceSubscriberError(r_hash) { return `Failed to subscribe to invoice ${r_hash}`; }
71
+ InvoiceSubscriberError(_) { return errors_1.ErrorMessages.INVOICE_SUBSCRIBER_ERROR; }
59
72
  ;
60
- RequireMinAmount(min_amount) { return `Amount must be greater than ${min_amount} satoshis."`; }
73
+ RequireMinAmount(_) { return errors_1.ErrorMessages.REQUIRE_MIN_AMOUNT; }
61
74
  ;
62
- PaymentIdNotFound(paymentId) { return `Invoice not found or expired. Please request a new invoice.`; }
75
+ PaymentIdNotFound(_) { return errors_1.ErrorMessages.PAYMENT_ID_NOT_FOUND; }
63
76
  ;
64
- AlreadyPaidInvoice() { return "Invoice is already paid"; }
77
+ AlreadyPaidInvoice(_) { return errors_1.ErrorMessages.ALREADY_PAID_INVOICE; }
65
78
  ;
66
- PaymentFailed(reason) { return `Payment failed: ${reason}`; }
79
+ PaymentFailed(_) { return errors_1.ErrorMessages.PAYMENT_FAILED; }
67
80
  ;
68
81
  }
69
82
  exports.default = VoltageErrors;
@@ -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,20 +7,14 @@ 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
- declare class Errors extends BaseErrors {
14
- /** Error Definition */
15
- s(subscription: string): string;
16
- RenewNotAllowed(remaining_duration_s: number, remaining_threshold_s: number): string;
17
- NotAvailableParentIndex(index: number): string;
18
- /** Handler methods */
14
+ declare class WalletErrors extends BaseErrors {
15
+ NotAvailableParentIndex(_?: any): "The selected wallet index is already in use";
19
16
  handle_wallet_error: (error: any, source_method: string) => ErrorHandlerResponse;
20
- get_error_code: (message: string) => {
21
- code: number;
22
- error: string;
23
- };
17
+ get_error_code: (message: string) => ErrorCodeEntry;
24
18
  }
25
- export default Errors;
19
+ export default WalletErrors;
26
20
  //# sourceMappingURL=WalletErrors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WalletErrors.d.ts","sourceRoot":"","sources":["../../src/errors/WalletErrors.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,MAAO,SAAQ,UAAU;IAC3B,uBAAuB;IAEhB,CAAC,CAAC,YAAY,EAAE,MAAM;IACtB,eAAe,CAAC,oBAAoB,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM;IAC3E,uBAAuB,CAAC,KAAK,EAAE,MAAM;IAE5C,sBAAsB;IAGf,mBAAmB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAarF;IAGM,cAAc,GAAI,SAAS,MAAM;;;MAgBvC;CACJ;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"WalletErrors.d.ts","sourceRoot":"","sources":["../../src/errors/WalletErrors.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,YAAa,SAAQ,UAAU;IAC1B,uBAAuB,CAAC,CAAC,CAAC,EAAE,GAAG;IAE/B,mBAAmB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAarF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAOxD;CACJ;AAED,eAAe,YAAY,CAAC"}
@@ -1,55 +1,66 @@
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"));
7
- class Errors extends errors_1.default {
36
+ const errors_1 = __importStar(require("./errors"));
37
+ class WalletErrors 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_wallet_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("You can only renew your deposit address when"))
37
- return this.codes[400];
38
- if (message.includes("Parent index already in use"))
39
- return this.codes[409];
40
- if (message.includes("Deposit address already exists for user id"))
41
- return this.codes[409];
42
- if (message.includes("fk_deposit_addresses_user_id") && message.includes("violates"))
43
- return this.codes[500];
44
- return {
45
- code: 500,
46
- error: "Internal Server Error"
47
- };
55
+ const base = this.get_error_code_base(message);
56
+ if (base)
57
+ return base;
58
+ if (message.includes("wallet index is already in use"))
59
+ return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.PARENT_INDEX_IN_USE });
60
+ return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
48
61
  };
49
62
  }
50
- s(subscription) { return `Failed to initialize webhooks on subscription ${subscription}`; }
63
+ NotAvailableParentIndex(_) { return errors_1.ErrorMessages.PARENT_INDEX_IN_USE; }
51
64
  ;
52
- 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.`; }
53
- NotAvailableParentIndex(index) { return `Parent index already in use.`; }
54
65
  }
55
- exports.default = Errors;
66
+ exports.default = WalletErrors;
@@ -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;IAED,uBAAuB;IAChB,YAAY;IACZ,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAC5B,YAAY;IACZ,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAC3C,kBAAkB;IAClB,eAAe,CAAC,oBAAoB,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM;IAC3E,eAAe,CAAC,eAAe,EAAE,MAAM;IACvC,mBAAmB,CAAC,MAAM,EAAE,MAAM;IAClC,mBAAmB,CAAC,KAAK,EAAE,MAAM;IACjC,sBAAsB;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,iBAAiB;IACjB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM;IAChC,sBAAsB;IACtB,aAAa,CAAC,EAAE,EAAE,MAAM;IACxB,eAAe;IACf,oBAAoB;IACpB,mBAAmB;IACnB,cAAc,CAAC,MAAM,EAAE,MAAM;IAC7B,yBAAyB;IACzB,gBAAgB;IAChB,aAAa;IAEpB,sBAAsB;IAEf,YAAY,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAkB9E;IAGM,mBAAmB,GAAI,SAAS,MAAM;;;aAqB5C;CACJ;AAED,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AACA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