@typus/typus-sdk 1.1.18 → 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.
@@ -0,0 +1,40 @@
1
+ import { JsonRpcProvider } from "@mysten/sui.js";
2
+ export declare function getPlaygrounds(provider: JsonRpcProvider, diceRegistry: string): Promise<Playground[]>;
3
+ export interface Playground {
4
+ id: string;
5
+ house_whitelist: string[];
6
+ public_key: string;
7
+ num_of_games: string;
8
+ stake_token: string;
9
+ opened_games: Map<string, Game>;
10
+ game_config: GameConfig;
11
+ is_active: boolean;
12
+ }
13
+ export interface GameConfig {
14
+ max_stake: string;
15
+ min_stake: string;
16
+ stake_lot_size: string;
17
+ base_exp_divisor: string;
18
+ losses_multiplier_bp: string;
19
+ critical_hits_multiplier_bp: string;
20
+ }
21
+ export interface Game {
22
+ game_id: string;
23
+ player: string;
24
+ stake_amount: string;
25
+ guess_1: string | null;
26
+ larger_than_1: boolean | null;
27
+ vrf_input_1: number[] | null;
28
+ guess_2: string | null;
29
+ larger_than_2: boolean | null;
30
+ vrf_input_2: number[] | null;
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 {};
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getHistory = exports.getPlaygrounds = void 0;
40
+ var token_1 = require("../token");
41
+ function getPlaygrounds(provider, diceRegistry) {
42
+ return __awaiter(this, void 0, void 0, function () {
43
+ var playgroundIds, objects, result;
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: diceRegistry })];
47
+ case 1:
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; });
51
+ return [4 /*yield*/, provider.multiGetObjects({
52
+ ids: playgroundIds,
53
+ options: { showContent: true },
54
+ })];
55
+ case 2:
56
+ objects = _a.sent();
57
+ result = objects
58
+ // @ts-ignore
59
+ .filter(function (object) { var _a, _b; return (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.type.endsWith("Playground"); })
60
+ .map(function (object) {
61
+ var _a;
62
+ // @ts-ignore
63
+ var fields = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content.fields;
64
+ // console.log(fields);
65
+ var opened_games = fields.opened_games.fields.contents.reduce(function (acc, curr) {
66
+ acc.set(curr.fields.key, curr.fields.value.fields);
67
+ return acc;
68
+ }, new Map());
69
+ var game_config = fields.game_config.fields;
70
+ // console.log(opened_games);
71
+ // console.log(game_config);
72
+ var playground = {
73
+ id: fields.id.id,
74
+ house_whitelist: fields.house_whitelist,
75
+ public_key: fields.public_key,
76
+ num_of_games: fields.num_of_games,
77
+ stake_token: fields.stake_token.fields.name,
78
+ opened_games: opened_games,
79
+ game_config: game_config,
80
+ is_active: fields.is_active,
81
+ };
82
+ return playground;
83
+ });
84
+ return [2 /*return*/, result];
85
+ }
86
+ });
87
+ });
88
+ }
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;
@@ -22,4 +22,6 @@ registry: string, index: string, coins: string[], amount: string): Promise<Trans
22
22
  ctx: &mut TxContext
23
23
  )
24
24
  */
25
- export declare function playGuessTx(gasBudget: number, packageId: string, registry: string, index: string, game_id: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
25
+ export declare function playGuessTx(gasBudget: number, packageId: string, registry: string, index: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
26
+ export declare function newGamePlayGuessTx(gasBudget: number, packageId: string, typeArguments: string[], // [TOKEN]
27
+ registry: string, index: string, coins: string[], amount: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
@@ -35,8 +35,24 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
38
54
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.playGuessTx = exports.newGameTx = void 0;
55
+ exports.newGamePlayGuessTx = exports.playGuessTx = exports.newGameTx = void 0;
40
56
  var sui_js_1 = require("@mysten/sui.js");
41
57
  /**
42
58
  public(friend) entry fun new_game<TOKEN>(
@@ -54,9 +70,9 @@ registry, index, coins, amount) {
54
70
  return __generator(this, function (_a) {
55
71
  tx = new sui_js_1.TransactionBlock();
56
72
  tx.moveCall({
57
- target: "".concat(packageId, "::tails_exp_dice::new_game"),
73
+ target: "".concat(packageId, "::tails_exp::new_game"),
58
74
  typeArguments: typeArguments,
59
- arguments: [tx.pure(registry), tx.pure(index), tx.makeMoveVec({ objects: coins.map(function (id) { return tx.object(id); }) }), tx.pure(amount)],
75
+ arguments: [tx.object(registry), tx.pure(index), tx.makeMoveVec({ objects: coins.map(function (id) { return tx.object(id); }) }), tx.pure(amount)],
60
76
  });
61
77
  tx.setGasBudget(gasBudget);
62
78
  return [2 /*return*/, tx];
@@ -76,18 +92,17 @@ exports.newGameTx = newGameTx;
76
92
  ctx: &mut TxContext
77
93
  )
78
94
  */
79
- function playGuessTx(gasBudget, packageId, registry, index, game_id, guess_1, larger_than_1, guess_2, larger_than_2) {
95
+ function playGuessTx(gasBudget, packageId, registry, index, guess_1, larger_than_1, guess_2, larger_than_2) {
80
96
  return __awaiter(this, void 0, void 0, function () {
81
97
  var tx;
82
98
  return __generator(this, function (_a) {
83
99
  tx = new sui_js_1.TransactionBlock();
84
100
  tx.moveCall({
85
- target: "".concat(packageId, "::tails_exp_dice::play_guess"),
101
+ target: "".concat(packageId, "::tails_exp::play_guess"),
86
102
  typeArguments: [],
87
103
  arguments: [
88
- tx.pure(registry),
104
+ tx.object(registry),
89
105
  tx.pure(index),
90
- tx.pure(game_id),
91
106
  tx.pure(guess_1),
92
107
  tx.pure(larger_than_1),
93
108
  tx.pure(guess_2),
@@ -100,3 +115,48 @@ function playGuessTx(gasBudget, packageId, registry, index, game_id, guess_1, la
100
115
  });
101
116
  }
102
117
  exports.playGuessTx = playGuessTx;
118
+ function newGamePlayGuessTx(gasBudget, packageId, typeArguments, // [TOKEN]
119
+ registry, index, coins, amount, guess_1, larger_than_1, guess_2, larger_than_2) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ var tx, _a, coin;
122
+ return __generator(this, function (_b) {
123
+ tx = new sui_js_1.TransactionBlock();
124
+ if (typeArguments[0] == "0x2::sui::SUI" ||
125
+ typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
126
+ _a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), coin = _a[0];
127
+ tx.moveCall({
128
+ target: "".concat(packageId, "::tails_exp::new_game"),
129
+ typeArguments: typeArguments,
130
+ arguments: [tx.object(registry), tx.pure(index), tx.makeMoveVec({ objects: [coin] }), tx.pure(amount)],
131
+ });
132
+ }
133
+ else {
134
+ tx.moveCall({
135
+ target: "".concat(packageId, "::tails_exp::new_game"),
136
+ typeArguments: typeArguments,
137
+ arguments: [
138
+ tx.object(registry),
139
+ tx.pure(index),
140
+ tx.makeMoveVec({ objects: coins.map(function (id) { return tx.object(id); }) }),
141
+ tx.pure(amount),
142
+ ],
143
+ });
144
+ }
145
+ tx.moveCall({
146
+ target: "".concat(packageId, "::tails_exp::play_guess"),
147
+ typeArguments: [],
148
+ arguments: [
149
+ tx.object(registry),
150
+ tx.pure(index),
151
+ tx.pure(guess_1),
152
+ tx.pure(larger_than_1),
153
+ tx.pure(guess_2),
154
+ tx.pure(larger_than_2),
155
+ ],
156
+ });
157
+ tx.setGasBudget(gasBudget);
158
+ return [2 /*return*/, tx];
159
+ });
160
+ });
161
+ }
162
+ exports.newGamePlayGuessTx = newGamePlayGuessTx;
@@ -112,6 +112,12 @@ function parseTxHistory(datas, originPackage, vaults) {
112
112
  case "2":
113
113
  period = "Monthly";
114
114
  break;
115
+ case "3":
116
+ period = "Hourly";
117
+ break;
118
+ case "4":
119
+ period = "10 Minutes";
120
+ break;
115
121
  default:
116
122
  period = "";
117
123
  break;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.1.18",
5
+ "version": "1.1.20",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",