@suilend/springsui-cli 1.0.13 → 2.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 (60) hide show
  1. package/cli/src/bytecode.js +28 -30
  2. package/cli/src/index.js +51 -86
  3. package/package.json +1 -1
  4. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
  5. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  6. package/sdk/src/_generated/_dependencies/source/0x1/index.js +3 -6
  7. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
  8. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  9. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +4 -4
  10. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +21 -59
  11. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
  12. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  13. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
  14. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  15. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
  16. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  17. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +52 -52
  18. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +206 -223
  19. package/sdk/src/_generated/_dependencies/source/0x2/index.js +3 -6
  20. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
  21. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  22. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +4 -4
  23. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +19 -24
  24. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +7 -7
  25. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +31 -36
  26. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +5 -5
  27. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +20 -25
  28. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +5 -5
  29. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +57 -97
  30. package/sdk/src/_generated/_dependencies/source/0x3/index.js +3 -6
  31. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +60 -60
  32. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +170 -218
  33. package/sdk/src/_generated/_framework/reified.d.ts +2 -2
  34. package/sdk/src/_generated/_framework/reified.js +27 -40
  35. package/sdk/src/_generated/_framework/util.d.ts +2 -14
  36. package/sdk/src/_generated/_framework/util.js +26 -40
  37. package/sdk/src/_generated/_framework/vector.d.ts +4 -4
  38. package/sdk/src/_generated/_framework/vector.js +16 -21
  39. package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +4 -4
  40. package/sdk/src/_generated/liquid_staking/cell/structs.js +31 -36
  41. package/sdk/src/_generated/liquid_staking/fees/functions.js +55 -75
  42. package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +21 -21
  43. package/sdk/src/_generated/liquid_staking/fees/structs.js +58 -65
  44. package/sdk/src/_generated/liquid_staking/index.js +6 -10
  45. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +86 -107
  46. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +98 -98
  47. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +264 -320
  48. package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +31 -31
  49. package/sdk/src/_generated/liquid_staking/storage/structs.js +85 -125
  50. package/sdk/src/_generated/liquid_staking/version/structs.d.ts +4 -4
  51. package/sdk/src/_generated/liquid_staking/version/structs.js +19 -24
  52. package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -56
  53. package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +41 -41
  54. package/sdk/src/_generated/liquid_staking/weight/structs.js +128 -141
  55. package/sdk/src/client.d.ts +16 -16
  56. package/sdk/src/client.js +39 -82
  57. package/sdk/src/index.js +2 -18
  58. package/sdk/src/lib/index.js +1 -17
  59. package/sdk/src/lib/transactions.d.ts +1 -1
  60. package/sdk/src/lib/transactions.js +3 -8
@@ -1,6 +1,6 @@
1
1
  import { BcsType } from "@mysten/sui/bcs";
2
2
  import { FieldsWithTypes } from "./util";
3
- import { SuiClient, SuiParsedData, SuiObjectData } from "@mysten/sui/client";
3
+ import { SuiJsonRpcClient, SuiParsedData, SuiObjectData } from "@mysten/sui/jsonRpc";
4
4
  export { vector } from "./vector";
5
5
  export interface StructClass {
6
6
  readonly $typeName: string;
@@ -37,7 +37,7 @@ export interface StructClassReified<T extends StructClass, Fields> {
37
37
  fromJSON: (json: Record<string, any>) => T;
38
38
  fromSuiParsedData: (content: SuiParsedData) => T;
39
39
  fromSuiObjectData: (data: SuiObjectData) => T;
40
- fetch: (client: SuiClient, id: string) => Promise<T>;
40
+ fetch: (client: SuiJsonRpcClient, id: string) => Promise<T>;
41
41
  new: (fields: Fields) => T;
42
42
  kind: "StructClassReified";
43
43
  }
@@ -1,22 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.vector = void 0;
4
- exports.phantom = phantom;
5
- exports.toBcs = toBcs;
6
- exports.extractType = extractType;
7
- exports.decodeFromFields = decodeFromFields;
8
- exports.decodeFromFieldsWithTypes = decodeFromFieldsWithTypes;
9
- exports.assertReifiedTypeArgsMatch = assertReifiedTypeArgsMatch;
10
- exports.assertFieldsWithTypesArgsMatch = assertFieldsWithTypesArgsMatch;
11
- exports.fieldToJSON = fieldToJSON;
12
- exports.decodeFromJSONField = decodeFromJSONField;
13
- const bcs_1 = require("@mysten/sui/bcs");
14
- const utils_1 = require("@mysten/sui/utils");
15
- const util_1 = require("./util");
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ import { fromHex, toHex } from "@mysten/sui/utils";
3
+ import { compressSuiType, parseTypeName } from "./util";
16
4
  // for backwards compatibility
17
- var vector_1 = require("./vector");
18
- Object.defineProperty(exports, "vector", { enumerable: true, get: function () { return vector_1.vector; } });
19
- function phantom(type) {
5
+ export { vector } from "./vector";
6
+ export function phantom(type) {
20
7
  if (typeof type === "string") {
21
8
  return {
22
9
  phantomType: type,
@@ -30,33 +17,33 @@ function phantom(type) {
30
17
  };
31
18
  }
32
19
  }
33
- const Address = bcs_1.bcs.bytes(32).transform({
34
- input: (val) => (0, utils_1.fromHEX)(val),
35
- output: (val) => (0, utils_1.toHEX)(val),
20
+ const Address = bcs.bytes(32).transform({
21
+ input: (val) => fromHex(val),
22
+ output: (val) => toHex(val),
36
23
  });
37
- function toBcs(arg) {
24
+ export function toBcs(arg) {
38
25
  switch (arg) {
39
26
  case "bool":
40
- return bcs_1.bcs.bool();
27
+ return bcs.bool();
41
28
  case "u8":
42
- return bcs_1.bcs.u8();
29
+ return bcs.u8();
43
30
  case "u16":
44
- return bcs_1.bcs.u16();
31
+ return bcs.u16();
45
32
  case "u32":
46
- return bcs_1.bcs.u32();
33
+ return bcs.u32();
47
34
  case "u64":
48
- return bcs_1.bcs.u64();
35
+ return bcs.u64();
49
36
  case "u128":
50
- return bcs_1.bcs.u128();
37
+ return bcs.u128();
51
38
  case "u256":
52
- return bcs_1.bcs.u256();
39
+ return bcs.u256();
53
40
  case "address":
54
41
  return Address;
55
42
  default:
56
43
  return arg.bcs;
57
44
  }
58
45
  }
59
- function extractType(reified) {
46
+ export function extractType(reified) {
60
47
  switch (reified) {
61
48
  case "u8":
62
49
  case "u16":
@@ -78,7 +65,7 @@ function extractType(reified) {
78
65
  }
79
66
  throw new Error("unreachable");
80
67
  }
81
- function decodeFromFields(reified, field) {
68
+ export function decodeFromFields(reified, field) {
82
69
  switch (reified) {
83
70
  case "bool":
84
71
  case "u8":
@@ -117,7 +104,7 @@ function decodeFromFields(reified, field) {
117
104
  return reified.fromFields(field);
118
105
  }
119
106
  }
120
- function decodeFromFieldsWithTypes(reified, item) {
107
+ export function decodeFromFieldsWithTypes(reified, item) {
121
108
  switch (reified) {
122
109
  case "bool":
123
110
  case "u8":
@@ -154,23 +141,23 @@ function decodeFromFieldsWithTypes(reified, item) {
154
141
  return reified.fromFieldsWithTypes(item);
155
142
  }
156
143
  }
157
- function assertReifiedTypeArgsMatch(fullType, typeArgs, reifiedTypeArgs) {
144
+ export function assertReifiedTypeArgsMatch(fullType, typeArgs, reifiedTypeArgs) {
158
145
  if (reifiedTypeArgs.length !== typeArgs.length) {
159
146
  throw new Error(`provided item has mismatching number of type argments ${fullType} (expected ${reifiedTypeArgs.length}, got ${typeArgs.length}))`);
160
147
  }
161
148
  for (let i = 0; i < typeArgs.length; i++) {
162
- if ((0, util_1.compressSuiType)(typeArgs[i]) !==
163
- (0, util_1.compressSuiType)(extractType(reifiedTypeArgs[i]))) {
149
+ if (compressSuiType(typeArgs[i]) !==
150
+ compressSuiType(extractType(reifiedTypeArgs[i]))) {
164
151
  throw new Error(`provided item has mismatching type argments ${fullType} (expected ${extractType(reifiedTypeArgs[i])}, got ${typeArgs[i]}))`);
165
152
  }
166
153
  }
167
154
  }
168
- function assertFieldsWithTypesArgsMatch(item, reifiedTypeArgs) {
169
- const { typeArgs: itemTypeArgs } = (0, util_1.parseTypeName)(item.type);
155
+ export function assertFieldsWithTypesArgsMatch(item, reifiedTypeArgs) {
156
+ const { typeArgs: itemTypeArgs } = parseTypeName(item.type);
170
157
  assertReifiedTypeArgsMatch(item.type, itemTypeArgs, reifiedTypeArgs);
171
158
  }
172
- function fieldToJSON(type, field) {
173
- const { typeName, typeArgs } = (0, util_1.parseTypeName)(type);
159
+ export function fieldToJSON(type, field) {
160
+ const { typeName, typeArgs } = parseTypeName(type);
174
161
  switch (typeName) {
175
162
  case "bool":
176
163
  return field;
@@ -204,7 +191,7 @@ function fieldToJSON(type, field) {
204
191
  return field.toJSONField();
205
192
  }
206
193
  }
207
- function decodeFromJSONField(typeArg, field) {
194
+ export function decodeFromJSONField(typeArg, field) {
208
195
  switch (typeArg) {
209
196
  case "bool":
210
197
  case "u8":
@@ -1,4 +1,4 @@
1
- import { Transaction, TransactionArgument, TransactionObjectInput } from "@mysten/sui/transactions";
1
+ import { Transaction, TransactionArgument, TransactionObjectArgument, TransactionObjectInput } from "@mysten/sui/transactions";
2
2
  export interface FieldsWithTypes {
3
3
  fields: Record<string, any>;
4
4
  type: string;
@@ -12,19 +12,7 @@ export declare function parseTypeName(name: string): {
12
12
  typeArgs: string[];
13
13
  };
14
14
  export declare function isTransactionArgument(arg: GenericArg): arg is TransactionArgument;
15
- export declare function obj(tx: Transaction, arg: TransactionObjectInput): {
16
- GasCoin: true;
17
- } | {
18
- Input: number;
19
- type?: "pure" | "object";
20
- } | {
21
- Result: number;
22
- } | {
23
- NestedResult: [number, number];
24
- } | ((tx: Transaction) => Exclude<import("valibot").InferInput<typeof import("@mysten/sui/dist/cjs/transactions/data/internal").ArgumentSchema>, {
25
- Input: unknown;
26
- type?: "pure";
27
- }>) | import("@mysten/sui/dist/cjs/transactions/Transaction").AsyncTransactionThunk<import("@mysten/sui/dist/cjs/transactions/Transaction").TransactionResultArgument>;
15
+ export declare function obj(tx: Transaction, arg: TransactionObjectInput): TransactionObjectArgument;
28
16
  export declare function pure(tx: Transaction, arg: PureArg, type: string): TransactionArgument;
29
17
  export declare function option(tx: Transaction, type: string, arg: GenericArg | null): TransactionArgument;
30
18
  export declare function generic(tx: Transaction, type: string, arg: GenericArg): TransactionArgument;
@@ -1,19 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitGenericParameters = splitGenericParameters;
4
- exports.parseTypeName = parseTypeName;
5
- exports.isTransactionArgument = isTransactionArgument;
6
- exports.obj = obj;
7
- exports.pure = pure;
8
- exports.option = option;
9
- exports.generic = generic;
10
- exports.vector = vector;
11
- exports.typeArgIsPure = typeArgIsPure;
12
- exports.compressSuiAddress = compressSuiAddress;
13
- exports.compressSuiType = compressSuiType;
14
- exports.composeSuiType = composeSuiType;
15
- const bcs_1 = require("@mysten/sui/bcs");
16
- function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ export function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
17
3
  const [left, right] = genericSeparators;
18
4
  const tok = [];
19
5
  let word = "";
@@ -36,7 +22,7 @@ function splitGenericParameters(str, genericSeparators = ["<", ">"]) {
36
22
  tok.push(word.trim());
37
23
  return tok;
38
24
  }
39
- function parseTypeName(name) {
25
+ export function parseTypeName(name) {
40
26
  if (typeof name !== "string") {
41
27
  throw new Error(`Illegal type passed as a name of the type: ${name}`);
42
28
  }
@@ -55,7 +41,7 @@ function parseTypeName(name) {
55
41
  const typeArgs = splitGenericParameters(name.slice(l_bound + 1, name.length - r_bound - 1), [left, right]);
56
42
  return { typeName, typeArgs };
57
43
  }
58
- function isTransactionArgument(arg) {
44
+ export function isTransactionArgument(arg) {
59
45
  if (!arg || typeof arg !== "object" || Array.isArray(arg)) {
60
46
  return false;
61
47
  }
@@ -64,10 +50,10 @@ function isTransactionArgument(arg) {
64
50
  "Result" in arg ||
65
51
  "NestedResult" in arg);
66
52
  }
67
- function obj(tx, arg) {
53
+ export function obj(tx, arg) {
68
54
  return isTransactionArgument(arg) ? arg : tx.object(arg);
69
55
  }
70
- function pure(tx, arg, type) {
56
+ export function pure(tx, arg, type) {
71
57
  if (isTransactionArgument(arg)) {
72
58
  return obj(tx, arg);
73
59
  }
@@ -75,30 +61,30 @@ function pure(tx, arg, type) {
75
61
  const { typeName, typeArgs } = parseTypeName(type);
76
62
  switch (typeName) {
77
63
  case "bool":
78
- return bcs_1.bcs.Bool;
64
+ return bcs.Bool;
79
65
  case "u8":
80
- return bcs_1.bcs.U8;
66
+ return bcs.U8;
81
67
  case "u16":
82
- return bcs_1.bcs.U16;
68
+ return bcs.U16;
83
69
  case "u32":
84
- return bcs_1.bcs.U32;
70
+ return bcs.U32;
85
71
  case "u64":
86
- return bcs_1.bcs.U64;
72
+ return bcs.U64;
87
73
  case "u128":
88
- return bcs_1.bcs.U128;
74
+ return bcs.U128;
89
75
  case "u256":
90
- return bcs_1.bcs.U256;
76
+ return bcs.U256;
91
77
  case "address":
92
- return bcs_1.bcs.Address;
78
+ return bcs.Address;
93
79
  case "0x1::string::String":
94
80
  case "0x1::ascii::String":
95
- return bcs_1.bcs.String;
81
+ return bcs.String;
96
82
  case "0x2::object::ID":
97
- return bcs_1.bcs.Address;
83
+ return bcs.Address;
98
84
  case "0x1::option::Option":
99
- return bcs_1.bcs.option(getBcsForType(typeArgs[0]));
85
+ return bcs.option(getBcsForType(typeArgs[0]));
100
86
  case "vector":
101
- return bcs_1.bcs.vector(getBcsForType(typeArgs[0]));
87
+ return bcs.vector(getBcsForType(typeArgs[0]));
102
88
  default:
103
89
  throw new Error(`invalid primitive type ${type}`);
104
90
  }
@@ -175,7 +161,7 @@ function pure(tx, arg, type) {
175
161
  throw new Error("expected an array for vector type");
176
162
  }
177
163
  if (arg.length === 0) {
178
- return tx.pure(bcs_1.bcs.vector(bcs_1.bcs.Bool).serialize([])); // bcs.Bool is arbitrary
164
+ return tx.pure(bcs.vector(bcs.Bool).serialize([])); // bcs.Bool is arbitrary
179
165
  }
180
166
  if (hasUndefinedOrNull(arg)) {
181
167
  throw new Error("the provided array contains undefined or null values");
@@ -194,7 +180,7 @@ function pure(tx, arg, type) {
194
180
  return tx.pure(getBcsForType(type).serialize(arg));
195
181
  }
196
182
  }
197
- function option(tx, type, arg) {
183
+ export function option(tx, type, arg) {
198
184
  if (isTransactionArgument(arg)) {
199
185
  return arg;
200
186
  }
@@ -216,7 +202,7 @@ function option(tx, type, arg) {
216
202
  arguments: [val],
217
203
  });
218
204
  }
219
- function generic(tx, type, arg) {
205
+ export function generic(tx, type, arg) {
220
206
  if (typeArgIsPure(type)) {
221
207
  return pure(tx, arg, type);
222
208
  }
@@ -234,7 +220,7 @@ function generic(tx, type, arg) {
234
220
  }
235
221
  }
236
222
  }
237
- function vector(tx, itemType, items) {
223
+ export function vector(tx, itemType, items) {
238
224
  if (typeof items === "function") {
239
225
  throw new Error("Transaction plugins are not supported");
240
226
  }
@@ -259,7 +245,7 @@ function vector(tx, itemType, items) {
259
245
  });
260
246
  }
261
247
  }
262
- function typeArgIsPure(type) {
248
+ export function typeArgIsPure(type) {
263
249
  const { typeName, typeArgs } = parseTypeName(type);
264
250
  switch (typeName) {
265
251
  case "bool":
@@ -284,7 +270,7 @@ function typeArgIsPure(type) {
284
270
  return false;
285
271
  }
286
272
  }
287
- function compressSuiAddress(addr) {
273
+ export function compressSuiAddress(addr) {
288
274
  // remove leading zeros
289
275
  const stripped = addr.split("0x").join("");
290
276
  for (let i = 0; i < stripped.length; i++) {
@@ -296,7 +282,7 @@ function compressSuiAddress(addr) {
296
282
  }
297
283
  // Recursively removes leading zeros from a type.
298
284
  // e.g. `0x00000002::module::Name<0x00001::a::C>` -> `0x2::module::Name<0x1::a::C>`
299
- function compressSuiType(type) {
285
+ export function compressSuiType(type) {
300
286
  const { typeName, typeArgs } = parseTypeName(type);
301
287
  switch (typeName) {
302
288
  case "bool":
@@ -324,7 +310,7 @@ function compressSuiType(type) {
324
310
  }
325
311
  }
326
312
  }
327
- function composeSuiType(typeName, ...typeArgs) {
313
+ export function composeSuiType(typeName, ...typeArgs) {
328
314
  if (typeArgs.length > 0) {
329
315
  return `${typeName}<${typeArgs.join(", ")}>`;
330
316
  }
@@ -16,14 +16,14 @@ export declare class Vector<T extends TypeArgument> implements VectorClass {
16
16
  static reified<T extends Reified<TypeArgument, any>>(T: T): VectorReified<ToTypeArgument<T>>;
17
17
  static get r(): typeof Vector.reified;
18
18
  static get bcs(): {
19
- <T extends import("@mysten/sui/bcs").BcsType<any>, Name extends string = `vector<${T["name"]}>`>(type: T, options?: import("@mysten/sui/bcs").BcsTypeOptions<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
19
+ <T extends import("@mysten/bcs").BcsType<any>, Name extends string = `vector<${T["name"]}>`>(type: T, options?: import("@mysten/bcs").BcsTypeOptions<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
20
20
  length: number;
21
- }, Name>): import("@mysten/sui/bcs").BcsType<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
21
+ }, Name>): import("@mysten/bcs").BcsType<import("@mysten/bcs").InferBcsType<T>[], Iterable<import("@mysten/bcs").InferBcsInput<T>> & {
22
22
  length: number;
23
23
  }, Name>;
24
- <T, Input, Name extends string = string>(type: import("@mysten/sui/bcs").BcsType<T, Input, Name>, options?: import("@mysten/sui/bcs").BcsTypeOptions<T[], Iterable<Input> & {
24
+ <T, Input, Name extends string = string>(type: import("@mysten/bcs").BcsType<T, Input, Name>, options?: import("@mysten/bcs").BcsTypeOptions<T[], Iterable<Input> & {
25
25
  length: number;
26
- }, `vector<${Name}>`>): import("@mysten/sui/bcs").BcsType<T[], Iterable<Input> & {
26
+ }, `vector<${Name}>`>): import("@mysten/bcs").BcsType<T[], Iterable<Input> & {
27
27
  length: number;
28
28
  }, `vector<${Name}>`>;
29
29
  };
@@ -1,34 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vector = void 0;
4
- exports.vector = vector;
5
- const bcs_1 = require("@mysten/sui/bcs");
6
- const reified_1 = require("./reified");
7
- const util_1 = require("./util");
8
- class Vector {
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, toBcs, fieldToJSON, } from "./reified";
3
+ import { composeSuiType } from "./util";
4
+ export class Vector {
9
5
  constructor(typeArgs, elements) {
10
6
  this.__VectorClass = true;
11
7
  this.$typeName = "vector";
12
8
  this.$isPhantom = [false];
13
- this.$fullTypeName = (0, util_1.composeSuiType)(this.$typeName, ...typeArgs);
9
+ this.$fullTypeName = composeSuiType(this.$typeName, ...typeArgs);
14
10
  this.$typeArgs = typeArgs;
15
11
  this.elements = elements;
16
12
  }
17
13
  static reified(T) {
18
14
  return {
19
15
  typeName: Vector.$typeName,
20
- fullTypeName: (0, util_1.composeSuiType)(Vector.$typeName, ...[(0, reified_1.extractType)(T)]),
21
- typeArgs: [(0, reified_1.extractType)(T)],
16
+ fullTypeName: composeSuiType(Vector.$typeName, ...[extractType(T)]),
17
+ typeArgs: [extractType(T)],
22
18
  isPhantom: Vector.$isPhantom,
23
19
  reifiedTypeArgs: [T],
24
20
  fromFields: (elements) => Vector.fromFields(T, elements),
25
21
  fromFieldsWithTypes: (item) => Vector.fromFieldsWithTypes(T, item),
26
22
  fromBcs: (data) => Vector.fromBcs(T, data),
27
- bcs: Vector.bcs((0, reified_1.toBcs)(T)),
23
+ bcs: Vector.bcs(toBcs(T)),
28
24
  fromJSONField: (field) => Vector.fromJSONField(T, field),
29
25
  fromJSON: (json) => Vector.fromJSON(T, json),
30
26
  new: (elements) => {
31
- return new Vector([(0, reified_1.extractType)(T)], elements);
27
+ return new Vector([extractType(T)], elements);
32
28
  },
33
29
  kind: "VectorClassReified",
34
30
  };
@@ -37,19 +33,19 @@ class Vector {
37
33
  return Vector.reified;
38
34
  }
39
35
  static get bcs() {
40
- return bcs_1.bcs.vector;
36
+ return bcs.vector;
41
37
  }
42
38
  static fromFields(typeArg, elements) {
43
- return Vector.reified(typeArg).new(elements.map((element) => (0, reified_1.decodeFromFields)(typeArg, element)));
39
+ return Vector.reified(typeArg).new(elements.map((element) => decodeFromFields(typeArg, element)));
44
40
  }
45
41
  static fromFieldsWithTypes(typeArg, item) {
46
- return Vector.reified(typeArg).new(item.map((field) => (0, reified_1.decodeFromFieldsWithTypes)(typeArg, field)));
42
+ return Vector.reified(typeArg).new(item.map((field) => decodeFromFieldsWithTypes(typeArg, field)));
47
43
  }
48
44
  static fromBcs(typeArg, data) {
49
- return Vector.fromFields(typeArg, Vector.bcs((0, reified_1.toBcs)(typeArg)).parse(data));
45
+ return Vector.fromFields(typeArg, Vector.bcs(toBcs(typeArg)).parse(data));
50
46
  }
51
47
  toJSONField() {
52
- return this.elements.map((element) => (0, reified_1.fieldToJSON)(this.$typeArgs[0], element));
48
+ return this.elements.map((element) => fieldToJSON(this.$typeArgs[0], element));
53
49
  }
54
50
  toJSON() {
55
51
  return {
@@ -59,7 +55,7 @@ class Vector {
59
55
  };
60
56
  }
61
57
  static fromJSONField(typeArg, field) {
62
- return Vector.reified(typeArg).new(field.map((field) => (0, reified_1.decodeFromJSONField)(typeArg, field)));
58
+ return Vector.reified(typeArg).new(field.map((field) => decodeFromJSONField(typeArg, field)));
63
59
  }
64
60
  static fromJSON(typeArg, json) {
65
61
  if (json.$typeName !== Vector.$typeName) {
@@ -68,10 +64,9 @@ class Vector {
68
64
  return Vector.fromJSONField(typeArg, json.elements);
69
65
  }
70
66
  }
71
- exports.Vector = Vector;
72
67
  Vector.$typeName = "vector";
73
68
  Vector.$numTypeParams = 1;
74
69
  Vector.$isPhantom = [false];
75
- function vector(T) {
70
+ export function vector(T) {
76
71
  return Vector.r(T);
77
72
  }
@@ -3,7 +3,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeArgument, ToTypeSt
3
3
  import { FieldsWithTypes } from "../../_framework/util";
4
4
  import { PKG_V1 } from "../index";
5
5
  import { BcsType } from "@mysten/sui/bcs";
6
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
6
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
7
7
  export declare function isCell(type: string): boolean;
8
8
  export interface CellFields<Element extends TypeArgument> {
9
9
  element: ToField<Option<Element>>;
@@ -24,8 +24,8 @@ export declare class Cell<Element extends TypeArgument> implements StructClass {
24
24
  static get r(): typeof Cell.reified;
25
25
  static phantom<Element extends Reified<TypeArgument, any>>(Element: Element): PhantomReified<ToTypeStr<Cell<ToTypeArgument<Element>>>>;
26
26
  static get p(): typeof Cell.phantom;
27
- static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/sui/bcs").BcsStruct<{
28
- element: import("@mysten/sui/bcs").BcsStruct<{
27
+ static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/bcs").BcsStruct<{
28
+ element: import("@mysten/bcs").BcsStruct<{
29
29
  vec: BcsType<import("@mysten/bcs").InferBcsType<Element>[], Iterable<import("@mysten/bcs").InferBcsInput<Element>> & {
30
30
  length: number;
31
31
  }, string>;
@@ -46,5 +46,5 @@ export declare class Cell<Element extends TypeArgument> implements StructClass {
46
46
  static fromJSON<Element extends Reified<TypeArgument, any>>(typeArg: Element, json: Record<string, any>): Cell<ToTypeArgument<Element>>;
47
47
  static fromSuiParsedData<Element extends Reified<TypeArgument, any>>(typeArg: Element, content: SuiParsedData): Cell<ToTypeArgument<Element>>;
48
48
  static fromSuiObjectData<Element extends Reified<TypeArgument, any>>(typeArg: Element, data: SuiObjectData): Cell<ToTypeArgument<Element>>;
49
- static fetch<Element extends Reified<TypeArgument, any>>(client: SuiClient, typeArg: Element, id: string): Promise<Cell<ToTypeArgument<Element>>>;
49
+ static fetch<Element extends Reified<TypeArgument, any>>(client: SuiJsonRpcClient, typeArg: Element, id: string): Promise<Cell<ToTypeArgument<Element>>>;
50
50
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,47 +7,44 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Cell = void 0;
13
- exports.isCell = isCell;
14
- const structs_1 = require("../../_dependencies/source/0x1/option/structs");
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");
10
+ import { Option } from "../../_dependencies/source/0x1/option/structs";
11
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../_framework/reified";
12
+ import { composeSuiType, compressSuiType, parseTypeName, } from "../../_framework/util";
13
+ import { PKG_V1 } from "../index";
14
+ import { bcs } from "@mysten/sui/bcs";
15
+ import { fromBase64 } from "@mysten/sui/utils";
20
16
  /* ============================== Cell =============================== */
21
- function isCell(type) {
22
- type = (0, util_1.compressSuiType)(type);
23
- return type.startsWith(`${index_1.PKG_V1}::cell::Cell` + "<");
17
+ export function isCell(type) {
18
+ type = compressSuiType(type);
19
+ return type.startsWith(`${PKG_V1}::cell::Cell` + "<");
24
20
  }
25
- class Cell {
21
+ export class Cell {
26
22
  constructor(typeArgs, fields) {
27
23
  this.__StructClass = true;
28
24
  this.$typeName = Cell.$typeName;
29
25
  this.$isPhantom = Cell.$isPhantom;
30
- this.$fullTypeName = (0, util_1.composeSuiType)(Cell.$typeName, ...typeArgs);
26
+ this.$fullTypeName = composeSuiType(Cell.$typeName, ...typeArgs);
31
27
  this.$typeArgs = typeArgs;
32
28
  this.element = fields.element;
33
29
  }
34
30
  static reified(Element) {
35
31
  return {
36
32
  typeName: Cell.$typeName,
37
- fullTypeName: (0, util_1.composeSuiType)(Cell.$typeName, ...[(0, reified_1.extractType)(Element)]),
38
- typeArgs: [(0, reified_1.extractType)(Element)],
33
+ fullTypeName: composeSuiType(Cell.$typeName, ...[extractType(Element)]),
34
+ typeArgs: [extractType(Element)],
39
35
  isPhantom: Cell.$isPhantom,
40
36
  reifiedTypeArgs: [Element],
41
37
  fromFields: (fields) => Cell.fromFields(Element, fields),
42
38
  fromFieldsWithTypes: (item) => Cell.fromFieldsWithTypes(Element, item),
43
39
  fromBcs: (data) => Cell.fromBcs(Element, data),
44
- bcs: Cell.bcs((0, reified_1.toBcs)(Element)),
40
+ bcs: Cell.bcs(toBcs(Element)),
45
41
  fromJSONField: (field) => Cell.fromJSONField(Element, field),
46
42
  fromJSON: (json) => Cell.fromJSON(Element, json),
47
43
  fromSuiParsedData: (content) => Cell.fromSuiParsedData(Element, content),
48
44
  fromSuiObjectData: (content) => Cell.fromSuiObjectData(Element, content),
49
45
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Cell.fetch(client, Element, id); }),
50
46
  new: (fields) => {
51
- return new Cell([(0, reified_1.extractType)(Element)], fields);
47
+ return new Cell([extractType(Element)], fields);
52
48
  },
53
49
  kind: "StructClassReified",
54
50
  };
@@ -57,37 +53,37 @@ class Cell {
57
53
  return Cell.reified;
58
54
  }
59
55
  static phantom(Element) {
60
- return (0, reified_1.phantom)(Cell.reified(Element));
56
+ return phantom(Cell.reified(Element));
61
57
  }
62
58
  static get p() {
63
59
  return Cell.phantom;
64
60
  }
65
61
  static get bcs() {
66
- return (Element) => bcs_1.bcs.struct(`Cell<${Element.name}>`, {
67
- element: structs_1.Option.bcs(Element),
62
+ return (Element) => bcs.struct(`Cell<${Element.name}>`, {
63
+ element: Option.bcs(Element),
68
64
  });
69
65
  }
70
66
  static fromFields(typeArg, fields) {
71
67
  return Cell.reified(typeArg).new({
72
- element: (0, reified_1.decodeFromFields)(structs_1.Option.reified(typeArg), fields.element),
68
+ element: decodeFromFields(Option.reified(typeArg), fields.element),
73
69
  });
74
70
  }
75
71
  static fromFieldsWithTypes(typeArg, item) {
76
72
  if (!isCell(item.type)) {
77
73
  throw new Error("not a Cell type");
78
74
  }
79
- (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
75
+ assertFieldsWithTypesArgsMatch(item, [typeArg]);
80
76
  return Cell.reified(typeArg).new({
81
- element: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Option.reified(typeArg), item.fields.element),
77
+ element: decodeFromFieldsWithTypes(Option.reified(typeArg), item.fields.element),
82
78
  });
83
79
  }
84
80
  static fromBcs(typeArg, data) {
85
81
  const typeArgs = [typeArg];
86
- return Cell.fromFields(typeArg, Cell.bcs((0, reified_1.toBcs)(typeArgs[0])).parse(data));
82
+ return Cell.fromFields(typeArg, Cell.bcs(toBcs(typeArgs[0])).parse(data));
87
83
  }
88
84
  toJSONField() {
89
85
  return {
90
- element: (0, reified_1.fieldToJSON)(`${structs_1.Option.$typeName}<${this.$typeArgs[0]}>`, this.element),
86
+ element: fieldToJSON(`${Option.$typeName}<${this.$typeArgs[0]}>`, this.element),
91
87
  };
92
88
  }
93
89
  toJSON() {
@@ -95,14 +91,14 @@ class Cell {
95
91
  }
96
92
  static fromJSONField(typeArg, field) {
97
93
  return Cell.reified(typeArg).new({
98
- element: (0, reified_1.decodeFromJSONField)(structs_1.Option.reified(typeArg), field.element),
94
+ element: decodeFromJSONField(Option.reified(typeArg), field.element),
99
95
  });
100
96
  }
101
97
  static fromJSON(typeArg, json) {
102
98
  if (json.$typeName !== Cell.$typeName) {
103
99
  throw new Error("not a WithTwoGenerics json object");
104
100
  }
105
- (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(Cell.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
101
+ assertReifiedTypeArgsMatch(composeSuiType(Cell.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
106
102
  return Cell.fromJSONField(typeArg, json);
107
103
  }
108
104
  static fromSuiParsedData(typeArg, content) {
@@ -119,16 +115,16 @@ class Cell {
119
115
  if (data.bcs.dataType !== "moveObject" || !isCell(data.bcs.type)) {
120
116
  throw new Error(`object at is not a Cell object`);
121
117
  }
122
- const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
118
+ const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
123
119
  if (gotTypeArgs.length !== 1) {
124
120
  throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
125
121
  }
126
- const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
127
- const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
128
- if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
122
+ const gotTypeArg = compressSuiType(gotTypeArgs[0]);
123
+ const expectedTypeArg = compressSuiType(extractType(typeArg));
124
+ if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
129
125
  throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
130
126
  }
131
- return Cell.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
127
+ return Cell.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
132
128
  }
133
129
  if (data.content) {
134
130
  return Cell.fromSuiParsedData(typeArg, data.content);
@@ -150,7 +146,6 @@ class Cell {
150
146
  });
151
147
  }
152
148
  }
153
- exports.Cell = Cell;
154
- Cell.$typeName = `${index_1.PKG_V1}::cell::Cell`;
149
+ Cell.$typeName = `${PKG_V1}::cell::Cell`;
155
150
  Cell.$numTypeParams = 1;
156
151
  Cell.$isPhantom = [false];