@typus/typus-sdk 1.0.85 → 1.0.86
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.
|
@@ -41,6 +41,7 @@ var token_1 = require("../token");
|
|
|
41
41
|
function getUserHistory(provider, originPackage, sender, startTimeMs) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
43
|
var senderFilter, result, txHistory, nextPage;
|
|
44
|
+
var _this = this;
|
|
44
45
|
return __generator(this, function (_a) {
|
|
45
46
|
switch (_a.label) {
|
|
46
47
|
case 0:
|
|
@@ -67,9 +68,26 @@ function getUserHistory(provider, originPackage, sender, startTimeMs) {
|
|
|
67
68
|
return [3 /*break*/, 6];
|
|
68
69
|
}
|
|
69
70
|
return [3 /*break*/, 3];
|
|
70
|
-
case 6:
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
case 6: return [4 /*yield*/, txHistory.reduce(function (promise, currentValue) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
var tx, i;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0: return [4 /*yield*/, promise];
|
|
76
|
+
case 1:
|
|
77
|
+
tx = _a.sent();
|
|
78
|
+
if (currentValue.Action == "IncentiveNewBid") {
|
|
79
|
+
i = tx.findIndex(function (x) { return x.txDigest == currentValue.txDigest && x.Action == "NewBid"; });
|
|
80
|
+
tx[i].BidPaidWithIncentive = tx[i].BidPaid - currentValue.IncentiveValue;
|
|
81
|
+
tx[i].IncentiveValue = currentValue.IncentiveValue;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
tx.push(currentValue);
|
|
85
|
+
}
|
|
86
|
+
return [2 /*return*/, tx];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); }, Promise.resolve(new Array()))];
|
|
90
|
+
case 7: return [2 /*return*/, _a.sent()];
|
|
73
91
|
}
|
|
74
92
|
});
|
|
75
93
|
});
|
|
@@ -86,7 +104,7 @@ function parseTxHistory(datas, originPackage) {
|
|
|
86
104
|
return type.startsWith(originPackage);
|
|
87
105
|
})
|
|
88
106
|
.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
89
|
-
var txHistory, functionType, action, matches, typeArgs, assets, asset, b_asset, parsedJson
|
|
107
|
+
var txHistory, functionType, action, matches, typeArgs, assets, asset, b_asset, parsedJson;
|
|
90
108
|
var _a;
|
|
91
109
|
return __generator(this, function (_b) {
|
|
92
110
|
switch (_b.label) {
|
|
@@ -102,24 +120,20 @@ function parseTxHistory(datas, originPackage) {
|
|
|
102
120
|
asset = action == "NewBid" ? assets[2] : assets[0];
|
|
103
121
|
b_asset = assets[1];
|
|
104
122
|
parsedJson = event.parsedJson;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
BidSize: Number(parsedJson.size) / Math.pow(10, (0, token_1.assetToDecimal)(asset)),
|
|
120
|
-
BidPaid: Number(parsedJson.coin_value) / Math.pow(10, (0, token_1.assetToDecimal)(b_asset)),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
+
txHistory.push({
|
|
124
|
+
Vault: parsedJson.index,
|
|
125
|
+
Action: action,
|
|
126
|
+
Date: new Date(Number(event.timestampMs)),
|
|
127
|
+
txDigest: event.id.txDigest,
|
|
128
|
+
Asset: asset,
|
|
129
|
+
Amount: Number(parsedJson.amount) / Math.pow(10, (0, token_1.assetToDecimal)(asset)),
|
|
130
|
+
Fee: Number(parsedJson.fee) / Math.pow(10, (0, token_1.assetToDecimal)(asset)),
|
|
131
|
+
BidSize: Number(parsedJson.size) / Math.pow(10, (0, token_1.assetToDecimal)(asset)),
|
|
132
|
+
BidPaid: Number(parsedJson.coin_value) / Math.pow(10, (0, token_1.assetToDecimal)(b_asset)),
|
|
133
|
+
BidPaidWithIncentive: undefined,
|
|
134
|
+
BidPaidAsset: b_asset,
|
|
135
|
+
IncentiveValue: Number(parsedJson.incentive_value) / Math.pow(10, (0, token_1.assetToDecimal)(asset)),
|
|
136
|
+
});
|
|
123
137
|
return [2 /*return*/, txHistory];
|
|
124
138
|
}
|
|
125
139
|
return [2 /*return*/];
|