@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,167 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.String = void 0;
36
+ exports.isString = isString;
37
+ const reified = __importStar(require("../../../../_framework/reified"));
38
+ const reified_1 = require("../../../../_framework/reified");
39
+ const util_1 = require("../../../../_framework/util");
40
+ const index_1 = require("../index");
41
+ const bcs_1 = require("@mysten/sui/bcs");
42
+ const utils_1 = require("@mysten/sui/utils");
43
+ /* ============================== String =============================== */
44
+ function isString(type) {
45
+ type = (0, util_1.compressSuiType)(type);
46
+ return type === `${index_1.PKG_V10}::string::String`;
47
+ }
48
+ class String {
49
+ constructor(typeArgs, fields) {
50
+ this.__StructClass = true;
51
+ this.$typeName = String.$typeName;
52
+ this.$isPhantom = String.$isPhantom;
53
+ this.$fullTypeName = (0, util_1.composeSuiType)(String.$typeName, ...typeArgs);
54
+ this.$typeArgs = typeArgs;
55
+ this.bytes = fields.bytes;
56
+ }
57
+ static reified() {
58
+ return {
59
+ typeName: String.$typeName,
60
+ fullTypeName: (0, util_1.composeSuiType)(String.$typeName, ...[]),
61
+ typeArgs: [],
62
+ isPhantom: String.$isPhantom,
63
+ reifiedTypeArgs: [],
64
+ fromFields: (fields) => String.fromFields(fields),
65
+ fromFieldsWithTypes: (item) => String.fromFieldsWithTypes(item),
66
+ fromBcs: (data) => String.fromBcs(data),
67
+ bcs: String.bcs,
68
+ fromJSONField: (field) => String.fromJSONField(field),
69
+ fromJSON: (json) => String.fromJSON(json),
70
+ fromSuiParsedData: (content) => String.fromSuiParsedData(content),
71
+ fromSuiObjectData: (content) => String.fromSuiObjectData(content),
72
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return String.fetch(client, id); }),
73
+ new: (fields) => {
74
+ return new String([], fields);
75
+ },
76
+ kind: "StructClassReified",
77
+ };
78
+ }
79
+ static get r() {
80
+ return String.reified();
81
+ }
82
+ static phantom() {
83
+ return (0, reified_1.phantom)(String.reified());
84
+ }
85
+ static get p() {
86
+ return String.phantom();
87
+ }
88
+ static get bcs() {
89
+ return bcs_1.bcs.struct("String", {
90
+ bytes: bcs_1.bcs.vector(bcs_1.bcs.u8()),
91
+ });
92
+ }
93
+ static fromFields(fields) {
94
+ return String.reified().new({
95
+ bytes: (0, reified_1.decodeFromFields)(reified.vector("u8"), fields.bytes),
96
+ });
97
+ }
98
+ static fromFieldsWithTypes(item) {
99
+ if (!isString(item.type)) {
100
+ throw new Error("not a String type");
101
+ }
102
+ return String.reified().new({
103
+ bytes: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector("u8"), item.fields.bytes),
104
+ });
105
+ }
106
+ static fromBcs(data) {
107
+ return String.fromFields(String.bcs.parse(data));
108
+ }
109
+ toJSONField() {
110
+ return {
111
+ bytes: (0, reified_1.fieldToJSON)(`vector<u8>`, this.bytes),
112
+ };
113
+ }
114
+ toJSON() {
115
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
116
+ }
117
+ static fromJSONField(field) {
118
+ return String.reified().new({
119
+ bytes: (0, reified_1.decodeFromJSONField)(reified.vector("u8"), field.bytes),
120
+ });
121
+ }
122
+ static fromJSON(json) {
123
+ if (json.$typeName !== String.$typeName) {
124
+ throw new Error("not a WithTwoGenerics json object");
125
+ }
126
+ return String.fromJSONField(json);
127
+ }
128
+ static fromSuiParsedData(content) {
129
+ if (content.dataType !== "moveObject") {
130
+ throw new Error("not an object");
131
+ }
132
+ if (!isString(content.type)) {
133
+ throw new Error(`object at ${content.fields.id} is not a String object`);
134
+ }
135
+ return String.fromFieldsWithTypes(content);
136
+ }
137
+ static fromSuiObjectData(data) {
138
+ if (data.bcs) {
139
+ if (data.bcs.dataType !== "moveObject" || !isString(data.bcs.type)) {
140
+ throw new Error(`object at is not a String object`);
141
+ }
142
+ return String.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
143
+ }
144
+ if (data.content) {
145
+ return String.fromSuiParsedData(data.content);
146
+ }
147
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
148
+ }
149
+ static fetch(client, id) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ var _a, _b;
152
+ const res = yield client.getObject({ id, options: { showBcs: true } });
153
+ if (res.error) {
154
+ throw new Error(`error fetching String object at id ${id}: ${res.error.code}`);
155
+ }
156
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
157
+ !isString(res.data.bcs.type)) {
158
+ throw new Error(`object at id ${id} is not a String object`);
159
+ }
160
+ return String.fromSuiObjectData(res.data);
161
+ });
162
+ }
163
+ }
164
+ exports.String = String;
165
+ String.$typeName = `${index_1.PKG_V10}::string::String`;
166
+ String.$numTypeParams = 0;
167
+ String.$isPhantom = [];
@@ -0,0 +1,53 @@
1
+ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
+ import { FieldsWithTypes } from "../../../../_framework/util";
3
+ import { String } from "../ascii/structs";
4
+ import { PKG_V10 } from "../index";
5
+ import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
6
+ export declare function isTypeName(type: string): boolean;
7
+ export interface TypeNameFields {
8
+ name: ToField<String>;
9
+ }
10
+ export type TypeNameReified = Reified<TypeName, TypeNameFields>;
11
+ export declare class TypeName implements StructClass {
12
+ __StructClass: true;
13
+ static readonly $typeName = "0x1::type_name::TypeName";
14
+ static readonly $numTypeParams = 0;
15
+ static readonly $isPhantom: readonly [];
16
+ readonly $typeName = "0x1::type_name::TypeName";
17
+ readonly $fullTypeName: `${typeof PKG_V10}::type_name::TypeName`;
18
+ readonly $typeArgs: [];
19
+ readonly $isPhantom: readonly [];
20
+ readonly name: ToField<String>;
21
+ private constructor();
22
+ static reified(): TypeNameReified;
23
+ static get r(): import("../../../../_framework/reified").StructClassReified<TypeName, TypeNameFields>;
24
+ static phantom(): PhantomReified<ToTypeStr<TypeName>>;
25
+ static get p(): PhantomReified<"0x1::type_name::TypeName">;
26
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
27
+ name: {
28
+ bytes: number[];
29
+ };
30
+ }, {
31
+ name: {
32
+ bytes: Iterable<number> & {
33
+ length: number;
34
+ };
35
+ };
36
+ }>;
37
+ static fromFields(fields: Record<string, any>): TypeName;
38
+ static fromFieldsWithTypes(item: FieldsWithTypes): TypeName;
39
+ static fromBcs(data: Uint8Array): TypeName;
40
+ toJSONField(): {
41
+ name: string;
42
+ };
43
+ toJSON(): {
44
+ name: string;
45
+ $typeName: string;
46
+ $typeArgs: [];
47
+ };
48
+ static fromJSONField(field: any): TypeName;
49
+ static fromJSON(json: Record<string, any>): TypeName;
50
+ static fromSuiParsedData(content: SuiParsedData): TypeName;
51
+ static fromSuiObjectData(data: SuiObjectData): TypeName;
52
+ static fetch(client: SuiClient, id: string): Promise<TypeName>;
53
+ }
@@ -0,0 +1,144 @@
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.TypeName = void 0;
13
+ exports.isTypeName = isTypeName;
14
+ const reified_1 = require("../../../../_framework/reified");
15
+ const util_1 = require("../../../../_framework/util");
16
+ const structs_1 = require("../ascii/structs");
17
+ const index_1 = require("../index");
18
+ const bcs_1 = require("@mysten/sui/bcs");
19
+ const utils_1 = require("@mysten/sui/utils");
20
+ /* ============================== TypeName =============================== */
21
+ function isTypeName(type) {
22
+ type = (0, util_1.compressSuiType)(type);
23
+ return type === `${index_1.PKG_V10}::type_name::TypeName`;
24
+ }
25
+ class TypeName {
26
+ constructor(typeArgs, fields) {
27
+ this.__StructClass = true;
28
+ this.$typeName = TypeName.$typeName;
29
+ this.$isPhantom = TypeName.$isPhantom;
30
+ this.$fullTypeName = (0, util_1.composeSuiType)(TypeName.$typeName, ...typeArgs);
31
+ this.$typeArgs = typeArgs;
32
+ this.name = fields.name;
33
+ }
34
+ static reified() {
35
+ return {
36
+ typeName: TypeName.$typeName,
37
+ fullTypeName: (0, util_1.composeSuiType)(TypeName.$typeName, ...[]),
38
+ typeArgs: [],
39
+ isPhantom: TypeName.$isPhantom,
40
+ reifiedTypeArgs: [],
41
+ fromFields: (fields) => TypeName.fromFields(fields),
42
+ fromFieldsWithTypes: (item) => TypeName.fromFieldsWithTypes(item),
43
+ fromBcs: (data) => TypeName.fromBcs(data),
44
+ bcs: TypeName.bcs,
45
+ fromJSONField: (field) => TypeName.fromJSONField(field),
46
+ fromJSON: (json) => TypeName.fromJSON(json),
47
+ fromSuiParsedData: (content) => TypeName.fromSuiParsedData(content),
48
+ fromSuiObjectData: (content) => TypeName.fromSuiObjectData(content),
49
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return TypeName.fetch(client, id); }),
50
+ new: (fields) => {
51
+ return new TypeName([], fields);
52
+ },
53
+ kind: "StructClassReified",
54
+ };
55
+ }
56
+ static get r() {
57
+ return TypeName.reified();
58
+ }
59
+ static phantom() {
60
+ return (0, reified_1.phantom)(TypeName.reified());
61
+ }
62
+ static get p() {
63
+ return TypeName.phantom();
64
+ }
65
+ static get bcs() {
66
+ return bcs_1.bcs.struct("TypeName", {
67
+ name: structs_1.String.bcs,
68
+ });
69
+ }
70
+ static fromFields(fields) {
71
+ return TypeName.reified().new({
72
+ name: (0, reified_1.decodeFromFields)(structs_1.String.reified(), fields.name),
73
+ });
74
+ }
75
+ static fromFieldsWithTypes(item) {
76
+ if (!isTypeName(item.type)) {
77
+ throw new Error("not a TypeName type");
78
+ }
79
+ return TypeName.reified().new({
80
+ name: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.String.reified(), item.fields.name),
81
+ });
82
+ }
83
+ static fromBcs(data) {
84
+ return TypeName.fromFields(TypeName.bcs.parse(data));
85
+ }
86
+ toJSONField() {
87
+ return {
88
+ name: this.name,
89
+ };
90
+ }
91
+ toJSON() {
92
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
93
+ }
94
+ static fromJSONField(field) {
95
+ return TypeName.reified().new({
96
+ name: (0, reified_1.decodeFromJSONField)(structs_1.String.reified(), field.name),
97
+ });
98
+ }
99
+ static fromJSON(json) {
100
+ if (json.$typeName !== TypeName.$typeName) {
101
+ throw new Error("not a WithTwoGenerics json object");
102
+ }
103
+ return TypeName.fromJSONField(json);
104
+ }
105
+ static fromSuiParsedData(content) {
106
+ if (content.dataType !== "moveObject") {
107
+ throw new Error("not an object");
108
+ }
109
+ if (!isTypeName(content.type)) {
110
+ throw new Error(`object at ${content.fields.id} is not a TypeName object`);
111
+ }
112
+ return TypeName.fromFieldsWithTypes(content);
113
+ }
114
+ static fromSuiObjectData(data) {
115
+ if (data.bcs) {
116
+ if (data.bcs.dataType !== "moveObject" || !isTypeName(data.bcs.type)) {
117
+ throw new Error(`object at is not a TypeName object`);
118
+ }
119
+ return TypeName.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
120
+ }
121
+ if (data.content) {
122
+ return TypeName.fromSuiParsedData(data.content);
123
+ }
124
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
125
+ }
126
+ static fetch(client, id) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ var _a, _b;
129
+ const res = yield client.getObject({ id, options: { showBcs: true } });
130
+ if (res.error) {
131
+ throw new Error(`error fetching TypeName object at id ${id}: ${res.error.code}`);
132
+ }
133
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
134
+ !isTypeName(res.data.bcs.type)) {
135
+ throw new Error(`object at id ${id} is not a TypeName object`);
136
+ }
137
+ return TypeName.fromSuiObjectData(res.data);
138
+ });
139
+ }
140
+ }
141
+ exports.TypeName = TypeName;
142
+ TypeName.$typeName = `${index_1.PKG_V10}::type_name::TypeName`;
143
+ TypeName.$numTypeParams = 0;
144
+ TypeName.$isPhantom = [];
@@ -0,0 +1,61 @@
1
+ import { PhantomReified, Reified, StructClass, ToField, 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 isBag(type: string): boolean;
7
+ export interface BagFields {
8
+ id: ToField<UID>;
9
+ size: ToField<"u64">;
10
+ }
11
+ export type BagReified = Reified<Bag, BagFields>;
12
+ export declare class Bag implements StructClass {
13
+ __StructClass: true;
14
+ static readonly $typeName = "0x2::bag::Bag";
15
+ static readonly $numTypeParams = 0;
16
+ static readonly $isPhantom: readonly [];
17
+ readonly $typeName = "0x2::bag::Bag";
18
+ readonly $fullTypeName: `${typeof PKG_V28}::bag::Bag`;
19
+ readonly $typeArgs: [];
20
+ readonly $isPhantom: readonly [];
21
+ readonly id: ToField<UID>;
22
+ readonly size: ToField<"u64">;
23
+ private constructor();
24
+ static reified(): BagReified;
25
+ static get r(): import("../../../../_framework/reified").StructClassReified<Bag, BagFields>;
26
+ static phantom(): PhantomReified<ToTypeStr<Bag>>;
27
+ static get p(): PhantomReified<"0x2::bag::Bag">;
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(fields: Record<string, any>): Bag;
44
+ static fromFieldsWithTypes(item: FieldsWithTypes): Bag;
45
+ static fromBcs(data: Uint8Array): Bag;
46
+ toJSONField(): {
47
+ id: string;
48
+ size: string;
49
+ };
50
+ toJSON(): {
51
+ id: string;
52
+ size: string;
53
+ $typeName: string;
54
+ $typeArgs: [];
55
+ };
56
+ static fromJSONField(field: any): Bag;
57
+ static fromJSON(json: Record<string, any>): Bag;
58
+ static fromSuiParsedData(content: SuiParsedData): Bag;
59
+ static fromSuiObjectData(data: SuiObjectData): Bag;
60
+ static fetch(client: SuiClient, id: string): Promise<Bag>;
61
+ }
@@ -0,0 +1,149 @@
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.Bag = void 0;
13
+ exports.isBag = isBag;
14
+ const reified_1 = require("../../../../_framework/reified");
15
+ const util_1 = require("../../../../_framework/util");
16
+ const index_1 = require("../index");
17
+ const structs_1 = require("../object/structs");
18
+ const bcs_1 = require("@mysten/sui/bcs");
19
+ const utils_1 = require("@mysten/sui/utils");
20
+ /* ============================== Bag =============================== */
21
+ function isBag(type) {
22
+ type = (0, util_1.compressSuiType)(type);
23
+ return type === `${index_1.PKG_V28}::bag::Bag`;
24
+ }
25
+ class Bag {
26
+ constructor(typeArgs, fields) {
27
+ this.__StructClass = true;
28
+ this.$typeName = Bag.$typeName;
29
+ this.$isPhantom = Bag.$isPhantom;
30
+ this.$fullTypeName = (0, util_1.composeSuiType)(Bag.$typeName, ...typeArgs);
31
+ this.$typeArgs = typeArgs;
32
+ this.id = fields.id;
33
+ this.size = fields.size;
34
+ }
35
+ static reified() {
36
+ return {
37
+ typeName: Bag.$typeName,
38
+ fullTypeName: (0, util_1.composeSuiType)(Bag.$typeName, ...[]),
39
+ typeArgs: [],
40
+ isPhantom: Bag.$isPhantom,
41
+ reifiedTypeArgs: [],
42
+ fromFields: (fields) => Bag.fromFields(fields),
43
+ fromFieldsWithTypes: (item) => Bag.fromFieldsWithTypes(item),
44
+ fromBcs: (data) => Bag.fromBcs(data),
45
+ bcs: Bag.bcs,
46
+ fromJSONField: (field) => Bag.fromJSONField(field),
47
+ fromJSON: (json) => Bag.fromJSON(json),
48
+ fromSuiParsedData: (content) => Bag.fromSuiParsedData(content),
49
+ fromSuiObjectData: (content) => Bag.fromSuiObjectData(content),
50
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Bag.fetch(client, id); }),
51
+ new: (fields) => {
52
+ return new Bag([], fields);
53
+ },
54
+ kind: "StructClassReified",
55
+ };
56
+ }
57
+ static get r() {
58
+ return Bag.reified();
59
+ }
60
+ static phantom() {
61
+ return (0, reified_1.phantom)(Bag.reified());
62
+ }
63
+ static get p() {
64
+ return Bag.phantom();
65
+ }
66
+ static get bcs() {
67
+ return bcs_1.bcs.struct("Bag", {
68
+ id: structs_1.UID.bcs,
69
+ size: bcs_1.bcs.u64(),
70
+ });
71
+ }
72
+ static fromFields(fields) {
73
+ return Bag.reified().new({
74
+ id: (0, reified_1.decodeFromFields)(structs_1.UID.reified(), fields.id),
75
+ size: (0, reified_1.decodeFromFields)("u64", fields.size),
76
+ });
77
+ }
78
+ static fromFieldsWithTypes(item) {
79
+ if (!isBag(item.type)) {
80
+ throw new Error("not a Bag type");
81
+ }
82
+ return Bag.reified().new({
83
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.UID.reified(), item.fields.id),
84
+ size: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.size),
85
+ });
86
+ }
87
+ static fromBcs(data) {
88
+ return Bag.fromFields(Bag.bcs.parse(data));
89
+ }
90
+ toJSONField() {
91
+ return {
92
+ id: this.id,
93
+ size: this.size.toString(),
94
+ };
95
+ }
96
+ toJSON() {
97
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
98
+ }
99
+ static fromJSONField(field) {
100
+ return Bag.reified().new({
101
+ id: (0, reified_1.decodeFromJSONField)(structs_1.UID.reified(), field.id),
102
+ size: (0, reified_1.decodeFromJSONField)("u64", field.size),
103
+ });
104
+ }
105
+ static fromJSON(json) {
106
+ if (json.$typeName !== Bag.$typeName) {
107
+ throw new Error("not a WithTwoGenerics json object");
108
+ }
109
+ return Bag.fromJSONField(json);
110
+ }
111
+ static fromSuiParsedData(content) {
112
+ if (content.dataType !== "moveObject") {
113
+ throw new Error("not an object");
114
+ }
115
+ if (!isBag(content.type)) {
116
+ throw new Error(`object at ${content.fields.id} is not a Bag object`);
117
+ }
118
+ return Bag.fromFieldsWithTypes(content);
119
+ }
120
+ static fromSuiObjectData(data) {
121
+ if (data.bcs) {
122
+ if (data.bcs.dataType !== "moveObject" || !isBag(data.bcs.type)) {
123
+ throw new Error(`object at is not a Bag object`);
124
+ }
125
+ return Bag.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
126
+ }
127
+ if (data.content) {
128
+ return Bag.fromSuiParsedData(data.content);
129
+ }
130
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
131
+ }
132
+ static fetch(client, id) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ var _a, _b;
135
+ const res = yield client.getObject({ id, options: { showBcs: true } });
136
+ if (res.error) {
137
+ throw new Error(`error fetching Bag object at id ${id}: ${res.error.code}`);
138
+ }
139
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isBag(res.data.bcs.type)) {
140
+ throw new Error(`object at id ${id} is not a Bag object`);
141
+ }
142
+ return Bag.fromSuiObjectData(res.data);
143
+ });
144
+ }
145
+ }
146
+ exports.Bag = Bag;
147
+ Bag.$typeName = `${index_1.PKG_V28}::bag::Bag`;
148
+ Bag.$numTypeParams = 0;
149
+ Bag.$isPhantom = [];
@@ -0,0 +1,88 @@
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 { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
5
+ export declare function isBalance(type: string): boolean;
6
+ export interface BalanceFields<T extends PhantomTypeArgument> {
7
+ value: ToField<"u64">;
8
+ }
9
+ export type BalanceReified<T extends PhantomTypeArgument> = Reified<Balance<T>, BalanceFields<T>>;
10
+ export declare class Balance<T extends PhantomTypeArgument> implements StructClass {
11
+ __StructClass: true;
12
+ static readonly $typeName = "0x2::balance::Balance";
13
+ static readonly $numTypeParams = 1;
14
+ static readonly $isPhantom: readonly [true];
15
+ readonly $typeName = "0x2::balance::Balance";
16
+ readonly $fullTypeName: `${typeof PKG_V28}::balance::Balance<${PhantomToTypeStr<T>}>`;
17
+ readonly $typeArgs: [PhantomToTypeStr<T>];
18
+ readonly $isPhantom: readonly [true];
19
+ readonly value: ToField<"u64">;
20
+ private constructor();
21
+ static reified<T extends PhantomReified<PhantomTypeArgument>>(T: T): BalanceReified<ToPhantomTypeArgument<T>>;
22
+ static get r(): typeof Balance.reified;
23
+ static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Balance<ToPhantomTypeArgument<T>>>>;
24
+ static get p(): typeof Balance.phantom;
25
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
26
+ value: string;
27
+ }, {
28
+ value: string | number | bigint;
29
+ }>;
30
+ static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Balance<ToPhantomTypeArgument<T>>;
31
+ static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Balance<ToPhantomTypeArgument<T>>;
32
+ static fromBcs<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: Uint8Array): Balance<ToPhantomTypeArgument<T>>;
33
+ toJSONField(): {
34
+ value: string;
35
+ };
36
+ toJSON(): {
37
+ value: string;
38
+ $typeName: string;
39
+ $typeArgs: [PhantomToTypeStr<T>];
40
+ };
41
+ static fromJSONField<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, field: any): Balance<ToPhantomTypeArgument<T>>;
42
+ static fromJSON<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, json: Record<string, any>): Balance<ToPhantomTypeArgument<T>>;
43
+ static fromSuiParsedData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, content: SuiParsedData): Balance<ToPhantomTypeArgument<T>>;
44
+ static fromSuiObjectData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: SuiObjectData): Balance<ToPhantomTypeArgument<T>>;
45
+ static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiClient, typeArg: T, id: string): Promise<Balance<ToPhantomTypeArgument<T>>>;
46
+ }
47
+ export declare function isSupply(type: string): boolean;
48
+ export interface SupplyFields<T extends PhantomTypeArgument> {
49
+ value: ToField<"u64">;
50
+ }
51
+ export type SupplyReified<T extends PhantomTypeArgument> = Reified<Supply<T>, SupplyFields<T>>;
52
+ export declare class Supply<T extends PhantomTypeArgument> implements StructClass {
53
+ __StructClass: true;
54
+ static readonly $typeName = "0x2::balance::Supply";
55
+ static readonly $numTypeParams = 1;
56
+ static readonly $isPhantom: readonly [true];
57
+ readonly $typeName = "0x2::balance::Supply";
58
+ readonly $fullTypeName: `${typeof PKG_V28}::balance::Supply<${PhantomToTypeStr<T>}>`;
59
+ readonly $typeArgs: [PhantomToTypeStr<T>];
60
+ readonly $isPhantom: readonly [true];
61
+ readonly value: ToField<"u64">;
62
+ private constructor();
63
+ static reified<T extends PhantomReified<PhantomTypeArgument>>(T: T): SupplyReified<ToPhantomTypeArgument<T>>;
64
+ static get r(): typeof Supply.reified;
65
+ static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Supply<ToPhantomTypeArgument<T>>>>;
66
+ static get p(): typeof Supply.phantom;
67
+ static get bcs(): import("@mysten/sui/bcs").BcsType<{
68
+ value: string;
69
+ }, {
70
+ value: string | number | bigint;
71
+ }>;
72
+ static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
73
+ static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Supply<ToPhantomTypeArgument<T>>;
74
+ static fromBcs<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: Uint8Array): Supply<ToPhantomTypeArgument<T>>;
75
+ toJSONField(): {
76
+ value: string;
77
+ };
78
+ toJSON(): {
79
+ value: string;
80
+ $typeName: string;
81
+ $typeArgs: [PhantomToTypeStr<T>];
82
+ };
83
+ static fromJSONField<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, field: any): Supply<ToPhantomTypeArgument<T>>;
84
+ static fromJSON<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, json: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
85
+ static fromSuiParsedData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, content: SuiParsedData): Supply<ToPhantomTypeArgument<T>>;
86
+ static fromSuiObjectData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: SuiObjectData): Supply<ToPhantomTypeArgument<T>>;
87
+ static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiClient, typeArg: T, id: string): Promise<Supply<ToPhantomTypeArgument<T>>>;
88
+ }