@typus/typus-sdk 1.1.17 → 1.1.19

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,31 @@
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
+ }
@@ -0,0 +1,86 @@
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.getPlaygrounds = void 0;
40
+ function getPlaygrounds(provider, diceRegistry) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var playgroundIds, objects, result;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: diceRegistry })];
46
+ case 1:
47
+ playgroundIds = (_a.sent()).data.map(function (x) { return x.objectId; });
48
+ return [4 /*yield*/, provider.multiGetObjects({
49
+ ids: playgroundIds,
50
+ options: { showContent: true },
51
+ })];
52
+ case 2:
53
+ objects = _a.sent();
54
+ result = objects
55
+ // @ts-ignore
56
+ .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"); })
57
+ .map(function (object) {
58
+ var _a;
59
+ // @ts-ignore
60
+ var fields = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content.fields;
61
+ // console.log(fields);
62
+ var opened_games = fields.opened_games.fields.contents.reduce(function (acc, curr) {
63
+ acc.set(curr.fields.key, curr.fields.value.fields);
64
+ return acc;
65
+ }, new Map());
66
+ var game_config = fields.game_config.fields;
67
+ // console.log(opened_games);
68
+ // console.log(game_config);
69
+ var playground = {
70
+ id: fields.id.id,
71
+ house_whitelist: fields.house_whitelist,
72
+ public_key: fields.public_key,
73
+ num_of_games: fields.num_of_games,
74
+ stake_token: fields.stake_token.fields.name,
75
+ opened_games: opened_games,
76
+ game_config: game_config,
77
+ is_active: fields.is_active,
78
+ };
79
+ return playground;
80
+ });
81
+ return [2 /*return*/, result];
82
+ }
83
+ });
84
+ });
85
+ }
86
+ exports.getPlaygrounds = getPlaygrounds;
@@ -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;
@@ -150,10 +156,13 @@ function parseTxHistory(datas, originPackage, vaults) {
150
156
  break;
151
157
  case "2":
152
158
  optionType = "Call Spread";
159
+ break;
153
160
  case "3":
154
161
  optionType = "Put Spread";
162
+ break;
155
163
  case "4":
156
164
  optionType = "Capped Call";
165
+ break;
157
166
  default:
158
167
  optionType = "";
159
168
  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.17",
5
+ "version": "1.1.19",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",