hive-keychain-commons 1.7.3 → 1.8.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/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/interfaces/exchange.d.ts +7 -0
- package/lib/interfaces/exchange.js +2 -0
- package/lib/utils/transfer.utils.d.ts +11 -1
- package/lib/utils/transfer.utils.js +45 -2
- package/lib/utils/vsc.utils.d.ts +3 -3
- package/lib/utils/vsc.utils.js +3 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.LeaseKeys = void 0;
|
|
18
|
+
__exportStar(require("./interfaces/exchange"), exports);
|
|
18
19
|
__exportStar(require("./interfaces/global-properties"), exports);
|
|
19
20
|
__exportStar(require("./interfaces/keychain"), exports);
|
|
20
21
|
__exportStar(require("./interfaces/price"), exports);
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { Exchange } from '../interfaces/exchange';
|
|
2
|
+
export declare enum TransferWarning {
|
|
3
|
+
PRIVATE_KEY_IN_MEMO = "private_key_in_memo",
|
|
4
|
+
PHISHING = "phishing",
|
|
5
|
+
EXCHANGE_DEPOSIT = "exchange_deposit",
|
|
6
|
+
EXCHANGE_MEMO = "exchange_memo",
|
|
7
|
+
EXCHANGE_RECURRENT = "exchange_recurrent"
|
|
8
|
+
}
|
|
9
|
+
export declare const TransferUtils: {
|
|
10
|
+
getTransferWarning: (account: string, exchanges: Exchange[], currency: string, memo: any, phisingAccounts: any, isRecurrent?: boolean) => TransferWarning | undefined;
|
|
11
|
+
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TransferUtils = exports.TransferWarning = void 0;
|
|
4
4
|
const crypto_utils_1 = require("./crypto.utils");
|
|
5
5
|
const keys_utils_1 = require("./keys.utils");
|
|
6
|
+
var TransferWarning;
|
|
7
|
+
(function (TransferWarning) {
|
|
8
|
+
TransferWarning["PRIVATE_KEY_IN_MEMO"] = "private_key_in_memo";
|
|
9
|
+
TransferWarning["PHISHING"] = "phishing";
|
|
10
|
+
TransferWarning["EXCHANGE_DEPOSIT"] = "exchange_deposit";
|
|
11
|
+
TransferWarning["EXCHANGE_MEMO"] = "exchange_memo";
|
|
12
|
+
TransferWarning["EXCHANGE_RECURRENT"] = "exchange_recurrent";
|
|
13
|
+
})(TransferWarning = exports.TransferWarning || (exports.TransferWarning = {}));
|
|
6
14
|
const getPrivateKeysMemoValidationWarning = (memo) => {
|
|
7
15
|
const memoTemp = memo.startsWith('#')
|
|
8
16
|
? memo.substring(1, memo.length)
|
|
@@ -22,4 +30,39 @@ const getPrivateKeysMemoValidationWarning = (memo) => {
|
|
|
22
30
|
}
|
|
23
31
|
return false;
|
|
24
32
|
};
|
|
25
|
-
|
|
33
|
+
const getTransferWarning = (account, exchanges, currency, memo, phisingAccounts, isRecurrent) => {
|
|
34
|
+
const exchangeWarning = getExchangeValidationWarning(account, exchanges, currency, memo.length > 0, isRecurrent);
|
|
35
|
+
if (exchangeWarning)
|
|
36
|
+
return exchangeWarning;
|
|
37
|
+
const privateKeyInMemoWarning = getPrivateKeysMemoValidationWarning(memo);
|
|
38
|
+
if (privateKeyInMemoWarning)
|
|
39
|
+
return TransferWarning.PRIVATE_KEY_IN_MEMO;
|
|
40
|
+
// return chrome.i18n.getMessage('popup_warning_private_key_in_memo');
|
|
41
|
+
if (phisingAccounts.includes(account)) {
|
|
42
|
+
return TransferWarning.PHISHING;
|
|
43
|
+
// return chrome.i18n.getMessage('popup_warning_phishing', [account]);
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
};
|
|
47
|
+
const getExchangeValidationWarning = (account, exchanges, currency, hasMemo, isRecurrent) => {
|
|
48
|
+
const exchange = exchanges.find((exch) => exch.username === account);
|
|
49
|
+
if (!exchange)
|
|
50
|
+
return;
|
|
51
|
+
if (!exchange.acceptedCoins.includes(currency)) {
|
|
52
|
+
// return chrome.i18n.getMessage('popup_warning_exchange_deposit', [currency]);
|
|
53
|
+
return TransferWarning.EXCHANGE_DEPOSIT;
|
|
54
|
+
}
|
|
55
|
+
if (!hasMemo) {
|
|
56
|
+
// return chrome.i18n.getMessage('popup_warning_exchange_memo');
|
|
57
|
+
return TransferWarning.EXCHANGE_MEMO;
|
|
58
|
+
}
|
|
59
|
+
if (isRecurrent)
|
|
60
|
+
return TransferWarning.EXCHANGE_RECURRENT;
|
|
61
|
+
// return chrome.i18n.getMessage(
|
|
62
|
+
// 'popup_html_transfer_recurrent_exchange_warning',
|
|
63
|
+
// );
|
|
64
|
+
return;
|
|
65
|
+
};
|
|
66
|
+
exports.TransferUtils = {
|
|
67
|
+
getTransferWarning,
|
|
68
|
+
};
|
package/lib/utils/vsc.utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RequestVscStaking, RequestVscTransfer, RequestVscWithdrawal } from '../interfaces/keychain';
|
|
2
|
-
import { VscHistoryItem,
|
|
2
|
+
import { VscHistoryItem, VscStatus } from '../interfaces/vsc';
|
|
3
3
|
export declare const VscUtils: {
|
|
4
|
-
checkStatus: (id: string
|
|
5
|
-
waitForStatus: (id: string,
|
|
4
|
+
checkStatus: (id: string) => Promise<VscStatus>;
|
|
5
|
+
waitForStatus: (id: string, timeoutSeconds?: number, endAtStatus?: VscStatus) => Promise<VscStatus>;
|
|
6
6
|
getOrganizedHistory: (username: string) => Promise<VscHistoryItem[]>;
|
|
7
7
|
getAddressFromDid: (did: string) => string | undefined;
|
|
8
8
|
getAccountBalance: (username: string) => Promise<any>;
|
package/lib/utils/vsc.utils.js
CHANGED
|
@@ -17,13 +17,13 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
17
17
|
const config_1 = __importDefault(require("../config"));
|
|
18
18
|
const vsc_1 = require("../interfaces/vsc");
|
|
19
19
|
const format_utils_1 = require("./format.utils");
|
|
20
|
-
const waitForStatus = (id,
|
|
20
|
+
const waitForStatus = (id, timeoutSeconds = 10, endAtStatus = vsc_1.VscStatus.CONFIRMED) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
let iterations = 0;
|
|
22
22
|
let status = vsc_1.VscStatus.UNCONFIRMED;
|
|
23
23
|
const wait = 500;
|
|
24
24
|
const maxIterations = (timeoutSeconds / wait) * 1000;
|
|
25
25
|
while (iterations < maxIterations) {
|
|
26
|
-
status = yield checkStatus(id
|
|
26
|
+
status = yield checkStatus(id);
|
|
27
27
|
if (status === endAtStatus || status === vsc_1.VscStatus.FAILED)
|
|
28
28
|
return status;
|
|
29
29
|
iterations++;
|
|
@@ -31,7 +31,7 @@ const waitForStatus = (id, type, timeoutSeconds = 10, endAtStatus = vsc_1.VscSta
|
|
|
31
31
|
}
|
|
32
32
|
return status;
|
|
33
33
|
});
|
|
34
|
-
const checkStatus = (id
|
|
34
|
+
const checkStatus = (id) => {
|
|
35
35
|
const query = `{
|
|
36
36
|
findTransaction(
|
|
37
37
|
filterOptions: {byId:"${id}"}
|