@ercworldio/blockchain-shared 1.0.1-dev.9 → 1.0.2-dev-PROJ-1265.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.
- 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/artifacts/Escrow.json +16 -0
- 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/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/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
|
@@ -1,95 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 =
|
|
36
|
+
const errors_1 = __importStar(require("./errors"));
|
|
7
37
|
class TransactionsErrors extends errors_1.default {
|
|
8
38
|
constructor() {
|
|
9
|
-
/** Error Definition */
|
|
10
39
|
super(...arguments);
|
|
11
|
-
/** Handler methods */
|
|
12
|
-
// Return status code, error, and message
|
|
13
40
|
this.handle_transactions_error = (error, source_method) => {
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Try custom class error codes
|
|
34
|
-
if (message.includes("AlchemyActionError:"))
|
|
35
|
-
return this.codes[500];
|
|
36
|
-
if (message.includes("Withdraw request"))
|
|
37
|
-
return this.codes[409];
|
|
55
|
+
const base = this.get_error_code_base(message);
|
|
56
|
+
if (base)
|
|
57
|
+
return base;
|
|
58
|
+
if (message.includes("Withdrawal request has not been approved"))
|
|
59
|
+
return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.REQUEST_NOT_APPROVED });
|
|
38
60
|
if (message.includes("Receiver address is missing"))
|
|
39
|
-
return this.codes[400];
|
|
40
|
-
if (message.includes("
|
|
41
|
-
return this.codes[
|
|
42
|
-
if (message.includes("
|
|
43
|
-
return this.codes[
|
|
44
|
-
if (message.includes("
|
|
45
|
-
return this.codes[400];
|
|
46
|
-
if (message.includes("
|
|
47
|
-
return this.codes[409];
|
|
48
|
-
if (message.includes("
|
|
49
|
-
return this.codes[400];
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
61
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.RECEIVER_REQUIRED });
|
|
62
|
+
if (message.includes("wallet address associated with your deposit"))
|
|
63
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNEXPECTED_RECEIVER });
|
|
64
|
+
if (message.includes("claim for this request is already in progress"))
|
|
65
|
+
return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.DUPLICATE_CLAIM_JOB });
|
|
66
|
+
if (message.includes("wallet address provided is invalid"))
|
|
67
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.INVALID_ADDRESS });
|
|
68
|
+
if (message.includes("already been fulfilled"))
|
|
69
|
+
return Object.assign(Object.assign({}, this.codes[409]), { error_code: errors_1.ErrorCodes.REQUEST_FULFILLED });
|
|
70
|
+
if (message.includes("Withdrawal request not found"))
|
|
71
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.WITHDRAW_REQUEST_NOT_FOUND });
|
|
72
|
+
if (message.includes("selected network is not supported"))
|
|
73
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_NETWORK });
|
|
74
|
+
if (message.includes("address format is not compatible"))
|
|
75
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNSUPPORTED_ADDRESS });
|
|
76
|
+
if (message.includes("does not match the expected format"))
|
|
77
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ADDRESS_FORMAT });
|
|
78
|
+
if (message.includes("payload cannot be empty"))
|
|
79
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.EMPTY_PAYLOAD });
|
|
80
|
+
if (message.includes("only supports stablecoin withdrawals"))
|
|
81
|
+
return Object.assign(Object.assign({}, this.codes[400]), { error_code: errors_1.ErrorCodes.ONLY_STABLECOIN_WITHDRAWAL });
|
|
82
|
+
return Object.assign(Object.assign({}, this.codes[500]), { error_code: errors_1.ErrorCodes.UNEXPECTED_ERROR });
|
|
62
83
|
};
|
|
63
84
|
}
|
|
64
|
-
|
|
85
|
+
RequestNotApproved(_) { return errors_1.ErrorMessages.REQUEST_NOT_APPROVED; }
|
|
65
86
|
;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return `Withdraw request is in "${status}" status`;
|
|
74
|
-
}
|
|
75
|
-
ReceiverRequired() { return "Receiver address is missing. Please contact support."; }
|
|
87
|
+
ReceiverRequired(_) { return errors_1.ErrorMessages.RECEIVER_REQUIRED; }
|
|
88
|
+
;
|
|
89
|
+
UnexpectedReceiver(_) { return errors_1.ErrorMessages.UNEXPECTED_RECEIVER; }
|
|
90
|
+
;
|
|
91
|
+
DuplicateClaimJob(_) { return errors_1.ErrorMessages.DUPLICATE_CLAIM_JOB; }
|
|
92
|
+
;
|
|
93
|
+
InvalidAddress(_) { return errors_1.ErrorMessages.INVALID_WALLET_ADDRESS; }
|
|
76
94
|
;
|
|
77
|
-
|
|
95
|
+
RequestFulfilled(_) { return errors_1.ErrorMessages.REQUEST_FULFILLED; }
|
|
78
96
|
;
|
|
79
|
-
|
|
97
|
+
NotExistWithdrawRequest(_) { return errors_1.ErrorMessages.WITHDRAW_REQUEST_NOT_FOUND; }
|
|
80
98
|
;
|
|
81
|
-
|
|
99
|
+
UnsupportedNetwork(_) { return errors_1.ErrorMessages.UNSUPPORTED_NETWORK; }
|
|
82
100
|
;
|
|
83
|
-
|
|
101
|
+
UnsupportedAddress(_, __) { return errors_1.ErrorMessages.UNSUPPORTED_ADDRESS; }
|
|
84
102
|
;
|
|
85
|
-
|
|
103
|
+
UnexpectedAddressFormat(_, __) { return errors_1.ErrorMessages.UNEXPECTED_ADDRESS_FORMAT; }
|
|
86
104
|
;
|
|
87
|
-
|
|
105
|
+
EmptyPayload(_) { return errors_1.ErrorMessages.EMPTY_PAYLOAD; }
|
|
88
106
|
;
|
|
89
|
-
|
|
90
|
-
UnexpectedAddressFormat(current_network, expected_network) { return `The address you provided looks like a ${expected_network} address. Either enter a valid ${current_network} address, or change the network to ${expected_network}`; }
|
|
91
|
-
EmptyPayload(action) { return `Payload cannot be empty for ${action}`; }
|
|
92
|
-
OnlyStablecoinWithdrawal() { return `This network only supports stablecoin withdrawal.`; }
|
|
107
|
+
OnlyStablecoinWithdrawal(_) { return errors_1.ErrorMessages.ONLY_STABLECOIN_WITHDRAWAL; }
|
|
93
108
|
;
|
|
94
109
|
}
|
|
95
110
|
exports.default = TransactionsErrors;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BaseErrors from "./errors";
|
|
1
|
+
import BaseErrors, { ErrorCodeEntry, ErrorCode } from "./errors";
|
|
2
2
|
interface ErrorHandlerResponse {
|
|
3
3
|
status_code: number;
|
|
4
4
|
response: ResponseObject;
|
|
@@ -7,23 +7,18 @@ interface ErrorHandlerResponse {
|
|
|
7
7
|
interface ResponseObject {
|
|
8
8
|
status: boolean;
|
|
9
9
|
message: string;
|
|
10
|
+
error_code: ErrorCode | null;
|
|
10
11
|
data: any;
|
|
11
12
|
error: string;
|
|
12
13
|
}
|
|
13
14
|
declare class VoltageErrors extends BaseErrors {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
AlreadyPaidInvoice(): string;
|
|
20
|
-
PaymentFailed(reason: string): string;
|
|
21
|
-
/** Handler methods */
|
|
15
|
+
InvoiceSubscriberError(_?: any): "Failed to subscribe to the invoice. Please try again";
|
|
16
|
+
RequireMinAmount(_?: any): "The amount is below the minimum required";
|
|
17
|
+
PaymentIdNotFound(_?: any): "Invoice not found or expired. Please request a new one";
|
|
18
|
+
AlreadyPaidInvoice(_?: any): "This invoice has already been paid";
|
|
19
|
+
PaymentFailed(_?: any): "Payment could not be processed. Please try again";
|
|
22
20
|
handle_voltage_error: (error: any, source_method: string) => ErrorHandlerResponse;
|
|
23
|
-
get_error_code: (message: string) =>
|
|
24
|
-
code: number;
|
|
25
|
-
error: string;
|
|
26
|
-
};
|
|
21
|
+
get_error_code: (message: string) => ErrorCodeEntry;
|
|
27
22
|
}
|
|
28
23
|
export default VoltageErrors;
|
|
29
24
|
//# sourceMappingURL=VoltageErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoltageErrors.d.ts","sourceRoot":"","sources":["../../src/errors/VoltageErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"VoltageErrors.d.ts","sourceRoot":"","sources":["../../src/errors/VoltageErrors.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,cAAc,EAAc,SAAS,EAAiB,MAAM,UAAU,CAAC;AAE5F,UAAU,oBAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,cAAc;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,aAAc,SAAQ,UAAU;IAC3B,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC9B,gBAAgB,CAAC,CAAC,CAAC,EAAE,GAAG;IACxB,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG;IACzB,kBAAkB,CAAC,CAAC,CAAC,EAAE,GAAG;IAC1B,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG;IAErB,oBAAoB,GAAI,OAAO,GAAG,EAAE,eAAe,MAAM,KAAG,oBAAoB,CAatF;IAEM,cAAc,GAAI,SAAS,MAAM,KAAG,cAAc,CAWxD;CACJ;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,69 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 =
|
|
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
|
-
|
|
14
|
-
|
|
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
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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(
|
|
73
|
+
RequireMinAmount(_) { return errors_1.ErrorMessages.REQUIRE_MIN_AMOUNT; }
|
|
61
74
|
;
|
|
62
|
-
PaymentIdNotFound(
|
|
75
|
+
PaymentIdNotFound(_) { return errors_1.ErrorMessages.PAYMENT_ID_NOT_FOUND; }
|
|
63
76
|
;
|
|
64
|
-
AlreadyPaidInvoice() { return
|
|
77
|
+
AlreadyPaidInvoice(_) { return errors_1.ErrorMessages.ALREADY_PAID_INVOICE; }
|
|
65
78
|
;
|
|
66
|
-
PaymentFailed(
|
|
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
|
|
14
|
-
|
|
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
|
|
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;
|
|
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
|
|
3
|
-
|
|
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 =
|
|
7
|
-
class
|
|
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
|
-
|
|
15
|
-
|
|
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
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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 =
|
|
66
|
+
exports.default = WalletErrors;
|