@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,1045 @@
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.TreasuryCap = exports.RegulatedCoinMetadata = exports.DenyCapV2 = exports.DenyCap = exports.CurrencyCreated = exports.CoinMetadata = exports.Coin = void 0;
13
+ exports.isCoin = isCoin;
14
+ exports.isCoinMetadata = isCoinMetadata;
15
+ exports.isCurrencyCreated = isCurrencyCreated;
16
+ exports.isDenyCap = isDenyCap;
17
+ exports.isDenyCapV2 = isDenyCapV2;
18
+ exports.isRegulatedCoinMetadata = isRegulatedCoinMetadata;
19
+ exports.isTreasuryCap = isTreasuryCap;
20
+ const reified_1 = require("../../../../_framework/reified");
21
+ const util_1 = require("../../../../_framework/util");
22
+ const structs_1 = require("../../0x1/ascii/structs");
23
+ const structs_2 = require("../../0x1/option/structs");
24
+ const structs_3 = require("../../0x1/string/structs");
25
+ const structs_4 = require("../balance/structs");
26
+ const index_1 = require("../index");
27
+ const structs_5 = require("../object/structs");
28
+ const structs_6 = require("../url/structs");
29
+ const bcs_1 = require("@mysten/sui/bcs");
30
+ const utils_1 = require("@mysten/sui/utils");
31
+ /* ============================== Coin =============================== */
32
+ function isCoin(type) {
33
+ type = (0, util_1.compressSuiType)(type);
34
+ return type.startsWith(`${index_1.PKG_V28}::coin::Coin` + "<");
35
+ }
36
+ class Coin {
37
+ constructor(typeArgs, fields) {
38
+ this.__StructClass = true;
39
+ this.$typeName = Coin.$typeName;
40
+ this.$isPhantom = Coin.$isPhantom;
41
+ this.$fullTypeName = (0, util_1.composeSuiType)(Coin.$typeName, ...typeArgs);
42
+ this.$typeArgs = typeArgs;
43
+ this.id = fields.id;
44
+ this.balance = fields.balance;
45
+ }
46
+ static reified(T) {
47
+ return {
48
+ typeName: Coin.$typeName,
49
+ fullTypeName: (0, util_1.composeSuiType)(Coin.$typeName, ...[(0, reified_1.extractType)(T)]),
50
+ typeArgs: [(0, reified_1.extractType)(T)],
51
+ isPhantom: Coin.$isPhantom,
52
+ reifiedTypeArgs: [T],
53
+ fromFields: (fields) => Coin.fromFields(T, fields),
54
+ fromFieldsWithTypes: (item) => Coin.fromFieldsWithTypes(T, item),
55
+ fromBcs: (data) => Coin.fromBcs(T, data),
56
+ bcs: Coin.bcs,
57
+ fromJSONField: (field) => Coin.fromJSONField(T, field),
58
+ fromJSON: (json) => Coin.fromJSON(T, json),
59
+ fromSuiParsedData: (content) => Coin.fromSuiParsedData(T, content),
60
+ fromSuiObjectData: (content) => Coin.fromSuiObjectData(T, content),
61
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Coin.fetch(client, T, id); }),
62
+ new: (fields) => {
63
+ return new Coin([(0, reified_1.extractType)(T)], fields);
64
+ },
65
+ kind: "StructClassReified",
66
+ };
67
+ }
68
+ static get r() {
69
+ return Coin.reified;
70
+ }
71
+ static phantom(T) {
72
+ return (0, reified_1.phantom)(Coin.reified(T));
73
+ }
74
+ static get p() {
75
+ return Coin.phantom;
76
+ }
77
+ static get bcs() {
78
+ return bcs_1.bcs.struct("Coin", {
79
+ id: structs_5.UID.bcs,
80
+ balance: structs_4.Balance.bcs,
81
+ });
82
+ }
83
+ static fromFields(typeArg, fields) {
84
+ return Coin.reified(typeArg).new({
85
+ id: (0, reified_1.decodeFromFields)(structs_5.UID.reified(), fields.id),
86
+ balance: (0, reified_1.decodeFromFields)(structs_4.Balance.reified(typeArg), fields.balance),
87
+ });
88
+ }
89
+ static fromFieldsWithTypes(typeArg, item) {
90
+ if (!isCoin(item.type)) {
91
+ throw new Error("not a Coin type");
92
+ }
93
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
94
+ return Coin.reified(typeArg).new({
95
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.UID.reified(), item.fields.id),
96
+ balance: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.Balance.reified(typeArg), item.fields.balance),
97
+ });
98
+ }
99
+ static fromBcs(typeArg, data) {
100
+ return Coin.fromFields(typeArg, Coin.bcs.parse(data));
101
+ }
102
+ toJSONField() {
103
+ return {
104
+ id: this.id,
105
+ balance: this.balance.toJSONField(),
106
+ };
107
+ }
108
+ toJSON() {
109
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
110
+ }
111
+ static fromJSONField(typeArg, field) {
112
+ return Coin.reified(typeArg).new({
113
+ id: (0, reified_1.decodeFromJSONField)(structs_5.UID.reified(), field.id),
114
+ balance: (0, reified_1.decodeFromJSONField)(structs_4.Balance.reified(typeArg), field.balance),
115
+ });
116
+ }
117
+ static fromJSON(typeArg, json) {
118
+ if (json.$typeName !== Coin.$typeName) {
119
+ throw new Error("not a WithTwoGenerics json object");
120
+ }
121
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(Coin.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
122
+ return Coin.fromJSONField(typeArg, json);
123
+ }
124
+ static fromSuiParsedData(typeArg, content) {
125
+ if (content.dataType !== "moveObject") {
126
+ throw new Error("not an object");
127
+ }
128
+ if (!isCoin(content.type)) {
129
+ throw new Error(`object at ${content.fields.id} is not a Coin object`);
130
+ }
131
+ return Coin.fromFieldsWithTypes(typeArg, content);
132
+ }
133
+ static fromSuiObjectData(typeArg, data) {
134
+ if (data.bcs) {
135
+ if (data.bcs.dataType !== "moveObject" || !isCoin(data.bcs.type)) {
136
+ throw new Error(`object at is not a Coin object`);
137
+ }
138
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
139
+ if (gotTypeArgs.length !== 1) {
140
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
141
+ }
142
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
143
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
144
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
145
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
146
+ }
147
+ return Coin.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
148
+ }
149
+ if (data.content) {
150
+ return Coin.fromSuiParsedData(typeArg, data.content);
151
+ }
152
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
153
+ }
154
+ static fetch(client, typeArg, id) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ var _a, _b;
157
+ const res = yield client.getObject({ id, options: { showBcs: true } });
158
+ if (res.error) {
159
+ throw new Error(`error fetching Coin object at id ${id}: ${res.error.code}`);
160
+ }
161
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
162
+ !isCoin(res.data.bcs.type)) {
163
+ throw new Error(`object at id ${id} is not a Coin object`);
164
+ }
165
+ return Coin.fromSuiObjectData(typeArg, res.data);
166
+ });
167
+ }
168
+ }
169
+ exports.Coin = Coin;
170
+ Coin.$typeName = `${index_1.PKG_V28}::coin::Coin`;
171
+ Coin.$numTypeParams = 1;
172
+ Coin.$isPhantom = [true];
173
+ /* ============================== CoinMetadata =============================== */
174
+ function isCoinMetadata(type) {
175
+ type = (0, util_1.compressSuiType)(type);
176
+ return type.startsWith(`${index_1.PKG_V28}::coin::CoinMetadata` + "<");
177
+ }
178
+ class CoinMetadata {
179
+ constructor(typeArgs, fields) {
180
+ this.__StructClass = true;
181
+ this.$typeName = CoinMetadata.$typeName;
182
+ this.$isPhantom = CoinMetadata.$isPhantom;
183
+ this.$fullTypeName = (0, util_1.composeSuiType)(CoinMetadata.$typeName, ...typeArgs);
184
+ this.$typeArgs = typeArgs;
185
+ this.id = fields.id;
186
+ this.decimals = fields.decimals;
187
+ this.name = fields.name;
188
+ this.symbol = fields.symbol;
189
+ this.description = fields.description;
190
+ this.iconUrl = fields.iconUrl;
191
+ }
192
+ static reified(T) {
193
+ return {
194
+ typeName: CoinMetadata.$typeName,
195
+ fullTypeName: (0, util_1.composeSuiType)(CoinMetadata.$typeName, ...[(0, reified_1.extractType)(T)]),
196
+ typeArgs: [(0, reified_1.extractType)(T)],
197
+ isPhantom: CoinMetadata.$isPhantom,
198
+ reifiedTypeArgs: [T],
199
+ fromFields: (fields) => CoinMetadata.fromFields(T, fields),
200
+ fromFieldsWithTypes: (item) => CoinMetadata.fromFieldsWithTypes(T, item),
201
+ fromBcs: (data) => CoinMetadata.fromBcs(T, data),
202
+ bcs: CoinMetadata.bcs,
203
+ fromJSONField: (field) => CoinMetadata.fromJSONField(T, field),
204
+ fromJSON: (json) => CoinMetadata.fromJSON(T, json),
205
+ fromSuiParsedData: (content) => CoinMetadata.fromSuiParsedData(T, content),
206
+ fromSuiObjectData: (content) => CoinMetadata.fromSuiObjectData(T, content),
207
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return CoinMetadata.fetch(client, T, id); }),
208
+ new: (fields) => {
209
+ return new CoinMetadata([(0, reified_1.extractType)(T)], fields);
210
+ },
211
+ kind: "StructClassReified",
212
+ };
213
+ }
214
+ static get r() {
215
+ return CoinMetadata.reified;
216
+ }
217
+ static phantom(T) {
218
+ return (0, reified_1.phantom)(CoinMetadata.reified(T));
219
+ }
220
+ static get p() {
221
+ return CoinMetadata.phantom;
222
+ }
223
+ static get bcs() {
224
+ return bcs_1.bcs.struct("CoinMetadata", {
225
+ id: structs_5.UID.bcs,
226
+ decimals: bcs_1.bcs.u8(),
227
+ name: structs_3.String.bcs,
228
+ symbol: structs_1.String.bcs,
229
+ description: structs_3.String.bcs,
230
+ icon_url: structs_2.Option.bcs(structs_6.Url.bcs),
231
+ });
232
+ }
233
+ static fromFields(typeArg, fields) {
234
+ return CoinMetadata.reified(typeArg).new({
235
+ id: (0, reified_1.decodeFromFields)(structs_5.UID.reified(), fields.id),
236
+ decimals: (0, reified_1.decodeFromFields)("u8", fields.decimals),
237
+ name: (0, reified_1.decodeFromFields)(structs_3.String.reified(), fields.name),
238
+ symbol: (0, reified_1.decodeFromFields)(structs_1.String.reified(), fields.symbol),
239
+ description: (0, reified_1.decodeFromFields)(structs_3.String.reified(), fields.description),
240
+ iconUrl: (0, reified_1.decodeFromFields)(structs_2.Option.reified(structs_6.Url.reified()), fields.icon_url),
241
+ });
242
+ }
243
+ static fromFieldsWithTypes(typeArg, item) {
244
+ if (!isCoinMetadata(item.type)) {
245
+ throw new Error("not a CoinMetadata type");
246
+ }
247
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
248
+ return CoinMetadata.reified(typeArg).new({
249
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.UID.reified(), item.fields.id),
250
+ decimals: (0, reified_1.decodeFromFieldsWithTypes)("u8", item.fields.decimals),
251
+ name: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.String.reified(), item.fields.name),
252
+ symbol: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.String.reified(), item.fields.symbol),
253
+ description: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.String.reified(), item.fields.description),
254
+ iconUrl: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.Option.reified(structs_6.Url.reified()), item.fields.icon_url),
255
+ });
256
+ }
257
+ static fromBcs(typeArg, data) {
258
+ return CoinMetadata.fromFields(typeArg, CoinMetadata.bcs.parse(data));
259
+ }
260
+ toJSONField() {
261
+ return {
262
+ id: this.id,
263
+ decimals: this.decimals,
264
+ name: this.name,
265
+ symbol: this.symbol,
266
+ description: this.description,
267
+ iconUrl: (0, reified_1.fieldToJSON)(`${structs_2.Option.$typeName}<${structs_6.Url.$typeName}>`, this.iconUrl),
268
+ };
269
+ }
270
+ toJSON() {
271
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
272
+ }
273
+ static fromJSONField(typeArg, field) {
274
+ return CoinMetadata.reified(typeArg).new({
275
+ id: (0, reified_1.decodeFromJSONField)(structs_5.UID.reified(), field.id),
276
+ decimals: (0, reified_1.decodeFromJSONField)("u8", field.decimals),
277
+ name: (0, reified_1.decodeFromJSONField)(structs_3.String.reified(), field.name),
278
+ symbol: (0, reified_1.decodeFromJSONField)(structs_1.String.reified(), field.symbol),
279
+ description: (0, reified_1.decodeFromJSONField)(structs_3.String.reified(), field.description),
280
+ iconUrl: (0, reified_1.decodeFromJSONField)(structs_2.Option.reified(structs_6.Url.reified()), field.iconUrl),
281
+ });
282
+ }
283
+ static fromJSON(typeArg, json) {
284
+ if (json.$typeName !== CoinMetadata.$typeName) {
285
+ throw new Error("not a WithTwoGenerics json object");
286
+ }
287
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(CoinMetadata.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
288
+ return CoinMetadata.fromJSONField(typeArg, json);
289
+ }
290
+ static fromSuiParsedData(typeArg, content) {
291
+ if (content.dataType !== "moveObject") {
292
+ throw new Error("not an object");
293
+ }
294
+ if (!isCoinMetadata(content.type)) {
295
+ throw new Error(`object at ${content.fields.id} is not a CoinMetadata object`);
296
+ }
297
+ return CoinMetadata.fromFieldsWithTypes(typeArg, content);
298
+ }
299
+ static fromSuiObjectData(typeArg, data) {
300
+ if (data.bcs) {
301
+ if (data.bcs.dataType !== "moveObject" ||
302
+ !isCoinMetadata(data.bcs.type)) {
303
+ throw new Error(`object at is not a CoinMetadata object`);
304
+ }
305
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
306
+ if (gotTypeArgs.length !== 1) {
307
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
308
+ }
309
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
310
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
311
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
312
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
313
+ }
314
+ return CoinMetadata.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
315
+ }
316
+ if (data.content) {
317
+ return CoinMetadata.fromSuiParsedData(typeArg, data.content);
318
+ }
319
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
320
+ }
321
+ static fetch(client, typeArg, id) {
322
+ return __awaiter(this, void 0, void 0, function* () {
323
+ var _a, _b;
324
+ const res = yield client.getObject({ id, options: { showBcs: true } });
325
+ if (res.error) {
326
+ throw new Error(`error fetching CoinMetadata object at id ${id}: ${res.error.code}`);
327
+ }
328
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
329
+ !isCoinMetadata(res.data.bcs.type)) {
330
+ throw new Error(`object at id ${id} is not a CoinMetadata object`);
331
+ }
332
+ return CoinMetadata.fromSuiObjectData(typeArg, res.data);
333
+ });
334
+ }
335
+ }
336
+ exports.CoinMetadata = CoinMetadata;
337
+ CoinMetadata.$typeName = `${index_1.PKG_V28}::coin::CoinMetadata`;
338
+ CoinMetadata.$numTypeParams = 1;
339
+ CoinMetadata.$isPhantom = [true];
340
+ /* ============================== CurrencyCreated =============================== */
341
+ function isCurrencyCreated(type) {
342
+ type = (0, util_1.compressSuiType)(type);
343
+ return type.startsWith(`${index_1.PKG_V28}::coin::CurrencyCreated` + "<");
344
+ }
345
+ class CurrencyCreated {
346
+ constructor(typeArgs, fields) {
347
+ this.__StructClass = true;
348
+ this.$typeName = CurrencyCreated.$typeName;
349
+ this.$isPhantom = CurrencyCreated.$isPhantom;
350
+ this.$fullTypeName = (0, util_1.composeSuiType)(CurrencyCreated.$typeName, ...typeArgs);
351
+ this.$typeArgs = typeArgs;
352
+ this.decimals = fields.decimals;
353
+ }
354
+ static reified(T) {
355
+ return {
356
+ typeName: CurrencyCreated.$typeName,
357
+ fullTypeName: (0, util_1.composeSuiType)(CurrencyCreated.$typeName, ...[(0, reified_1.extractType)(T)]),
358
+ typeArgs: [(0, reified_1.extractType)(T)],
359
+ isPhantom: CurrencyCreated.$isPhantom,
360
+ reifiedTypeArgs: [T],
361
+ fromFields: (fields) => CurrencyCreated.fromFields(T, fields),
362
+ fromFieldsWithTypes: (item) => CurrencyCreated.fromFieldsWithTypes(T, item),
363
+ fromBcs: (data) => CurrencyCreated.fromBcs(T, data),
364
+ bcs: CurrencyCreated.bcs,
365
+ fromJSONField: (field) => CurrencyCreated.fromJSONField(T, field),
366
+ fromJSON: (json) => CurrencyCreated.fromJSON(T, json),
367
+ fromSuiParsedData: (content) => CurrencyCreated.fromSuiParsedData(T, content),
368
+ fromSuiObjectData: (content) => CurrencyCreated.fromSuiObjectData(T, content),
369
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return CurrencyCreated.fetch(client, T, id); }),
370
+ new: (fields) => {
371
+ return new CurrencyCreated([(0, reified_1.extractType)(T)], fields);
372
+ },
373
+ kind: "StructClassReified",
374
+ };
375
+ }
376
+ static get r() {
377
+ return CurrencyCreated.reified;
378
+ }
379
+ static phantom(T) {
380
+ return (0, reified_1.phantom)(CurrencyCreated.reified(T));
381
+ }
382
+ static get p() {
383
+ return CurrencyCreated.phantom;
384
+ }
385
+ static get bcs() {
386
+ return bcs_1.bcs.struct("CurrencyCreated", {
387
+ decimals: bcs_1.bcs.u8(),
388
+ });
389
+ }
390
+ static fromFields(typeArg, fields) {
391
+ return CurrencyCreated.reified(typeArg).new({
392
+ decimals: (0, reified_1.decodeFromFields)("u8", fields.decimals),
393
+ });
394
+ }
395
+ static fromFieldsWithTypes(typeArg, item) {
396
+ if (!isCurrencyCreated(item.type)) {
397
+ throw new Error("not a CurrencyCreated type");
398
+ }
399
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
400
+ return CurrencyCreated.reified(typeArg).new({
401
+ decimals: (0, reified_1.decodeFromFieldsWithTypes)("u8", item.fields.decimals),
402
+ });
403
+ }
404
+ static fromBcs(typeArg, data) {
405
+ return CurrencyCreated.fromFields(typeArg, CurrencyCreated.bcs.parse(data));
406
+ }
407
+ toJSONField() {
408
+ return {
409
+ decimals: this.decimals,
410
+ };
411
+ }
412
+ toJSON() {
413
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
414
+ }
415
+ static fromJSONField(typeArg, field) {
416
+ return CurrencyCreated.reified(typeArg).new({
417
+ decimals: (0, reified_1.decodeFromJSONField)("u8", field.decimals),
418
+ });
419
+ }
420
+ static fromJSON(typeArg, json) {
421
+ if (json.$typeName !== CurrencyCreated.$typeName) {
422
+ throw new Error("not a WithTwoGenerics json object");
423
+ }
424
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(CurrencyCreated.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
425
+ return CurrencyCreated.fromJSONField(typeArg, json);
426
+ }
427
+ static fromSuiParsedData(typeArg, content) {
428
+ if (content.dataType !== "moveObject") {
429
+ throw new Error("not an object");
430
+ }
431
+ if (!isCurrencyCreated(content.type)) {
432
+ throw new Error(`object at ${content.fields.id} is not a CurrencyCreated object`);
433
+ }
434
+ return CurrencyCreated.fromFieldsWithTypes(typeArg, content);
435
+ }
436
+ static fromSuiObjectData(typeArg, data) {
437
+ if (data.bcs) {
438
+ if (data.bcs.dataType !== "moveObject" ||
439
+ !isCurrencyCreated(data.bcs.type)) {
440
+ throw new Error(`object at is not a CurrencyCreated object`);
441
+ }
442
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
443
+ if (gotTypeArgs.length !== 1) {
444
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
445
+ }
446
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
447
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
448
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
449
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
450
+ }
451
+ return CurrencyCreated.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
452
+ }
453
+ if (data.content) {
454
+ return CurrencyCreated.fromSuiParsedData(typeArg, data.content);
455
+ }
456
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
457
+ }
458
+ static fetch(client, typeArg, id) {
459
+ return __awaiter(this, void 0, void 0, function* () {
460
+ var _a, _b;
461
+ const res = yield client.getObject({ id, options: { showBcs: true } });
462
+ if (res.error) {
463
+ throw new Error(`error fetching CurrencyCreated object at id ${id}: ${res.error.code}`);
464
+ }
465
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
466
+ !isCurrencyCreated(res.data.bcs.type)) {
467
+ throw new Error(`object at id ${id} is not a CurrencyCreated object`);
468
+ }
469
+ return CurrencyCreated.fromSuiObjectData(typeArg, res.data);
470
+ });
471
+ }
472
+ }
473
+ exports.CurrencyCreated = CurrencyCreated;
474
+ CurrencyCreated.$typeName = `${index_1.PKG_V28}::coin::CurrencyCreated`;
475
+ CurrencyCreated.$numTypeParams = 1;
476
+ CurrencyCreated.$isPhantom = [true];
477
+ /* ============================== DenyCap =============================== */
478
+ function isDenyCap(type) {
479
+ type = (0, util_1.compressSuiType)(type);
480
+ return type.startsWith(`${index_1.PKG_V28}::coin::DenyCap` + "<");
481
+ }
482
+ class DenyCap {
483
+ constructor(typeArgs, fields) {
484
+ this.__StructClass = true;
485
+ this.$typeName = DenyCap.$typeName;
486
+ this.$isPhantom = DenyCap.$isPhantom;
487
+ this.$fullTypeName = (0, util_1.composeSuiType)(DenyCap.$typeName, ...typeArgs);
488
+ this.$typeArgs = typeArgs;
489
+ this.id = fields.id;
490
+ }
491
+ static reified(T) {
492
+ return {
493
+ typeName: DenyCap.$typeName,
494
+ fullTypeName: (0, util_1.composeSuiType)(DenyCap.$typeName, ...[(0, reified_1.extractType)(T)]),
495
+ typeArgs: [(0, reified_1.extractType)(T)],
496
+ isPhantom: DenyCap.$isPhantom,
497
+ reifiedTypeArgs: [T],
498
+ fromFields: (fields) => DenyCap.fromFields(T, fields),
499
+ fromFieldsWithTypes: (item) => DenyCap.fromFieldsWithTypes(T, item),
500
+ fromBcs: (data) => DenyCap.fromBcs(T, data),
501
+ bcs: DenyCap.bcs,
502
+ fromJSONField: (field) => DenyCap.fromJSONField(T, field),
503
+ fromJSON: (json) => DenyCap.fromJSON(T, json),
504
+ fromSuiParsedData: (content) => DenyCap.fromSuiParsedData(T, content),
505
+ fromSuiObjectData: (content) => DenyCap.fromSuiObjectData(T, content),
506
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return DenyCap.fetch(client, T, id); }),
507
+ new: (fields) => {
508
+ return new DenyCap([(0, reified_1.extractType)(T)], fields);
509
+ },
510
+ kind: "StructClassReified",
511
+ };
512
+ }
513
+ static get r() {
514
+ return DenyCap.reified;
515
+ }
516
+ static phantom(T) {
517
+ return (0, reified_1.phantom)(DenyCap.reified(T));
518
+ }
519
+ static get p() {
520
+ return DenyCap.phantom;
521
+ }
522
+ static get bcs() {
523
+ return bcs_1.bcs.struct("DenyCap", {
524
+ id: structs_5.UID.bcs,
525
+ });
526
+ }
527
+ static fromFields(typeArg, fields) {
528
+ return DenyCap.reified(typeArg).new({
529
+ id: (0, reified_1.decodeFromFields)(structs_5.UID.reified(), fields.id),
530
+ });
531
+ }
532
+ static fromFieldsWithTypes(typeArg, item) {
533
+ if (!isDenyCap(item.type)) {
534
+ throw new Error("not a DenyCap type");
535
+ }
536
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
537
+ return DenyCap.reified(typeArg).new({
538
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.UID.reified(), item.fields.id),
539
+ });
540
+ }
541
+ static fromBcs(typeArg, data) {
542
+ return DenyCap.fromFields(typeArg, DenyCap.bcs.parse(data));
543
+ }
544
+ toJSONField() {
545
+ return {
546
+ id: this.id,
547
+ };
548
+ }
549
+ toJSON() {
550
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
551
+ }
552
+ static fromJSONField(typeArg, field) {
553
+ return DenyCap.reified(typeArg).new({
554
+ id: (0, reified_1.decodeFromJSONField)(structs_5.UID.reified(), field.id),
555
+ });
556
+ }
557
+ static fromJSON(typeArg, json) {
558
+ if (json.$typeName !== DenyCap.$typeName) {
559
+ throw new Error("not a WithTwoGenerics json object");
560
+ }
561
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(DenyCap.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
562
+ return DenyCap.fromJSONField(typeArg, json);
563
+ }
564
+ static fromSuiParsedData(typeArg, content) {
565
+ if (content.dataType !== "moveObject") {
566
+ throw new Error("not an object");
567
+ }
568
+ if (!isDenyCap(content.type)) {
569
+ throw new Error(`object at ${content.fields.id} is not a DenyCap object`);
570
+ }
571
+ return DenyCap.fromFieldsWithTypes(typeArg, content);
572
+ }
573
+ static fromSuiObjectData(typeArg, data) {
574
+ if (data.bcs) {
575
+ if (data.bcs.dataType !== "moveObject" || !isDenyCap(data.bcs.type)) {
576
+ throw new Error(`object at is not a DenyCap object`);
577
+ }
578
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
579
+ if (gotTypeArgs.length !== 1) {
580
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
581
+ }
582
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
583
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
584
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
585
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
586
+ }
587
+ return DenyCap.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
588
+ }
589
+ if (data.content) {
590
+ return DenyCap.fromSuiParsedData(typeArg, data.content);
591
+ }
592
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
593
+ }
594
+ static fetch(client, typeArg, id) {
595
+ return __awaiter(this, void 0, void 0, function* () {
596
+ var _a, _b;
597
+ const res = yield client.getObject({ id, options: { showBcs: true } });
598
+ if (res.error) {
599
+ throw new Error(`error fetching DenyCap object at id ${id}: ${res.error.code}`);
600
+ }
601
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
602
+ !isDenyCap(res.data.bcs.type)) {
603
+ throw new Error(`object at id ${id} is not a DenyCap object`);
604
+ }
605
+ return DenyCap.fromSuiObjectData(typeArg, res.data);
606
+ });
607
+ }
608
+ }
609
+ exports.DenyCap = DenyCap;
610
+ DenyCap.$typeName = `${index_1.PKG_V28}::coin::DenyCap`;
611
+ DenyCap.$numTypeParams = 1;
612
+ DenyCap.$isPhantom = [true];
613
+ /* ============================== DenyCapV2 =============================== */
614
+ function isDenyCapV2(type) {
615
+ type = (0, util_1.compressSuiType)(type);
616
+ return type.startsWith(`${index_1.PKG_V28}::coin::DenyCapV2` + "<");
617
+ }
618
+ class DenyCapV2 {
619
+ constructor(typeArgs, fields) {
620
+ this.__StructClass = true;
621
+ this.$typeName = DenyCapV2.$typeName;
622
+ this.$isPhantom = DenyCapV2.$isPhantom;
623
+ this.$fullTypeName = (0, util_1.composeSuiType)(DenyCapV2.$typeName, ...typeArgs);
624
+ this.$typeArgs = typeArgs;
625
+ this.id = fields.id;
626
+ this.allowGlobalPause = fields.allowGlobalPause;
627
+ }
628
+ static reified(T) {
629
+ return {
630
+ typeName: DenyCapV2.$typeName,
631
+ fullTypeName: (0, util_1.composeSuiType)(DenyCapV2.$typeName, ...[(0, reified_1.extractType)(T)]),
632
+ typeArgs: [(0, reified_1.extractType)(T)],
633
+ isPhantom: DenyCapV2.$isPhantom,
634
+ reifiedTypeArgs: [T],
635
+ fromFields: (fields) => DenyCapV2.fromFields(T, fields),
636
+ fromFieldsWithTypes: (item) => DenyCapV2.fromFieldsWithTypes(T, item),
637
+ fromBcs: (data) => DenyCapV2.fromBcs(T, data),
638
+ bcs: DenyCapV2.bcs,
639
+ fromJSONField: (field) => DenyCapV2.fromJSONField(T, field),
640
+ fromJSON: (json) => DenyCapV2.fromJSON(T, json),
641
+ fromSuiParsedData: (content) => DenyCapV2.fromSuiParsedData(T, content),
642
+ fromSuiObjectData: (content) => DenyCapV2.fromSuiObjectData(T, content),
643
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return DenyCapV2.fetch(client, T, id); }),
644
+ new: (fields) => {
645
+ return new DenyCapV2([(0, reified_1.extractType)(T)], fields);
646
+ },
647
+ kind: "StructClassReified",
648
+ };
649
+ }
650
+ static get r() {
651
+ return DenyCapV2.reified;
652
+ }
653
+ static phantom(T) {
654
+ return (0, reified_1.phantom)(DenyCapV2.reified(T));
655
+ }
656
+ static get p() {
657
+ return DenyCapV2.phantom;
658
+ }
659
+ static get bcs() {
660
+ return bcs_1.bcs.struct("DenyCapV2", {
661
+ id: structs_5.UID.bcs,
662
+ allow_global_pause: bcs_1.bcs.bool(),
663
+ });
664
+ }
665
+ static fromFields(typeArg, fields) {
666
+ return DenyCapV2.reified(typeArg).new({
667
+ id: (0, reified_1.decodeFromFields)(structs_5.UID.reified(), fields.id),
668
+ allowGlobalPause: (0, reified_1.decodeFromFields)("bool", fields.allow_global_pause),
669
+ });
670
+ }
671
+ static fromFieldsWithTypes(typeArg, item) {
672
+ if (!isDenyCapV2(item.type)) {
673
+ throw new Error("not a DenyCapV2 type");
674
+ }
675
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
676
+ return DenyCapV2.reified(typeArg).new({
677
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.UID.reified(), item.fields.id),
678
+ allowGlobalPause: (0, reified_1.decodeFromFieldsWithTypes)("bool", item.fields.allow_global_pause),
679
+ });
680
+ }
681
+ static fromBcs(typeArg, data) {
682
+ return DenyCapV2.fromFields(typeArg, DenyCapV2.bcs.parse(data));
683
+ }
684
+ toJSONField() {
685
+ return {
686
+ id: this.id,
687
+ allowGlobalPause: this.allowGlobalPause,
688
+ };
689
+ }
690
+ toJSON() {
691
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
692
+ }
693
+ static fromJSONField(typeArg, field) {
694
+ return DenyCapV2.reified(typeArg).new({
695
+ id: (0, reified_1.decodeFromJSONField)(structs_5.UID.reified(), field.id),
696
+ allowGlobalPause: (0, reified_1.decodeFromJSONField)("bool", field.allowGlobalPause),
697
+ });
698
+ }
699
+ static fromJSON(typeArg, json) {
700
+ if (json.$typeName !== DenyCapV2.$typeName) {
701
+ throw new Error("not a WithTwoGenerics json object");
702
+ }
703
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(DenyCapV2.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
704
+ return DenyCapV2.fromJSONField(typeArg, json);
705
+ }
706
+ static fromSuiParsedData(typeArg, content) {
707
+ if (content.dataType !== "moveObject") {
708
+ throw new Error("not an object");
709
+ }
710
+ if (!isDenyCapV2(content.type)) {
711
+ throw new Error(`object at ${content.fields.id} is not a DenyCapV2 object`);
712
+ }
713
+ return DenyCapV2.fromFieldsWithTypes(typeArg, content);
714
+ }
715
+ static fromSuiObjectData(typeArg, data) {
716
+ if (data.bcs) {
717
+ if (data.bcs.dataType !== "moveObject" || !isDenyCapV2(data.bcs.type)) {
718
+ throw new Error(`object at is not a DenyCapV2 object`);
719
+ }
720
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
721
+ if (gotTypeArgs.length !== 1) {
722
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
723
+ }
724
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
725
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
726
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
727
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
728
+ }
729
+ return DenyCapV2.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
730
+ }
731
+ if (data.content) {
732
+ return DenyCapV2.fromSuiParsedData(typeArg, data.content);
733
+ }
734
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
735
+ }
736
+ static fetch(client, typeArg, id) {
737
+ return __awaiter(this, void 0, void 0, function* () {
738
+ var _a, _b;
739
+ const res = yield client.getObject({ id, options: { showBcs: true } });
740
+ if (res.error) {
741
+ throw new Error(`error fetching DenyCapV2 object at id ${id}: ${res.error.code}`);
742
+ }
743
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
744
+ !isDenyCapV2(res.data.bcs.type)) {
745
+ throw new Error(`object at id ${id} is not a DenyCapV2 object`);
746
+ }
747
+ return DenyCapV2.fromSuiObjectData(typeArg, res.data);
748
+ });
749
+ }
750
+ }
751
+ exports.DenyCapV2 = DenyCapV2;
752
+ DenyCapV2.$typeName = `${index_1.PKG_V28}::coin::DenyCapV2`;
753
+ DenyCapV2.$numTypeParams = 1;
754
+ DenyCapV2.$isPhantom = [true];
755
+ /* ============================== RegulatedCoinMetadata =============================== */
756
+ function isRegulatedCoinMetadata(type) {
757
+ type = (0, util_1.compressSuiType)(type);
758
+ return type.startsWith(`${index_1.PKG_V28}::coin::RegulatedCoinMetadata` + "<");
759
+ }
760
+ class RegulatedCoinMetadata {
761
+ constructor(typeArgs, fields) {
762
+ this.__StructClass = true;
763
+ this.$typeName = RegulatedCoinMetadata.$typeName;
764
+ this.$isPhantom = RegulatedCoinMetadata.$isPhantom;
765
+ this.$fullTypeName = (0, util_1.composeSuiType)(RegulatedCoinMetadata.$typeName, ...typeArgs);
766
+ this.$typeArgs = typeArgs;
767
+ this.id = fields.id;
768
+ this.coinMetadataObject = fields.coinMetadataObject;
769
+ this.denyCapObject = fields.denyCapObject;
770
+ }
771
+ static reified(T) {
772
+ return {
773
+ typeName: RegulatedCoinMetadata.$typeName,
774
+ fullTypeName: (0, util_1.composeSuiType)(RegulatedCoinMetadata.$typeName, ...[(0, reified_1.extractType)(T)]),
775
+ typeArgs: [(0, reified_1.extractType)(T)],
776
+ isPhantom: RegulatedCoinMetadata.$isPhantom,
777
+ reifiedTypeArgs: [T],
778
+ fromFields: (fields) => RegulatedCoinMetadata.fromFields(T, fields),
779
+ fromFieldsWithTypes: (item) => RegulatedCoinMetadata.fromFieldsWithTypes(T, item),
780
+ fromBcs: (data) => RegulatedCoinMetadata.fromBcs(T, data),
781
+ bcs: RegulatedCoinMetadata.bcs,
782
+ fromJSONField: (field) => RegulatedCoinMetadata.fromJSONField(T, field),
783
+ fromJSON: (json) => RegulatedCoinMetadata.fromJSON(T, json),
784
+ fromSuiParsedData: (content) => RegulatedCoinMetadata.fromSuiParsedData(T, content),
785
+ fromSuiObjectData: (content) => RegulatedCoinMetadata.fromSuiObjectData(T, content),
786
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return RegulatedCoinMetadata.fetch(client, T, id); }),
787
+ new: (fields) => {
788
+ return new RegulatedCoinMetadata([(0, reified_1.extractType)(T)], fields);
789
+ },
790
+ kind: "StructClassReified",
791
+ };
792
+ }
793
+ static get r() {
794
+ return RegulatedCoinMetadata.reified;
795
+ }
796
+ static phantom(T) {
797
+ return (0, reified_1.phantom)(RegulatedCoinMetadata.reified(T));
798
+ }
799
+ static get p() {
800
+ return RegulatedCoinMetadata.phantom;
801
+ }
802
+ static get bcs() {
803
+ return bcs_1.bcs.struct("RegulatedCoinMetadata", {
804
+ id: structs_5.UID.bcs,
805
+ coin_metadata_object: structs_5.ID.bcs,
806
+ deny_cap_object: structs_5.ID.bcs,
807
+ });
808
+ }
809
+ static fromFields(typeArg, fields) {
810
+ return RegulatedCoinMetadata.reified(typeArg).new({
811
+ id: (0, reified_1.decodeFromFields)(structs_5.UID.reified(), fields.id),
812
+ coinMetadataObject: (0, reified_1.decodeFromFields)(structs_5.ID.reified(), fields.coin_metadata_object),
813
+ denyCapObject: (0, reified_1.decodeFromFields)(structs_5.ID.reified(), fields.deny_cap_object),
814
+ });
815
+ }
816
+ static fromFieldsWithTypes(typeArg, item) {
817
+ if (!isRegulatedCoinMetadata(item.type)) {
818
+ throw new Error("not a RegulatedCoinMetadata type");
819
+ }
820
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
821
+ return RegulatedCoinMetadata.reified(typeArg).new({
822
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.UID.reified(), item.fields.id),
823
+ coinMetadataObject: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.ID.reified(), item.fields.coin_metadata_object),
824
+ denyCapObject: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.ID.reified(), item.fields.deny_cap_object),
825
+ });
826
+ }
827
+ static fromBcs(typeArg, data) {
828
+ return RegulatedCoinMetadata.fromFields(typeArg, RegulatedCoinMetadata.bcs.parse(data));
829
+ }
830
+ toJSONField() {
831
+ return {
832
+ id: this.id,
833
+ coinMetadataObject: this.coinMetadataObject,
834
+ denyCapObject: this.denyCapObject,
835
+ };
836
+ }
837
+ toJSON() {
838
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
839
+ }
840
+ static fromJSONField(typeArg, field) {
841
+ return RegulatedCoinMetadata.reified(typeArg).new({
842
+ id: (0, reified_1.decodeFromJSONField)(structs_5.UID.reified(), field.id),
843
+ coinMetadataObject: (0, reified_1.decodeFromJSONField)(structs_5.ID.reified(), field.coinMetadataObject),
844
+ denyCapObject: (0, reified_1.decodeFromJSONField)(structs_5.ID.reified(), field.denyCapObject),
845
+ });
846
+ }
847
+ static fromJSON(typeArg, json) {
848
+ if (json.$typeName !== RegulatedCoinMetadata.$typeName) {
849
+ throw new Error("not a WithTwoGenerics json object");
850
+ }
851
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(RegulatedCoinMetadata.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
852
+ return RegulatedCoinMetadata.fromJSONField(typeArg, json);
853
+ }
854
+ static fromSuiParsedData(typeArg, content) {
855
+ if (content.dataType !== "moveObject") {
856
+ throw new Error("not an object");
857
+ }
858
+ if (!isRegulatedCoinMetadata(content.type)) {
859
+ throw new Error(`object at ${content.fields.id} is not a RegulatedCoinMetadata object`);
860
+ }
861
+ return RegulatedCoinMetadata.fromFieldsWithTypes(typeArg, content);
862
+ }
863
+ static fromSuiObjectData(typeArg, data) {
864
+ if (data.bcs) {
865
+ if (data.bcs.dataType !== "moveObject" ||
866
+ !isRegulatedCoinMetadata(data.bcs.type)) {
867
+ throw new Error(`object at is not a RegulatedCoinMetadata object`);
868
+ }
869
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
870
+ if (gotTypeArgs.length !== 1) {
871
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
872
+ }
873
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
874
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
875
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
876
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
877
+ }
878
+ return RegulatedCoinMetadata.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
879
+ }
880
+ if (data.content) {
881
+ return RegulatedCoinMetadata.fromSuiParsedData(typeArg, data.content);
882
+ }
883
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
884
+ }
885
+ static fetch(client, typeArg, id) {
886
+ return __awaiter(this, void 0, void 0, function* () {
887
+ var _a, _b;
888
+ const res = yield client.getObject({ id, options: { showBcs: true } });
889
+ if (res.error) {
890
+ throw new Error(`error fetching RegulatedCoinMetadata object at id ${id}: ${res.error.code}`);
891
+ }
892
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
893
+ !isRegulatedCoinMetadata(res.data.bcs.type)) {
894
+ throw new Error(`object at id ${id} is not a RegulatedCoinMetadata object`);
895
+ }
896
+ return RegulatedCoinMetadata.fromSuiObjectData(typeArg, res.data);
897
+ });
898
+ }
899
+ }
900
+ exports.RegulatedCoinMetadata = RegulatedCoinMetadata;
901
+ RegulatedCoinMetadata.$typeName = `${index_1.PKG_V28}::coin::RegulatedCoinMetadata`;
902
+ RegulatedCoinMetadata.$numTypeParams = 1;
903
+ RegulatedCoinMetadata.$isPhantom = [true];
904
+ /* ============================== TreasuryCap =============================== */
905
+ function isTreasuryCap(type) {
906
+ type = (0, util_1.compressSuiType)(type);
907
+ return type.startsWith(`${index_1.PKG_V28}::coin::TreasuryCap` + "<");
908
+ }
909
+ class TreasuryCap {
910
+ constructor(typeArgs, fields) {
911
+ this.__StructClass = true;
912
+ this.$typeName = TreasuryCap.$typeName;
913
+ this.$isPhantom = TreasuryCap.$isPhantom;
914
+ this.$fullTypeName = (0, util_1.composeSuiType)(TreasuryCap.$typeName, ...typeArgs);
915
+ this.$typeArgs = typeArgs;
916
+ this.id = fields.id;
917
+ this.totalSupply = fields.totalSupply;
918
+ }
919
+ static reified(T) {
920
+ return {
921
+ typeName: TreasuryCap.$typeName,
922
+ fullTypeName: (0, util_1.composeSuiType)(TreasuryCap.$typeName, ...[(0, reified_1.extractType)(T)]),
923
+ typeArgs: [(0, reified_1.extractType)(T)],
924
+ isPhantom: TreasuryCap.$isPhantom,
925
+ reifiedTypeArgs: [T],
926
+ fromFields: (fields) => TreasuryCap.fromFields(T, fields),
927
+ fromFieldsWithTypes: (item) => TreasuryCap.fromFieldsWithTypes(T, item),
928
+ fromBcs: (data) => TreasuryCap.fromBcs(T, data),
929
+ bcs: TreasuryCap.bcs,
930
+ fromJSONField: (field) => TreasuryCap.fromJSONField(T, field),
931
+ fromJSON: (json) => TreasuryCap.fromJSON(T, json),
932
+ fromSuiParsedData: (content) => TreasuryCap.fromSuiParsedData(T, content),
933
+ fromSuiObjectData: (content) => TreasuryCap.fromSuiObjectData(T, content),
934
+ fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return TreasuryCap.fetch(client, T, id); }),
935
+ new: (fields) => {
936
+ return new TreasuryCap([(0, reified_1.extractType)(T)], fields);
937
+ },
938
+ kind: "StructClassReified",
939
+ };
940
+ }
941
+ static get r() {
942
+ return TreasuryCap.reified;
943
+ }
944
+ static phantom(T) {
945
+ return (0, reified_1.phantom)(TreasuryCap.reified(T));
946
+ }
947
+ static get p() {
948
+ return TreasuryCap.phantom;
949
+ }
950
+ static get bcs() {
951
+ return bcs_1.bcs.struct("TreasuryCap", {
952
+ id: structs_5.UID.bcs,
953
+ total_supply: structs_4.Supply.bcs,
954
+ });
955
+ }
956
+ static fromFields(typeArg, fields) {
957
+ return TreasuryCap.reified(typeArg).new({
958
+ id: (0, reified_1.decodeFromFields)(structs_5.UID.reified(), fields.id),
959
+ totalSupply: (0, reified_1.decodeFromFields)(structs_4.Supply.reified(typeArg), fields.total_supply),
960
+ });
961
+ }
962
+ static fromFieldsWithTypes(typeArg, item) {
963
+ if (!isTreasuryCap(item.type)) {
964
+ throw new Error("not a TreasuryCap type");
965
+ }
966
+ (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
967
+ return TreasuryCap.reified(typeArg).new({
968
+ id: (0, reified_1.decodeFromFieldsWithTypes)(structs_5.UID.reified(), item.fields.id),
969
+ totalSupply: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.Supply.reified(typeArg), item.fields.total_supply),
970
+ });
971
+ }
972
+ static fromBcs(typeArg, data) {
973
+ return TreasuryCap.fromFields(typeArg, TreasuryCap.bcs.parse(data));
974
+ }
975
+ toJSONField() {
976
+ return {
977
+ id: this.id,
978
+ totalSupply: this.totalSupply.toJSONField(),
979
+ };
980
+ }
981
+ toJSON() {
982
+ return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
983
+ }
984
+ static fromJSONField(typeArg, field) {
985
+ return TreasuryCap.reified(typeArg).new({
986
+ id: (0, reified_1.decodeFromJSONField)(structs_5.UID.reified(), field.id),
987
+ totalSupply: (0, reified_1.decodeFromJSONField)(structs_4.Supply.reified(typeArg), field.totalSupply),
988
+ });
989
+ }
990
+ static fromJSON(typeArg, json) {
991
+ if (json.$typeName !== TreasuryCap.$typeName) {
992
+ throw new Error("not a WithTwoGenerics json object");
993
+ }
994
+ (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(TreasuryCap.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
995
+ return TreasuryCap.fromJSONField(typeArg, json);
996
+ }
997
+ static fromSuiParsedData(typeArg, content) {
998
+ if (content.dataType !== "moveObject") {
999
+ throw new Error("not an object");
1000
+ }
1001
+ if (!isTreasuryCap(content.type)) {
1002
+ throw new Error(`object at ${content.fields.id} is not a TreasuryCap object`);
1003
+ }
1004
+ return TreasuryCap.fromFieldsWithTypes(typeArg, content);
1005
+ }
1006
+ static fromSuiObjectData(typeArg, data) {
1007
+ if (data.bcs) {
1008
+ if (data.bcs.dataType !== "moveObject" || !isTreasuryCap(data.bcs.type)) {
1009
+ throw new Error(`object at is not a TreasuryCap object`);
1010
+ }
1011
+ const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
1012
+ if (gotTypeArgs.length !== 1) {
1013
+ throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
1014
+ }
1015
+ const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
1016
+ const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
1017
+ if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
1018
+ throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
1019
+ }
1020
+ return TreasuryCap.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
1021
+ }
1022
+ if (data.content) {
1023
+ return TreasuryCap.fromSuiParsedData(typeArg, data.content);
1024
+ }
1025
+ throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
1026
+ }
1027
+ static fetch(client, typeArg, id) {
1028
+ return __awaiter(this, void 0, void 0, function* () {
1029
+ var _a, _b;
1030
+ const res = yield client.getObject({ id, options: { showBcs: true } });
1031
+ if (res.error) {
1032
+ throw new Error(`error fetching TreasuryCap object at id ${id}: ${res.error.code}`);
1033
+ }
1034
+ if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
1035
+ !isTreasuryCap(res.data.bcs.type)) {
1036
+ throw new Error(`object at id ${id} is not a TreasuryCap object`);
1037
+ }
1038
+ return TreasuryCap.fromSuiObjectData(typeArg, res.data);
1039
+ });
1040
+ }
1041
+ }
1042
+ exports.TreasuryCap = TreasuryCap;
1043
+ TreasuryCap.$typeName = `${index_1.PKG_V28}::coin::TreasuryCap`;
1044
+ TreasuryCap.$numTypeParams = 1;
1045
+ TreasuryCap.$isPhantom = [true];