hive-keychain-commons 1.7.2 → 1.7.3
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/utils/vsc.utils.d.ts +1 -1
- package/lib/utils/vsc.utils.js +5 -19
- package/package.json +1 -1
package/lib/utils/vsc.utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { RequestVscStaking, RequestVscTransfer, RequestVscWithdrawal } from '../
|
|
|
2
2
|
import { VscHistoryItem, VscHistoryType, VscStatus } from '../interfaces/vsc';
|
|
3
3
|
export declare const VscUtils: {
|
|
4
4
|
checkStatus: (id: string, type: VscHistoryType) => Promise<VscStatus>;
|
|
5
|
-
waitForStatus: (id: string, type: VscHistoryType,
|
|
5
|
+
waitForStatus: (id: string, type: VscHistoryType, 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,12 +17,14 @@ 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, type,
|
|
20
|
+
const waitForStatus = (id, type, 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
|
+
const wait = 500;
|
|
24
|
+
const maxIterations = (timeoutSeconds / wait) * 1000;
|
|
23
25
|
while (iterations < maxIterations) {
|
|
24
26
|
status = yield checkStatus(id, type);
|
|
25
|
-
if (status ===
|
|
27
|
+
if (status === endAtStatus || status === vsc_1.VscStatus.FAILED)
|
|
26
28
|
return status;
|
|
27
29
|
iterations++;
|
|
28
30
|
yield new Promise((resolve) => setTimeout(resolve, wait));
|
|
@@ -30,29 +32,13 @@ const waitForStatus = (id, type, maxIterations = 20, wait = 500) => __awaiter(vo
|
|
|
30
32
|
return status;
|
|
31
33
|
});
|
|
32
34
|
const checkStatus = (id, type) => {
|
|
33
|
-
|
|
34
|
-
if (type === vsc_1.VscHistoryType.CONTRACT_CALL ||
|
|
35
|
-
type === vsc_1.VscHistoryType.WITHDRAW ||
|
|
36
|
-
type === vsc_1.VscHistoryType.STAKING ||
|
|
37
|
-
type === vsc_1.VscHistoryType.UNSTAKING ||
|
|
38
|
-
type === vsc_1.VscHistoryType.TRANSFER) {
|
|
39
|
-
query = `{
|
|
35
|
+
const query = `{
|
|
40
36
|
findTransaction(
|
|
41
37
|
filterOptions: {byId:"${id}"}
|
|
42
38
|
) {
|
|
43
39
|
status
|
|
44
40
|
}
|
|
45
41
|
}`;
|
|
46
|
-
}
|
|
47
|
-
else if (type === vsc_1.VscHistoryType.DEPOSIT) {
|
|
48
|
-
query = `{
|
|
49
|
-
findLedgerTXs(filterOptions: {byTxId: "${id}"}) {
|
|
50
|
-
|
|
51
|
-
id
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}`;
|
|
55
|
-
}
|
|
56
42
|
return fetchQuery(query).then((res) => {
|
|
57
43
|
var _a, _b, _c, _d, _e, _f;
|
|
58
44
|
if ((_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.findTransaction) === null || _b === void 0 ? void 0 : _b[0])
|