@typus/typus-sdk 1.3.2 → 1.3.21

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,155 @@
1
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
+ /**
3
+ public fun stake_tails(
4
+ version: &mut Version,
5
+ tails_staking_registry: &mut TailsStakingRegistry,
6
+ kiosk: &mut Kiosk,
7
+ kiosk_owner_cap: &KioskOwnerCap,
8
+ tails: address,
9
+ coin: Coin<SUI>,
10
+ ctx: &mut TxContext,
11
+ ) {
12
+ */
13
+ export declare function getStakeTailsTx(input: {
14
+ tx: TransactionBlock;
15
+ typusPackageId: string;
16
+ typusEcosystemVersion: string;
17
+ typusTailsStakingRegistry: string;
18
+ kiosk: string;
19
+ kioskCap: string;
20
+ tails: string;
21
+ fee: string;
22
+ personalKioskPackageId: string | undefined;
23
+ }): Promise<TransactionBlock>;
24
+ /**
25
+ public fun unstake_tails(
26
+ version: &mut Version,
27
+ tails_staking_registry: &mut TailsStakingRegistry,
28
+ kiosk: &mut Kiosk,
29
+ kiosk_owner_cap: &KioskOwnerCap,
30
+ tails: address,
31
+ ctx: &TxContext,
32
+ ) {
33
+ */
34
+ export declare function getUnstakeTailsTx(input: {
35
+ tx: TransactionBlock;
36
+ typusPackageId: string;
37
+ typusEcosystemVersion: string;
38
+ typusTailsStakingRegistry: string;
39
+ kiosk: string;
40
+ kioskCap: string;
41
+ tails: string;
42
+ personalKioskPackageId: string | undefined;
43
+ }): Promise<TransactionBlock>;
44
+ /**
45
+ public fun transfer_tails(
46
+ version: &mut Version,
47
+ tails_staking_registry: &TailsStakingRegistry,
48
+ kiosk: &mut Kiosk,
49
+ kiosk_owner_cap: &KioskOwnerCap,
50
+ tails: address,
51
+ coin: Coin<SUI>,
52
+ recipient: address,
53
+ ctx: &mut TxContext,
54
+ ) {
55
+ */
56
+ export declare function getTransferTailsTx(input: {
57
+ tx: TransactionBlock;
58
+ typusPackageId: string;
59
+ typusEcosystemVersion: string;
60
+ typusTailsStakingRegistry: string;
61
+ kiosk: string;
62
+ kioskCap: string;
63
+ tails: string;
64
+ recipient: string;
65
+ fee: string;
66
+ personalKioskPackageId: string | undefined;
67
+ }): Promise<TransactionBlock>;
68
+ /**
69
+ entry fun daily_sign_up(
70
+ version: &Version,
71
+ tails_staking_registry: &mut TailsStakingRegistry,
72
+ clock: &Clock,
73
+ ctx: &TxContext,
74
+ ) {
75
+ */
76
+ export declare function getDailySignUpTx(input: {
77
+ tx: TransactionBlock;
78
+ typusPackageId: string;
79
+ typusEcosystemVersion: string;
80
+ typusTailsStakingRegistry: string;
81
+ }): Promise<TransactionBlock>;
82
+ /**
83
+ public fun claim_profit_sharing<TOKEN>(
84
+ version: &mut Version,
85
+ tails_staking_registry: &mut TailsStakingRegistry,
86
+ ctx: &mut TxContext,
87
+ ): Balance<TOKEN>
88
+ */
89
+ export declare function getClaimProfitSharingTx(input: {
90
+ tx: TransactionBlock;
91
+ typusPackageId: string;
92
+ typusEcosystemVersion: string;
93
+ typusTailsStakingRegistry: string;
94
+ typeArguments: string[];
95
+ user: string;
96
+ }): Promise<TransactionBlock>;
97
+ /**
98
+ entry fun level_up(
99
+ version: &Version,
100
+ tails_staking_registry: &mut TailsStakingRegistry,
101
+ tails: address,
102
+ raw: bool,
103
+ ) {
104
+ */
105
+ export declare function getLevelUpTx(input: {
106
+ tx: TransactionBlock;
107
+ typusPackageId: string;
108
+ typusEcosystemVersion: string;
109
+ typusTailsStakingRegistry: string;
110
+ tails: string;
111
+ raw: boolean;
112
+ }): Promise<TransactionBlock>;
113
+ /**
114
+ entry fun exp_up(
115
+ version: &Version,
116
+ tails_staking_registry: &mut TailsStakingRegistry,
117
+ typus_user_registry: &mut TypusUserRegistry,
118
+ tails: address,
119
+ amount: u64,
120
+ ctx: &TxContext,
121
+ ) {
122
+ */
123
+ export declare function getExpUpTx(input: {
124
+ tx: TransactionBlock;
125
+ typusPackageId: string;
126
+ typusEcosystemVersion: string;
127
+ typusTailsStakingRegistry: string;
128
+ typusUserRegistry: string;
129
+ tails: string;
130
+ amount: string;
131
+ }): Promise<TransactionBlock>;
132
+ /**
133
+ entry fun exp_up_without_staking(
134
+ version: &Version,
135
+ tails_staking_registry: &TailsStakingRegistry,
136
+ typus_user_registry: &mut TypusUserRegistry,
137
+ kiosk: &mut Kiosk,
138
+ kiosk_owner_cap: &KioskOwnerCap,
139
+ tails: address,
140
+ amount: u64,
141
+ ctx: &TxContext,
142
+ ) {
143
+ */
144
+ export declare function getExpUpWithoutStakingTx(input: {
145
+ tx: TransactionBlock;
146
+ typusPackageId: string;
147
+ typusEcosystemVersion: string;
148
+ typusTailsStakingRegistry: string;
149
+ typusUserRegistry: string;
150
+ kiosk: string;
151
+ kioskCap: string;
152
+ tails: string;
153
+ amount: string;
154
+ personalKioskPackageId: string | undefined;
155
+ }): Promise<TransactionBlock>;
@@ -0,0 +1,388 @@
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
+ 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
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.getExpUpWithoutStakingTx = exports.getExpUpTx = exports.getLevelUpTx = exports.getClaimProfitSharingTx = exports.getDailySignUpTx = exports.getTransferTailsTx = exports.getUnstakeTailsTx = exports.getStakeTailsTx = void 0;
56
+ var constants_1 = require("../../constants");
57
+ /**
58
+ public fun stake_tails(
59
+ version: &mut Version,
60
+ tails_staking_registry: &mut TailsStakingRegistry,
61
+ kiosk: &mut Kiosk,
62
+ kiosk_owner_cap: &KioskOwnerCap,
63
+ tails: address,
64
+ coin: Coin<SUI>,
65
+ ctx: &mut TxContext,
66
+ ) {
67
+ */
68
+ function getStakeTailsTx(input) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var _a, coin, _b, personalKioskCap, borrow;
71
+ return __generator(this, function (_c) {
72
+ _a = __read(input.tx.splitCoins(input.tx.gas, [input.tx.pure(input.fee)]), 1), coin = _a[0];
73
+ if (input.personalKioskPackageId) {
74
+ _b = __read(input.tx.moveCall({
75
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::borrow_val"),
76
+ arguments: [input.tx.object(input.kioskCap)],
77
+ }), 2), personalKioskCap = _b[0], borrow = _b[1];
78
+ input.tx.moveCall({
79
+ target: "".concat(input.typusPackageId, "::tails_staking::stake_tails"),
80
+ typeArguments: [],
81
+ arguments: [
82
+ input.tx.object(input.typusEcosystemVersion),
83
+ input.tx.object(input.typusTailsStakingRegistry),
84
+ input.tx.object(input.kiosk),
85
+ personalKioskCap,
86
+ input.tx.pure(input.tails),
87
+ coin,
88
+ ],
89
+ });
90
+ input.tx.moveCall({
91
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::return_val"),
92
+ arguments: [input.tx.object(input.kioskCap), personalKioskCap, borrow],
93
+ });
94
+ }
95
+ else {
96
+ input.tx.moveCall({
97
+ target: "".concat(input.typusPackageId, "::tails_staking::stake_tails"),
98
+ typeArguments: [],
99
+ arguments: [
100
+ input.tx.object(input.typusEcosystemVersion),
101
+ input.tx.object(input.typusTailsStakingRegistry),
102
+ input.tx.object(input.kiosk),
103
+ input.tx.object(input.kioskCap),
104
+ input.tx.pure(input.tails),
105
+ coin,
106
+ ],
107
+ });
108
+ }
109
+ return [2 /*return*/, input.tx];
110
+ });
111
+ });
112
+ }
113
+ exports.getStakeTailsTx = getStakeTailsTx;
114
+ /**
115
+ public fun unstake_tails(
116
+ version: &mut Version,
117
+ tails_staking_registry: &mut TailsStakingRegistry,
118
+ kiosk: &mut Kiosk,
119
+ kiosk_owner_cap: &KioskOwnerCap,
120
+ tails: address,
121
+ ctx: &TxContext,
122
+ ) {
123
+ */
124
+ function getUnstakeTailsTx(input) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var _a, personalKioskCap, borrow;
127
+ return __generator(this, function (_b) {
128
+ if (input.personalKioskPackageId) {
129
+ _a = __read(input.tx.moveCall({
130
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::borrow_val"),
131
+ arguments: [input.tx.object(input.kioskCap)],
132
+ }), 2), personalKioskCap = _a[0], borrow = _a[1];
133
+ input.tx.moveCall({
134
+ target: "".concat(input.typusPackageId, "::tails_staking::unstake_tails"),
135
+ typeArguments: [],
136
+ arguments: [
137
+ input.tx.object(input.typusEcosystemVersion),
138
+ input.tx.object(input.typusTailsStakingRegistry),
139
+ input.tx.object(input.kiosk),
140
+ personalKioskCap,
141
+ input.tx.pure(input.tails),
142
+ ],
143
+ });
144
+ input.tx.moveCall({
145
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::return_val"),
146
+ arguments: [input.tx.object(input.kioskCap), personalKioskCap, borrow],
147
+ });
148
+ }
149
+ else {
150
+ input.tx.moveCall({
151
+ target: "".concat(input.typusPackageId, "::tails_staking::unstake_tails"),
152
+ typeArguments: [],
153
+ arguments: [
154
+ input.tx.object(input.typusEcosystemVersion),
155
+ input.tx.object(input.typusTailsStakingRegistry),
156
+ input.tx.object(input.kiosk),
157
+ input.tx.object(input.kioskCap),
158
+ input.tx.pure(input.tails),
159
+ ],
160
+ });
161
+ }
162
+ return [2 /*return*/, input.tx];
163
+ });
164
+ });
165
+ }
166
+ exports.getUnstakeTailsTx = getUnstakeTailsTx;
167
+ /**
168
+ public fun transfer_tails(
169
+ version: &mut Version,
170
+ tails_staking_registry: &TailsStakingRegistry,
171
+ kiosk: &mut Kiosk,
172
+ kiosk_owner_cap: &KioskOwnerCap,
173
+ tails: address,
174
+ coin: Coin<SUI>,
175
+ recipient: address,
176
+ ctx: &mut TxContext,
177
+ ) {
178
+ */
179
+ function getTransferTailsTx(input) {
180
+ return __awaiter(this, void 0, void 0, function () {
181
+ var _a, coin, _b, personalKioskCap, borrow;
182
+ return __generator(this, function (_c) {
183
+ _a = __read(input.tx.splitCoins(input.tx.gas, [input.tx.pure(input.fee)]), 1), coin = _a[0];
184
+ if (input.personalKioskPackageId) {
185
+ _b = __read(input.tx.moveCall({
186
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::borrow_val"),
187
+ arguments: [input.tx.object(input.kioskCap)],
188
+ }), 2), personalKioskCap = _b[0], borrow = _b[1];
189
+ input.tx.moveCall({
190
+ target: "".concat(input.typusPackageId, "::tails_staking::transfer_tails"),
191
+ typeArguments: [],
192
+ arguments: [
193
+ input.tx.object(input.typusEcosystemVersion),
194
+ input.tx.object(input.typusTailsStakingRegistry),
195
+ input.tx.object(input.kiosk),
196
+ personalKioskCap,
197
+ input.tx.pure(input.tails),
198
+ coin,
199
+ input.tx.pure(input.recipient),
200
+ ],
201
+ });
202
+ input.tx.moveCall({
203
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::return_val"),
204
+ arguments: [input.tx.object(input.kioskCap), personalKioskCap, borrow],
205
+ });
206
+ }
207
+ else {
208
+ input.tx.moveCall({
209
+ target: "".concat(input.typusPackageId, "::tails_staking::transfer_tails"),
210
+ typeArguments: [],
211
+ arguments: [
212
+ input.tx.object(input.typusEcosystemVersion),
213
+ input.tx.object(input.typusTailsStakingRegistry),
214
+ input.tx.object(input.kiosk),
215
+ input.tx.object(input.kioskCap),
216
+ input.tx.pure(input.tails),
217
+ coin,
218
+ input.tx.pure(input.recipient),
219
+ ],
220
+ });
221
+ }
222
+ return [2 /*return*/, input.tx];
223
+ });
224
+ });
225
+ }
226
+ exports.getTransferTailsTx = getTransferTailsTx;
227
+ /**
228
+ entry fun daily_sign_up(
229
+ version: &Version,
230
+ tails_staking_registry: &mut TailsStakingRegistry,
231
+ clock: &Clock,
232
+ ctx: &TxContext,
233
+ ) {
234
+ */
235
+ function getDailySignUpTx(input) {
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var result;
238
+ return __generator(this, function (_a) {
239
+ result = input.tx.moveCall({
240
+ target: "".concat(input.typusPackageId, "::tails_staking::daily_sign_up"),
241
+ typeArguments: [],
242
+ arguments: [input.tx.object(input.typusEcosystemVersion), input.tx.object(input.typusTailsStakingRegistry), input.tx.pure(constants_1.CLOCK)],
243
+ });
244
+ return [2 /*return*/, input.tx];
245
+ });
246
+ });
247
+ }
248
+ exports.getDailySignUpTx = getDailySignUpTx;
249
+ /**
250
+ public fun claim_profit_sharing<TOKEN>(
251
+ version: &mut Version,
252
+ tails_staking_registry: &mut TailsStakingRegistry,
253
+ ctx: &mut TxContext,
254
+ ): Balance<TOKEN>
255
+ */
256
+ function getClaimProfitSharingTx(input) {
257
+ return __awaiter(this, void 0, void 0, function () {
258
+ var result;
259
+ return __generator(this, function (_a) {
260
+ result = input.tx.moveCall({
261
+ target: "".concat(input.typusPackageId, "::tails_staking::claim_profit_sharing"),
262
+ typeArguments: input.typeArguments,
263
+ arguments: [input.tx.object(input.typusEcosystemVersion), input.tx.object(input.typusTailsStakingRegistry)],
264
+ });
265
+ input.tx.moveCall({
266
+ target: "".concat(input.typusPackageId, "::utility::transfer_balance"),
267
+ typeArguments: input.typeArguments,
268
+ arguments: [input.tx.object(result[0]), input.tx.pure(input.user)],
269
+ });
270
+ return [2 /*return*/, input.tx];
271
+ });
272
+ });
273
+ }
274
+ exports.getClaimProfitSharingTx = getClaimProfitSharingTx;
275
+ /**
276
+ entry fun level_up(
277
+ version: &Version,
278
+ tails_staking_registry: &mut TailsStakingRegistry,
279
+ tails: address,
280
+ raw: bool,
281
+ ) {
282
+ */
283
+ function getLevelUpTx(input) {
284
+ return __awaiter(this, void 0, void 0, function () {
285
+ return __generator(this, function (_a) {
286
+ input.tx.moveCall({
287
+ target: "".concat(input.typusPackageId, "::tails_staking::level_up"),
288
+ typeArguments: [],
289
+ arguments: [
290
+ input.tx.object(input.typusEcosystemVersion),
291
+ input.tx.object(input.typusTailsStakingRegistry),
292
+ input.tx.pure(input.tails),
293
+ input.tx.pure(input.raw),
294
+ ],
295
+ });
296
+ return [2 /*return*/, input.tx];
297
+ });
298
+ });
299
+ }
300
+ exports.getLevelUpTx = getLevelUpTx;
301
+ /**
302
+ entry fun exp_up(
303
+ version: &Version,
304
+ tails_staking_registry: &mut TailsStakingRegistry,
305
+ typus_user_registry: &mut TypusUserRegistry,
306
+ tails: address,
307
+ amount: u64,
308
+ ctx: &TxContext,
309
+ ) {
310
+ */
311
+ function getExpUpTx(input) {
312
+ return __awaiter(this, void 0, void 0, function () {
313
+ return __generator(this, function (_a) {
314
+ input.tx.moveCall({
315
+ target: "".concat(input.typusPackageId, "::tails_staking::exp_up"),
316
+ typeArguments: [],
317
+ arguments: [
318
+ input.tx.object(input.typusEcosystemVersion),
319
+ input.tx.object(input.typusTailsStakingRegistry),
320
+ input.tx.object(input.typusUserRegistry),
321
+ input.tx.pure(input.tails),
322
+ input.tx.pure(input.amount),
323
+ ],
324
+ });
325
+ return [2 /*return*/, input.tx];
326
+ });
327
+ });
328
+ }
329
+ exports.getExpUpTx = getExpUpTx;
330
+ /**
331
+ entry fun exp_up_without_staking(
332
+ version: &Version,
333
+ tails_staking_registry: &TailsStakingRegistry,
334
+ typus_user_registry: &mut TypusUserRegistry,
335
+ kiosk: &mut Kiosk,
336
+ kiosk_owner_cap: &KioskOwnerCap,
337
+ tails: address,
338
+ amount: u64,
339
+ ctx: &TxContext,
340
+ ) {
341
+ */
342
+ function getExpUpWithoutStakingTx(input) {
343
+ return __awaiter(this, void 0, void 0, function () {
344
+ var _a, personalKioskCap, borrow;
345
+ return __generator(this, function (_b) {
346
+ if (input.personalKioskPackageId) {
347
+ _a = __read(input.tx.moveCall({
348
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::borrow_val"),
349
+ arguments: [input.tx.object(input.kioskCap)],
350
+ }), 2), personalKioskCap = _a[0], borrow = _a[1];
351
+ input.tx.moveCall({
352
+ target: "".concat(input.typusPackageId, "::tails_staking::exp_up_without_staking"),
353
+ typeArguments: [],
354
+ arguments: [
355
+ input.tx.object(input.typusEcosystemVersion),
356
+ input.tx.object(input.typusTailsStakingRegistry),
357
+ input.tx.object(input.typusUserRegistry),
358
+ input.tx.object(input.kiosk),
359
+ personalKioskCap,
360
+ input.tx.pure(input.tails),
361
+ input.tx.pure(input.amount),
362
+ ],
363
+ });
364
+ input.tx.moveCall({
365
+ target: "".concat(input.personalKioskPackageId, "::personal_kiosk::return_val"),
366
+ arguments: [input.tx.object(input.kioskCap), personalKioskCap, borrow],
367
+ });
368
+ }
369
+ else {
370
+ input.tx.moveCall({
371
+ target: "".concat(input.typusPackageId, "::tails_staking::exp_up_without_staking"),
372
+ typeArguments: [],
373
+ arguments: [
374
+ input.tx.object(input.typusEcosystemVersion),
375
+ input.tx.object(input.typusTailsStakingRegistry),
376
+ input.tx.object(input.typusUserRegistry),
377
+ input.tx.object(input.kiosk),
378
+ input.tx.object(input.kioskCap),
379
+ input.tx.pure(input.tails),
380
+ input.tx.pure(input.amount),
381
+ ],
382
+ });
383
+ }
384
+ return [2 /*return*/, input.tx];
385
+ });
386
+ });
387
+ }
388
+ exports.getExpUpWithoutStakingTx = getExpUpWithoutStakingTx;
@@ -0,0 +1,21 @@
1
+ import { SuiClient } from "@mysten/sui.js/client";
2
+ export declare const SENDER = "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
3
+ export interface StakingInfo {
4
+ user: string;
5
+ tails: string[];
6
+ profits: string[];
7
+ u64Padding: string[];
8
+ }
9
+ export declare function getStakingInfo(input: {
10
+ provider: SuiClient;
11
+ typusPackageId: string;
12
+ typusEcosystemVersion: string;
13
+ typusTailsStakingRegistry: string;
14
+ user: string;
15
+ }): Promise<StakingInfo>;
16
+ export declare function getLevelCounts(input: {
17
+ provider: SuiClient;
18
+ typusPackageId: string;
19
+ typusEcosystemVersion: string;
20
+ typusTailsStakingRegistry: string;
21
+ }): Promise<number[]>;
@@ -0,0 +1,118 @@
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.getLevelCounts = exports.getStakingInfo = exports.SENDER = void 0;
40
+ var transactions_1 = require("@mysten/sui.js/transactions");
41
+ var bcs_1 = require("@mysten/bcs");
42
+ var tools_1 = require("../tools");
43
+ exports.SENDER = "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
44
+ function getStakingInfo(input) {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var transactionBlock, results, bytes, reader, length;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ transactionBlock = new transactions_1.TransactionBlock();
51
+ transactionBlock.moveCall({
52
+ target: "".concat(input.typusPackageId, "::tails_staking::get_staking_info"),
53
+ typeArguments: [],
54
+ arguments: [
55
+ transactionBlock.pure(input.typusEcosystemVersion),
56
+ transactionBlock.pure(input.typusTailsStakingRegistry),
57
+ transactionBlock.pure(input.user),
58
+ ],
59
+ });
60
+ return [4 /*yield*/, input.provider.devInspectTransactionBlock({ sender: exports.SENDER, transactionBlock: transactionBlock })];
61
+ case 1:
62
+ results = (_a.sent()).results;
63
+ bytes = results[results.length - 1].returnValues[0][0];
64
+ reader = new bcs_1.BcsReader(new Uint8Array(bytes));
65
+ length = reader.readULEB();
66
+ if (length > 0) {
67
+ return [2 /*return*/, {
68
+ user: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
69
+ tails: reader.readVec(function (reader) {
70
+ return reader.read64();
71
+ }),
72
+ profits: reader.readVec(function (reader) {
73
+ return reader.read64();
74
+ }),
75
+ u64Padding: reader.readVec(function (reader) {
76
+ return reader.read64();
77
+ }),
78
+ }];
79
+ }
80
+ else {
81
+ return [2 /*return*/, {
82
+ user: input.user,
83
+ tails: [],
84
+ profits: [],
85
+ u64Padding: ["0"],
86
+ }];
87
+ }
88
+ return [2 /*return*/];
89
+ }
90
+ });
91
+ });
92
+ }
93
+ exports.getStakingInfo = getStakingInfo;
94
+ function getLevelCounts(input) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var transactionBlock, results, bytes, reader;
97
+ return __generator(this, function (_a) {
98
+ switch (_a.label) {
99
+ case 0:
100
+ transactionBlock = new transactions_1.TransactionBlock();
101
+ transactionBlock.moveCall({
102
+ target: "".concat(input.typusPackageId, "::tails_staking::get_level_counts"),
103
+ typeArguments: [],
104
+ arguments: [transactionBlock.pure(input.typusEcosystemVersion), transactionBlock.pure(input.typusTailsStakingRegistry)],
105
+ });
106
+ return [4 /*yield*/, input.provider.devInspectTransactionBlock({ sender: exports.SENDER, transactionBlock: transactionBlock })];
107
+ case 1:
108
+ results = (_a.sent()).results;
109
+ bytes = results[results.length - 1].returnValues[0][0];
110
+ reader = new bcs_1.BcsReader(new Uint8Array(bytes));
111
+ return [2 /*return*/, reader.readVec(function (reader) {
112
+ return Number.parseInt(reader.read64());
113
+ })];
114
+ }
115
+ });
116
+ });
117
+ }
118
+ exports.getLevelCounts = getLevelCounts;