@typus/typus-sdk 1.4.71 → 1.4.73

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.
@@ -16,6 +16,9 @@ export interface UserBidData {
16
16
  able_to_claim: boolean;
17
17
  }
18
18
  export declare function getBidderInfo(config: TypusConfig, bidder: string): Promise<UserBidData>;
19
+ export declare function getBiddersInfo(config: TypusConfig, bidders: string[]): Promise<{
20
+ [key: string]: [UserBidData];
21
+ }>;
19
22
  export interface LaunchAuction {
20
23
  whitelist_ts_ms: string;
21
24
  start_ts_ms: string;
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getLaunchAuctionBids = getLaunchAuctionBids;
40
40
  exports.getBidderInfo = getBidderInfo;
41
+ exports.getBiddersInfo = getBiddersInfo;
41
42
  exports.getLaunchAuction = getLaunchAuction;
42
43
  var transactions_1 = require("@mysten/sui.js/transactions");
43
44
  var client_1 = require("@mysten/sui.js/client");
@@ -114,6 +115,44 @@ function getBidderInfo(config, bidder) {
114
115
  });
115
116
  });
116
117
  }
118
+ function getBiddersInfo(config, bidders) {
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ var provider, transactionBlock, results, bids;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0:
124
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
125
+ transactionBlock = new transactions_1.TransactionBlock();
126
+ bidders.forEach(function (bidder) {
127
+ transactionBlock.moveCall({
128
+ target: "".concat(config.package.launch.auction, "::auction::get_bidder_info"),
129
+ arguments: [transactionBlock.object(config.object.launchAuction), transactionBlock.pure(bidder)],
130
+ });
131
+ });
132
+ return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: constants_1.SENDER })];
133
+ case 1:
134
+ results = (_a.sent()).results;
135
+ bids = {};
136
+ results === null || results === void 0 ? void 0 : results.forEach(function (result, i) {
137
+ // @ts-ignore
138
+ var bytes = result.returnValues[0][0];
139
+ var reader = new bcs_1.BcsReader(new Uint8Array(bytes));
140
+ reader.read8();
141
+ var bid = {
142
+ whitelist_max_bid_size: reader.read64(),
143
+ whitelist_total_bid_size: reader.read64(),
144
+ total_bid_size: reader.read64(),
145
+ total_balance: reader.read64(),
146
+ refund: reader.read64(),
147
+ able_to_claim: reader.read8() == 1 ? false : true,
148
+ };
149
+ bids[bidders[i]] = [bid];
150
+ });
151
+ return [2 /*return*/, bids];
152
+ }
153
+ });
154
+ });
155
+ }
117
156
  function getLaunchAuction(config) {
118
157
  return __awaiter(this, void 0, void 0, function () {
119
158
  var provider, response;
@@ -4,6 +4,8 @@ export interface Vault {
4
4
  token: string;
5
5
  info: string[];
6
6
  config: string[];
7
+ fund: string;
8
+ refund: string;
7
9
  }
8
10
  export declare function getVault(config: TypusConfig, input: {
9
11
  indexes: string[];
@@ -26,3 +28,7 @@ export declare function getRefund(config: TypusConfig, input: {
26
28
  }): Promise<{
27
29
  [key: string]: [Fund[]];
28
30
  }>;
31
+ export declare function getAllFunds(config: TypusConfig, input: {
32
+ index: string;
33
+ users: string[];
34
+ }): Promise<Fund[]>;
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getVault = getVault;
40
40
  exports.getFund = getFund;
41
41
  exports.getRefund = getRefund;
42
+ exports.getAllFunds = getAllFunds;
42
43
  var transactions_1 = require("@mysten/sui.js/transactions");
43
44
  var client_1 = require("@mysten/sui.js/client");
44
45
  var bcs_1 = require("@mysten/bcs");
@@ -75,12 +76,18 @@ function getVault(config, input) {
75
76
  var config = reader.readVec(function (reader) {
76
77
  return reader.read64();
77
78
  });
79
+ var fund = (0, utils_1.AddressFromBytes)(reader.readBytes(32));
80
+ reader.read64();
81
+ var refund = (0, utils_1.AddressFromBytes)(reader.readBytes(32));
82
+ reader.read64();
78
83
  vaults[info[0]] = [
79
84
  {
80
85
  id: id,
81
86
  token: token,
82
87
  info: info,
83
88
  config: config,
89
+ fund: fund,
90
+ refund: refund,
84
91
  },
85
92
  ];
86
93
  });
@@ -169,3 +176,43 @@ function getRefund(config, input) {
169
176
  });
170
177
  });
171
178
  }
179
+ function getAllFunds(config, input) {
180
+ return __awaiter(this, void 0, void 0, function () {
181
+ var provider, transactionBlock, results, funds;
182
+ return __generator(this, function (_a) {
183
+ switch (_a.label) {
184
+ case 0:
185
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
186
+ transactionBlock = new transactions_1.TransactionBlock();
187
+ input.users.forEach(function (user) {
188
+ transactionBlock.moveCall({
189
+ target: "".concat(config.package.launch.fundingVault, "::funding_vault::get_fund_bcs"),
190
+ arguments: [
191
+ transactionBlock.object(config.registry.launch.fundingVault),
192
+ transactionBlock.pure(input.index),
193
+ transactionBlock.pure(user),
194
+ ],
195
+ });
196
+ });
197
+ return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: constants_1.SENDER, transactionBlock: transactionBlock })];
198
+ case 1:
199
+ results = (_a.sent()).results;
200
+ funds = [];
201
+ results === null || results === void 0 ? void 0 : results.forEach(function (result, i) {
202
+ // @ts-ignore
203
+ var bytes = result.returnValues[0][0];
204
+ var reader = new bcs_1.BcsReader(new Uint8Array(bytes));
205
+ reader.readULEB();
206
+ var fund = reader.readVec(function (reader) {
207
+ return {
208
+ balance: reader.read64(),
209
+ tsMs: reader.read64(),
210
+ };
211
+ });
212
+ funds = funds.concat(fund);
213
+ });
214
+ return [2 /*return*/, funds];
215
+ }
216
+ });
217
+ });
218
+ }
@@ -108,7 +108,8 @@ function parseTxHistory(datas) {
108
108
  switch (_a.label) {
109
109
  case 0: return [4 /*yield*/, datas
110
110
  .filter(function (event) {
111
- return event.type.includes("safu");
111
+ return (event.type.includes("safu") ||
112
+ event.type == "0x7dab89563066afa000ee154738aac2cc8e7d3e26cd0b470183db63630ee9f965::funding_vault::RaiseFundEvent");
112
113
  })
113
114
  .sort(function (a, b) {
114
115
  // From Old to New!
@@ -120,12 +121,41 @@ function parseTxHistory(datas) {
120
121
  }
121
122
  })
122
123
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
123
- var txHistory, action, log, reader, Token, asset, decimal;
124
+ var txHistory, log_1, action, log, reader, Token, asset, decimal;
124
125
  return __generator(this, function (_a) {
125
126
  switch (_a.label) {
126
127
  case 0: return [4 /*yield*/, promise];
127
128
  case 1:
128
129
  txHistory = _a.sent();
130
+ // console.log(event);
131
+ if (event.type == "0x7dab89563066afa000ee154738aac2cc8e7d3e26cd0b470183db63630ee9f965::funding_vault::RaiseFundEvent") {
132
+ log_1 = event.parsedJson.log;
133
+ if (log_1.length > 1) {
134
+ txHistory.push({
135
+ Action: "Deposit",
136
+ Index: "deepbook/".concat(log_1[0]),
137
+ Amount: divByDecimal(Number(log_1[1]), 9),
138
+ Token: event.parsedJson.token.name,
139
+ Exp: undefined,
140
+ Date: new Date(Number(event.timestampMs)),
141
+ txDigest: event.id.txDigest,
142
+ log: log_1,
143
+ });
144
+ }
145
+ else {
146
+ txHistory.push({
147
+ Action: "Deposit",
148
+ Index: "deepbook/0",
149
+ Amount: divByDecimal(Number(log_1[0]), 9),
150
+ Token: event.parsedJson.token.name,
151
+ Exp: undefined,
152
+ Date: new Date(Number(event.timestampMs)),
153
+ txDigest: event.id.txDigest,
154
+ log: log_1,
155
+ });
156
+ }
157
+ return [2 /*return*/, txHistory];
158
+ }
129
159
  action = event.parsedJson.action;
130
160
  log = event.parsedJson.log;
131
161
  // skip the event without tokenType
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.4.71",
5
+ "version": "1.4.73",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.8.10",