@suilend/springsui-cli 1.0.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 (63) hide show
  1. package/cli/src/index.d.ts +1 -0
  2. package/cli/src/index.js +304 -0
  3. package/package.json +1 -0
  4. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +92 -0
  5. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +289 -0
  6. package/sdk/src/_generated/_dependencies/source/0x1/index.d.ts +3 -0
  7. package/sdk/src/_generated/_dependencies/source/0x1/index.js +6 -0
  8. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +52 -0
  9. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +180 -0
  10. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +50 -0
  11. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +167 -0
  12. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +53 -0
  13. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +144 -0
  14. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +61 -0
  15. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +149 -0
  16. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +88 -0
  17. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +291 -0
  18. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +460 -0
  19. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +1045 -0
  20. package/sdk/src/_generated/_dependencies/source/0x2/index.d.ts +3 -0
  21. package/sdk/src/_generated/_dependencies/source/0x2/index.js +6 -0
  22. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +92 -0
  23. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +270 -0
  24. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +46 -0
  25. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +142 -0
  26. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +61 -0
  27. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +163 -0
  28. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +53 -0
  29. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +143 -0
  30. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +111 -0
  31. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +325 -0
  32. package/sdk/src/_generated/_dependencies/source/0x3/index.d.ts +3 -0
  33. package/sdk/src/_generated/_dependencies/source/0x3/index.js +6 -0
  34. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +487 -0
  35. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +915 -0
  36. package/sdk/src/_generated/_framework/reified.d.ts +108 -0
  37. package/sdk/src/_generated/_framework/reified.js +240 -0
  38. package/sdk/src/_generated/_framework/util.d.ts +35 -0
  39. package/sdk/src/_generated/_framework/util.js +334 -0
  40. package/sdk/src/_generated/_framework/vector.d.ts +35 -0
  41. package/sdk/src/_generated/_framework/vector.js +77 -0
  42. package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +54 -0
  43. package/sdk/src/_generated/liquid_staking/cell/structs.js +156 -0
  44. package/sdk/src/_generated/liquid_staking/fees/functions.d.ts +51 -0
  45. package/sdk/src/_generated/liquid_staking/fees/functions.js +130 -0
  46. package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +165 -0
  47. package/sdk/src/_generated/liquid_staking/fees/structs.js +307 -0
  48. package/sdk/src/_generated/liquid_staking/index.d.ts +4 -0
  49. package/sdk/src/_generated/liquid_staking/index.js +10 -0
  50. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.d.ts +88 -0
  51. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +199 -0
  52. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +955 -0
  53. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +1477 -0
  54. package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +358 -0
  55. package/sdk/src/_generated/liquid_staking/storage/structs.js +365 -0
  56. package/sdk/src/_generated/liquid_staking/version/structs.d.ts +46 -0
  57. package/sdk/src/_generated/liquid_staking/version/structs.js +143 -0
  58. package/sdk/src/_generated/liquid_staking/weight/functions.d.ts +19 -0
  59. package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -0
  60. package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +205 -0
  61. package/sdk/src/_generated/liquid_staking/weight/structs.js +332 -0
  62. package/sdk/src/index.d.ts +44 -0
  63. package/sdk/src/index.js +234 -0
@@ -0,0 +1,3 @@
1
+ export declare const PACKAGE_ID = "0x2";
2
+ export declare const PUBLISHED_AT = "0x2";
3
+ export declare const PKG_V28 = "0x2";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PKG_V28 = exports.PUBLISHED_AT = exports.PACKAGE_ID = void 0;
4
+ exports.PACKAGE_ID = "0x2";
5
+ exports.PUBLISHED_AT = "0x2";
6
+ exports.PKG_V28 = "0x2";
@@ -0,0 +1,92 @@
1
+ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
+ import { FieldsWithTypes } from "../../../../_framework/util";
3
+ import { PKG_V28 } from "../index";
4
+ import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
5
+ export declare function isID(type: string): boolean;
6
+ export interface IDFields {
7
+ bytes: ToField<"address">;
8
+ }
9
+ export type IDReified = Reified<ID, IDFields>;
10
+ export declare class ID implements StructClass {
11
+ __StructClass: true;
12
+ static readonly $typeName = "0x2::object::ID";
13
+ static readonly $numTypeParams = 0;
14
+ static readonly $isPhantom: readonly [];
15
+ readonly $typeName = "0x2::object::ID";
16
+ readonly $fullTypeName: `${typeof PKG_V28}::object::ID`;
17
+ readonly $typeArgs: [];
18
+ readonly $isPhantom: readonly [];
19
+ readonly bytes: ToField<"address">;
20
+ private constructor();
21
+ static reified(): IDReified;
22
+ static get r(): import("../../../../_framework/reified").StructClassReified<ID, IDFields>;
23
+ static phantom(): PhantomReified<ToTypeStr<ID>>;
24
+ static get p(): PhantomReified<"0x2::object::ID">;
25
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
26
+ bytes: string;
27
+ }, {
28
+ bytes: string;
29
+ }>;
30
+ static fromFields(fields: Record<string, any>): ID;
31
+ static fromFieldsWithTypes(item: FieldsWithTypes): ID;
32
+ static fromBcs(data: Uint8Array): ID;
33
+ toJSONField(): {
34
+ bytes: string;
35
+ };
36
+ toJSON(): {
37
+ bytes: string;
38
+ $typeName: string;
39
+ $typeArgs: [];
40
+ };
41
+ static fromJSONField(field: any): ID;
42
+ static fromJSON(json: Record<string, any>): ID;
43
+ static fromSuiParsedData(content: SuiParsedData): ID;
44
+ static fromSuiObjectData(data: SuiObjectData): ID;
45
+ static fetch(client: SuiClient, id: string): Promise<ID>;
46
+ }
47
+ export declare function isUID(type: string): boolean;
48
+ export interface UIDFields {
49
+ id: ToField<ID>;
50
+ }
51
+ export type UIDReified = Reified<UID, UIDFields>;
52
+ export declare class UID implements StructClass {
53
+ __StructClass: true;
54
+ static readonly $typeName = "0x2::object::UID";
55
+ static readonly $numTypeParams = 0;
56
+ static readonly $isPhantom: readonly [];
57
+ readonly $typeName = "0x2::object::UID";
58
+ readonly $fullTypeName: `${typeof PKG_V28}::object::UID`;
59
+ readonly $typeArgs: [];
60
+ readonly $isPhantom: readonly [];
61
+ readonly id: ToField<ID>;
62
+ private constructor();
63
+ static reified(): UIDReified;
64
+ static get r(): import("../../../../_framework/reified").StructClassReified<UID, UIDFields>;
65
+ static phantom(): PhantomReified<ToTypeStr<UID>>;
66
+ static get p(): PhantomReified<"0x2::object::UID">;
67
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
68
+ id: {
69
+ bytes: string;
70
+ };
71
+ }, {
72
+ id: {
73
+ bytes: string;
74
+ };
75
+ }>;
76
+ static fromFields(fields: Record<string, any>): UID;
77
+ static fromFieldsWithTypes(item: FieldsWithTypes): UID;
78
+ static fromBcs(data: Uint8Array): UID;
79
+ toJSONField(): {
80
+ id: string;
81
+ };
82
+ toJSON(): {
83
+ id: string;
84
+ $typeName: string;
85
+ $typeArgs: [];
86
+ };
87
+ static fromJSONField(field: any): UID;
88
+ static fromJSON(json: Record<string, any>): UID;
89
+ static fromSuiParsedData(content: SuiParsedData): UID;
90
+ static fromSuiObjectData(data: SuiObjectData): UID;
91
+ static fetch(client: SuiClient, id: string): Promise<UID>;
92
+ }
@@ -0,0 +1,270 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UID = exports.ID = void 0;
13
+ exports.isID = isID;
14
+ exports.isUID = isUID;
15
+ const reified_1 = require("../../../../_framework/reified");
16
+ const util_1 = require("../../../../_framework/util");
17
+ const index_1 = require("../index");
18
+ const bcs_1 = require("@mysten/sui/bcs");
19
+ const utils_1 = require("@mysten/sui/utils");
20
+ /* ============================== ID =============================== */
21
+ function isID(type) {
22
+ type = (0, util_1.compressSuiType)(type);
23
+ return type === `${index_1.PKG_V28}::object::ID`;
24
+ }
25
+ class ID {
26
+ constructor(typeArgs, fields) {
27
+ this.__StructClass = true;
28
+ this.$typeName = ID.$typeName;
29
+ this.$isPhantom = ID.$isPhantom;
30
+ this.$fullTypeName = (0, util_1.composeSuiType)(ID.$typeName, ...typeArgs);
31
+ this.$typeArgs = typeArgs;
32
+ this.bytes = fields.bytes;
33
+ }
34
+ static reified() {
35
+ return {
36
+ typeName: ID.$typeName,
37
+ fullTypeName: (0, util_1.composeSuiType)(ID.$typeName, ...[]),
38
+ typeArgs: [],
39
+ isPhantom: ID.$isPhantom,
40
+ reifiedTypeArgs: [],
41
+ fromFields: (fields) => ID.fromFields(fields),
42
+ fromFieldsWithTypes: (item) => ID.fromFieldsWithTypes(item),
43
+ fromBcs: (data) => ID.fromBcs(data),
44
+ bcs: ID.bcs,
45
+ fromJSONField: (field) => ID.fromJSONField(field),
46
+ fromJSON: (json) => ID.fromJSON(json),
47
+ fromSuiParsedData: (content) => ID.fromSuiParsedData(content),
48
+ fromSuiObjectData: (content) => ID.fromSuiObjectData(content),
49
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ID.fetch(client, id); }),
50
+ new: (fields) => {
51
+ return new ID([], fields);
52
+ },
53
+ kind: "StructClassReified",
54
+ };
55
+ }
56
+ static get r() {
57
+ return ID.reified();
58
+ }
59
+ static phantom() {
60
+ return (0, reified_1.phantom)(ID.reified());
61
+ }
62
+ static get p() {
63
+ return ID.phantom();
64
+ }
65
+ static get bcs() {
66
+ return bcs_1.bcs.struct("ID", {
67
+ bytes: bcs_1.bcs
68
+ .bytes(32)
69
+ .transform({
70
+ input: (val) => (0, utils_1.fromHEX)(val),
71
+ output: (val) => (0, utils_1.toHEX)(val),
72
+ }),
73
+ });
74
+ }
75
+ static fromFields(fields) {
76
+ return ID.reified().new({
77
+ bytes: (0, reified_1.decodeFromFields)("address", fields.bytes),
78
+ });
79
+ }
80
+ static fromFieldsWithTypes(item) {
81
+ if (!isID(item.type)) {
82
+ throw new Error("not a ID type");
83
+ }
84
+ return ID.reified().new({
85
+ bytes: (0, reified_1.decodeFromFieldsWithTypes)("address", item.fields.bytes),
86
+ });
87
+ }
88
+ static fromBcs(data) {
89
+ return ID.fromFields(ID.bcs.parse(data));
90
+ }
91
+ toJSONField() {
92
+ return {
93
+ bytes: this.bytes,
94
+ };
95
+ }
96
+ toJSON() {
97
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
98
+ }
99
+ static fromJSONField(field) {
100
+ return ID.reified().new({
101
+ bytes: (0, reified_1.decodeFromJSONField)("address", field.bytes),
102
+ });
103
+ }
104
+ static fromJSON(json) {
105
+ if (json.$typeName !== ID.$typeName) {
106
+ throw new Error("not a WithTwoGenerics json object");
107
+ }
108
+ return ID.fromJSONField(json);
109
+ }
110
+ static fromSuiParsedData(content) {
111
+ if (content.dataType !== "moveObject") {
112
+ throw new Error("not an object");
113
+ }
114
+ if (!isID(content.type)) {
115
+ throw new Error(`object at ${content.fields.id} is not a ID object`);
116
+ }
117
+ return ID.fromFieldsWithTypes(content);
118
+ }
119
+ static fromSuiObjectData(data) {
120
+ if (data.bcs) {
121
+ if (data.bcs.dataType !== "moveObject" || !isID(data.bcs.type)) {
122
+ throw new Error(`object at is not a ID object`);
123
+ }
124
+ return ID.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
125
+ }
126
+ if (data.content) {
127
+ return ID.fromSuiParsedData(data.content);
128
+ }
129
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
130
+ }
131
+ static fetch(client, id) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ var _a, _b;
134
+ const res = yield client.getObject({ id, options: { showBcs: true } });
135
+ if (res.error) {
136
+ throw new Error(`error fetching ID object at id ${id}: ${res.error.code}`);
137
+ }
138
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isID(res.data.bcs.type)) {
139
+ throw new Error(`object at id ${id} is not a ID object`);
140
+ }
141
+ return ID.fromSuiObjectData(res.data);
142
+ });
143
+ }
144
+ }
145
+ exports.ID = ID;
146
+ ID.$typeName = `${index_1.PKG_V28}::object::ID`;
147
+ ID.$numTypeParams = 0;
148
+ ID.$isPhantom = [];
149
+ /* ============================== UID =============================== */
150
+ function isUID(type) {
151
+ type = (0, util_1.compressSuiType)(type);
152
+ return type === `${index_1.PKG_V28}::object::UID`;
153
+ }
154
+ class UID {
155
+ constructor(typeArgs, fields) {
156
+ this.__StructClass = true;
157
+ this.$typeName = UID.$typeName;
158
+ this.$isPhantom = UID.$isPhantom;
159
+ this.$fullTypeName = (0, util_1.composeSuiType)(UID.$typeName, ...typeArgs);
160
+ this.$typeArgs = typeArgs;
161
+ this.id = fields.id;
162
+ }
163
+ static reified() {
164
+ return {
165
+ typeName: UID.$typeName,
166
+ fullTypeName: (0, util_1.composeSuiType)(UID.$typeName, ...[]),
167
+ typeArgs: [],
168
+ isPhantom: UID.$isPhantom,
169
+ reifiedTypeArgs: [],
170
+ fromFields: (fields) => UID.fromFields(fields),
171
+ fromFieldsWithTypes: (item) => UID.fromFieldsWithTypes(item),
172
+ fromBcs: (data) => UID.fromBcs(data),
173
+ bcs: UID.bcs,
174
+ fromJSONField: (field) => UID.fromJSONField(field),
175
+ fromJSON: (json) => UID.fromJSON(json),
176
+ fromSuiParsedData: (content) => UID.fromSuiParsedData(content),
177
+ fromSuiObjectData: (content) => UID.fromSuiObjectData(content),
178
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return UID.fetch(client, id); }),
179
+ new: (fields) => {
180
+ return new UID([], fields);
181
+ },
182
+ kind: "StructClassReified",
183
+ };
184
+ }
185
+ static get r() {
186
+ return UID.reified();
187
+ }
188
+ static phantom() {
189
+ return (0, reified_1.phantom)(UID.reified());
190
+ }
191
+ static get p() {
192
+ return UID.phantom();
193
+ }
194
+ static get bcs() {
195
+ return bcs_1.bcs.struct("UID", {
196
+ id: ID.bcs,
197
+ });
198
+ }
199
+ static fromFields(fields) {
200
+ return UID.reified().new({ id: (0, reified_1.decodeFromFields)(ID.reified(), fields.id) });
201
+ }
202
+ static fromFieldsWithTypes(item) {
203
+ if (!isUID(item.type)) {
204
+ throw new Error("not a UID type");
205
+ }
206
+ return UID.reified().new({
207
+ id: (0, reified_1.decodeFromFieldsWithTypes)(ID.reified(), item.fields.id),
208
+ });
209
+ }
210
+ static fromBcs(data) {
211
+ return UID.fromFields(UID.bcs.parse(data));
212
+ }
213
+ toJSONField() {
214
+ return {
215
+ id: this.id,
216
+ };
217
+ }
218
+ toJSON() {
219
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
220
+ }
221
+ static fromJSONField(field) {
222
+ return UID.reified().new({
223
+ id: (0, reified_1.decodeFromJSONField)(ID.reified(), field.id),
224
+ });
225
+ }
226
+ static fromJSON(json) {
227
+ if (json.$typeName !== UID.$typeName) {
228
+ throw new Error("not a WithTwoGenerics json object");
229
+ }
230
+ return UID.fromJSONField(json);
231
+ }
232
+ static fromSuiParsedData(content) {
233
+ if (content.dataType !== "moveObject") {
234
+ throw new Error("not an object");
235
+ }
236
+ if (!isUID(content.type)) {
237
+ throw new Error(`object at ${content.fields.id} is not a UID object`);
238
+ }
239
+ return UID.fromFieldsWithTypes(content);
240
+ }
241
+ static fromSuiObjectData(data) {
242
+ if (data.bcs) {
243
+ if (data.bcs.dataType !== "moveObject" || !isUID(data.bcs.type)) {
244
+ throw new Error(`object at is not a UID object`);
245
+ }
246
+ return UID.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
247
+ }
248
+ if (data.content) {
249
+ return UID.fromSuiParsedData(data.content);
250
+ }
251
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
252
+ }
253
+ static fetch(client, id) {
254
+ return __awaiter(this, void 0, void 0, function* () {
255
+ var _a, _b;
256
+ const res = yield client.getObject({ id, options: { showBcs: true } });
257
+ if (res.error) {
258
+ throw new Error(`error fetching UID object at id ${id}: ${res.error.code}`);
259
+ }
260
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isUID(res.data.bcs.type)) {
261
+ throw new Error(`object at id ${id} is not a UID object`);
262
+ }
263
+ return UID.fromSuiObjectData(res.data);
264
+ });
265
+ }
266
+ }
267
+ exports.UID = UID;
268
+ UID.$typeName = `${index_1.PKG_V28}::object::UID`;
269
+ UID.$numTypeParams = 0;
270
+ UID.$isPhantom = [];
@@ -0,0 +1,46 @@
1
+ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
+ import { FieldsWithTypes } from "../../../../_framework/util";
3
+ import { PKG_V28 } from "../index";
4
+ import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
5
+ export declare function isSUI(type: string): boolean;
6
+ export interface SUIFields {
7
+ dummyField: ToField<"bool">;
8
+ }
9
+ export type SUIReified = Reified<SUI, SUIFields>;
10
+ export declare class SUI implements StructClass {
11
+ __StructClass: true;
12
+ static readonly $typeName = "0x2::sui::SUI";
13
+ static readonly $numTypeParams = 0;
14
+ static readonly $isPhantom: readonly [];
15
+ readonly $typeName = "0x2::sui::SUI";
16
+ readonly $fullTypeName: `${typeof PKG_V28}::sui::SUI`;
17
+ readonly $typeArgs: [];
18
+ readonly $isPhantom: readonly [];
19
+ readonly dummyField: ToField<"bool">;
20
+ private constructor();
21
+ static reified(): SUIReified;
22
+ static get r(): import("../../../../_framework/reified").StructClassReified<SUI, SUIFields>;
23
+ static phantom(): PhantomReified<ToTypeStr<SUI>>;
24
+ static get p(): PhantomReified<"0x2::sui::SUI">;
25
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
26
+ dummy_field: boolean;
27
+ }, {
28
+ dummy_field: boolean;
29
+ }>;
30
+ static fromFields(fields: Record<string, any>): SUI;
31
+ static fromFieldsWithTypes(item: FieldsWithTypes): SUI;
32
+ static fromBcs(data: Uint8Array): SUI;
33
+ toJSONField(): {
34
+ dummyField: boolean;
35
+ };
36
+ toJSON(): {
37
+ dummyField: boolean;
38
+ $typeName: string;
39
+ $typeArgs: [];
40
+ };
41
+ static fromJSONField(field: any): SUI;
42
+ static fromJSON(json: Record<string, any>): SUI;
43
+ static fromSuiParsedData(content: SuiParsedData): SUI;
44
+ static fromSuiObjectData(data: SuiObjectData): SUI;
45
+ static fetch(client: SuiClient, id: string): Promise<SUI>;
46
+ }
@@ -0,0 +1,142 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SUI = void 0;
13
+ exports.isSUI = isSUI;
14
+ const reified_1 = require("../../../../_framework/reified");
15
+ const util_1 = require("../../../../_framework/util");
16
+ const index_1 = require("../index");
17
+ const bcs_1 = require("@mysten/sui/bcs");
18
+ const utils_1 = require("@mysten/sui/utils");
19
+ /* ============================== SUI =============================== */
20
+ function isSUI(type) {
21
+ type = (0, util_1.compressSuiType)(type);
22
+ return type === `${index_1.PKG_V28}::sui::SUI`;
23
+ }
24
+ class SUI {
25
+ constructor(typeArgs, fields) {
26
+ this.__StructClass = true;
27
+ this.$typeName = SUI.$typeName;
28
+ this.$isPhantom = SUI.$isPhantom;
29
+ this.$fullTypeName = (0, util_1.composeSuiType)(SUI.$typeName, ...typeArgs);
30
+ this.$typeArgs = typeArgs;
31
+ this.dummyField = fields.dummyField;
32
+ }
33
+ static reified() {
34
+ return {
35
+ typeName: SUI.$typeName,
36
+ fullTypeName: (0, util_1.composeSuiType)(SUI.$typeName, ...[]),
37
+ typeArgs: [],
38
+ isPhantom: SUI.$isPhantom,
39
+ reifiedTypeArgs: [],
40
+ fromFields: (fields) => SUI.fromFields(fields),
41
+ fromFieldsWithTypes: (item) => SUI.fromFieldsWithTypes(item),
42
+ fromBcs: (data) => SUI.fromBcs(data),
43
+ bcs: SUI.bcs,
44
+ fromJSONField: (field) => SUI.fromJSONField(field),
45
+ fromJSON: (json) => SUI.fromJSON(json),
46
+ fromSuiParsedData: (content) => SUI.fromSuiParsedData(content),
47
+ fromSuiObjectData: (content) => SUI.fromSuiObjectData(content),
48
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return SUI.fetch(client, id); }),
49
+ new: (fields) => {
50
+ return new SUI([], fields);
51
+ },
52
+ kind: "StructClassReified",
53
+ };
54
+ }
55
+ static get r() {
56
+ return SUI.reified();
57
+ }
58
+ static phantom() {
59
+ return (0, reified_1.phantom)(SUI.reified());
60
+ }
61
+ static get p() {
62
+ return SUI.phantom();
63
+ }
64
+ static get bcs() {
65
+ return bcs_1.bcs.struct("SUI", {
66
+ dummy_field: bcs_1.bcs.bool(),
67
+ });
68
+ }
69
+ static fromFields(fields) {
70
+ return SUI.reified().new({
71
+ dummyField: (0, reified_1.decodeFromFields)("bool", fields.dummy_field),
72
+ });
73
+ }
74
+ static fromFieldsWithTypes(item) {
75
+ if (!isSUI(item.type)) {
76
+ throw new Error("not a SUI type");
77
+ }
78
+ return SUI.reified().new({
79
+ dummyField: (0, reified_1.decodeFromFieldsWithTypes)("bool", item.fields.dummy_field),
80
+ });
81
+ }
82
+ static fromBcs(data) {
83
+ return SUI.fromFields(SUI.bcs.parse(data));
84
+ }
85
+ toJSONField() {
86
+ return {
87
+ dummyField: this.dummyField,
88
+ };
89
+ }
90
+ toJSON() {
91
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
92
+ }
93
+ static fromJSONField(field) {
94
+ return SUI.reified().new({
95
+ dummyField: (0, reified_1.decodeFromJSONField)("bool", field.dummyField),
96
+ });
97
+ }
98
+ static fromJSON(json) {
99
+ if (json.$typeName !== SUI.$typeName) {
100
+ throw new Error("not a WithTwoGenerics json object");
101
+ }
102
+ return SUI.fromJSONField(json);
103
+ }
104
+ static fromSuiParsedData(content) {
105
+ if (content.dataType !== "moveObject") {
106
+ throw new Error("not an object");
107
+ }
108
+ if (!isSUI(content.type)) {
109
+ throw new Error(`object at ${content.fields.id} is not a SUI object`);
110
+ }
111
+ return SUI.fromFieldsWithTypes(content);
112
+ }
113
+ static fromSuiObjectData(data) {
114
+ if (data.bcs) {
115
+ if (data.bcs.dataType !== "moveObject" || !isSUI(data.bcs.type)) {
116
+ throw new Error(`object at is not a SUI object`);
117
+ }
118
+ return SUI.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
119
+ }
120
+ if (data.content) {
121
+ return SUI.fromSuiParsedData(data.content);
122
+ }
123
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
124
+ }
125
+ static fetch(client, id) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ var _a, _b;
128
+ const res = yield client.getObject({ id, options: { showBcs: true } });
129
+ if (res.error) {
130
+ throw new Error(`error fetching SUI object at id ${id}: ${res.error.code}`);
131
+ }
132
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isSUI(res.data.bcs.type)) {
133
+ throw new Error(`object at id ${id} is not a SUI object`);
134
+ }
135
+ return SUI.fromSuiObjectData(res.data);
136
+ });
137
+ }
138
+ }
139
+ exports.SUI = SUI;
140
+ SUI.$typeName = `${index_1.PKG_V28}::sui::SUI`;
141
+ SUI.$numTypeParams = 0;
142
+ SUI.$isPhantom = [];
@@ -0,0 +1,61 @@
1
+ import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr } from "../../../../_framework/reified";
2
+ import { FieldsWithTypes } from "../../../../_framework/util";
3
+ import { PKG_V28 } from "../index";
4
+ import { UID } from "../object/structs";
5
+ import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
6
+ export declare function isTable(type: string): boolean;
7
+ export interface TableFields<K extends PhantomTypeArgument, V extends PhantomTypeArgument> {
8
+ id: ToField<UID>;
9
+ size: ToField<"u64">;
10
+ }
11
+ export type TableReified<K extends PhantomTypeArgument, V extends PhantomTypeArgument> = Reified<Table<K, V>, TableFields<K, V>>;
12
+ export declare class Table<K extends PhantomTypeArgument, V extends PhantomTypeArgument> implements StructClass {
13
+ __StructClass: true;
14
+ static readonly $typeName = "0x2::table::Table";
15
+ static readonly $numTypeParams = 2;
16
+ static readonly $isPhantom: readonly [true, true];
17
+ readonly $typeName = "0x2::table::Table";
18
+ readonly $fullTypeName: `${typeof PKG_V28}::table::Table<${PhantomToTypeStr<K>}, ${PhantomToTypeStr<V>}>`;
19
+ readonly $typeArgs: [PhantomToTypeStr<K>, PhantomToTypeStr<V>];
20
+ readonly $isPhantom: readonly [true, true];
21
+ readonly id: ToField<UID>;
22
+ readonly size: ToField<"u64">;
23
+ private constructor();
24
+ static reified<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): TableReified<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
25
+ static get r(): typeof Table.reified;
26
+ static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): PhantomReified<ToTypeStr<Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>>;
27
+ static get p(): typeof Table.phantom;
28
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
29
+ id: {
30
+ id: {
31
+ bytes: string;
32
+ };
33
+ };
34
+ size: string;
35
+ }, {
36
+ id: {
37
+ id: {
38
+ bytes: string;
39
+ };
40
+ };
41
+ size: string | number | bigint;
42
+ }>;
43
+ static fromFields<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], fields: Record<string, any>): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
44
+ static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], item: FieldsWithTypes): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
45
+ static fromBcs<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: Uint8Array): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
46
+ toJSONField(): {
47
+ id: string;
48
+ size: string;
49
+ };
50
+ toJSON(): {
51
+ id: string;
52
+ size: string;
53
+ $typeName: string;
54
+ $typeArgs: [PhantomToTypeStr<K>, PhantomToTypeStr<V>];
55
+ };
56
+ static fromJSONField<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], field: any): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
57
+ static fromJSON<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], json: Record<string, any>): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
58
+ static fromSuiParsedData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], content: SuiParsedData): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
59
+ static fromSuiObjectData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: SuiObjectData): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
60
+ static fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(client: SuiClient, typeArgs: [K, V], id: string): Promise<Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>;
61
+ }