@typus/typus-sdk 1.1.19 → 1.1.20
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.
|
@@ -29,3 +29,12 @@ export interface Game {
|
|
|
29
29
|
larger_than_2: boolean | null;
|
|
30
30
|
vrf_input_2: number[] | null;
|
|
31
31
|
}
|
|
32
|
+
export declare function getHistory(provider: JsonRpcProvider, dicePackage: string, playgrounds: Playground[]): Promise<DrawDisplay[]>;
|
|
33
|
+
interface DrawDisplay {
|
|
34
|
+
player: string;
|
|
35
|
+
guess_1: string;
|
|
36
|
+
guess_2: string;
|
|
37
|
+
bet_amount: string;
|
|
38
|
+
exp: string;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -36,7 +36,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getPlaygrounds = void 0;
|
|
39
|
+
exports.getHistory = exports.getPlaygrounds = void 0;
|
|
40
|
+
var token_1 = require("../token");
|
|
40
41
|
function getPlaygrounds(provider, diceRegistry) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
43
|
var playgroundIds, objects, result;
|
|
@@ -44,7 +45,9 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
44
45
|
switch (_a.label) {
|
|
45
46
|
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: diceRegistry })];
|
|
46
47
|
case 1:
|
|
47
|
-
playgroundIds = (_a.sent()).data
|
|
48
|
+
playgroundIds = (_a.sent()).data
|
|
49
|
+
.sort(function (a, b) { return Number(a.name.value) - Number(b.name.value); })
|
|
50
|
+
.map(function (x) { return x.objectId; });
|
|
48
51
|
return [4 /*yield*/, provider.multiGetObjects({
|
|
49
52
|
ids: playgroundIds,
|
|
50
53
|
options: { showContent: true },
|
|
@@ -84,3 +87,42 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
89
|
exports.getPlaygrounds = getPlaygrounds;
|
|
90
|
+
function getHistory(provider, dicePackage, playgrounds) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var eventFilter, events, result;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
eventFilter = {
|
|
97
|
+
MoveEventType: "".concat(dicePackage, "::tails_exp::Draw"),
|
|
98
|
+
};
|
|
99
|
+
return [4 /*yield*/, provider.queryEvents({ query: eventFilter, order: "descending" })];
|
|
100
|
+
case 1:
|
|
101
|
+
events = _a.sent();
|
|
102
|
+
result = events.data.map(function (event) {
|
|
103
|
+
var drawEvent = event.parsedJson;
|
|
104
|
+
var playground = playgrounds[Number(drawEvent.index)];
|
|
105
|
+
var coinType = "0x" + playground.stake_token;
|
|
106
|
+
var asset = (0, token_1.typeArgToAsset)(coinType);
|
|
107
|
+
var decimal = (0, token_1.assetToDecimal)(asset);
|
|
108
|
+
var guess_1 = drawEvent.larger_than_1
|
|
109
|
+
? "Roll Over ".concat(Number(drawEvent.guess_1) / 100)
|
|
110
|
+
: "Roll Under ".concat(Number(drawEvent.guess_1) / 100);
|
|
111
|
+
var guess_2 = drawEvent.larger_than_2
|
|
112
|
+
? "Roll Over ".concat(Number(drawEvent.guess_2) / 100)
|
|
113
|
+
: "Roll Under ".concat(Number(drawEvent.guess_2) / 100);
|
|
114
|
+
var display = {
|
|
115
|
+
player: drawEvent.player,
|
|
116
|
+
guess_1: guess_1,
|
|
117
|
+
guess_2: guess_2,
|
|
118
|
+
bet_amount: "".concat(Number(drawEvent.stake_amount) / Math.pow(10, decimal), " ").concat(asset),
|
|
119
|
+
exp: "".concat(Number(drawEvent.exp), " EXP"),
|
|
120
|
+
};
|
|
121
|
+
return display;
|
|
122
|
+
});
|
|
123
|
+
return [2 /*return*/, result];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
exports.getHistory = getHistory;
|