@ercworldio/blockchain-shared 1.0.1-dev.8 → 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.
- package/README.md +26 -0
- package/build/chains/networks_dev.json +116 -25
- package/build/chains/networks_prod-bu.json +116 -8
- package/build/chains/networks_prod-dz.json +216 -13
- package/build/chains/networks_stg-bu.json +36 -9
- package/build/chains/networks_stg-dz.json +82 -22
- package/build/chains/networks_stg-sh.json +534 -0
- package/build/chains/networks_stg-yb.json +435 -0
- package/build/chains/stg-sh.json +93 -0
- package/build/contracts/Escrow.d.ts +1 -1
- package/build/contracts/Escrow.d.ts.map +1 -1
- package/build/contracts/Escrow.js +2 -2
- package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/IERC1363.d.ts +232 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/IERC1363.d.ts.map +1 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/IERC1363.js +2 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/index.d.ts +1 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/interfaces/index.d.ts.map +1 -1
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/index.d.ts +2 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/index.d.ts.map +1 -1
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.d.ts +21 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.d.ts.map +1 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.js +2 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/index.d.ts +2 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/index.d.ts.map +1 -0
- package/build/contracts/typechain-types/@openzeppelin/contracts/token/ERC20/utils/index.js +2 -0
- package/build/contracts/typechain-types/contracts/escrow/Escrow.d.ts +5 -3
- package/build/contracts/typechain-types/contracts/escrow/Escrow.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1363__factory.d.ts +290 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1363__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC1363__factory.js +390 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/index.d.ts +1 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/index.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/interfaces/index.js +3 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.d.ts +1 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.js +2 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/SafeERC20__factory.d.ts +47 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/SafeERC20__factory.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/SafeERC20__factory.js +71 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/index.d.ts +2 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/index.d.ts.map +1 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/token/ERC20/utils/index.js +8 -0
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.js +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.js +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.js +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowAccessControl__factory.js +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowErrors__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowErrors__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowErrors__factory.js +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/EscrowSignature__factory.js +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.d.ts +13 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/Escrow__factory.js +17 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/TokensWhitelist__factory.d.ts +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/TokensWhitelist__factory.d.ts.map +1 -1
- package/build/contracts/typechain-types/factories/contracts/escrow/TokensWhitelist__factory.js +1 -1
- package/build/contracts/typechain-types/index.d.ts +4 -0
- package/build/contracts/typechain-types/index.d.ts.map +1 -1
- package/build/contracts/typechain-types/index.js +5 -1
- package/build/entities/DepositAddressArchive.js +1 -1
- package/build/errors/AdminErrors.d.ts +5 -9
- package/build/errors/AdminErrors.d.ts.map +1 -1
- package/build/errors/AdminErrors.js +49 -24
- package/build/errors/AlchemyErrors.d.ts +14 -18
- package/build/errors/AlchemyErrors.d.ts.map +1 -1
- package/build/errors/AlchemyErrors.js +76 -49
- package/build/errors/BalanceErrors.d.ts +3 -7
- package/build/errors/BalanceErrors.d.ts.map +1 -1
- package/build/errors/BalanceErrors.js +47 -26
- package/build/errors/DatabaseErrors.d.ts +5 -9
- package/build/errors/DatabaseErrors.d.ts.map +1 -1
- package/build/errors/DatabaseErrors.js +49 -28
- package/build/errors/TransactionsErrors.d.ts +15 -20
- package/build/errors/TransactionsErrors.d.ts.map +1 -1
- package/build/errors/TransactionsErrors.js +81 -66
- package/build/errors/VoltageErrors.d.ts +8 -13
- package/build/errors/VoltageErrors.d.ts.map +1 -1
- package/build/errors/VoltageErrors.js +58 -45
- package/build/errors/WalletErrors.d.ts +6 -12
- package/build/errors/WalletErrors.d.ts.map +1 -1
- package/build/errors/WalletErrors.js +48 -37
- package/build/errors/errors.d.ts +169 -27
- package/build/errors/errors.d.ts.map +1 -1
- package/build/errors/errors.js +292 -66
- package/build/errors/index.d.ts +37 -36
- package/build/errors/index.d.ts.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/interfaces.d.ts +5 -1
- package/build/interfaces.d.ts.map +1 -1
- package/build/interfaces.js +1 -0
- package/build/services/AlchemyWebhookAddressManager.d.ts.map +1 -1
- package/build/services/AlchemyWebhookAddressManager.js +3 -1
- package/build/services/BalanceService.js +1 -1
- package/build/services/DepositAddressArchiveService.js +2 -2
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts +1 -2
- package/build/services/quicknode-notifications/QnWebhookAddressManager.d.ts.map +1 -1
- package/build/services/quicknode-notifications/QnWebhookAddressManager.js +25 -42
- package/build/services/quicknode-notifications/SetupNotifications.d.ts +1 -0
- package/build/services/quicknode-notifications/SetupNotifications.d.ts.map +1 -1
- package/build/services/quicknode-notifications/SetupNotifications.js +29 -2
- package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts +1 -1
- package/build/services/solana/escrow/SolanaEscrowAdmin.d.ts.map +1 -1
- package/build/services/solana/escrow/SolanaEscrowAdmin.js +8 -4
- package/build/services/solana/escrow/services/EscrowAdminUtility.d.ts.map +1 -1
- package/build/services/solana/escrow/services/EscrowAdminUtility.js +5 -2
- package/build/services/solana/escrow/services/SolanaTokenProgramCache.d.ts +9 -0
- package/build/services/solana/escrow/services/SolanaTokenProgramCache.d.ts.map +1 -0
- package/build/services/solana/escrow/services/SolanaTokenProgramCache.js +38 -0
- package/build/services/types/bo_withdrawal.d.ts +17 -0
- package/build/services/types/bo_withdrawal.d.ts.map +1 -0
- package/build/services/types/bo_withdrawal.js +9 -0
- package/build/services/types/chain_manager.d.ts +7 -0
- package/build/services/types/chain_manager.d.ts.map +1 -1
- package/build/services/types/index.d.ts +1 -0
- package/build/services/types/index.d.ts.map +1 -1
- package/build/services/types/index.js +1 -0
- package/build/utils/Logger.d.ts.map +1 -1
- package/build/utils/Logger.js +13 -2
- package/build/utils/RpcLimiter.d.ts +1 -0
- package/build/utils/RpcLimiter.d.ts.map +1 -1
- package/build/utils/RpcLimiter.js +1 -0
- package/build/utils/solana.d.ts +2 -1
- package/build/utils/solana.d.ts.map +1 -1
- package/build/utils/solana.js +28 -3
- package/package.json +1 -1
package/build/errors/errors.d.ts
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
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 UNEXPECTED_ERROR: "An unexpected error occurred. Please try again later";
|
|
19
|
+
readonly DATABASE_NOT_INITIALIZED: "Database connection is not available";
|
|
20
|
+
readonly INVALID_USER_ID: "The provided user ID is invalid";
|
|
21
|
+
readonly NO_PAYMENT_TOKENS: "No payment tokens are configured for this network";
|
|
22
|
+
readonly SERVER_NOT_INITIALIZED: "Server is starting up. Please try again in a moment";
|
|
23
|
+
readonly SERVER_NOT_RESPONDING: "The server is not responding. Please try again later";
|
|
24
|
+
readonly INVALID_ADDRESS: "The provided address is invalid";
|
|
25
|
+
readonly PAYMENT_REQUEST_NOT_APPROVED: "Payment request has not been approved";
|
|
26
|
+
readonly REQUIRE_PAYMENT_ID: "Payment ID is required";
|
|
27
|
+
readonly ADDRESS_EXISTS: "A deposit address already exists for this account";
|
|
28
|
+
readonly UNSUPPORTED_ALCHEMY_NETWORK: "The blockchain network is not supported by Alchemy";
|
|
29
|
+
readonly FAILED_INITIALIZE_WEBHOOKS: "Failed to initialize webhooks. Please try again later";
|
|
30
|
+
readonly SERVER_UNAVAILABLE: "Service is temporarily unavailable. Please try again later";
|
|
31
|
+
readonly FAILED_GET_TRANSACTIONS: "Failed to retrieve transaction count. Please try again later";
|
|
32
|
+
readonly INVOICE_SUBSCRIBER_ERROR: "Failed to subscribe to the invoice. Please try again";
|
|
33
|
+
readonly REQUIRE_MIN_AMOUNT: "The amount is below the minimum required";
|
|
34
|
+
readonly PAYMENT_ID_NOT_FOUND: "Invoice not found or expired. Please request a new one";
|
|
35
|
+
readonly ALREADY_PAID_INVOICE: "This invoice has already been paid";
|
|
36
|
+
readonly PAYMENT_FAILED: "Payment could not be processed. Please try again";
|
|
37
|
+
readonly FAILED_WEBHOOK_ACTION: "A webhook operation failed. Please try again later";
|
|
38
|
+
readonly ORM_REPO_NOT_INITIALIZED: "A required database repository is not initialized";
|
|
39
|
+
readonly NO_WEBHOOKS: "No webhooks found for this subscription";
|
|
40
|
+
readonly FAILED_GET_WEBHOOK_ADDRESSES: "Failed to retrieve webhook addresses. Please try again later";
|
|
41
|
+
readonly PARENT_INDEX_IN_USE: "The selected wallet index is already in use";
|
|
42
|
+
readonly REQUEST_NOT_APPROVED: "Withdrawal request has not been approved";
|
|
43
|
+
readonly RECEIVER_REQUIRED: "Receiver address is missing. Please contact support";
|
|
44
|
+
readonly UNEXPECTED_RECEIVER: "Please use the wallet address associated with your deposit";
|
|
45
|
+
readonly DUPLICATE_CLAIM_JOB: "A claim for this request is already in progress. Please check back in a few minutes";
|
|
46
|
+
readonly INVALID_WALLET_ADDRESS: "The wallet address provided is invalid";
|
|
47
|
+
readonly REQUEST_FULFILLED: "This request has already been fulfilled";
|
|
48
|
+
readonly WITHDRAW_REQUEST_NOT_FOUND: "Withdrawal request not found";
|
|
49
|
+
readonly UNSUPPORTED_NETWORK: "The selected network is not supported";
|
|
50
|
+
readonly UNSUPPORTED_ADDRESS: "The address format is not compatible with the selected network";
|
|
51
|
+
readonly UNEXPECTED_ADDRESS_FORMAT: "The address does not match the expected format for the selected network";
|
|
52
|
+
readonly EMPTY_PAYLOAD: "Request payload cannot be empty";
|
|
53
|
+
readonly ONLY_STABLECOIN_WITHDRAWAL: "This network only supports stablecoin withdrawals";
|
|
54
|
+
/** Chain Config Related */
|
|
55
|
+
readonly CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support";
|
|
56
|
+
readonly ALLOWED_RECEIVERS_CONFIG_NOT_SET: "Allowed receiver addresses not configured. Please contact support";
|
|
57
|
+
readonly ACCOUNTING_CONFIG_NOT_SET: "Accounting configuration is missing. Please contact support";
|
|
58
|
+
/** BO Admin Errors */
|
|
59
|
+
readonly ZERO_VALUE_TX: "Withdrawal amount cannot be zero";
|
|
60
|
+
readonly UNSUPPORTED_BLOCKCHAIN: "The selected blockchain is not supported";
|
|
61
|
+
readonly NOT_WHITELISTED: "The provided wallet address is not whitelisted";
|
|
62
|
+
readonly INVALID_WALLET_TYPE: "WalletType is invalid. Use \"funding\", \"rent-energy\" or \"escrow\"";
|
|
63
|
+
readonly ONLY_NATIVE_WITHDRAWAL: "Only native tokens can be withdrawn";
|
|
64
|
+
readonly RENT_ENERGY_API_ERROR: "Encountered error when calling rent API";
|
|
65
|
+
readonly INSUFFICIENT_ENERGY_WALLET_BALANCE: "Rent energy wallet has insufficient balance";
|
|
66
|
+
readonly RENT_ENERGY_MIN_WITHDRAWAL_ERROR: "Minimum withdrawal of 50TRX required.";
|
|
67
|
+
};
|
|
68
|
+
export declare const ErrorCodes: {
|
|
69
|
+
readonly INTERNAL_SERVER: "error.internal_server_error";
|
|
70
|
+
readonly UNAUTHORIZED: "error.unauthorized";
|
|
71
|
+
readonly REQUIRE_PARAMETER: "error.require_parameter";
|
|
72
|
+
readonly USER_NOT_FOUND: "error.user_not_found";
|
|
73
|
+
readonly INVALID_VALUE: "error.invalid_value";
|
|
74
|
+
readonly INVALID_TOKEN_FORMAT: "error.invalid_token_format";
|
|
75
|
+
readonly RENEW_NOT_ALLOWED: "error.renew_not_allowed";
|
|
76
|
+
readonly VALIDATION_ERROR: "error.validation_error";
|
|
77
|
+
readonly UNSUPPORTED_RESOURCE: "error.unsupported_resource";
|
|
78
|
+
readonly INVALID_PAYMENT_TOKEN: "error.invalid_payment_token";
|
|
79
|
+
readonly UNEXPECTED_PAYMENT_TOKEN: "error.unexpected_payment_token";
|
|
80
|
+
readonly NOT_FOUND: "error.not_found";
|
|
81
|
+
readonly UNEXPECTED_ERROR: "error.unexpected_error";
|
|
82
|
+
readonly DATABASE_NOT_INITIALIZED: "error.database_not_initialized";
|
|
83
|
+
readonly INVALID_USER_ID: "error.invalid_user_id";
|
|
84
|
+
readonly NO_PAYMENT_TOKENS: "error.no_payment_tokens";
|
|
85
|
+
readonly SERVER_NOT_INITIALIZED: "error.server_not_initialized";
|
|
86
|
+
readonly SERVER_NOT_RESPONDING: "error.server_not_responding";
|
|
87
|
+
readonly INVALID_ADDRESS: "error.invalid_address";
|
|
88
|
+
readonly PAYMENT_REQUEST_NOT_APPROVED: "error.payment_request_not_approved";
|
|
89
|
+
readonly REQUIRE_PAYMENT_ID: "error.require_payment_id";
|
|
90
|
+
readonly ADDRESS_EXISTS: "error.address_exists";
|
|
91
|
+
readonly UNSUPPORTED_ALCHEMY_NETWORK: "error.unsupported_alchemy_network";
|
|
92
|
+
readonly FAILED_INITIALIZE_WEBHOOKS: "error.failed_initialize_webhooks";
|
|
93
|
+
readonly SERVER_UNAVAILABLE: "error.server_unavailable";
|
|
94
|
+
readonly FAILED_GET_TRANSACTIONS: "error.failed_get_transactions";
|
|
95
|
+
readonly ORM_REPO_NOT_INITIALIZED: "error.orm_repo_not_initialized";
|
|
96
|
+
readonly INVOICE_SUBSCRIBER_ERROR: "error.invoice_subscriber_error";
|
|
97
|
+
readonly REQUIRE_MIN_AMOUNT: "error.require_min_amount";
|
|
98
|
+
readonly PAYMENT_ID_NOT_FOUND: "error.payment_id_not_found";
|
|
99
|
+
readonly ALREADY_PAID_INVOICE: "error.already_paid_invoice";
|
|
100
|
+
readonly PAYMENT_FAILED: "error.payment_failed";
|
|
101
|
+
readonly FAILED_WEBHOOK_ACTION: "error.failed_webhook_action";
|
|
102
|
+
readonly NO_WEBHOOKS: "error.no_webhooks";
|
|
103
|
+
readonly FAILED_GET_WEBHOOK_ADDRESSES: "error.failed_get_webhook_addresses";
|
|
104
|
+
readonly PARENT_INDEX_IN_USE: "error.parent_index_in_use";
|
|
105
|
+
readonly REQUEST_NOT_APPROVED: "error.request_not_approved";
|
|
106
|
+
readonly RECEIVER_REQUIRED: "error.receiver_required";
|
|
107
|
+
readonly UNEXPECTED_RECEIVER: "error.unexpected_receiver";
|
|
108
|
+
readonly DUPLICATE_CLAIM_JOB: "error.duplicate_claim_job";
|
|
109
|
+
readonly REQUEST_FULFILLED: "error.request_fulfilled";
|
|
110
|
+
readonly WITHDRAW_REQUEST_NOT_FOUND: "error.withdraw_request_not_found";
|
|
111
|
+
readonly UNSUPPORTED_NETWORK: "error.unsupported_network";
|
|
112
|
+
readonly UNSUPPORTED_ADDRESS: "error.unsupported_address";
|
|
113
|
+
readonly UNEXPECTED_ADDRESS_FORMAT: "error.unexpected_address_format";
|
|
114
|
+
readonly EMPTY_PAYLOAD: "error.empty_payload";
|
|
115
|
+
readonly ONLY_STABLECOIN_WITHDRAWAL: "error.only_stablecoin_withdrawal";
|
|
116
|
+
readonly CHAIN_CONFIG_NOT_SET: "error.chain_config_not_set";
|
|
117
|
+
readonly ACCOUNTING_CONFIG_NOT_SET: "error.accounting_config_not_set";
|
|
118
|
+
readonly ALLOWED_RECEIVERS_CONFIG_NOT_SET: "error.allowed_receivers_config_not_set";
|
|
119
|
+
readonly ZERO_VALUE_TX: "error.zero_value_tx";
|
|
120
|
+
readonly UNSUPPORTED_BLOCKCHAIN: "error.unsupported_blockchain";
|
|
121
|
+
readonly NOT_WHITELISTED: "error.not_whitelisted_wallet_address";
|
|
122
|
+
readonly INVALID_WALLET_TYPE: "error.invalid_wallet_type";
|
|
123
|
+
readonly ONLY_NATIVE_WITHDRAWAL: "error.only_native_withdrawal";
|
|
124
|
+
readonly RENT_ENERGY_API_ERROR: "error.rent_enegy_api_error";
|
|
125
|
+
readonly INSUFFICIENT_ENERGY_WALLET_BALANCE: "error.insufficient_energy_wallet_balance";
|
|
126
|
+
readonly RENT_ENERGY_MIN_WITHDRAWAL_ERROR: "error.rent_energy_min_withdrawal_error";
|
|
127
|
+
};
|
|
128
|
+
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
129
|
+
export interface ErrorCodeEntry {
|
|
130
|
+
code: number;
|
|
131
|
+
error: string;
|
|
132
|
+
error_code: ErrorCode;
|
|
133
|
+
}
|
|
1
134
|
interface ErrorHandlerResponse {
|
|
2
135
|
status_code: number;
|
|
3
136
|
response: ResponseObject;
|
|
@@ -6,6 +139,8 @@ interface ErrorHandlerResponse {
|
|
|
6
139
|
interface ResponseObject {
|
|
7
140
|
status: boolean;
|
|
8
141
|
message: string;
|
|
142
|
+
/** Static CMS translation key. Null for unrecognised/internal errors. */
|
|
143
|
+
error_code: ErrorCode | null;
|
|
9
144
|
data: any;
|
|
10
145
|
error: string;
|
|
11
146
|
}
|
|
@@ -40,35 +175,42 @@ declare class BaseErrors {
|
|
|
40
175
|
error: string;
|
|
41
176
|
};
|
|
42
177
|
};
|
|
43
|
-
/** Error
|
|
44
|
-
Unauthorized():
|
|
45
|
-
RequireParameter(
|
|
46
|
-
NotFoundUser():
|
|
47
|
-
InvalidValue(
|
|
48
|
-
InvalidTokenFormat():
|
|
49
|
-
RenewNotAllowed(
|
|
50
|
-
ValidationError(
|
|
51
|
-
UnsupportedResource(
|
|
52
|
-
InvalidPaymentToken(
|
|
53
|
-
UnexpectedPaymentToken():
|
|
54
|
-
NotFound(
|
|
55
|
-
ChainConfigNotSet():
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
178
|
+
/** Error definitions — unchanged, backward compatible */
|
|
179
|
+
Unauthorized(_?: any): "You are not authorized to perform this action";
|
|
180
|
+
RequireParameter(_?: any): "A required parameter is missing";
|
|
181
|
+
NotFoundUser(_?: any): "User not found";
|
|
182
|
+
InvalidValue(_?: any, __?: any): "One or more values provided are invalid";
|
|
183
|
+
InvalidTokenFormat(_?: any): "Invalid authorization format. Expected: Bearer <token>";
|
|
184
|
+
RenewNotAllowed(_?: any, __?: any): "Your deposit address is not yet eligible for renewal";
|
|
185
|
+
ValidationError(_?: any): "Request validation failed";
|
|
186
|
+
UnsupportedResource(_?: any): "The requested resource is not supported";
|
|
187
|
+
InvalidPaymentToken(_?: any): "The payment token provided is not recognized";
|
|
188
|
+
UnexpectedPaymentToken(_?: any): "The selected payment token is not supported on this network";
|
|
189
|
+
NotFound(_?: any): "The requested resource was not found";
|
|
190
|
+
ChainConfigNotSet(_?: any): "Chain configuration is missing. Please contact support";
|
|
191
|
+
AccountingNotSet(): "Accounting configuration is missing. Please contact support";
|
|
192
|
+
AllowedReceiversNotSet(): "Allowed receiver addresses not configured. Please contact support";
|
|
193
|
+
UnexpectedError(_?: any): "An unexpected error occurred. Please try again later";
|
|
194
|
+
NotInitializedDatabase(_?: any): "Database connection is not available";
|
|
195
|
+
InvalidUserId(_?: any): "The provided user ID is invalid";
|
|
196
|
+
NoPaymentTokens(_?: any): "No payment tokens are configured for this network";
|
|
197
|
+
NotInitializedServer(_?: any): "Server is starting up. Please try again in a moment";
|
|
198
|
+
ServerNotResponding(_?: any): "The server is not responding. Please try again later";
|
|
199
|
+
InvalidAddress(_?: any): string;
|
|
200
|
+
NotApprovedPaymentRequest(_?: any): "Payment request has not been approved";
|
|
201
|
+
RequirePaymentId(_?: any): "Payment ID is required";
|
|
202
|
+
AddressExists(_?: any): "A deposit address already exists for this account";
|
|
203
|
+
UnsupportedBlockchainType(): "The selected blockchain is not supported";
|
|
204
|
+
ZeroValueTx(): "Withdrawal amount cannot be zero";
|
|
205
|
+
NotWhitelisted(): "The provided wallet address is not whitelisted";
|
|
206
|
+
InvalidWalletType(): "WalletType is invalid. Use \"funding\", \"rent-energy\" or \"escrow\"";
|
|
207
|
+
OnlyNativeWithdrawal(): "Only native tokens can be withdrawn";
|
|
208
|
+
RentEnergyApiError(): "Encountered error when calling rent API";
|
|
209
|
+
InsufficientRentEnergyWalletBalance(): "Rent energy wallet has insufficient balance";
|
|
210
|
+
RentEnergyMinWithdrawalError(): "Minimum withdrawal of 50TRX required.";
|
|
66
211
|
/** Handler methods */
|
|
67
212
|
handle_error: (error: any, source_method: string) => ErrorHandlerResponse;
|
|
68
|
-
get_error_code_base: (message: string) =>
|
|
69
|
-
code: number;
|
|
70
|
-
error: string;
|
|
71
|
-
} | null;
|
|
213
|
+
get_error_code_base: (message: string) => ErrorCodeEntry | null;
|
|
72
214
|
}
|
|
73
215
|
export default BaseErrors;
|
|
74
216
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqFtB,2BAA2B;;;;IAK3B,sBAAsB;;;;;;;;;CAYhB,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEb,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,SAAS,CAAC;CACzB;AAED,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,yEAAyE;IACzE,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,cAAM,UAAU;IACL,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQX;IAED,yDAAyD;IAClD,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG;IACpB,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG;IACpB,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG;IAC9B,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC1B,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG;IACjC,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG;IACvB,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC3B,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC3B,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC9B,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG;IAChB,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,gBAAgB;IAChB,sBAAsB;IACtB,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG;IACvB,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC9B,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,eAAe,CAAC,CAAC,CAAC,EAAE,GAAG;IACvB,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC5B,mBAAmB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC3B,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM;IAC/B,yBAAyB,CAAC,CAAC,CAAC,EAAE,GAAG;IACjC,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IACrB,yBAAyB;IACzB,WAAW;IACX,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,kBAAkB;IAClB,mCAAmC;IACnC,4BAA4B;IAEnC,sBAAsB;IACf,YAAY,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAuB9E;IAEM,mBAAmB,GAAI,SAAS,MAAM,KAAG,cAAc,GAAG,IAAI,CAmCpE;CACJ;AAED,eAAe,UAAU,CAAC"}
|
package/build/errors/errors.js
CHANGED
|
@@ -1,5 +1,174 @@
|
|
|
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
|
+
UNEXPECTED_ERROR: "An unexpected error occurred. Please try again later",
|
|
32
|
+
DATABASE_NOT_INITIALIZED: "Database connection is not available",
|
|
33
|
+
// 400
|
|
34
|
+
INVALID_USER_ID: "The provided user ID is invalid",
|
|
35
|
+
NO_PAYMENT_TOKENS: "No payment tokens are configured for this network",
|
|
36
|
+
SERVER_NOT_INITIALIZED: "Server is starting up. Please try again in a moment",
|
|
37
|
+
// 400
|
|
38
|
+
SERVER_NOT_RESPONDING: "The server is not responding. Please try again later",
|
|
39
|
+
// 400
|
|
40
|
+
INVALID_ADDRESS: "The provided address is invalid",
|
|
41
|
+
PAYMENT_REQUEST_NOT_APPROVED: "Payment request has not been approved",
|
|
42
|
+
// 400
|
|
43
|
+
REQUIRE_PAYMENT_ID: "Payment ID is required",
|
|
44
|
+
// 409
|
|
45
|
+
ADDRESS_EXISTS: "A deposit address already exists for this account",
|
|
46
|
+
// Admin / webhook
|
|
47
|
+
UNSUPPORTED_ALCHEMY_NETWORK: "The blockchain network is not supported by Alchemy",
|
|
48
|
+
FAILED_INITIALIZE_WEBHOOKS: "Failed to initialize webhooks. Please try again later",
|
|
49
|
+
// Database
|
|
50
|
+
SERVER_UNAVAILABLE: "Service is temporarily unavailable. Please try again later",
|
|
51
|
+
FAILED_GET_TRANSACTIONS: "Failed to retrieve transaction count. Please try again later",
|
|
52
|
+
// Alchemy / Voltage shared
|
|
53
|
+
INVOICE_SUBSCRIBER_ERROR: "Failed to subscribe to the invoice. Please try again",
|
|
54
|
+
// 400
|
|
55
|
+
REQUIRE_MIN_AMOUNT: "The amount is below the minimum required",
|
|
56
|
+
// 400
|
|
57
|
+
PAYMENT_ID_NOT_FOUND: "Invoice not found or expired. Please request a new one",
|
|
58
|
+
// 409
|
|
59
|
+
ALREADY_PAID_INVOICE: "This invoice has already been paid",
|
|
60
|
+
PAYMENT_FAILED: "Payment could not be processed. Please try again",
|
|
61
|
+
FAILED_WEBHOOK_ACTION: "A webhook operation failed. Please try again later",
|
|
62
|
+
ORM_REPO_NOT_INITIALIZED: "A required database repository is not initialized",
|
|
63
|
+
NO_WEBHOOKS: "No webhooks found for this subscription",
|
|
64
|
+
FAILED_GET_WEBHOOK_ADDRESSES: "Failed to retrieve webhook addresses. Please try again later",
|
|
65
|
+
// Wallet
|
|
66
|
+
// 409
|
|
67
|
+
PARENT_INDEX_IN_USE: "The selected wallet index is already in use",
|
|
68
|
+
// Transactions
|
|
69
|
+
// 409
|
|
70
|
+
REQUEST_NOT_APPROVED: "Withdrawal request has not been approved",
|
|
71
|
+
// 400
|
|
72
|
+
RECEIVER_REQUIRED: "Receiver address is missing. Please contact support",
|
|
73
|
+
// 400
|
|
74
|
+
UNEXPECTED_RECEIVER: "Please use the wallet address associated with your deposit",
|
|
75
|
+
// 409
|
|
76
|
+
DUPLICATE_CLAIM_JOB: "A claim for this request is already in progress. Please check back in a few minutes", // 400
|
|
77
|
+
INVALID_WALLET_ADDRESS: "The wallet address provided is invalid",
|
|
78
|
+
// 409
|
|
79
|
+
REQUEST_FULFILLED: "This request has already been fulfilled",
|
|
80
|
+
// 400
|
|
81
|
+
WITHDRAW_REQUEST_NOT_FOUND: "Withdrawal request not found",
|
|
82
|
+
// 400
|
|
83
|
+
UNSUPPORTED_NETWORK: "The selected network is not supported",
|
|
84
|
+
// 400
|
|
85
|
+
UNSUPPORTED_ADDRESS: "The address format is not compatible with the selected network",
|
|
86
|
+
// 400
|
|
87
|
+
UNEXPECTED_ADDRESS_FORMAT: "The address does not match the expected format for the selected network",
|
|
88
|
+
// 400
|
|
89
|
+
EMPTY_PAYLOAD: "Request payload cannot be empty",
|
|
90
|
+
// 400
|
|
91
|
+
ONLY_STABLECOIN_WITHDRAWAL: "This network only supports stablecoin withdrawals",
|
|
92
|
+
/** Chain Config Related */
|
|
93
|
+
CHAIN_CONFIG_NOT_SET: "Chain configuration is missing. Please contact support", // 500
|
|
94
|
+
ALLOWED_RECEIVERS_CONFIG_NOT_SET: "Allowed receiver addresses not configured. Please contact support", //500
|
|
95
|
+
ACCOUNTING_CONFIG_NOT_SET: "Accounting configuration is missing. Please contact support", //500
|
|
96
|
+
/** BO Admin Errors */
|
|
97
|
+
ZERO_VALUE_TX: `Withdrawal amount cannot be zero`, // 400
|
|
98
|
+
UNSUPPORTED_BLOCKCHAIN: `The selected blockchain is not supported`, // 400
|
|
99
|
+
NOT_WHITELISTED: `The provided wallet address is not whitelisted`, // 400
|
|
100
|
+
INVALID_WALLET_TYPE: `WalletType is invalid. Use "funding", "rent-energy" or "escrow"`, // 400
|
|
101
|
+
ONLY_NATIVE_WITHDRAWAL: `Only native tokens can be withdrawn`, // 400
|
|
102
|
+
RENT_ENERGY_API_ERROR: `Encountered error when calling rent API`, // 500
|
|
103
|
+
INSUFFICIENT_ENERGY_WALLET_BALANCE: `Rent energy wallet has insufficient balance`,
|
|
104
|
+
RENT_ENERGY_MIN_WITHDRAWAL_ERROR: `Minimum withdrawal of 50TRX required.`,
|
|
105
|
+
};
|
|
106
|
+
exports.ErrorCodes = {
|
|
107
|
+
INTERNAL_SERVER: 'error.internal_server_error',
|
|
108
|
+
UNAUTHORIZED: 'error.unauthorized',
|
|
109
|
+
REQUIRE_PARAMETER: 'error.require_parameter',
|
|
110
|
+
USER_NOT_FOUND: 'error.user_not_found',
|
|
111
|
+
INVALID_VALUE: 'error.invalid_value',
|
|
112
|
+
INVALID_TOKEN_FORMAT: 'error.invalid_token_format',
|
|
113
|
+
RENEW_NOT_ALLOWED: 'error.renew_not_allowed',
|
|
114
|
+
VALIDATION_ERROR: 'error.validation_error',
|
|
115
|
+
UNSUPPORTED_RESOURCE: 'error.unsupported_resource',
|
|
116
|
+
INVALID_PAYMENT_TOKEN: 'error.invalid_payment_token',
|
|
117
|
+
UNEXPECTED_PAYMENT_TOKEN: 'error.unexpected_payment_token',
|
|
118
|
+
NOT_FOUND: 'error.not_found',
|
|
119
|
+
UNEXPECTED_ERROR: 'error.unexpected_error',
|
|
120
|
+
DATABASE_NOT_INITIALIZED: 'error.database_not_initialized',
|
|
121
|
+
INVALID_USER_ID: 'error.invalid_user_id',
|
|
122
|
+
NO_PAYMENT_TOKENS: 'error.no_payment_tokens',
|
|
123
|
+
SERVER_NOT_INITIALIZED: 'error.server_not_initialized',
|
|
124
|
+
SERVER_NOT_RESPONDING: 'error.server_not_responding',
|
|
125
|
+
INVALID_ADDRESS: 'error.invalid_address',
|
|
126
|
+
PAYMENT_REQUEST_NOT_APPROVED: 'error.payment_request_not_approved',
|
|
127
|
+
REQUIRE_PAYMENT_ID: 'error.require_payment_id',
|
|
128
|
+
ADDRESS_EXISTS: 'error.address_exists',
|
|
129
|
+
// Admin / webhook
|
|
130
|
+
UNSUPPORTED_ALCHEMY_NETWORK: 'error.unsupported_alchemy_network',
|
|
131
|
+
FAILED_INITIALIZE_WEBHOOKS: 'error.failed_initialize_webhooks',
|
|
132
|
+
// Database
|
|
133
|
+
SERVER_UNAVAILABLE: 'error.server_unavailable',
|
|
134
|
+
FAILED_GET_TRANSACTIONS: 'error.failed_get_transactions',
|
|
135
|
+
ORM_REPO_NOT_INITIALIZED: 'error.orm_repo_not_initialized',
|
|
136
|
+
// Alchemy / Voltage shared
|
|
137
|
+
INVOICE_SUBSCRIBER_ERROR: 'error.invoice_subscriber_error',
|
|
138
|
+
REQUIRE_MIN_AMOUNT: 'error.require_min_amount',
|
|
139
|
+
PAYMENT_ID_NOT_FOUND: 'error.payment_id_not_found',
|
|
140
|
+
ALREADY_PAID_INVOICE: 'error.already_paid_invoice',
|
|
141
|
+
PAYMENT_FAILED: 'error.payment_failed',
|
|
142
|
+
FAILED_WEBHOOK_ACTION: 'error.failed_webhook_action',
|
|
143
|
+
NO_WEBHOOKS: 'error.no_webhooks',
|
|
144
|
+
FAILED_GET_WEBHOOK_ADDRESSES: 'error.failed_get_webhook_addresses',
|
|
145
|
+
// Wallet
|
|
146
|
+
PARENT_INDEX_IN_USE: 'error.parent_index_in_use',
|
|
147
|
+
// Transactions
|
|
148
|
+
REQUEST_NOT_APPROVED: 'error.request_not_approved',
|
|
149
|
+
RECEIVER_REQUIRED: 'error.receiver_required',
|
|
150
|
+
UNEXPECTED_RECEIVER: 'error.unexpected_receiver',
|
|
151
|
+
DUPLICATE_CLAIM_JOB: 'error.duplicate_claim_job',
|
|
152
|
+
REQUEST_FULFILLED: 'error.request_fulfilled',
|
|
153
|
+
WITHDRAW_REQUEST_NOT_FOUND: 'error.withdraw_request_not_found',
|
|
154
|
+
UNSUPPORTED_NETWORK: 'error.unsupported_network',
|
|
155
|
+
UNSUPPORTED_ADDRESS: 'error.unsupported_address',
|
|
156
|
+
UNEXPECTED_ADDRESS_FORMAT: 'error.unexpected_address_format',
|
|
157
|
+
EMPTY_PAYLOAD: 'error.empty_payload',
|
|
158
|
+
ONLY_STABLECOIN_WITHDRAWAL: 'error.only_stablecoin_withdrawal',
|
|
159
|
+
// Chain/Network Config
|
|
160
|
+
CHAIN_CONFIG_NOT_SET: 'error.chain_config_not_set',
|
|
161
|
+
ACCOUNTING_CONFIG_NOT_SET: 'error.accounting_config_not_set',
|
|
162
|
+
ALLOWED_RECEIVERS_CONFIG_NOT_SET: 'error.allowed_receivers_config_not_set',
|
|
163
|
+
ZERO_VALUE_TX: `error.zero_value_tx`,
|
|
164
|
+
UNSUPPORTED_BLOCKCHAIN: `error.unsupported_blockchain`,
|
|
165
|
+
NOT_WHITELISTED: `error.not_whitelisted_wallet_address`,
|
|
166
|
+
INVALID_WALLET_TYPE: `error.invalid_wallet_type`,
|
|
167
|
+
ONLY_NATIVE_WITHDRAWAL: `error.only_native_withdrawal`,
|
|
168
|
+
RENT_ENERGY_API_ERROR: `error.rent_enegy_api_error`,
|
|
169
|
+
INSUFFICIENT_ENERGY_WALLET_BALANCE: `error.insufficient_energy_wallet_balance`,
|
|
170
|
+
RENT_ENERGY_MIN_WITHDRAWAL_ERROR: `error.rent_energy_min_withdrawal_error`,
|
|
171
|
+
};
|
|
3
172
|
class BaseErrors {
|
|
4
173
|
constructor() {
|
|
5
174
|
this.codes = {
|
|
@@ -12,106 +181,163 @@ class BaseErrors {
|
|
|
12
181
|
503: { code: 503, error: "Service Unavailable" }
|
|
13
182
|
};
|
|
14
183
|
/** Handler methods */
|
|
15
|
-
// Return status code, error, and message
|
|
16
184
|
this.handle_error = (error, source_method) => {
|
|
17
185
|
const result = {
|
|
18
186
|
status_code: 500,
|
|
187
|
+
source_method,
|
|
19
188
|
response: {
|
|
20
189
|
status: false,
|
|
21
190
|
message: "Unexpected error occured. Please try again later.",
|
|
191
|
+
error_code: null,
|
|
22
192
|
data: {},
|
|
23
193
|
error: "Internal Server Error"
|
|
24
194
|
}
|
|
25
195
|
};
|
|
26
|
-
|
|
196
|
+
const status = this.get_error_code_base(error.message);
|
|
27
197
|
if (!status)
|
|
28
|
-
return
|
|
198
|
+
return result;
|
|
29
199
|
result.status_code = status.code;
|
|
30
|
-
result.response.message = status.code
|
|
200
|
+
result.response.message = status.code === 500 && !error.message
|
|
201
|
+
? "Unexpected error occured. Please try again later."
|
|
202
|
+
: error.message;
|
|
31
203
|
result.response.error = status.error;
|
|
32
|
-
|
|
204
|
+
result.response.error_code = status.error_code;
|
|
205
|
+
return result;
|
|
33
206
|
};
|
|
34
|
-
// Get the status code and error message
|
|
35
207
|
this.get_error_code_base = (message) => {
|
|
36
|
-
if (message.includes("
|
|
37
|
-
return this.codes[
|
|
38
|
-
if (message.includes("Unauthorized"))
|
|
39
|
-
return this.codes[401];
|
|
40
|
-
if (message.includes("User not found"))
|
|
41
|
-
return this.codes[403];
|
|
208
|
+
if (message.includes("not authorized"))
|
|
209
|
+
return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.UNAUTHORIZED });
|
|
42
210
|
if (message.includes("jwt expired"))
|
|
43
|
-
return this.codes[401];
|
|
44
|
-
if (message.includes("
|
|
45
|
-
return this.codes[400];
|
|
46
|
-
if (message.includes("
|
|
47
|
-
return this.codes[400];
|
|
48
|
-
if (message.includes("
|
|
49
|
-
return this.codes[
|
|
50
|
-
if (message.includes(
|
|
51
|
-
return this.codes[400];
|
|
52
|
-
if (message.includes(
|
|
53
|
-
return this.codes[400];
|
|
54
|
-
if (message.includes(
|
|
55
|
-
return this.codes[
|
|
56
|
-
if (message.includes(
|
|
57
|
-
return this.codes[400];
|
|
58
|
-
if (message.includes(
|
|
59
|
-
return this.codes[
|
|
60
|
-
if (message.includes(
|
|
61
|
-
return this.codes[400];
|
|
62
|
-
if (message.includes(
|
|
63
|
-
return this.codes[400];
|
|
64
|
-
if (message.includes("
|
|
65
|
-
return this.codes[400];
|
|
66
|
-
if (message.includes("
|
|
67
|
-
return this.codes[
|
|
68
|
-
if (message.includes("
|
|
69
|
-
return this.codes[
|
|
70
|
-
if (message.includes("
|
|
71
|
-
return this.codes[
|
|
72
|
-
if (message.includes("
|
|
73
|
-
return this.codes[
|
|
211
|
+
return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.UNAUTHORIZED });
|
|
212
|
+
if (message.includes("required parameter is missing"))
|
|
213
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.REQUIRE_PARAMETER });
|
|
214
|
+
if (message.includes("Payment ID is required"))
|
|
215
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.REQUIRE_PAYMENT_ID });
|
|
216
|
+
if (message.includes("User not found"))
|
|
217
|
+
return Object.assign(Object.assign({}, this.codes[403]), { error_code: exports.ErrorCodes.USER_NOT_FOUND });
|
|
218
|
+
if (message.includes("values provided are invalid"))
|
|
219
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_VALUE });
|
|
220
|
+
if (message.includes("Invalid authorization format"))
|
|
221
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_TOKEN_FORMAT });
|
|
222
|
+
if (message.includes("not yet eligible for renewal"))
|
|
223
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.RENEW_NOT_ALLOWED });
|
|
224
|
+
if (message.includes("Request validation failed"))
|
|
225
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.VALIDATION_ERROR });
|
|
226
|
+
if (message.includes("resource is not supported"))
|
|
227
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.UNSUPPORTED_RESOURCE });
|
|
228
|
+
if (message.includes("payment token provided is not recognized"))
|
|
229
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_PAYMENT_TOKEN });
|
|
230
|
+
if (message.includes("not supported on this network"))
|
|
231
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.UNEXPECTED_PAYMENT_TOKEN });
|
|
232
|
+
if (message.includes("resource was not found"))
|
|
233
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.NOT_FOUND });
|
|
234
|
+
if (message.includes("Chain configuration is missing"))
|
|
235
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.CHAIN_CONFIG_NOT_SET });
|
|
236
|
+
if (message.includes("unexpected error occurred"))
|
|
237
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.UNEXPECTED_ERROR });
|
|
238
|
+
if (message.includes("Database connection is not available"))
|
|
239
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.DATABASE_NOT_INITIALIZED });
|
|
240
|
+
if (message.includes("user ID is invalid"))
|
|
241
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_USER_ID });
|
|
242
|
+
if (message.includes("No payment tokens are configured"))
|
|
243
|
+
return Object.assign(Object.assign({}, this.codes[502]), { error_code: exports.ErrorCodes.NO_PAYMENT_TOKENS });
|
|
244
|
+
if (message.includes("Server is starting up"))
|
|
245
|
+
return Object.assign(Object.assign({}, this.codes[503]), { error_code: exports.ErrorCodes.SERVER_NOT_INITIALIZED });
|
|
246
|
+
if (message.includes("server is not responding"))
|
|
247
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.SERVER_NOT_RESPONDING });
|
|
248
|
+
if (message.includes("provided address is invalid"))
|
|
249
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_ADDRESS });
|
|
250
|
+
if (message.includes("Payment request has not been approved"))
|
|
251
|
+
return Object.assign(Object.assign({}, this.codes[401]), { error_code: exports.ErrorCodes.PAYMENT_REQUEST_NOT_APPROVED });
|
|
252
|
+
if (message.includes("deposit address already exists"))
|
|
253
|
+
return Object.assign(Object.assign({}, this.codes[409]), { error_code: exports.ErrorCodes.ADDRESS_EXISTS });
|
|
254
|
+
if (message.includes(exports.ErrorMessages.ACCOUNTING_CONFIG_NOT_SET))
|
|
255
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.ACCOUNTING_CONFIG_NOT_SET });
|
|
256
|
+
if (message.includes(exports.ErrorMessages.ALLOWED_RECEIVERS_CONFIG_NOT_SET))
|
|
257
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: exports.ErrorCodes.ALLOWED_RECEIVERS_CONFIG_NOT_SET });
|
|
258
|
+
if (message.includes(exports.ErrorMessages.NOT_WHITELISTED))
|
|
259
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.NOT_WHITELISTED });
|
|
260
|
+
if (message.includes(exports.ErrorMessages.UNSUPPORTED_BLOCKCHAIN))
|
|
261
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.UNSUPPORTED_BLOCKCHAIN });
|
|
262
|
+
if (message.includes(exports.ErrorMessages.ZERO_VALUE_TX))
|
|
263
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.ZERO_VALUE_TX });
|
|
264
|
+
if (message.includes(exports.ErrorMessages.INVALID_WALLET_TYPE))
|
|
265
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INVALID_WALLET_TYPE });
|
|
266
|
+
if (message.includes(exports.ErrorMessages.ONLY_NATIVE_WITHDRAWAL))
|
|
267
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.ONLY_NATIVE_WITHDRAWAL });
|
|
268
|
+
if (message.includes(exports.ErrorMessages.RENT_ENERGY_API_ERROR))
|
|
269
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.RENT_ENERGY_API_ERROR });
|
|
270
|
+
if (message.includes(exports.ErrorMessages.INSUFFICIENT_ENERGY_WALLET_BALANCE))
|
|
271
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.INSUFFICIENT_ENERGY_WALLET_BALANCE });
|
|
272
|
+
if (message.includes(exports.ErrorMessages.RENT_ENERGY_MIN_WITHDRAWAL_ERROR))
|
|
273
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: exports.ErrorCodes.RENT_ENERGY_MIN_WITHDRAWAL_ERROR });
|
|
74
274
|
return null;
|
|
75
275
|
};
|
|
76
276
|
}
|
|
77
|
-
/** Error
|
|
78
|
-
Unauthorized() { return
|
|
277
|
+
/** Error definitions — unchanged, backward compatible */
|
|
278
|
+
Unauthorized(_) { return exports.ErrorMessages.UNAUTHORIZED; }
|
|
279
|
+
;
|
|
280
|
+
RequireParameter(_) { return exports.ErrorMessages.REQUIRE_PARAMETER; }
|
|
281
|
+
;
|
|
282
|
+
NotFoundUser(_) { return exports.ErrorMessages.USER_NOT_FOUND; }
|
|
283
|
+
;
|
|
284
|
+
InvalidValue(_, __) { return exports.ErrorMessages.INVALID_VALUE; }
|
|
285
|
+
;
|
|
286
|
+
InvalidTokenFormat(_) { return exports.ErrorMessages.INVALID_TOKEN_FORMAT; }
|
|
287
|
+
;
|
|
288
|
+
RenewNotAllowed(_, __) { return exports.ErrorMessages.RENEW_NOT_ALLOWED; }
|
|
289
|
+
;
|
|
290
|
+
ValidationError(_) { return exports.ErrorMessages.VALIDATION_ERROR; }
|
|
291
|
+
;
|
|
292
|
+
UnsupportedResource(_) { return exports.ErrorMessages.UNSUPPORTED_RESOURCE; }
|
|
293
|
+
;
|
|
294
|
+
InvalidPaymentToken(_) { return exports.ErrorMessages.INVALID_PAYMENT_TOKEN; }
|
|
295
|
+
;
|
|
296
|
+
UnexpectedPaymentToken(_) { return exports.ErrorMessages.UNEXPECTED_PAYMENT_TOKEN; }
|
|
297
|
+
;
|
|
298
|
+
NotFound(_) { return exports.ErrorMessages.NOT_FOUND; }
|
|
299
|
+
;
|
|
300
|
+
ChainConfigNotSet(_) { return exports.ErrorMessages.CHAIN_CONFIG_NOT_SET; }
|
|
301
|
+
;
|
|
302
|
+
AccountingNotSet() { return exports.ErrorMessages.ACCOUNTING_CONFIG_NOT_SET; }
|
|
303
|
+
;
|
|
304
|
+
AllowedReceiversNotSet() { return exports.ErrorMessages.ALLOWED_RECEIVERS_CONFIG_NOT_SET; }
|
|
305
|
+
;
|
|
306
|
+
UnexpectedError(_) { return exports.ErrorMessages.UNEXPECTED_ERROR; }
|
|
307
|
+
;
|
|
308
|
+
NotInitializedDatabase(_) { return exports.ErrorMessages.DATABASE_NOT_INITIALIZED; }
|
|
309
|
+
;
|
|
310
|
+
InvalidUserId(_) { return exports.ErrorMessages.INVALID_USER_ID; }
|
|
79
311
|
;
|
|
80
|
-
|
|
312
|
+
NoPaymentTokens(_) { return exports.ErrorMessages.NO_PAYMENT_TOKENS; }
|
|
81
313
|
;
|
|
82
|
-
|
|
314
|
+
NotInitializedServer(_) { return exports.ErrorMessages.SERVER_NOT_INITIALIZED; }
|
|
83
315
|
;
|
|
84
|
-
|
|
316
|
+
ServerNotResponding(_) { return exports.ErrorMessages.SERVER_NOT_RESPONDING; }
|
|
85
317
|
;
|
|
86
|
-
|
|
318
|
+
InvalidAddress(_) { return exports.ErrorMessages.INVALID_ADDRESS; }
|
|
87
319
|
;
|
|
88
|
-
|
|
89
|
-
ValidationError(validation_type) { return `Failed while validating ${validation_type}`; }
|
|
320
|
+
NotApprovedPaymentRequest(_) { return exports.ErrorMessages.PAYMENT_REQUEST_NOT_APPROVED; }
|
|
90
321
|
;
|
|
91
|
-
|
|
322
|
+
RequirePaymentId(_) { return exports.ErrorMessages.REQUIRE_PAYMENT_ID; }
|
|
92
323
|
;
|
|
93
|
-
|
|
324
|
+
AddressExists(_) { return exports.ErrorMessages.ADDRESS_EXISTS; }
|
|
94
325
|
;
|
|
95
|
-
|
|
96
|
-
NotFound(resource_name) { return `${resource_name} not found`; }
|
|
326
|
+
UnsupportedBlockchainType() { return exports.ErrorMessages.UNSUPPORTED_BLOCKCHAIN; }
|
|
97
327
|
;
|
|
98
|
-
|
|
328
|
+
ZeroValueTx() { return exports.ErrorMessages.ZERO_VALUE_TX; }
|
|
99
329
|
;
|
|
100
|
-
|
|
101
|
-
NotInitializedDatabase() { return "Database driver is not initialized."; }
|
|
330
|
+
NotWhitelisted() { return exports.ErrorMessages.NOT_WHITELISTED; }
|
|
102
331
|
;
|
|
103
|
-
|
|
332
|
+
InvalidWalletType() { return exports.ErrorMessages.INVALID_WALLET_TYPE; }
|
|
104
333
|
;
|
|
105
|
-
|
|
334
|
+
OnlyNativeWithdrawal() { return exports.ErrorMessages.ONLY_NATIVE_WITHDRAWAL; }
|
|
106
335
|
;
|
|
107
|
-
|
|
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"; }
|
|
336
|
+
RentEnergyApiError() { return exports.ErrorMessages.RENT_ENERGY_API_ERROR; }
|
|
111
337
|
;
|
|
112
|
-
|
|
338
|
+
InsufficientRentEnergyWalletBalance() { return exports.ErrorMessages.INSUFFICIENT_ENERGY_WALLET_BALANCE; }
|
|
113
339
|
;
|
|
114
|
-
|
|
340
|
+
RentEnergyMinWithdrawalError() { return exports.ErrorMessages.RENT_ENERGY_MIN_WITHDRAWAL_ERROR; }
|
|
115
341
|
;
|
|
116
342
|
}
|
|
117
343
|
exports.default = BaseErrors;
|