@typus/typus-sdk 1.9.2 → 1.9.4

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.
Files changed (31) hide show
  1. package/dist/src/auto-bid/view-function.js +1 -1
  2. package/dist/src/dice/fetch.js +2 -2
  3. package/dist/src/typus/airdrop/view-function.js +2 -0
  4. package/dist/src/typus/leaderboard/view-function.js +2 -0
  5. package/dist/src/typus/tails-staking/view-function.js +4 -0
  6. package/dist/src/typus-dov-single-v2/function/index.d.ts +0 -1
  7. package/dist/src/typus-dov-single-v2/function/index.js +0 -1
  8. package/dist/src/typus-dov-single-v2/view-function.d.ts +3 -0
  9. package/dist/src/typus-dov-single-v2/view-function.js +45 -1
  10. package/dist/src/typus-hedge/user-history.d.ts +2 -1
  11. package/dist/src/typus-hedge/user-history.js +22 -17
  12. package/dist/src/typus-launch/airdrop/view-function.js +5 -1
  13. package/dist/src/typus-launch/funding-vault/view-function.js +1 -1
  14. package/dist/src/typus-launch/improvement-proposal/view-function.js +20 -4
  15. package/dist/src/typus-launch/ve-typus/view-function.js +5 -1
  16. package/dist/src/typus-nft/fetch.d.ts +36 -0
  17. package/dist/src/typus-nft/fetch.js +269 -0
  18. package/dist/src/typus-nft/index.d.ts +1 -0
  19. package/dist/src/typus-nft/index.js +17 -0
  20. package/dist/src/typus-safu/user-history.d.ts +2 -1
  21. package/dist/src/typus-safu/user-history.js +176 -158
  22. package/dist/src/utils/api/price.js +5 -57
  23. package/dist/src/utils/api/sentio/events.js +4 -4
  24. package/dist/src/utils/api/sentio/leader-board.js +1 -1
  25. package/dist/src/utils/api/sentio/reward-generated.js +16 -16
  26. package/dist/src/utils/api/sentio/vault-history.js +1 -1
  27. package/dist/src/utils/graphQl.d.ts +1 -0
  28. package/dist/src/utils/graphQl.js +1 -1
  29. package/package.json +1 -1
  30. package/dist/src/typus-dov-single-v2/function/bidding.d.ts +0 -88
  31. package/dist/src/typus-dov-single-v2/function/bidding.js +0 -652
@@ -200,7 +200,7 @@ function getStrategyPool(config) {
200
200
  switch (_f.label) {
201
201
  case 0:
202
202
  provider = config.gRpcClient();
203
- return [4 /*yield*/, provider.getObject({ id: config.registry.dov.autoBid, include: { content: true } })];
203
+ return [4 /*yield*/, provider.getObject({ objectId: config.registry.dov.autoBid, include: { content: true } })];
204
204
  case 1:
205
205
  pool = (_e = (_f.sent()).data) === null || _e === void 0 ? void 0 : _e.content.fields;
206
206
  vaults = pool.strategies.fields.contents;
@@ -114,7 +114,7 @@ function getHistory(config, input) {
114
114
  return [4 /*yield*/, (0, graphQl_1.getEvents)(graphQlClient, MoveEventType, null, null, false)];
115
115
  case 1:
116
116
  events = _a.sent();
117
- return [4 /*yield*/, parseHistory(events, input.playgrounds)];
117
+ return [4 /*yield*/, parseHistory(events.events, input.playgrounds)];
118
118
  case 2:
119
119
  history = _a.sent();
120
120
  return [2 /*return*/, history];
@@ -228,7 +228,7 @@ function parseHistory(datas, playgrounds) {
228
228
  // }
229
229
  // export async function getProfitSharing(provider: SuiClient, diceProfitSharing: string) {
230
230
  // let object = await provider.getObject({
231
- // id: diceProfitSharing,
231
+ // objectId: diceProfitSharing,
232
232
  // include: { content: true },
233
233
  // });
234
234
  // // @ts-ignore
@@ -59,6 +59,8 @@ function getAirdrop(config, input) {
59
59
  });
60
60
  return [4 /*yield*/, provider.simulateTransaction({
61
61
  transaction: transaction,
62
+ checksEnabled: false,
63
+ include: { commandResults: true },
62
64
  })];
63
65
  case 1:
64
66
  results = (_a.sent()).commandResults;
@@ -63,6 +63,8 @@ function getRankings(config, input) {
63
63
  });
64
64
  return [4 /*yield*/, provider.simulateTransaction({
65
65
  transaction: transaction,
66
+ checksEnabled: false,
67
+ include: { commandResults: true },
66
68
  })];
67
69
  case 1:
68
70
  results = (_a.sent()).commandResults;
@@ -60,6 +60,8 @@ function getStakingInfo(config, input) {
60
60
  });
61
61
  return [4 /*yield*/, provider.simulateTransaction({
62
62
  transaction: transaction,
63
+ checksEnabled: false,
64
+ include: { commandResults: true },
63
65
  })];
64
66
  case 1:
65
67
  results = (_a.sent()).commandResults;
@@ -108,6 +110,8 @@ function getLevelCounts(config) {
108
110
  });
109
111
  return [4 /*yield*/, provider.simulateTransaction({
110
112
  transaction: transaction,
113
+ checksEnabled: false,
114
+ include: { commandResults: true },
111
115
  })];
112
116
  case 1:
113
117
  results = (_a.sent()).commandResults;
@@ -1,3 +1,2 @@
1
- export * from "./bidding";
2
1
  export * from "./token";
3
2
  export * from "./vault";
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./bidding"), exports);
18
17
  __exportStar(require("./token"), exports);
19
18
  __exportStar(require("./vault"), exports);
@@ -224,3 +224,6 @@ export declare function getRefundShares(config: TypusConfig, input: {
224
224
  }): Promise<{
225
225
  [key: string]: string;
226
226
  }>;
227
+ export declare function getUserOwnedObjects(config: TypusConfig, user: string): Promise<import("@mysten/sui/client", { with: { "resolution-mode": "import" } }).SuiClientTypes.Object<{
228
+ content: true;
229
+ }>[]>;
@@ -51,6 +51,15 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
54
63
  Object.defineProperty(exports, "__esModule", { value: true });
55
64
  exports.getVaults = getVaults;
56
65
  exports.getAuctions = getAuctions;
@@ -58,6 +67,7 @@ exports.getAuctionBids = getAuctionBids;
58
67
  exports.getDepositShares = getDepositShares;
59
68
  exports.getMyBids = getMyBids;
60
69
  exports.getRefundShares = getRefundShares;
70
+ exports.getUserOwnedObjects = getUserOwnedObjects;
61
71
  var transactions_1 = require("@mysten/sui/transactions");
62
72
  var bcs_1 = require("@mysten/bcs");
63
73
  var utils_1 = require("../../src/utils");
@@ -503,7 +513,7 @@ function getMyBids(config, input) {
503
513
  // early return if no results
504
514
  return [2 /*return*/, {}];
505
515
  }
506
- bytes = results[results.length - 1].returnValues[0][0];
516
+ bytes = results[results.length - 1].returnValues[0].bcs;
507
517
  reader = new bcs_1.BcsReader(new Uint8Array(bytes));
508
518
  result = Array.from(new Map()).reduce(function (map, _a) {
509
519
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
@@ -561,6 +571,8 @@ function getRefundShares(config, input) {
561
571
  });
562
572
  return [4 /*yield*/, provider.simulateTransaction({
563
573
  transaction: transaction,
574
+ checksEnabled: false,
575
+ include: { commandResults: true },
564
576
  })];
565
577
  case 1:
566
578
  results = (_a.sent()).commandResults;
@@ -583,3 +595,35 @@ function getRefundShares(config, input) {
583
595
  });
584
596
  });
585
597
  }
598
+ function getUserOwnedObjects(config, user) {
599
+ return __awaiter(this, void 0, void 0, function () {
600
+ var provider, result, hasNextPage, data, cursor;
601
+ return __generator(this, function (_a) {
602
+ switch (_a.label) {
603
+ case 0:
604
+ provider = config.gRpcClient();
605
+ return [4 /*yield*/, provider.listOwnedObjects({ owner: user, include: { content: true } })];
606
+ case 1:
607
+ result = _a.sent();
608
+ hasNextPage = result.hasNextPage;
609
+ data = result.objects;
610
+ cursor = result.cursor;
611
+ _a.label = 2;
612
+ case 2:
613
+ if (!hasNextPage) return [3 /*break*/, 4];
614
+ return [4 /*yield*/, provider.listOwnedObjects({
615
+ owner: user,
616
+ cursor: cursor,
617
+ include: { content: true },
618
+ })];
619
+ case 3:
620
+ result = _a.sent();
621
+ data = __spreadArray(__spreadArray([], __read(data), false), __read(result.objects), false);
622
+ hasNextPage = result.hasNextPage;
623
+ cursor = result.cursor;
624
+ return [3 /*break*/, 2];
625
+ case 4: return [2 /*return*/, data];
626
+ }
627
+ });
628
+ });
629
+ }
@@ -1,3 +1,4 @@
1
+ import { Event } from "../../src/utils";
1
2
  export interface TxHistory {
2
3
  Action: string;
3
4
  Index: string;
@@ -8,4 +9,4 @@ export interface TxHistory {
8
9
  txDigest: string;
9
10
  log: string[];
10
11
  }
11
- export declare function parseTxHistory(datas: Array<any>): Promise<Array<TxHistory>>;
12
+ export declare function parseTxHistory(datas: Array<Event>): Promise<Array<TxHistory>>;
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.parseTxHistory = parseTxHistory;
40
- var bcs_1 = require("@mysten/bcs");
40
+ var bcs_1 = require("@mysten/sui/bcs");
41
41
  var constants_1 = require("../../src/constants");
42
42
  function parseTxHistory(datas) {
43
43
  return __awaiter(this, void 0, void 0, function () {
@@ -47,27 +47,29 @@ function parseTxHistory(datas) {
47
47
  switch (_a.label) {
48
48
  case 0: return [4 /*yield*/, datas
49
49
  .filter(function (event) {
50
- return event.type == "0x15f0d9c093179f38ec90b20ac336750f82921730c25fed63e951d37a1a542bf0::event::UserEvent";
50
+ var _a, _b;
51
+ return ((_b = (_a = event.contents) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.repr) == "0x15f0d9c093179f38ec90b20ac336750f82921730c25fed63e951d37a1a542bf0::event::UserEvent";
51
52
  })
52
53
  .sort(function (a, b) {
53
54
  // From Old to New!
54
- if (a.timestampMs == b.timestampMs) {
55
- return Number(a.id.eventSeq) - Number(b.id.eventSeq);
55
+ if (a.timestamp == b.timestamp) {
56
+ return Number(a.sequenceNumber) - Number(b.sequenceNumber);
56
57
  }
57
58
  else {
58
- return Number(a.timestampMs) - Number(b.timestampMs);
59
+ return Number(a.timestamp) - Number(b.timestamp);
59
60
  }
60
61
  })
61
62
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
62
63
  var txHistory, action, log, bcs_padding, mainToken, mainTokenDecimal, hedgeToken, hedgeTokenDecimal, mainTokenAmount, hedgeTokenAmount, mainTokenWarmupAmount, hedgeTokenWarmupAmount, mainTokenActiveAmount, hedgeTokenActiveAmount;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
64
+ var _a, _b, _c;
65
+ return __generator(this, function (_d) {
66
+ switch (_d.label) {
65
67
  case 0: return [4 /*yield*/, promise];
66
68
  case 1:
67
- txHistory = _a.sent();
68
- action = event.parsedJson.action;
69
- log = toMap(event.parsedJson.log.contents);
70
- bcs_padding = toMap(event.parsedJson.bcs_padding.contents);
69
+ txHistory = _d.sent();
70
+ action = event.contents.json.action;
71
+ log = toMap(event.contents.json.log.contents);
72
+ bcs_padding = toMap(event.contents.json.bcs_padding);
71
73
  // console.log(action, log, bcs_padding, bcs_padding.size);
72
74
  if (bcs_padding.size == 0) {
73
75
  return [2 /*return*/, txHistory];
@@ -87,8 +89,9 @@ function parseTxHistory(datas) {
87
89
  Amount: [mainTokenAmount, hedgeTokenAmount],
88
90
  Token: [mainToken, hedgeToken],
89
91
  Exp: log.get("exps"),
90
- Date: new Date(Number(event.timestampMs)),
91
- txDigest: event.id.txDigest,
92
+ Date: new Date(Number(event.timestamp)),
93
+ //@ts-ignore
94
+ txDigest: (_a = event.transaction) === null || _a === void 0 ? void 0 : _a.digest,
92
95
  log: [],
93
96
  });
94
97
  break;
@@ -102,8 +105,9 @@ function parseTxHistory(datas) {
102
105
  Amount: [mainTokenWarmupAmount, hedgeTokenWarmupAmount],
103
106
  Token: [mainToken, hedgeToken],
104
107
  Exp: log.get("exps"),
105
- Date: new Date(Number(event.timestampMs)),
106
- txDigest: event.id.txDigest,
108
+ Date: new Date(Number(event.timestamp)),
109
+ //@ts-ignore
110
+ txDigest: (_b = event.transaction) === null || _b === void 0 ? void 0 : _b.digest,
107
111
  log: [],
108
112
  });
109
113
  }
@@ -116,8 +120,9 @@ function parseTxHistory(datas) {
116
120
  Amount: [mainTokenActiveAmount, hedgeTokenActiveAmount],
117
121
  Token: [mainToken, hedgeToken],
118
122
  Exp: log["exps"],
119
- Date: new Date(Number(event.timestampMs)),
120
- txDigest: event.id.txDigest,
123
+ Date: new Date(Number(event.timestamp)),
124
+ //@ts-ignore
125
+ txDigest: (_c = event.transaction) === null || _c === void 0 ? void 0 : _c.digest,
121
126
  log: [],
122
127
  });
123
128
  }
@@ -57,7 +57,11 @@ function getAirdrop(config, input) {
57
57
  target: "".concat(config.package.launch.airdrop, "::airdrop::get_airdrop_bcs"),
58
58
  arguments: [transaction.object(config.registry.launch.airdrop), transaction.pure.address(input.user)],
59
59
  });
60
- return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
60
+ return [4 /*yield*/, provider.simulateTransaction({
61
+ transaction: transaction,
62
+ checksEnabled: false,
63
+ include: { commandResults: true },
64
+ })];
61
65
  case 1:
62
66
  devInspectTransactionBlockResult = _a.sent();
63
67
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -118,11 +118,11 @@ function getFund(config, input) {
118
118
  results = (_a.sent())
119
119
  .commandResults;
120
120
  funds = {};
121
+ // console.log(results);
121
122
  results === null || results === void 0 ? void 0 : results.forEach(function (result, i) {
122
123
  // @ts-ignore
123
124
  var bytes = result.returnValues[0].bcs;
124
125
  var reader = new bcs_1.BcsReader(new Uint8Array(bytes));
125
- reader.readULEB();
126
126
  var fund = reader.readVec(function (reader) {
127
127
  return {
128
128
  balance: reader.read64(),
@@ -133,7 +133,11 @@ function getEndedTips(config) {
133
133
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ended_tips_bcs"),
134
134
  arguments: [transaction.object(config.registry.launch.improvementProposal)],
135
135
  });
136
- return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
136
+ return [4 /*yield*/, provider.simulateTransaction({
137
+ transaction: transaction,
138
+ checksEnabled: false,
139
+ include: { commandResults: true },
140
+ })];
137
141
  case 1:
138
142
  devInspectTransactionBlockResult = _a.sent();
139
143
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -198,7 +202,11 @@ function getOngoingTipVotes(config, input) {
198
202
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ongoing_tip_votes_bcs"),
199
203
  arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.address(input.user)],
200
204
  });
201
- return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
205
+ return [4 /*yield*/, provider.simulateTransaction({
206
+ transaction: transaction,
207
+ checksEnabled: false,
208
+ include: { commandResults: true },
209
+ })];
202
210
  case 1:
203
211
  devInspectTransactionBlockResult = _a.sent();
204
212
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -235,7 +243,11 @@ function getEndedTipVotes(config, input) {
235
243
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ended_tip_votes_bcs"),
236
244
  arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.address(input.user)],
237
245
  });
238
- return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
246
+ return [4 /*yield*/, provider.simulateTransaction({
247
+ transaction: transaction,
248
+ checksEnabled: false,
249
+ include: { commandResults: true },
250
+ })];
239
251
  case 1:
240
252
  devInspectTransactionBlockResult = _a.sent();
241
253
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -272,7 +284,11 @@ function getTipVotes(config, input) {
272
284
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_tip_votes_bcs"),
273
285
  arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.u64(input.index)],
274
286
  });
275
- return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
287
+ return [4 /*yield*/, provider.simulateTransaction({
288
+ transaction: transaction,
289
+ checksEnabled: false,
290
+ include: { commandResults: true },
291
+ })];
276
292
  case 1:
277
293
  devInspectTransactionBlockResult = _a.sent();
278
294
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -54,7 +54,11 @@ function getVeTypus(config, input) {
54
54
  target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus_bcs"),
55
55
  arguments: [transaction.object(config.registry.launch.veTypus), transaction.pure.address(input.user)],
56
56
  });
57
- return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
57
+ return [4 /*yield*/, provider.simulateTransaction({
58
+ transaction: transaction,
59
+ checksEnabled: false,
60
+ include: { commandResults: true },
61
+ })];
58
62
  case 1:
59
63
  devInspectTransactionBlockResult = _a.sent();
60
64
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -0,0 +1,36 @@
1
+ import { KioskClient, KioskListing } from "@mysten/kiosk";
2
+ import { SuiGraphQLClient } from "@mysten/sui/graphql";
3
+ export interface TailsId {
4
+ nftId: string;
5
+ kiosk: string;
6
+ kioskCap: string;
7
+ tails: Tails | undefined;
8
+ isPersonal: boolean;
9
+ listing?: KioskListing;
10
+ }
11
+ export interface kioskOwnerCap {
12
+ kioskId: string;
13
+ objectId: string;
14
+ isPersonal: boolean;
15
+ }
16
+ export declare function getTailsIds(kioskClient: KioskClient, NFT_PACKAGE_ORIGIN: string, kioskOwnerCaps: kioskOwnerCap[]): Promise<TailsId[]>;
17
+ export interface TailsWithType extends Tails {
18
+ type: string | null | undefined;
19
+ }
20
+ export declare function getTails(provider: SuiGraphQLClient, tailsIds: string[]): Promise<TailsWithType[]>;
21
+ export interface Tails {
22
+ id: string;
23
+ name: string;
24
+ number: string;
25
+ url: string;
26
+ level: string;
27
+ exp: string;
28
+ first_bid: string;
29
+ first_deposit: string;
30
+ first_deposit_nft: string;
31
+ attributes: Map<string, string>;
32
+ u64_padding: Map<string, string>;
33
+ }
34
+ export declare function getLevelExp(level: number): number | undefined;
35
+ export declare const LevelExpVec: number[];
36
+ export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];