@suilend/springsui-cli 1.0.10 → 1.0.11

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 (51) hide show
  1. package/cli/src/bytecode.d.ts +1 -0
  2. package/cli/src/bytecode.js +111 -0
  3. package/package.json +1 -1
  4. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +3 -3
  5. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +4 -4
  6. package/sdk/src/_generated/_dependencies/source/0x1/index.d.ts +1 -1
  7. package/sdk/src/_generated/_dependencies/source/0x1/index.js +2 -2
  8. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +2 -2
  9. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +2 -2
  10. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +2 -2
  11. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +2 -2
  12. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +2 -2
  13. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +2 -2
  14. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +2 -2
  15. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +2 -2
  16. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +3 -3
  17. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +4 -4
  18. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +8 -8
  19. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +14 -14
  20. package/sdk/src/_generated/_dependencies/source/0x2/index.d.ts +1 -1
  21. package/sdk/src/_generated/_dependencies/source/0x2/index.js +2 -2
  22. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +3 -3
  23. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +4 -4
  24. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +2 -2
  25. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +2 -2
  26. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +2 -2
  27. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +2 -2
  28. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +2 -2
  29. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +2 -2
  30. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +3 -3
  31. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +4 -4
  32. package/sdk/src/_generated/_dependencies/source/0x3/index.d.ts +1 -1
  33. package/sdk/src/_generated/_dependencies/source/0x3/index.js +2 -2
  34. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +7 -7
  35. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +12 -12
  36. package/sdk/src/_generated/liquid_staking/index.d.ts +1 -0
  37. package/sdk/src/_generated/liquid_staking/index.js +2 -1
  38. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.d.ts +1 -1
  39. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +8 -8
  40. package/sdk/src/_generated/liquid_staking/weight/functions.d.ts +7 -0
  41. package/sdk/src/_generated/liquid_staking/weight/functions.js +19 -0
  42. package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +125 -2
  43. package/sdk/src/_generated/liquid_staking/weight/structs.js +296 -30
  44. package/sdk/src/client.d.ts +7 -0
  45. package/sdk/src/client.js +50 -10
  46. package/sdk/src/lib/index.d.ts +0 -2
  47. package/sdk/src/lib/index.js +0 -2
  48. package/sdk/src/lib/coinType.d.ts +0 -4
  49. package/sdk/src/lib/coinType.js +0 -11
  50. package/sdk/src/lib/lsts.d.ts +0 -12
  51. package/sdk/src/lib/lsts.js +0 -56
@@ -1,12 +1,135 @@
1
+ import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
1
2
  import { Bag } from "../../_dependencies/source/0x2/bag/structs";
2
- import { UID } from "../../_dependencies/source/0x2/object/structs";
3
+ import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
3
4
  import { VecMap } from "../../_dependencies/source/0x2/vec-map/structs";
4
5
  import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr } from "../../_framework/reified";
5
6
  import { FieldsWithTypes } from "../../_framework/util";
6
- import { PKG_V1 } from "../index";
7
+ import { PKG_V1, PKG_V5 } from "../index";
7
8
  import { AdminCap } from "../liquid-staking/structs";
8
9
  import { Version } from "../version/structs";
9
10
  import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
11
+ export declare function isCreateEvent(type: string): boolean;
12
+ export interface CreateEventFields {
13
+ typename: ToField<TypeName>;
14
+ weightHookId: ToField<ID>;
15
+ weightHookAdminCapId: ToField<ID>;
16
+ }
17
+ export type CreateEventReified = Reified<CreateEvent, CreateEventFields>;
18
+ export declare class CreateEvent implements StructClass {
19
+ __StructClass: true;
20
+ static readonly $typeName = "0x8d196820b321bb3c56863b3eb0dd90a49f9eb52e3473373efcebf4388bf04416::weight::CreateEvent";
21
+ static readonly $numTypeParams = 0;
22
+ static readonly $isPhantom: readonly [];
23
+ readonly $typeName = "0x8d196820b321bb3c56863b3eb0dd90a49f9eb52e3473373efcebf4388bf04416::weight::CreateEvent";
24
+ readonly $fullTypeName: `${typeof PKG_V5}::weight::CreateEvent`;
25
+ readonly $typeArgs: [];
26
+ readonly $isPhantom: readonly [];
27
+ readonly typename: ToField<TypeName>;
28
+ readonly weightHookId: ToField<ID>;
29
+ readonly weightHookAdminCapId: ToField<ID>;
30
+ private constructor();
31
+ static reified(): CreateEventReified;
32
+ static get r(): import("../../_framework/reified").StructClassReified<CreateEvent, CreateEventFields>;
33
+ static phantom(): PhantomReified<ToTypeStr<CreateEvent>>;
34
+ static get p(): PhantomReified<"0x8d196820b321bb3c56863b3eb0dd90a49f9eb52e3473373efcebf4388bf04416::weight::CreateEvent">;
35
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
36
+ typename: {
37
+ name: {
38
+ bytes: number[];
39
+ };
40
+ };
41
+ weight_hook_id: {
42
+ bytes: string;
43
+ };
44
+ weight_hook_admin_cap_id: {
45
+ bytes: string;
46
+ };
47
+ }, {
48
+ typename: {
49
+ name: {
50
+ bytes: Iterable<number> & {
51
+ length: number;
52
+ };
53
+ };
54
+ };
55
+ weight_hook_id: {
56
+ bytes: string;
57
+ };
58
+ weight_hook_admin_cap_id: {
59
+ bytes: string;
60
+ };
61
+ }>;
62
+ static fromFields(fields: Record<string, any>): CreateEvent;
63
+ static fromFieldsWithTypes(item: FieldsWithTypes): CreateEvent;
64
+ static fromBcs(data: Uint8Array): CreateEvent;
65
+ toJSONField(): {
66
+ typename: {
67
+ name: string;
68
+ };
69
+ weightHookId: string;
70
+ weightHookAdminCapId: string;
71
+ };
72
+ toJSON(): {
73
+ typename: {
74
+ name: string;
75
+ };
76
+ weightHookId: string;
77
+ weightHookAdminCapId: string;
78
+ $typeName: string;
79
+ $typeArgs: [];
80
+ };
81
+ static fromJSONField(field: any): CreateEvent;
82
+ static fromJSON(json: Record<string, any>): CreateEvent;
83
+ static fromSuiParsedData(content: SuiParsedData): CreateEvent;
84
+ static fromSuiObjectData(data: SuiObjectData): CreateEvent;
85
+ static fetch(client: SuiClient, id: string): Promise<CreateEvent>;
86
+ }
87
+ export declare function isRegistryInfo(type: string): boolean;
88
+ export interface RegistryInfoFields {
89
+ weightHookId: ToField<ID>;
90
+ }
91
+ export type RegistryInfoReified = Reified<RegistryInfo, RegistryInfoFields>;
92
+ export declare class RegistryInfo implements StructClass {
93
+ __StructClass: true;
94
+ static readonly $typeName = "0x8d196820b321bb3c56863b3eb0dd90a49f9eb52e3473373efcebf4388bf04416::weight::RegistryInfo";
95
+ static readonly $numTypeParams = 0;
96
+ static readonly $isPhantom: readonly [];
97
+ readonly $typeName = "0x8d196820b321bb3c56863b3eb0dd90a49f9eb52e3473373efcebf4388bf04416::weight::RegistryInfo";
98
+ readonly $fullTypeName: `${typeof PKG_V5}::weight::RegistryInfo`;
99
+ readonly $typeArgs: [];
100
+ readonly $isPhantom: readonly [];
101
+ readonly weightHookId: ToField<ID>;
102
+ private constructor();
103
+ static reified(): RegistryInfoReified;
104
+ static get r(): import("../../_framework/reified").StructClassReified<RegistryInfo, RegistryInfoFields>;
105
+ static phantom(): PhantomReified<ToTypeStr<RegistryInfo>>;
106
+ static get p(): PhantomReified<"0x8d196820b321bb3c56863b3eb0dd90a49f9eb52e3473373efcebf4388bf04416::weight::RegistryInfo">;
107
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
108
+ weight_hook_id: {
109
+ bytes: string;
110
+ };
111
+ }, {
112
+ weight_hook_id: {
113
+ bytes: string;
114
+ };
115
+ }>;
116
+ static fromFields(fields: Record<string, any>): RegistryInfo;
117
+ static fromFieldsWithTypes(item: FieldsWithTypes): RegistryInfo;
118
+ static fromBcs(data: Uint8Array): RegistryInfo;
119
+ toJSONField(): {
120
+ weightHookId: string;
121
+ };
122
+ toJSON(): {
123
+ weightHookId: string;
124
+ $typeName: string;
125
+ $typeArgs: [];
126
+ };
127
+ static fromJSONField(field: any): RegistryInfo;
128
+ static fromJSON(json: Record<string, any>): RegistryInfo;
129
+ static fromSuiParsedData(content: SuiParsedData): RegistryInfo;
130
+ static fromSuiObjectData(data: SuiObjectData): RegistryInfo;
131
+ static fetch(client: SuiClient, id: string): Promise<RegistryInfo>;
132
+ }
10
133
  export declare function isWEIGHT(type: string): boolean;
11
134
  export interface WEIGHTFields {
12
135
  dummyField: ToField<"bool">;
@@ -9,20 +9,286 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.WeightHookAdminCap = exports.WeightHook = exports.WEIGHT = void 0;
12
+ exports.WeightHookAdminCap = exports.WeightHook = exports.WEIGHT = exports.RegistryInfo = exports.CreateEvent = void 0;
13
+ exports.isCreateEvent = isCreateEvent;
14
+ exports.isRegistryInfo = isRegistryInfo;
13
15
  exports.isWEIGHT = isWEIGHT;
14
16
  exports.isWeightHook = isWeightHook;
15
17
  exports.isWeightHookAdminCap = isWeightHookAdminCap;
16
- const structs_1 = require("../../_dependencies/source/0x2/bag/structs");
17
- const structs_2 = require("../../_dependencies/source/0x2/object/structs");
18
- const structs_3 = require("../../_dependencies/source/0x2/vec-map/structs");
18
+ const structs_1 = require("../../_dependencies/source/0x1/type-name/structs");
19
+ const structs_2 = require("../../_dependencies/source/0x2/bag/structs");
20
+ const structs_3 = require("../../_dependencies/source/0x2/object/structs");
21
+ const structs_4 = require("../../_dependencies/source/0x2/vec-map/structs");
19
22
  const reified_1 = require("../../_framework/reified");
20
23
  const util_1 = require("../../_framework/util");
21
24
  const index_1 = require("../index");
22
- const structs_4 = require("../liquid-staking/structs");
23
- const structs_5 = require("../version/structs");
25
+ const structs_5 = require("../liquid-staking/structs");
26
+ const structs_6 = require("../version/structs");
24
27
  const bcs_1 = require("@mysten/sui/bcs");
25
28
  const utils_1 = require("@mysten/sui/utils");
29
+ /* ============================== CreateEvent =============================== */
30
+ function isCreateEvent(type) {
31
+ type = (0, util_1.compressSuiType)(type);
32
+ return type === `${index_1.PKG_V5}::weight::CreateEvent`;
33
+ }
34
+ class CreateEvent {
35
+ constructor(typeArgs, fields) {
36
+ this.__StructClass = true;
37
+ this.$typeName = CreateEvent.$typeName;
38
+ this.$isPhantom = CreateEvent.$isPhantom;
39
+ this.$fullTypeName = (0, util_1.composeSuiType)(CreateEvent.$typeName, ...typeArgs);
40
+ this.$typeArgs = typeArgs;
41
+ this.typename = fields.typename;
42
+ this.weightHookId = fields.weightHookId;
43
+ this.weightHookAdminCapId = fields.weightHookAdminCapId;
44
+ }
45
+ static reified() {
46
+ return {
47
+ typeName: CreateEvent.$typeName,
48
+ fullTypeName: (0, util_1.composeSuiType)(CreateEvent.$typeName, ...[]),
49
+ typeArgs: [],
50
+ isPhantom: CreateEvent.$isPhantom,
51
+ reifiedTypeArgs: [],
52
+ fromFields: (fields) => CreateEvent.fromFields(fields),
53
+ fromFieldsWithTypes: (item) => CreateEvent.fromFieldsWithTypes(item),
54
+ fromBcs: (data) => CreateEvent.fromBcs(data),
55
+ bcs: CreateEvent.bcs,
56
+ fromJSONField: (field) => CreateEvent.fromJSONField(field),
57
+ fromJSON: (json) => CreateEvent.fromJSON(json),
58
+ fromSuiParsedData: (content) => CreateEvent.fromSuiParsedData(content),
59
+ fromSuiObjectData: (content) => CreateEvent.fromSuiObjectData(content),
60
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return CreateEvent.fetch(client, id); }),
61
+ new: (fields) => {
62
+ return new CreateEvent([], fields);
63
+ },
64
+ kind: "StructClassReified",
65
+ };
66
+ }
67
+ static get r() {
68
+ return CreateEvent.reified();
69
+ }
70
+ static phantom() {
71
+ return (0, reified_1.phantom)(CreateEvent.reified());
72
+ }
73
+ static get p() {
74
+ return CreateEvent.phantom();
75
+ }
76
+ static get bcs() {
77
+ return bcs_1.bcs.struct("CreateEvent", {
78
+ typename: structs_1.TypeName.bcs,
79
+ weight_hook_id: structs_3.ID.bcs,
80
+ weight_hook_admin_cap_id: structs_3.ID.bcs,
81
+ });
82
+ }
83
+ static fromFields(fields) {
84
+ return CreateEvent.reified().new({
85
+ typename: (0, reified_1.decodeFromFields)(structs_1.TypeName.reified(), fields.typename),
86
+ weightHookId: (0, reified_1.decodeFromFields)(structs_3.ID.reified(), fields.weight_hook_id),
87
+ weightHookAdminCapId: (0, reified_1.decodeFromFields)(structs_3.ID.reified(), fields.weight_hook_admin_cap_id),
88
+ });
89
+ }
90
+ static fromFieldsWithTypes(item) {
91
+ if (!isCreateEvent(item.type)) {
92
+ throw new Error("not a CreateEvent type");
93
+ }
94
+ return CreateEvent.reified().new({
95
+ typename: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.TypeName.reified(), item.fields.typename),
96
+ weightHookId: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.ID.reified(), item.fields.weight_hook_id),
97
+ weightHookAdminCapId: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.ID.reified(), item.fields.weight_hook_admin_cap_id),
98
+ });
99
+ }
100
+ static fromBcs(data) {
101
+ return CreateEvent.fromFields(CreateEvent.bcs.parse(data));
102
+ }
103
+ toJSONField() {
104
+ return {
105
+ typename: this.typename.toJSONField(),
106
+ weightHookId: this.weightHookId,
107
+ weightHookAdminCapId: this.weightHookAdminCapId,
108
+ };
109
+ }
110
+ toJSON() {
111
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
112
+ }
113
+ static fromJSONField(field) {
114
+ return CreateEvent.reified().new({
115
+ typename: (0, reified_1.decodeFromJSONField)(structs_1.TypeName.reified(), field.typename),
116
+ weightHookId: (0, reified_1.decodeFromJSONField)(structs_3.ID.reified(), field.weightHookId),
117
+ weightHookAdminCapId: (0, reified_1.decodeFromJSONField)(structs_3.ID.reified(), field.weightHookAdminCapId),
118
+ });
119
+ }
120
+ static fromJSON(json) {
121
+ if (json.$typeName !== CreateEvent.$typeName) {
122
+ throw new Error("not a WithTwoGenerics json object");
123
+ }
124
+ return CreateEvent.fromJSONField(json);
125
+ }
126
+ static fromSuiParsedData(content) {
127
+ if (content.dataType !== "moveObject") {
128
+ throw new Error("not an object");
129
+ }
130
+ if (!isCreateEvent(content.type)) {
131
+ throw new Error(`object at ${content.fields.id} is not a CreateEvent object`);
132
+ }
133
+ return CreateEvent.fromFieldsWithTypes(content);
134
+ }
135
+ static fromSuiObjectData(data) {
136
+ if (data.bcs) {
137
+ if (data.bcs.dataType !== "moveObject" || !isCreateEvent(data.bcs.type)) {
138
+ throw new Error(`object at is not a CreateEvent object`);
139
+ }
140
+ return CreateEvent.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
141
+ }
142
+ if (data.content) {
143
+ return CreateEvent.fromSuiParsedData(data.content);
144
+ }
145
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
146
+ }
147
+ static fetch(client, id) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ var _a, _b;
150
+ const res = yield client.getObject({ id, options: { showBcs: true } });
151
+ if (res.error) {
152
+ throw new Error(`error fetching CreateEvent object at id ${id}: ${res.error.code}`);
153
+ }
154
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
155
+ !isCreateEvent(res.data.bcs.type)) {
156
+ throw new Error(`object at id ${id} is not a CreateEvent object`);
157
+ }
158
+ return CreateEvent.fromSuiObjectData(res.data);
159
+ });
160
+ }
161
+ }
162
+ exports.CreateEvent = CreateEvent;
163
+ CreateEvent.$typeName = `${index_1.PKG_V5}::weight::CreateEvent`;
164
+ CreateEvent.$numTypeParams = 0;
165
+ CreateEvent.$isPhantom = [];
166
+ /* ============================== RegistryInfo =============================== */
167
+ function isRegistryInfo(type) {
168
+ type = (0, util_1.compressSuiType)(type);
169
+ return type === `${index_1.PKG_V5}::weight::RegistryInfo`;
170
+ }
171
+ class RegistryInfo {
172
+ constructor(typeArgs, fields) {
173
+ this.__StructClass = true;
174
+ this.$typeName = RegistryInfo.$typeName;
175
+ this.$isPhantom = RegistryInfo.$isPhantom;
176
+ this.$fullTypeName = (0, util_1.composeSuiType)(RegistryInfo.$typeName, ...typeArgs);
177
+ this.$typeArgs = typeArgs;
178
+ this.weightHookId = fields.weightHookId;
179
+ }
180
+ static reified() {
181
+ return {
182
+ typeName: RegistryInfo.$typeName,
183
+ fullTypeName: (0, util_1.composeSuiType)(RegistryInfo.$typeName, ...[]),
184
+ typeArgs: [],
185
+ isPhantom: RegistryInfo.$isPhantom,
186
+ reifiedTypeArgs: [],
187
+ fromFields: (fields) => RegistryInfo.fromFields(fields),
188
+ fromFieldsWithTypes: (item) => RegistryInfo.fromFieldsWithTypes(item),
189
+ fromBcs: (data) => RegistryInfo.fromBcs(data),
190
+ bcs: RegistryInfo.bcs,
191
+ fromJSONField: (field) => RegistryInfo.fromJSONField(field),
192
+ fromJSON: (json) => RegistryInfo.fromJSON(json),
193
+ fromSuiParsedData: (content) => RegistryInfo.fromSuiParsedData(content),
194
+ fromSuiObjectData: (content) => RegistryInfo.fromSuiObjectData(content),
195
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return RegistryInfo.fetch(client, id); }),
196
+ new: (fields) => {
197
+ return new RegistryInfo([], fields);
198
+ },
199
+ kind: "StructClassReified",
200
+ };
201
+ }
202
+ static get r() {
203
+ return RegistryInfo.reified();
204
+ }
205
+ static phantom() {
206
+ return (0, reified_1.phantom)(RegistryInfo.reified());
207
+ }
208
+ static get p() {
209
+ return RegistryInfo.phantom();
210
+ }
211
+ static get bcs() {
212
+ return bcs_1.bcs.struct("RegistryInfo", {
213
+ weight_hook_id: structs_3.ID.bcs,
214
+ });
215
+ }
216
+ static fromFields(fields) {
217
+ return RegistryInfo.reified().new({
218
+ weightHookId: (0, reified_1.decodeFromFields)(structs_3.ID.reified(), fields.weight_hook_id),
219
+ });
220
+ }
221
+ static fromFieldsWithTypes(item) {
222
+ if (!isRegistryInfo(item.type)) {
223
+ throw new Error("not a RegistryInfo type");
224
+ }
225
+ return RegistryInfo.reified().new({
226
+ weightHookId: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.ID.reified(), item.fields.weight_hook_id),
227
+ });
228
+ }
229
+ static fromBcs(data) {
230
+ return RegistryInfo.fromFields(RegistryInfo.bcs.parse(data));
231
+ }
232
+ toJSONField() {
233
+ return {
234
+ weightHookId: this.weightHookId,
235
+ };
236
+ }
237
+ toJSON() {
238
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
239
+ }
240
+ static fromJSONField(field) {
241
+ return RegistryInfo.reified().new({
242
+ weightHookId: (0, reified_1.decodeFromJSONField)(structs_3.ID.reified(), field.weightHookId),
243
+ });
244
+ }
245
+ static fromJSON(json) {
246
+ if (json.$typeName !== RegistryInfo.$typeName) {
247
+ throw new Error("not a WithTwoGenerics json object");
248
+ }
249
+ return RegistryInfo.fromJSONField(json);
250
+ }
251
+ static fromSuiParsedData(content) {
252
+ if (content.dataType !== "moveObject") {
253
+ throw new Error("not an object");
254
+ }
255
+ if (!isRegistryInfo(content.type)) {
256
+ throw new Error(`object at ${content.fields.id} is not a RegistryInfo object`);
257
+ }
258
+ return RegistryInfo.fromFieldsWithTypes(content);
259
+ }
260
+ static fromSuiObjectData(data) {
261
+ if (data.bcs) {
262
+ if (data.bcs.dataType !== "moveObject" ||
263
+ !isRegistryInfo(data.bcs.type)) {
264
+ throw new Error(`object at is not a RegistryInfo object`);
265
+ }
266
+ return RegistryInfo.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
267
+ }
268
+ if (data.content) {
269
+ return RegistryInfo.fromSuiParsedData(data.content);
270
+ }
271
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
272
+ }
273
+ static fetch(client, id) {
274
+ return __awaiter(this, void 0, void 0, function* () {
275
+ var _a, _b;
276
+ const res = yield client.getObject({ id, options: { showBcs: true } });
277
+ if (res.error) {
278
+ throw new Error(`error fetching RegistryInfo object at id ${id}: ${res.error.code}`);
279
+ }
280
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
281
+ !isRegistryInfo(res.data.bcs.type)) {
282
+ throw new Error(`object at id ${id} is not a RegistryInfo object`);
283
+ }
284
+ return RegistryInfo.fromSuiObjectData(res.data);
285
+ });
286
+ }
287
+ }
288
+ exports.RegistryInfo = RegistryInfo;
289
+ RegistryInfo.$typeName = `${index_1.PKG_V5}::weight::RegistryInfo`;
290
+ RegistryInfo.$numTypeParams = 0;
291
+ RegistryInfo.$isPhantom = [];
26
292
  /* ============================== WEIGHT =============================== */
27
293
  function isWEIGHT(type) {
28
294
  type = (0, util_1.compressSuiType)(type);
@@ -200,27 +466,27 @@ class WeightHook {
200
466
  }
201
467
  static get bcs() {
202
468
  return bcs_1.bcs.struct("WeightHook", {
203
- id: structs_2.UID.bcs,
204
- validator_addresses_and_weights: structs_3.VecMap.bcs(bcs_1.bcs
469
+ id: structs_3.UID.bcs,
470
+ validator_addresses_and_weights: structs_4.VecMap.bcs(bcs_1.bcs
205
471
  .bytes(32)
206
472
  .transform({
207
473
  input: (val) => (0, utils_1.fromHEX)(val),
208
474
  output: (val) => (0, utils_1.toHEX)(val),
209
475
  }), bcs_1.bcs.u64()),
210
476
  total_weight: bcs_1.bcs.u64(),
211
- admin_cap: structs_4.AdminCap.bcs,
212
- version: structs_5.Version.bcs,
213
- extra_fields: structs_1.Bag.bcs,
477
+ admin_cap: structs_5.AdminCap.bcs,
478
+ version: structs_6.Version.bcs,
479
+ extra_fields: structs_2.Bag.bcs,
214
480
  });
215
481
  }
216
482
  static fromFields(typeArg, fields) {
217
483
  return WeightHook.reified(typeArg).new({
218
- id: (0, reified_1.decodeFromFields)(structs_2.UID.reified(), fields.id),
219
- validatorAddressesAndWeights: (0, reified_1.decodeFromFields)(structs_3.VecMap.reified("address", "u64"), fields.validator_addresses_and_weights),
484
+ id: (0, reified_1.decodeFromFields)(structs_3.UID.reified(), fields.id),
485
+ validatorAddressesAndWeights: (0, reified_1.decodeFromFields)(structs_4.VecMap.reified("address", "u64"), fields.validator_addresses_and_weights),
220
486
  totalWeight: (0, reified_1.decodeFromFields)("u64", fields.total_weight),
221
- adminCap: (0, reified_1.decodeFromFields)(structs_4.AdminCap.reified(typeArg), fields.admin_cap),
222
- version: (0, reified_1.decodeFromFields)(structs_5.Version.reified(), fields.version),
223
- extraFields: (0, reified_1.decodeFromFields)(structs_1.Bag.reified(), fields.extra_fields),
487
+ adminCap: (0, reified_1.decodeFromFields)(structs_5.AdminCap.reified(typeArg), fields.admin_cap),
488
+ version: (0, reified_1.decodeFromFields)(structs_6.Version.reified(), fields.version),
489
+ extraFields: (0, reified_1.decodeFromFields)(structs_2.Bag.reified(), fields.extra_fields),
224
490
  });
225
491
  }
226
492
  static fromFieldsWithTypes(typeArg, item) {
@@ -229,12 +495,12 @@ class WeightHook {
229
495
  }
230
496
  (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
231
497
  return WeightHook.reified(typeArg).new({
232
- id: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.UID.reified(), item.fields.id),
233
- validatorAddressesAndWeights: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.VecMap.reified("address", "u64"), item.fields.validator_addresses_and_weights),
498
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.UID.reified(), item.fields.id),
499
+ validatorAddressesAndWeights: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.VecMap.reified("address", "u64"), item.fields.validator_addresses_and_weights),
234
500
  totalWeight: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.total_weight),
235
- adminCap: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.AdminCap.reified(typeArg), item.fields.admin_cap),
236
- version: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.Version.reified(), item.fields.version),
237
- extraFields: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Bag.reified(), item.fields.extra_fields),
501
+ adminCap: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.AdminCap.reified(typeArg), item.fields.admin_cap),
502
+ version: (0, reified_1.decodeFromFieldsWithTypes)(structs_6.Version.reified(), item.fields.version),
503
+ extraFields: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.Bag.reified(), item.fields.extra_fields),
238
504
  });
239
505
  }
240
506
  static fromBcs(typeArg, data) {
@@ -255,12 +521,12 @@ class WeightHook {
255
521
  }
256
522
  static fromJSONField(typeArg, field) {
257
523
  return WeightHook.reified(typeArg).new({
258
- id: (0, reified_1.decodeFromJSONField)(structs_2.UID.reified(), field.id),
259
- validatorAddressesAndWeights: (0, reified_1.decodeFromJSONField)(structs_3.VecMap.reified("address", "u64"), field.validatorAddressesAndWeights),
524
+ id: (0, reified_1.decodeFromJSONField)(structs_3.UID.reified(), field.id),
525
+ validatorAddressesAndWeights: (0, reified_1.decodeFromJSONField)(structs_4.VecMap.reified("address", "u64"), field.validatorAddressesAndWeights),
260
526
  totalWeight: (0, reified_1.decodeFromJSONField)("u64", field.totalWeight),
261
- adminCap: (0, reified_1.decodeFromJSONField)(structs_4.AdminCap.reified(typeArg), field.adminCap),
262
- version: (0, reified_1.decodeFromJSONField)(structs_5.Version.reified(), field.version),
263
- extraFields: (0, reified_1.decodeFromJSONField)(structs_1.Bag.reified(), field.extraFields),
527
+ adminCap: (0, reified_1.decodeFromJSONField)(structs_5.AdminCap.reified(typeArg), field.adminCap),
528
+ version: (0, reified_1.decodeFromJSONField)(structs_6.Version.reified(), field.version),
529
+ extraFields: (0, reified_1.decodeFromJSONField)(structs_2.Bag.reified(), field.extraFields),
264
530
  });
265
531
  }
266
532
  static fromJSON(typeArg, json) {
@@ -366,12 +632,12 @@ class WeightHookAdminCap {
366
632
  }
367
633
  static get bcs() {
368
634
  return bcs_1.bcs.struct("WeightHookAdminCap", {
369
- id: structs_2.UID.bcs,
635
+ id: structs_3.UID.bcs,
370
636
  });
371
637
  }
372
638
  static fromFields(typeArg, fields) {
373
639
  return WeightHookAdminCap.reified(typeArg).new({
374
- id: (0, reified_1.decodeFromFields)(structs_2.UID.reified(), fields.id),
640
+ id: (0, reified_1.decodeFromFields)(structs_3.UID.reified(), fields.id),
375
641
  });
376
642
  }
377
643
  static fromFieldsWithTypes(typeArg, item) {
@@ -380,7 +646,7 @@ class WeightHookAdminCap {
380
646
  }
381
647
  (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
382
648
  return WeightHookAdminCap.reified(typeArg).new({
383
- id: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.UID.reified(), item.fields.id),
649
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.UID.reified(), item.fields.id),
384
650
  });
385
651
  }
386
652
  static fromBcs(typeArg, data) {
@@ -396,7 +662,7 @@ class WeightHookAdminCap {
396
662
  }
397
663
  static fromJSONField(typeArg, field) {
398
664
  return WeightHookAdminCap.reified(typeArg).new({
399
- id: (0, reified_1.decodeFromJSONField)(structs_2.UID.reified(), field.id),
665
+ id: (0, reified_1.decodeFromJSONField)(structs_3.UID.reified(), field.id),
400
666
  });
401
667
  }
402
668
  static fromJSON(typeArg, json) {
@@ -56,3 +56,10 @@ export declare class LstClient {
56
56
  getSpringSuiApy(): Promise<BigNumber>;
57
57
  }
58
58
  export declare const fetchLiquidStakingInfo: (info: LiquidStakingObjectInfo, client: SuiClient) => Promise<LiquidStakingInfo<any>>;
59
+ export declare const fetchRegistryLiquidStakingInfoMap: (client: SuiClient) => Promise<{
60
+ [x: string]: LiquidStakingObjectInfo | {
61
+ id: any;
62
+ type: string;
63
+ weightHookId: any;
64
+ };
65
+ }>;
package/sdk/src/client.js CHANGED
@@ -45,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.fetchLiquidStakingInfo = exports.LstClient = exports.SUILEND_VALIDATOR_ADDRESS = void 0;
48
+ exports.fetchRegistryLiquidStakingInfoMap = exports.fetchLiquidStakingInfo = exports.LstClient = exports.SUILEND_VALIDATOR_ADDRESS = void 0;
49
49
  const transactions_1 = require("@mysten/sui/transactions");
50
50
  const utils_1 = require("@mysten/sui/utils");
51
51
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
@@ -87,12 +87,17 @@ class LstClient {
87
87
  feeConfig,
88
88
  lstTreasuryCap: treasuryCap,
89
89
  });
90
+ const [weightHook, weightHookAdminCap] = weightHookGenerated.new_(tx, coinType, adminCap);
91
+ weightHookGenerated.addToRegistry(tx, coinType, {
92
+ self: weightHook,
93
+ registry: tx.object("0x577c5a3b474403aec4629a56bab97b95715d3e87867517650651014cbef23e18"),
94
+ liquidStakingInfo,
95
+ });
90
96
  tx.moveCall({
91
97
  target: `0x2::transfer::public_share_object`,
92
98
  typeArguments: [`${structs_1.LiquidStakingInfo.$typeName}<${coinType}>`],
93
99
  arguments: [liquidStakingInfo],
94
100
  });
95
- const [weightHook, weightHookAdminCap] = weightHookGenerated.new_(tx, coinType, adminCap);
96
101
  tx.moveCall({
97
102
  target: `0x2::transfer::public_share_object`,
98
103
  typeArguments: [`${structs_2.WeightHook.$typeName}<${coinType}>`],
@@ -287,14 +292,16 @@ class LstClient {
287
292
  const liquidStakingInfo = yield (0, exports.fetchLiquidStakingInfo)(this.liquidStakingObject, this.client);
288
293
  const totalSuiSupply = new bignumber_js_1.default(liquidStakingInfo.storage.totalSuiSupply.toString()).div(10 ** utils_1.SUI_DECIMALS);
289
294
  const spreadFeePercent = new bignumber_js_1.default((_b = (_a = liquidStakingInfo.feeConfig.element) === null || _a === void 0 ? void 0 : _a.spreadFeeBps.toString()) !== null && _b !== void 0 ? _b : 0).div(100);
290
- return new bignumber_js_1.default(liquidStakingInfo.storage.validatorInfos
291
- .reduce((acc, validatorInfo) => {
292
- var _a, _b;
293
- const validatorApy = new bignumber_js_1.default((_b = (_a = validatorApys.find((_apy) => _apy.address === validatorInfo.validatorAddress)) === null || _a === void 0 ? void 0 : _a.apy) !== null && _b !== void 0 ? _b : 0);
294
- const validatorTotalSuiAmount = new bignumber_js_1.default(validatorInfo.totalSuiAmount.toString()).div(10 ** utils_1.SUI_DECIMALS);
295
- return acc.plus(validatorApy.times(validatorTotalSuiAmount));
296
- }, new bignumber_js_1.default(0))
297
- .div(totalSuiSupply)).times(new bignumber_js_1.default(1).minus(spreadFeePercent.div(100)));
295
+ return new bignumber_js_1.default(totalSuiSupply.gt(0)
296
+ ? liquidStakingInfo.storage.validatorInfos
297
+ .reduce((acc, validatorInfo) => {
298
+ var _a, _b;
299
+ const validatorApy = new bignumber_js_1.default((_b = (_a = validatorApys.find((_apy) => _apy.address === validatorInfo.validatorAddress)) === null || _a === void 0 ? void 0 : _a.apy) !== null && _b !== void 0 ? _b : 0);
300
+ const validatorTotalSuiAmount = new bignumber_js_1.default(validatorInfo.totalSuiAmount.toString()).div(10 ** utils_1.SUI_DECIMALS);
301
+ return acc.plus(validatorApy.times(validatorTotalSuiAmount));
302
+ }, new bignumber_js_1.default(0))
303
+ .div(totalSuiSupply)
304
+ : new bignumber_js_1.default(0)).times(new bignumber_js_1.default(1).minus(spreadFeePercent.div(100)));
298
305
  });
299
306
  }
300
307
  }
@@ -302,3 +309,36 @@ exports.LstClient = LstClient;
302
309
  // user functions
303
310
  const fetchLiquidStakingInfo = (info, client) => structs_1.LiquidStakingInfo.fetch(client, (0, reified_1.phantom)(info.type), info.id);
304
311
  exports.fetchLiquidStakingInfo = fetchLiquidStakingInfo;
312
+ const fetchRegistryLiquidStakingInfoMap = (client) => __awaiter(void 0, void 0, void 0, function* () {
313
+ const REGISTRY_ID = "0x06d6b6881ef14ad1a8cc29d1f97ba3397ecea56af5afa0642093e981b1fda3f4";
314
+ const registryObjectIds = (yield client.getDynamicFields({ parentId: REGISTRY_ID })).data.map((d) => d.objectId);
315
+ const registryObjects = yield Promise.all(registryObjectIds.map((objectId) => client.getObject({
316
+ id: objectId,
317
+ options: {
318
+ showContent: true,
319
+ },
320
+ })));
321
+ const LIQUID_STAKING_INFO_MAP = registryObjects.reduce((acc, obj) => {
322
+ var _a;
323
+ const fields = ((_a = obj.data) === null || _a === void 0 ? void 0 : _a.content).fields;
324
+ const id = fields.value.fields.liquid_staking_info_id;
325
+ const coinType = (0, utils_1.normalizeStructTag)(fields.name.fields.name);
326
+ if ([
327
+ "0x460c669acd3f294dc4247a6877ec2532340ffde76162ab201e72fe95355830e7::asui::ASUI",
328
+ "0x752f18582da315f9104bb8b7828188c474e64f23255ed9fd231ed3fa883f27e0::tt_sui::TT_SUI",
329
+ "0x86097c930d227f32dd2cd2ffd03d92b57504abb2b9c9cb83013c3923fa185341::tt_sui::TT_SUI",
330
+ "0x86518340cc15853c76bcb63996c6fb36cd566755a870f46bccd3e95f6a0a4993::test_sui::TEST_SUI",
331
+ "0xbf609bb629a11e7ee7c72bc3d5cf98c1c26cd2e35b2d017be4895d7e0c6be898::temps_sui::TEMPS_SUI",
332
+ "0x4bf0e1d42f731c19066d910ebf7ba12ffe4025258f50b6cc490af38080a15dfb::t0sui::T0SUI",
333
+ "0xbdf600b2f3b5d2b315f0c82ad190d4b40666b823144f5013c02f26045cda98b6::tt_sui::TT_SUI",
334
+ "0xfadc3b0fd8aea6aa485ab48271c957922396ab4984a7045da570cf836ed895cc::root_sui::ROOT_SUI",
335
+ "0xeea0564444d930f77341d7cfed9634b691463988456abcf106f6d6ed02519e43::testy_sui::TESTY_SUI",
336
+ "0xad421271913607cab135184481d65d25f10b3ef4464004fe6333930503404e3d::mjsui2::MJSUI2",
337
+ ].includes(coinType))
338
+ return acc;
339
+ const weightHookId = fields.value.fields.extra_info.fields.weight_hook_id;
340
+ return Object.assign(Object.assign({}, acc), { [coinType]: { id, type: coinType, weightHookId } });
341
+ }, {});
342
+ return LIQUID_STAKING_INFO_MAP;
343
+ });
344
+ exports.fetchRegistryLiquidStakingInfoMap = fetchRegistryLiquidStakingInfoMap;
@@ -1,3 +1 @@
1
- export * from "./coinType";
2
- export * from "./lsts";
3
1
  export * from "./transactions";
@@ -14,6 +14,4 @@ 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("./coinType"), exports);
18
- __exportStar(require("./lsts"), exports);
19
17
  __exportStar(require("./transactions"), exports);
@@ -1,4 +0,0 @@
1
- export declare const NORMALIZED_LST_COINTYPES: string[];
2
- export declare const NORMALIZED_ECOSYSTEM_LST_COINTYPES: string[];
3
- export declare const isLst: (coinType: string) => boolean;
4
- export declare const isEcosystemLst: (coinType: string) => boolean;