@typus/typus-sdk 1.8.43 → 1.9.0

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 (52) hide show
  1. package/dist/src/auto-bid/view-function.d.ts +0 -2
  2. package/dist/src/auto-bid/view-function.js +7 -76
  3. package/dist/src/dice/fetch.d.ts +2 -2
  4. package/dist/src/dice/fetch.js +34 -91
  5. package/dist/src/typus/airdrop/view-function.js +5 -8
  6. package/dist/src/typus/leaderboard/view-function.js +5 -8
  7. package/dist/src/typus/tails-staking/view-function.js +10 -14
  8. package/dist/src/typus/user/view-function.js +5 -6
  9. package/dist/src/typus-dov-single-v2/function/index.d.ts +0 -1
  10. package/dist/src/typus-dov-single-v2/function/index.js +0 -1
  11. package/dist/src/typus-dov-single-v2/function/token.js +1 -1
  12. package/dist/src/typus-dov-single-v2/history/index.d.ts +0 -1
  13. package/dist/src/typus-dov-single-v2/history/index.js +0 -1
  14. package/dist/src/typus-dov-single-v2/history/user-history.d.ts +5 -3
  15. package/dist/src/typus-dov-single-v2/history/user-history.js +124 -187
  16. package/dist/src/typus-dov-single-v2/otc-entry.js +5 -6
  17. package/dist/src/typus-dov-single-v2/user-entry.d.ts +1 -1
  18. package/dist/src/typus-dov-single-v2/view-function.d.ts +3 -0
  19. package/dist/src/typus-dov-single-v2/view-function.js +72 -28
  20. package/dist/src/typus-hedge/view-function.js +10 -10
  21. package/dist/src/typus-launch/airdrop/view-function.js +3 -5
  22. package/dist/src/typus-launch/auction/view-function.js +17 -16
  23. package/dist/src/typus-launch/funding-vault/view-function.js +21 -19
  24. package/dist/src/typus-launch/improvement-proposal/view-function.js +17 -18
  25. package/dist/src/typus-launch/ve-typus/view-function.js +15 -15
  26. package/dist/src/typus-nft/fetch.d.ts +2 -36
  27. package/dist/src/typus-nft/fetch.js +34 -396
  28. package/dist/src/typus-nft/index.d.ts +0 -1
  29. package/dist/src/typus-nft/index.js +0 -1
  30. package/dist/src/typus-safu/view-function.js +13 -13
  31. package/dist/src/utils/api/price.js +6 -58
  32. package/dist/src/utils/api/sentio/events.js +4 -4
  33. package/dist/src/utils/api/sentio/leader-board.js +1 -1
  34. package/dist/src/utils/api/sentio/reward-generated.js +16 -16
  35. package/dist/src/utils/api/sentio/vault-history.js +1 -1
  36. package/dist/src/utils/graphQl.d.ts +27 -0
  37. package/dist/src/utils/graphQl.js +132 -0
  38. package/dist/src/utils/index.d.ts +1 -0
  39. package/dist/src/utils/index.js +1 -0
  40. package/dist/src/utils/oracle.js +13 -14
  41. package/dist/src/utils/sponsoredTx.d.ts +2 -2
  42. package/dist/src/utils/typusConfig.d.ts +4 -0
  43. package/dist/src/utils/typusConfig.js +33 -31
  44. package/package.json +10 -9
  45. package/dist/src/dice/view-function.d.ts +0 -1
  46. package/dist/src/dice/view-function.js +0 -20
  47. package/dist/src/typus-dov-single-v2/function/bidding.d.ts +0 -87
  48. package/dist/src/typus-dov-single-v2/function/bidding.js +0 -653
  49. package/dist/src/typus-dov-single-v2/history/vault-history.d.ts +0 -123
  50. package/dist/src/typus-dov-single-v2/history/vault-history.js +0 -307
  51. package/dist/src/typus-nft/user-entry.d.ts +0 -57
  52. package/dist/src/typus-nft/user-entry.js +0 -161
@@ -59,7 +59,7 @@ exports.getExerciseFromSentio = getExerciseFromSentio;
59
59
  var typus_dov_single_v2_1 = require("../../../../src/typus-dov-single-v2");
60
60
  var constants_1 = require("../../../../src/constants");
61
61
  var headers = {
62
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
62
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
63
63
  "Content-Type": "application/json",
64
64
  };
65
65
  function getFromSentio(event, userAddress, startTimestamp) {
@@ -71,7 +71,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
71
71
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
72
72
  requestData = {
73
73
  sqlQuery: {
74
- sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinct_id = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
74
+ sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinctId = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
75
75
  size: 1000,
76
76
  },
77
77
  };
@@ -86,7 +86,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
86
86
  return [4 /*yield*/, response.json()];
87
87
  case 2:
88
88
  data = _a.sent();
89
- // console.log(data);
89
+ console.log(data);
90
90
  return [2 /*return*/, data.result.rows];
91
91
  }
92
92
  });
@@ -101,7 +101,7 @@ function getFromSentioWithExpUp(event, userAddress, startTimestamp) {
101
101
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
102
102
  requestData = {
103
103
  sqlQuery: {
104
- sql: "\n SELECT *\n FROM ".concat(event, " N\n LEFT JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash AND N.log_index + 1 = S.log_index\n WHERE N.distinct_id = '").concat(userAddress, "' AND N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
104
+ sql: "\n SELECT *\n FROM ".concat(event, " N\n LEFT JOIN (\n SELECT number, distinctId, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash AND N.log_index + 1 = S.log_index\n WHERE N.distinctId = '").concat(userAddress, "' AND N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
105
105
  size: 1000,
106
106
  },
107
107
  };
@@ -50,7 +50,7 @@ function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
50
50
  });
51
51
  }
52
52
  var headers = {
53
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
53
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
54
54
  "Content-Type": "application/json",
55
55
  };
56
56
  function getExpLeaderBoard(startTimestamp, endTimestamp) {
@@ -55,7 +55,7 @@ exports.getAccumulatedUser = getAccumulatedUser;
55
55
  exports.getAccumulatedNotionalVolumeUSD = getAccumulatedNotionalVolumeUSD;
56
56
  exports.getSafuAccumulatedRewardGeneratedUSD = getSafuAccumulatedRewardGeneratedUSD;
57
57
  var headers = {
58
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
58
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
59
59
  "Content-Type": "application/json",
60
60
  };
61
61
  function getTotalDepositorIncentive() {
@@ -96,7 +96,7 @@ function getTotalPremium() {
96
96
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
97
97
  requestData = {
98
98
  timeRange: {
99
- start: "now",
99
+ start: "now-1h",
100
100
  end: "now",
101
101
  step: 3600,
102
102
  timezone: "Europe/Paris",
@@ -148,7 +148,7 @@ function getAccumulatedRewardGeneratedUSD() {
148
148
  apiUrlV1 = "https://app.sentio.xyz/api/v1/insights/typus/typus_v1/query";
149
149
  requestDataV1 = {
150
150
  timeRange: {
151
- start: "now",
151
+ start: "now-1h",
152
152
  end: "now",
153
153
  step: 3600,
154
154
  timezone: "Asia/Taipei",
@@ -188,7 +188,7 @@ function getAccumulatedRewardGeneratedUSD() {
188
188
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
189
189
  requestData = {
190
190
  timeRange: {
191
- start: "now",
191
+ start: "now-1h",
192
192
  end: "now",
193
193
  step: 3600,
194
194
  timezone: "Asia/Taipei",
@@ -283,12 +283,10 @@ function getAccumulatedUser() {
283
283
  apiUrl = apiUrls_1_1.value;
284
284
  requestData = {
285
285
  timeRange: {
286
- start: "now-1h",
286
+ start: "now-3d",
287
287
  end: "now",
288
- step: 3600,
289
- timezone: "Asia/Taipei",
288
+ step: 86400,
290
289
  },
291
- limit: 1,
292
290
  queries: [
293
291
  {
294
292
  eventsQuery: {
@@ -307,7 +305,7 @@ function getAccumulatedUser() {
307
305
  },
308
306
  },
309
307
  groupBy: [],
310
- limit: 1,
308
+ limit: 0,
311
309
  functions: [],
312
310
  disabled: false,
313
311
  },
@@ -328,8 +326,8 @@ function getAccumulatedUser() {
328
326
  return [4 /*yield*/, response.json()];
329
327
  case 4:
330
328
  data = _b.sent();
331
- // console.log(data.results[0].matrix.samples[0].values[0].value);
332
- result.push(data.results[0].matrix.samples[0].values[0].value);
329
+ // console.dir(data.results[0].matrix, { depth: null });
330
+ result.push(data.results[0].matrix.samples[0].values.at(-1).value);
333
331
  _b.label = 5;
334
332
  case 5:
335
333
  apiUrls_1_1 = apiUrls_1.next();
@@ -375,10 +373,9 @@ function getAccumulatedNotionalVolumeUSD() {
375
373
  apiUrl = apiUrls_2_1.value;
376
374
  requestData = {
377
375
  timeRange: {
378
- start: "now",
376
+ start: "now-1h",
379
377
  end: "now",
380
378
  step: 3600,
381
- timezone: "Asia/Taipei",
382
379
  },
383
380
  limit: 1,
384
381
  queries: [
@@ -446,7 +443,7 @@ function getSafuAccumulatedRewardGeneratedUSD() {
446
443
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
447
444
  requestData = {
448
445
  timeRange: {
449
- start: "now",
446
+ start: "now-1h",
450
447
  end: "now",
451
448
  step: 3600,
452
449
  timezone: "Asia/Taipei",
@@ -489,5 +486,8 @@ function getSafuAccumulatedRewardGeneratedUSD() {
489
486
  });
490
487
  });
491
488
  }
492
- // getAccumulatedNotionalVolumeUSD();
493
- // getAccumulatedUser();
489
+ // getTotalDepositorIncentive().then((res) => console.log(res));
490
+ // getTotalPremium().then((res) => console.log(res));
491
+ // getAccumulatedNotionalVolumeUSD().then((res) => console.log(res));
492
+ // getAccumulatedUser().then((res) => console.log(res));
493
+ // getAccumulatedRewardGeneratedUSD().then((res) => console.log(res));
@@ -40,7 +40,7 @@ exports.getVaultHistorySummary = getVaultHistorySummary;
40
40
  exports.getFilledSummary = getFilledSummary;
41
41
  exports.getVaultHistory = getVaultHistory;
42
42
  var headers = {
43
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
43
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
44
44
  "Content-Type": "application/json",
45
45
  };
46
46
  function getVaultHistorySummary(startTimestamp) {
@@ -0,0 +1,27 @@
1
+ import { SuiGraphQLClient } from "@mysten/sui/graphql";
2
+ export declare function getDynamicObjectFields(graphQlClient: SuiGraphQLClient, parent: string, typeFilter?: string): Promise<any[] | undefined>;
3
+ export interface Event {
4
+ transaction: {
5
+ digest: string;
6
+ } | null;
7
+ transactionModule: {
8
+ name: string;
9
+ package: {
10
+ digest: string | null;
11
+ } | null;
12
+ } | null;
13
+ sender: {
14
+ address: string;
15
+ } | null;
16
+ timestamp: string | null;
17
+ contents: {
18
+ type: {
19
+ repr: string;
20
+ } | null;
21
+ json: unknown;
22
+ } | null;
23
+ }
24
+ export declare function getEvents(graphQlClient: SuiGraphQLClient, module: string | null, sender: string | null, beforeCursor?: string | null, getAll?: boolean): Promise<{
25
+ events: Event[];
26
+ beforeCursor: string | null;
27
+ }>;
@@ -0,0 +1,132 @@
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["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
+ 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
+ };
63
+ Object.defineProperty(exports, "__esModule", { value: true });
64
+ exports.getDynamicObjectFields = getDynamicObjectFields;
65
+ exports.getEvents = getEvents;
66
+ var schema_1 = require("@mysten/sui/graphql/schema");
67
+ function getDynamicObjectFields(graphQlClient_1, parent_1) {
68
+ return __awaiter(this, arguments, void 0, function (graphQlClient, parent, typeFilter) {
69
+ var x;
70
+ var _a, _b, _c;
71
+ if (typeFilter === void 0) { typeFilter = ""; }
72
+ return __generator(this, function (_d) {
73
+ switch (_d.label) {
74
+ case 0: return [4 /*yield*/, graphQlClient.query({
75
+ query: dynamicFieldsQuery,
76
+ variables: {
77
+ id: parent,
78
+ },
79
+ })];
80
+ case 1:
81
+ x = _d.sent();
82
+ // @ts-ignore
83
+ return [2 /*return*/, ((_c = (_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.dynamicFields) === null || _c === void 0 ? void 0 : _c.nodes.filter(function (a) { var _a, _b; return ((_a = a.value) === null || _a === void 0 ? void 0 : _a.contents) && ((_b = a.value) === null || _b === void 0 ? void 0 : _b.contents.type.repr.endsWith(typeFilter)); }).sort(function (a, b) { var _a, _b; return Number((_a = a.name) === null || _a === void 0 ? void 0 : _a.json) - Number((_b = b.name) === null || _b === void 0 ? void 0 : _b.json); }).map(function (x_1) {
84
+ var _a;
85
+ // @ts-ignore
86
+ var json = (_a = x_1.value) === null || _a === void 0 ? void 0 : _a.contents.json;
87
+ // console.dir(json, { depth: null });
88
+ return json;
89
+ }))];
90
+ }
91
+ });
92
+ });
93
+ }
94
+ var dynamicFieldsQuery = (0, schema_1.graphql)("\n query ($id: SuiAddress!) {\n address(address: $id) {\n dynamicFields {\n nodes {\n name {\n ...Value\n }\n value {\n ... on MoveValue {\n ...Value\n }\n ... on MoveObject {\n contents {\n ...Value\n }\n }\n }\n }\n }\n }\n }\n\n fragment Value on MoveValue {\n type {\n repr\n }\n json\n }\n");
95
+ var eventsQuery = (0, schema_1.graphql)("\n query QueryEvents($type: String, $before: String, $sender: SuiAddress) {\n events(last: 50, before: $before, filter: { type: $type, sender: $sender }) {\n pageInfo {\n hasPreviousPage\n hasNextPage\n startCursor\n endCursor\n }\n edges {\n cursor\n }\n nodes {\n transaction {\n digest\n }\n transactionModule {\n name\n package {\n digest\n }\n }\n sender {\n address\n }\n timestamp\n contents {\n type {\n repr\n }\n json\n }\n }\n }\n }\n");
96
+ function getEvents(graphQlClient_1, module_1, sender_1) {
97
+ return __awaiter(this, arguments, void 0, function (graphQlClient, module, sender, beforeCursor, getAll) {
98
+ var hasPreviousPage, events, x;
99
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
100
+ if (beforeCursor === void 0) { beforeCursor = null; }
101
+ if (getAll === void 0) { getAll = true; }
102
+ return __generator(this, function (_k) {
103
+ switch (_k.label) {
104
+ case 0:
105
+ hasPreviousPage = true;
106
+ events = [];
107
+ _k.label = 1;
108
+ case 1:
109
+ if (!hasPreviousPage) return [3 /*break*/, 3];
110
+ return [4 /*yield*/, graphQlClient.query({
111
+ query: eventsQuery,
112
+ variables: {
113
+ type: module,
114
+ before: beforeCursor,
115
+ sender: sender,
116
+ },
117
+ })];
118
+ case 2:
119
+ x = _k.sent();
120
+ // console.dir(x.data?.events?.nodes, { depth: null })
121
+ events.push.apply(events, __spreadArray([], __read(((_c = (_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.nodes.reverse()) !== null && _c !== void 0 ? _c : [])), false));
122
+ if (!getAll) {
123
+ return [3 /*break*/, 3];
124
+ }
125
+ hasPreviousPage = (_f = (_e = (_d = x.data) === null || _d === void 0 ? void 0 : _d.events) === null || _e === void 0 ? void 0 : _e.pageInfo.hasPreviousPage) !== null && _f !== void 0 ? _f : false;
126
+ beforeCursor = (_j = (_h = (_g = x.data) === null || _g === void 0 ? void 0 : _g.events) === null || _h === void 0 ? void 0 : _h.pageInfo.startCursor) !== null && _j !== void 0 ? _j : null;
127
+ return [3 /*break*/, 1];
128
+ case 3: return [2 /*return*/, { events: events, beforeCursor: beforeCursor }];
129
+ }
130
+ });
131
+ });
132
+ }
@@ -5,3 +5,4 @@ export * from "./mint";
5
5
  export * from "./tools";
6
6
  export * from "./typusConfig";
7
7
  export * from "./oracle";
8
+ export * from "./graphQl";
@@ -21,3 +21,4 @@ __exportStar(require("./mint"), exports);
21
21
  __exportStar(require("./tools"), exports);
22
22
  __exportStar(require("./typusConfig"), exports);
23
23
  __exportStar(require("./oracle"), exports);
24
+ __exportStar(require("./graphQl"), exports);
@@ -35,14 +35,10 @@ 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 __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
38
  Object.defineProperty(exports, "__esModule", { value: true });
42
39
  exports.parseFullTypusOracleData = void 0;
43
40
  exports.updateOracleWithSignatureTx = updateOracleWithSignatureTx;
44
41
  var utils_1 = require("@mysten/sui/utils");
45
- var axios_1 = __importDefault(require("axios"));
46
42
  var constants_1 = require("../../src/constants");
47
43
  var token_1 = require("../../src/constants/token");
48
44
  var bcs_1 = require("@mysten/bcs");
@@ -58,7 +54,7 @@ var parseFullTypusOracleData = function (data) {
58
54
  exports.parseFullTypusOracleData = parseFullTypusOracleData;
59
55
  function updateOracleWithSignatureTx(network, tx, oracleContract, tokenType) {
60
56
  return __awaiter(this, void 0, void 0, function () {
61
- var baseTokenType, oracleData, result, error_1, oracleAddress, oracleIdBytes, pairBytes, priceBytes, twapBytes, timestampBytes, totalLength, messageBytes, offset, signatureHex, signatureBytes;
57
+ var baseTokenType, oracleData, result, data, error_1, oracleAddress, oracleIdBytes, pairBytes, priceBytes, twapBytes, timestampBytes, totalLength, messageBytes, offset, signatureHex, signatureBytes;
62
58
  return __generator(this, function (_a) {
63
59
  switch (_a.label) {
64
60
  case 0:
@@ -66,22 +62,25 @@ function updateOracleWithSignatureTx(network, tx, oracleContract, tokenType) {
66
62
  oracleData = null;
67
63
  _a.label = 1;
68
64
  case 1:
69
- _a.trys.push([1, 3, , 4]);
70
- return [4 /*yield*/, axios_1.default.get("https://asia-east1-aqueous-freedom-378103.cloudfunctions.net/get-price?pair=".concat(tokenType))];
65
+ _a.trys.push([1, 4, , 5]);
66
+ return [4 /*yield*/, fetch("https://asia-east1-aqueous-freedom-378103.cloudfunctions.net/get-price?pair=".concat(tokenType))];
71
67
  case 2:
72
68
  result = _a.sent();
73
- if (result.data) {
74
- oracleData = (0, exports.parseFullTypusOracleData)(result.data);
75
- }
76
- return [3 /*break*/, 4];
69
+ return [4 /*yield*/, result.json()];
77
70
  case 3:
71
+ data = _a.sent();
72
+ if (data) {
73
+ oracleData = (0, exports.parseFullTypusOracleData)(data);
74
+ }
75
+ return [3 /*break*/, 5];
76
+ case 4:
78
77
  error_1 = _a.sent();
79
78
  console.error(error_1);
80
79
  return [2 /*return*/, tx];
81
- case 4:
80
+ case 5:
82
81
  oracleAddress = constants_1.oracle[network][(0, token_1.typeArgToAsset)((0, utils_1.normalizeStructTag)(tokenType))];
83
82
  if (oracleData && oracleAddress) {
84
- oracleIdBytes = (0, bcs_1.fromHex)(oracleAddress.startsWith('0x') ? oracleAddress.slice(2) : oracleAddress);
83
+ oracleIdBytes = (0, bcs_1.fromHex)(oracleAddress.startsWith("0x") ? oracleAddress.slice(2) : oracleAddress);
85
84
  pairBytes = new Uint8Array(Buffer.from(baseTokenType, "utf8"));
86
85
  priceBytes = bcs_1.bcs.u64().serialize(oracleData.signed.price).toBytes();
87
86
  twapBytes = bcs_1.bcs.u64().serialize(oracleData.signed.twap).toBytes();
@@ -112,7 +111,7 @@ function updateOracleWithSignatureTx(network, tx, oracleContract, tokenType) {
112
111
  tx.pure.u64(oracleData.signed.price),
113
112
  tx.pure.u64(oracleData.signed.twap),
114
113
  tx.pure.u64(oracleData.signed.timestamp.toString()),
115
- tx.object("0x6")
114
+ tx.object("0x6"),
116
115
  ],
117
116
  });
118
117
  return [2 /*return*/, tx];
@@ -1,6 +1,6 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
- import { SuiClient } from "@mysten/sui/client";
3
- export declare function getSponsoredTx(provider: SuiClient, sender: string, tx: Transaction): Promise<sponsoredResponse>;
2
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
3
+ export declare function getSponsoredTx(provider: SuiGrpcClient, sender: string, tx: Transaction): Promise<sponsoredResponse>;
4
4
  interface sponsoredResponse {
5
5
  txBytes: string;
6
6
  sponsorSig: string;
@@ -1,3 +1,5 @@
1
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
2
+ import { SuiGraphQLClient } from "@mysten/sui/graphql";
1
3
  export declare class TypusConfig {
2
4
  network: "MAINNET" | "TESTNET";
3
5
  rpcEndpoint: string;
@@ -10,6 +12,8 @@ export declare class TypusConfig {
10
12
  static parse(json: any): TypusConfig;
11
13
  static local(path: any): TypusConfig;
12
14
  static default(network: "MAINNET" | "TESTNET", customRpcEndpoint: string | null, branch?: string): Promise<TypusConfig>;
15
+ gRpcClient(): SuiGrpcClient;
16
+ graphQlClient(): SuiGraphQLClient<{}>;
13
17
  }
14
18
  export interface Package {
15
19
  dice: string;
@@ -75,58 +75,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
75
75
  exports.TypusConfig = void 0;
76
76
  var camelcase_keys_deep_1 = __importDefault(require("camelcase-keys-deep"));
77
77
  var fs = __importStar(require("fs"));
78
+ var grpcweb_transport_1 = require("@protobuf-ts/grpcweb-transport");
79
+ var grpc_1 = require("@mysten/sui/grpc");
80
+ var graphql_1 = require("@mysten/sui/graphql");
78
81
  var TypusConfig = /** @class */ (function () {
79
82
  function TypusConfig() {
80
83
  this.sponsored = false;
81
84
  }
82
85
  TypusConfig.parse = function (json) {
83
- return JSON.parse(JSON.stringify((0, camelcase_keys_deep_1.default)(json)));
86
+ return Object.assign(new TypusConfig(), JSON.parse(JSON.stringify((0, camelcase_keys_deep_1.default)(json))));
84
87
  };
85
88
  TypusConfig.local = function (path) {
86
89
  return TypusConfig.parse(JSON.parse(fs.readFileSync(path, "utf-8")));
87
90
  };
88
91
  TypusConfig.default = function (network_1, customRpcEndpoint_1) {
89
92
  return __awaiter(this, arguments, void 0, function (network, customRpcEndpoint, branch) {
90
- var _a, typusConfig, _b, _c, _d, _e, _f, typusConfig, _g, _h, _j, _k, _l;
93
+ var url, data, _a, typusConfig;
91
94
  if (branch === void 0) { branch = "main"; }
92
- return __generator(this, function (_m) {
93
- switch (_m.label) {
95
+ return __generator(this, function (_b) {
96
+ switch (_b.label) {
94
97
  case 0:
95
- _a = network;
96
- switch (_a) {
97
- case "MAINNET": return [3 /*break*/, 1];
98
- case "TESTNET": return [3 /*break*/, 4];
99
- }
100
- return [3 /*break*/, 7];
101
- case 1:
102
- _c = (_b = JSON).parse;
103
- _e = (_d = JSON).stringify;
104
- _f = camelcase_keys_deep_1.default;
105
- return [4 /*yield*/, fetch("https://raw.githubusercontent.com/Typus-Lab/typus-config/".concat(branch, "/config-mainnet.json"))];
106
- case 2: return [4 /*yield*/, (_m.sent()).json()];
107
- case 3:
108
- typusConfig = _c.apply(_b, [_e.apply(_d, [_f.apply(void 0, [_m.sent()])])]);
109
- if (customRpcEndpoint) {
110
- typusConfig.rpcEndpoint = customRpcEndpoint;
111
- }
112
- return [2 /*return*/, typusConfig];
113
- case 4:
114
- _h = (_g = JSON).parse;
115
- _k = (_j = JSON).stringify;
116
- _l = camelcase_keys_deep_1.default;
117
- return [4 /*yield*/, fetch("https://raw.githubusercontent.com/Typus-Lab/typus-config/".concat(branch, "/config-testnet.json"))];
118
- case 5: return [4 /*yield*/, (_m.sent()).json()];
119
- case 6:
120
- typusConfig = _h.apply(_g, [_k.apply(_j, [_l.apply(void 0, [_m.sent()])])]);
98
+ url = network === "MAINNET"
99
+ ? "https://raw.githubusercontent.com/Typus-Lab/typus-config/".concat(branch, "/config-mainnet.json")
100
+ : "https://raw.githubusercontent.com/Typus-Lab/typus-config/".concat(branch, "/config-testnet.json");
101
+ _a = camelcase_keys_deep_1.default;
102
+ return [4 /*yield*/, fetch(url)];
103
+ case 1: return [4 /*yield*/, (_b.sent()).json()];
104
+ case 2:
105
+ data = _a.apply(void 0, [_b.sent()]);
106
+ typusConfig = Object.assign(new TypusConfig(), JSON.parse(JSON.stringify(data)));
121
107
  if (customRpcEndpoint) {
122
108
  typusConfig.rpcEndpoint = customRpcEndpoint;
123
109
  }
124
110
  return [2 /*return*/, typusConfig];
125
- case 7: return [2 /*return*/];
126
111
  }
127
112
  });
128
113
  });
129
114
  };
115
+ TypusConfig.prototype.gRpcClient = function () {
116
+ var transport = new grpcweb_transport_1.GrpcWebFetchTransport({
117
+ baseUrl: this.rpcEndpoint,
118
+ });
119
+ var provider = new grpc_1.SuiGrpcClient({
120
+ network: this.network.toLocaleLowerCase(),
121
+ transport: transport,
122
+ });
123
+ return provider;
124
+ };
125
+ TypusConfig.prototype.graphQlClient = function () {
126
+ var provider = new graphql_1.SuiGraphQLClient({
127
+ network: this.network.toLocaleLowerCase(),
128
+ url: "https://graphql.".concat(this.network.toLocaleLowerCase(), ".sui.io/graphql"),
129
+ });
130
+ return provider;
131
+ };
130
132
  return TypusConfig;
131
133
  }());
132
134
  exports.TypusConfig = TypusConfig;
package/package.json CHANGED
@@ -2,15 +2,13 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.8.43",
5
+ "version": "1.9.0",
6
6
  "dependencies": {
7
- "@mysten/bcs": "^1.6.1",
8
- "@mysten/kiosk": "^0.12.6",
9
- "@mysten/sui": "^1.30.0",
7
+ "@mysten/bcs": "2.0.3",
8
+ "@mysten/kiosk": "1.2.0",
9
+ "@mysten/sui": "2.13.2",
10
10
  "@pythnetwork/pyth-sui-js": "2.3.0",
11
- "@shinami/clients": "^0.9.6",
12
- "@types/node": "^20.5.7",
13
- "axios": "1.13.2",
11
+ "@shinami/clients": "0.10.0",
14
12
  "bignumber.js": "^9.1.2",
15
13
  "camelcase-keys-deep": "^0.1.0",
16
14
  "crypto-js": "^4.2.0",
@@ -20,12 +18,14 @@
20
18
  "node-rsa": "^1.1.1"
21
19
  },
22
20
  "resolutions": {
23
- "@mysten/sui": "^1.30.0"
21
+ "@mysten/bcs": "2.0.3",
22
+ "@mysten/sui": "2.13.2"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@types/camelcase-keys-deep": "^0.1.2",
27
26
  "@types/crypto-js": "^4.2.2",
28
27
  "@types/node-rsa": "^1.1.4",
28
+ "axios": "1.13.2",
29
29
  "prettier": "^3.0.0",
30
30
  "slack": "^11.0.2",
31
31
  "tsc-alias": "^1.8.10",
@@ -50,5 +50,6 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/Typus-Lab/typus-sdk/issues"
52
52
  },
53
- "homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
53
+ "homepage": "https://github.com/Typus-Lab/typus-sdk#readme",
54
+ "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
54
55
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function uint8ArrayToBCSStringArray(uint8Array) {
4
- var result = [];
5
- for (var i = 0; i < uint8Array.length; i++) {
6
- // Assume each byte is a UTF-8 character
7
- var character = String.fromCharCode(uint8Array[i]);
8
- // Convert character to its BCS representation (you need to implement this part)
9
- var bcsRepresentation = encodeToBCS(character);
10
- // Add BCS representation to the result array
11
- result.push(bcsRepresentation);
12
- }
13
- return result;
14
- }
15
- // Function to encode a character to its BCS representation
16
- function encodeToBCS(character) {
17
- // You need to implement this part based on BCS encoding rules
18
- // This is a placeholder; the actual implementation depends on BCS specifications
19
- return character.charCodeAt(0).toString();
20
- }