@suilend/sdk 1.1.99 → 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 (91) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  3. package/_generated/_dependencies/source/0x1/index.js +3 -6
  4. package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
  5. package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  6. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
  7. package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  8. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
  9. package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  10. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
  11. package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  12. package/_generated/_dependencies/source/0x2/index.js +3 -6
  13. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
  14. package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  15. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
  16. package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
  24. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
  25. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
  26. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
  27. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
  28. package/_generated/_framework/reified.d.ts +2 -2
  29. package/_generated/_framework/reified.js +27 -40
  30. package/_generated/_framework/util.js +26 -40
  31. package/_generated/_framework/vector.d.ts +4 -4
  32. package/_generated/_framework/vector.js +16 -21
  33. package/_generated/suilend/cell/structs.d.ts +4 -4
  34. package/_generated/suilend/cell/structs.js +31 -36
  35. package/_generated/suilend/decimal/structs.d.ts +4 -4
  36. package/_generated/suilend/decimal/structs.js +19 -24
  37. package/_generated/suilend/index.js +8 -12
  38. package/_generated/suilend/lending-market/functions.d.ts +1 -0
  39. package/_generated/suilend/lending-market/functions.js +271 -302
  40. package/_generated/suilend/lending-market/structs.d.ts +146 -146
  41. package/_generated/suilend/lending-market/structs.js +549 -617
  42. package/_generated/suilend/lending-market-registry/functions.js +7 -11
  43. package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
  44. package/_generated/suilend/liquidity-mining/structs.js +159 -205
  45. package/_generated/suilend/obligation/structs.d.ts +106 -106
  46. package/_generated/suilend/obligation/structs.js +313 -363
  47. package/_generated/suilend/rate-limiter/functions.js +23 -31
  48. package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
  49. package/_generated/suilend/rate-limiter/structs.js +49 -56
  50. package/_generated/suilend/reserve/structs.d.ts +139 -139
  51. package/_generated/suilend/reserve/structs.js +397 -451
  52. package/_generated/suilend/reserve-config/functions.js +149 -190
  53. package/_generated/suilend/reserve-config/structs.d.ts +33 -33
  54. package/_generated/suilend/reserve-config/structs.js +109 -149
  55. package/api/events.js +1 -5
  56. package/api/index.js +1 -17
  57. package/client.d.ts +10 -10
  58. package/client.js +118 -128
  59. package/index.js +7 -23
  60. package/lib/constants.js +3 -9
  61. package/lib/index.js +5 -21
  62. package/lib/initialize.d.ts +3 -3
  63. package/lib/initialize.js +103 -140
  64. package/lib/liquidityMining.d.ts +3 -3
  65. package/lib/liquidityMining.js +57 -72
  66. package/lib/pyth.js +9 -14
  67. package/lib/strategyOwnerCap.js +106 -119
  68. package/lib/transactions.js +2 -7
  69. package/lib/types.js +4 -7
  70. package/mmt.js +2 -5
  71. package/package.json +1 -1
  72. package/parsers/apiReserveAssetDataEvent.js +25 -33
  73. package/parsers/index.js +5 -21
  74. package/parsers/lendingMarket.d.ts +1 -1
  75. package/parsers/lendingMarket.js +12 -19
  76. package/parsers/obligation.js +19 -26
  77. package/parsers/rateLimiter.js +11 -19
  78. package/parsers/reserve.d.ts +1 -1
  79. package/parsers/reserve.js +42 -85
  80. package/strategies.d.ts +11 -11
  81. package/strategies.js +547 -586
  82. package/swap/index.js +2 -18
  83. package/swap/quote.js +57 -65
  84. package/swap/transaction.d.ts +2 -2
  85. package/swap/transaction.js +40 -35
  86. package/utils/events.d.ts +3 -3
  87. package/utils/events.js +18 -35
  88. package/utils/index.js +16 -40
  89. package/utils/obligation.d.ts +4 -4
  90. package/utils/obligation.js +17 -60
  91. package/utils/simulate.js +118 -143
@@ -3,7 +3,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
3
3
  import { FieldsWithTypes } from "../../../../_framework/util";
4
4
  import { Vector } from "../../../../_framework/vector";
5
5
  import { PKG_V13 } from "../index";
6
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
6
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
7
7
  export declare function isChar(type: string): boolean;
8
8
  export interface CharFields {
9
9
  byte: ToField<"u8">;
@@ -24,8 +24,8 @@ export declare class Char implements StructClass {
24
24
  static get r(): reified.StructClassReified<Char, CharFields>;
25
25
  static phantom(): PhantomReified<ToTypeStr<Char>>;
26
26
  static get p(): reified.PhantomReified<"0x1::ascii::Char">;
27
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
28
- byte: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
27
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
28
+ byte: import("@mysten/bcs").BcsType<number, number, "u8">;
29
29
  }, string>;
30
30
  static fromFields(fields: Record<string, any>): Char;
31
31
  static fromFieldsWithTypes(item: FieldsWithTypes): Char;
@@ -42,7 +42,7 @@ export declare class Char implements StructClass {
42
42
  static fromJSON(json: Record<string, any>): Char;
43
43
  static fromSuiParsedData(content: SuiParsedData): Char;
44
44
  static fromSuiObjectData(data: SuiObjectData): Char;
45
- static fetch(client: SuiClient, id: string): Promise<Char>;
45
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<Char>;
46
46
  }
47
47
  export declare function isString(type: string): boolean;
48
48
  export interface StringFields {
@@ -64,8 +64,8 @@ export declare class String implements StructClass {
64
64
  static get r(): reified.StructClassReified<String, StringFields>;
65
65
  static phantom(): PhantomReified<ToTypeStr<String>>;
66
66
  static get p(): reified.PhantomReified<"0x1::ascii::String">;
67
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
68
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
67
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
68
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
69
69
  length: number;
70
70
  }, string>;
71
71
  }, string>;
@@ -84,5 +84,5 @@ export declare class String implements StructClass {
84
84
  static fromJSON(json: Record<string, any>): String;
85
85
  static fromSuiParsedData(content: SuiParsedData): String;
86
86
  static fromSuiObjectData(data: SuiObjectData): String;
87
- static fetch(client: SuiClient, id: string): Promise<String>;
87
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<String>;
88
88
  }
@@ -1,37 +1,3 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -41,34 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
8
  });
43
9
  };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.String = exports.Char = void 0;
46
- exports.isChar = isChar;
47
- exports.isString = isString;
48
- const reified = __importStar(require("../../../../_framework/reified"));
49
- const reified_1 = require("../../../../_framework/reified");
50
- const util_1 = require("../../../../_framework/util");
51
- const index_1 = require("../index");
52
- const bcs_1 = require("@mysten/sui/bcs");
53
- const utils_1 = require("@mysten/sui/utils");
10
+ import * as reified from "../../../../_framework/reified";
11
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified";
12
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
13
+ import { PKG_V13 } from "../index";
14
+ import { bcs } from "@mysten/sui/bcs";
15
+ import { fromBase64 } from "@mysten/sui/utils";
54
16
  /* ============================== Char =============================== */
55
- function isChar(type) {
56
- type = (0, util_1.compressSuiType)(type);
57
- return type === `${index_1.PKG_V13}::ascii::Char`;
17
+ export function isChar(type) {
18
+ type = compressSuiType(type);
19
+ return type === `${PKG_V13}::ascii::Char`;
58
20
  }
59
- class Char {
21
+ export class Char {
60
22
  constructor(typeArgs, fields) {
61
23
  this.__StructClass = true;
62
24
  this.$typeName = Char.$typeName;
63
25
  this.$isPhantom = Char.$isPhantom;
64
- this.$fullTypeName = (0, util_1.composeSuiType)(Char.$typeName, ...typeArgs);
26
+ this.$fullTypeName = composeSuiType(Char.$typeName, ...typeArgs);
65
27
  this.$typeArgs = typeArgs;
66
28
  this.byte = fields.byte;
67
29
  }
68
30
  static reified() {
69
31
  return {
70
32
  typeName: Char.$typeName,
71
- fullTypeName: (0, util_1.composeSuiType)(Char.$typeName, ...[]),
33
+ fullTypeName: composeSuiType(Char.$typeName, ...[]),
72
34
  typeArgs: [],
73
35
  isPhantom: Char.$isPhantom,
74
36
  reifiedTypeArgs: [],
@@ -91,25 +53,25 @@ class Char {
91
53
  return Char.reified();
92
54
  }
93
55
  static phantom() {
94
- return (0, reified_1.phantom)(Char.reified());
56
+ return phantom(Char.reified());
95
57
  }
96
58
  static get p() {
97
59
  return Char.phantom();
98
60
  }
99
61
  static get bcs() {
100
- return bcs_1.bcs.struct("Char", {
101
- byte: bcs_1.bcs.u8(),
62
+ return bcs.struct("Char", {
63
+ byte: bcs.u8(),
102
64
  });
103
65
  }
104
66
  static fromFields(fields) {
105
- return Char.reified().new({ byte: (0, reified_1.decodeFromFields)("u8", fields.byte) });
67
+ return Char.reified().new({ byte: decodeFromFields("u8", fields.byte) });
106
68
  }
107
69
  static fromFieldsWithTypes(item) {
108
70
  if (!isChar(item.type)) {
109
71
  throw new Error("not a Char type");
110
72
  }
111
73
  return Char.reified().new({
112
- byte: (0, reified_1.decodeFromFieldsWithTypes)("u8", item.fields.byte),
74
+ byte: decodeFromFieldsWithTypes("u8", item.fields.byte),
113
75
  });
114
76
  }
115
77
  static fromBcs(data) {
@@ -124,7 +86,7 @@ class Char {
124
86
  return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
125
87
  }
126
88
  static fromJSONField(field) {
127
- return Char.reified().new({ byte: (0, reified_1.decodeFromJSONField)("u8", field.byte) });
89
+ return Char.reified().new({ byte: decodeFromJSONField("u8", field.byte) });
128
90
  }
129
91
  static fromJSON(json) {
130
92
  if (json.$typeName !== Char.$typeName) {
@@ -146,7 +108,7 @@ class Char {
146
108
  if (data.bcs.dataType !== "moveObject" || !isChar(data.bcs.type)) {
147
109
  throw new Error(`object at is not a Char object`);
148
110
  }
149
- return Char.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
111
+ return Char.fromBcs(fromBase64(data.bcs.bcsBytes));
150
112
  }
151
113
  if (data.content) {
152
114
  return Char.fromSuiParsedData(data.content);
@@ -168,28 +130,27 @@ class Char {
168
130
  });
169
131
  }
170
132
  }
171
- exports.Char = Char;
172
- Char.$typeName = `${index_1.PKG_V13}::ascii::Char`;
133
+ Char.$typeName = `${PKG_V13}::ascii::Char`;
173
134
  Char.$numTypeParams = 0;
174
135
  Char.$isPhantom = [];
175
136
  /* ============================== String =============================== */
176
- function isString(type) {
177
- type = (0, util_1.compressSuiType)(type);
178
- return type === `${index_1.PKG_V13}::ascii::String`;
137
+ export function isString(type) {
138
+ type = compressSuiType(type);
139
+ return type === `${PKG_V13}::ascii::String`;
179
140
  }
180
- class String {
141
+ export class String {
181
142
  constructor(typeArgs, fields) {
182
143
  this.__StructClass = true;
183
144
  this.$typeName = String.$typeName;
184
145
  this.$isPhantom = String.$isPhantom;
185
- this.$fullTypeName = (0, util_1.composeSuiType)(String.$typeName, ...typeArgs);
146
+ this.$fullTypeName = composeSuiType(String.$typeName, ...typeArgs);
186
147
  this.$typeArgs = typeArgs;
187
148
  this.bytes = fields.bytes;
188
149
  }
189
150
  static reified() {
190
151
  return {
191
152
  typeName: String.$typeName,
192
- fullTypeName: (0, util_1.composeSuiType)(String.$typeName, ...[]),
153
+ fullTypeName: composeSuiType(String.$typeName, ...[]),
193
154
  typeArgs: [],
194
155
  isPhantom: String.$isPhantom,
195
156
  reifiedTypeArgs: [],
@@ -212,19 +173,19 @@ class String {
212
173
  return String.reified();
213
174
  }
214
175
  static phantom() {
215
- return (0, reified_1.phantom)(String.reified());
176
+ return phantom(String.reified());
216
177
  }
217
178
  static get p() {
218
179
  return String.phantom();
219
180
  }
220
181
  static get bcs() {
221
- return bcs_1.bcs.struct("String", {
222
- bytes: bcs_1.bcs.vector(bcs_1.bcs.u8()),
182
+ return bcs.struct("String", {
183
+ bytes: bcs.vector(bcs.u8()),
223
184
  });
224
185
  }
225
186
  static fromFields(fields) {
226
187
  return String.reified().new({
227
- bytes: (0, reified_1.decodeFromFields)(reified.vector("u8"), fields.bytes),
188
+ bytes: decodeFromFields(reified.vector("u8"), fields.bytes),
228
189
  });
229
190
  }
230
191
  static fromFieldsWithTypes(item) {
@@ -232,7 +193,7 @@ class String {
232
193
  throw new Error("not a String type");
233
194
  }
234
195
  return String.reified().new({
235
- bytes: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector("u8"), item.fields.bytes),
196
+ bytes: decodeFromFieldsWithTypes(reified.vector("u8"), item.fields.bytes),
236
197
  });
237
198
  }
238
199
  static fromBcs(data) {
@@ -240,7 +201,7 @@ class String {
240
201
  }
241
202
  toJSONField() {
242
203
  return {
243
- bytes: (0, reified_1.fieldToJSON)(`vector<u8>`, this.bytes),
204
+ bytes: fieldToJSON(`vector<u8>`, this.bytes),
244
205
  };
245
206
  }
246
207
  toJSON() {
@@ -248,7 +209,7 @@ class String {
248
209
  }
249
210
  static fromJSONField(field) {
250
211
  return String.reified().new({
251
- bytes: (0, reified_1.decodeFromJSONField)(reified.vector("u8"), field.bytes),
212
+ bytes: decodeFromJSONField(reified.vector("u8"), field.bytes),
252
213
  });
253
214
  }
254
215
  static fromJSON(json) {
@@ -271,7 +232,7 @@ class String {
271
232
  if (data.bcs.dataType !== "moveObject" || !isString(data.bcs.type)) {
272
233
  throw new Error(`object at is not a String object`);
273
234
  }
274
- return String.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
235
+ return String.fromBcs(fromBase64(data.bcs.bcsBytes));
275
236
  }
276
237
  if (data.content) {
277
238
  return String.fromSuiParsedData(data.content);
@@ -293,7 +254,6 @@ class String {
293
254
  });
294
255
  }
295
256
  }
296
- exports.String = String;
297
- String.$typeName = `${index_1.PKG_V13}::ascii::String`;
257
+ String.$typeName = `${PKG_V13}::ascii::String`;
298
258
  String.$numTypeParams = 0;
299
259
  String.$isPhantom = [];
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PKG_V13 = exports.PUBLISHED_AT = exports.PACKAGE_ID = void 0;
4
- exports.PACKAGE_ID = "0x1";
5
- exports.PUBLISHED_AT = "0x1";
6
- exports.PKG_V13 = "0x1";
1
+ export const PACKAGE_ID = "0x1";
2
+ export const PUBLISHED_AT = "0x1";
3
+ export const PKG_V13 = "0x1";
@@ -4,7 +4,7 @@ import { FieldsWithTypes } from "../../../../_framework/util";
4
4
  import { Vector } from "../../../../_framework/vector";
5
5
  import { PKG_V13 } from "../index";
6
6
  import { BcsType } from "@mysten/sui/bcs";
7
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
7
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
8
8
  export declare function isOption(type: string): boolean;
9
9
  export interface OptionFields<Element extends TypeArgument> {
10
10
  vec: ToField<Vector<Element>>;
@@ -26,7 +26,7 @@ export declare class Option<Element extends TypeArgument> implements StructClass
26
26
  static get r(): typeof Option.reified;
27
27
  static phantom<Element extends Reified<TypeArgument, any>>(Element: Element): PhantomReified<ToTypeStr<Option<ToTypeArgument<Element>>>>;
28
28
  static get p(): typeof Option.phantom;
29
- static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/sui/bcs").BcsStruct<{
29
+ static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/bcs").BcsStruct<{
30
30
  vec: BcsType<import("@mysten/bcs").InferBcsType<Element>[], Iterable<import("@mysten/bcs").InferBcsInput<Element>> & {
31
31
  length: number;
32
32
  }, string>;
@@ -46,5 +46,5 @@ export declare class Option<Element extends TypeArgument> implements StructClass
46
46
  static fromJSON<Element extends Reified<TypeArgument, any>>(typeArg: Element, json: Record<string, any>): Option<ToTypeArgument<Element>>;
47
47
  static fromSuiParsedData<Element extends Reified<TypeArgument, any>>(typeArg: Element, content: SuiParsedData): Option<ToTypeArgument<Element>>;
48
48
  static fromSuiObjectData<Element extends Reified<TypeArgument, any>>(typeArg: Element, data: SuiObjectData): Option<ToTypeArgument<Element>>;
49
- static fetch<Element extends Reified<TypeArgument, any>>(client: SuiClient, typeArg: Element, id: string): Promise<Option<ToTypeArgument<Element>>>;
49
+ static fetch<Element extends Reified<TypeArgument, any>>(client: SuiJsonRpcClient, typeArg: Element, id: string): Promise<Option<ToTypeArgument<Element>>>;
50
50
  }
@@ -1,37 +1,3 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -41,48 +7,45 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
8
  });
43
9
  };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.Option = void 0;
46
- exports.isOption = isOption;
47
- const reified = __importStar(require("../../../../_framework/reified"));
48
- const reified_1 = require("../../../../_framework/reified");
49
- const util_1 = require("../../../../_framework/util");
50
- const index_1 = require("../index");
51
- const bcs_1 = require("@mysten/sui/bcs");
52
- const utils_1 = require("@mysten/sui/utils");
10
+ import * as reified from "../../../../_framework/reified";
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_V13 } from "../index";
14
+ import { bcs } from "@mysten/sui/bcs";
15
+ import { fromBase64 } from "@mysten/sui/utils";
53
16
  /* ============================== Option =============================== */
54
- function isOption(type) {
55
- type = (0, util_1.compressSuiType)(type);
56
- return type.startsWith(`${index_1.PKG_V13}::option::Option` + "<");
17
+ export function isOption(type) {
18
+ type = compressSuiType(type);
19
+ return type.startsWith(`${PKG_V13}::option::Option` + "<");
57
20
  }
58
- class Option {
21
+ export class Option {
59
22
  constructor(typeArgs, fields) {
60
23
  this.__StructClass = true;
61
24
  this.__inner = null; // for type checking in reified.ts
62
25
  this.$typeName = Option.$typeName;
63
26
  this.$isPhantom = Option.$isPhantom;
64
- this.$fullTypeName = (0, util_1.composeSuiType)(Option.$typeName, ...typeArgs);
27
+ this.$fullTypeName = composeSuiType(Option.$typeName, ...typeArgs);
65
28
  this.$typeArgs = typeArgs;
66
29
  this.vec = fields.vec;
67
30
  }
68
31
  static reified(Element) {
69
32
  return {
70
33
  typeName: Option.$typeName,
71
- fullTypeName: (0, util_1.composeSuiType)(Option.$typeName, ...[(0, reified_1.extractType)(Element)]),
72
- typeArgs: [(0, reified_1.extractType)(Element)],
34
+ fullTypeName: composeSuiType(Option.$typeName, ...[extractType(Element)]),
35
+ typeArgs: [extractType(Element)],
73
36
  isPhantom: Option.$isPhantom,
74
37
  reifiedTypeArgs: [Element],
75
38
  fromFields: (fields) => Option.fromFields(Element, fields),
76
39
  fromFieldsWithTypes: (item) => Option.fromFieldsWithTypes(Element, item),
77
40
  fromBcs: (data) => Option.fromBcs(Element, data),
78
- bcs: Option.bcs((0, reified_1.toBcs)(Element)),
41
+ bcs: Option.bcs(toBcs(Element)),
79
42
  fromJSONField: (field) => Option.fromJSONField(Element, field),
80
43
  fromJSON: (json) => Option.fromJSON(Element, json),
81
44
  fromSuiParsedData: (content) => Option.fromSuiParsedData(Element, content),
82
45
  fromSuiObjectData: (content) => Option.fromSuiObjectData(Element, content),
83
46
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Option.fetch(client, Element, id); }),
84
47
  new: (fields) => {
85
- return new Option([(0, reified_1.extractType)(Element)], fields);
48
+ return new Option([extractType(Element)], fields);
86
49
  },
87
50
  kind: "StructClassReified",
88
51
  };
@@ -91,37 +54,37 @@ class Option {
91
54
  return Option.reified;
92
55
  }
93
56
  static phantom(Element) {
94
- return (0, reified_1.phantom)(Option.reified(Element));
57
+ return phantom(Option.reified(Element));
95
58
  }
96
59
  static get p() {
97
60
  return Option.phantom;
98
61
  }
99
62
  static get bcs() {
100
- return (Element) => bcs_1.bcs.struct(`Option<${Element.name}>`, {
101
- vec: bcs_1.bcs.vector(Element),
63
+ return (Element) => bcs.struct(`Option<${Element.name}>`, {
64
+ vec: bcs.vector(Element),
102
65
  });
103
66
  }
104
67
  static fromFields(typeArg, fields) {
105
68
  return Option.reified(typeArg).new({
106
- vec: (0, reified_1.decodeFromFields)(reified.vector(typeArg), fields.vec),
69
+ vec: decodeFromFields(reified.vector(typeArg), fields.vec),
107
70
  });
108
71
  }
109
72
  static fromFieldsWithTypes(typeArg, item) {
110
73
  if (!isOption(item.type)) {
111
74
  throw new Error("not a Option type");
112
75
  }
113
- (0, reified_1.assertFieldsWithTypesArgsMatch)(item, [typeArg]);
76
+ assertFieldsWithTypesArgsMatch(item, [typeArg]);
114
77
  return Option.reified(typeArg).new({
115
- vec: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector(typeArg), item.fields.vec),
78
+ vec: decodeFromFieldsWithTypes(reified.vector(typeArg), item.fields.vec),
116
79
  });
117
80
  }
118
81
  static fromBcs(typeArg, data) {
119
82
  const typeArgs = [typeArg];
120
- return Option.fromFields(typeArg, Option.bcs((0, reified_1.toBcs)(typeArgs[0])).parse(data));
83
+ return Option.fromFields(typeArg, Option.bcs(toBcs(typeArgs[0])).parse(data));
121
84
  }
122
85
  toJSONField() {
123
86
  return {
124
- vec: (0, reified_1.fieldToJSON)(`vector<${this.$typeArgs[0]}>`, this.vec),
87
+ vec: fieldToJSON(`vector<${this.$typeArgs[0]}>`, this.vec),
125
88
  };
126
89
  }
127
90
  toJSON() {
@@ -129,14 +92,14 @@ class Option {
129
92
  }
130
93
  static fromJSONField(typeArg, field) {
131
94
  return Option.reified(typeArg).new({
132
- vec: (0, reified_1.decodeFromJSONField)(reified.vector(typeArg), field.vec),
95
+ vec: decodeFromJSONField(reified.vector(typeArg), field.vec),
133
96
  });
134
97
  }
135
98
  static fromJSON(typeArg, json) {
136
99
  if (json.$typeName !== Option.$typeName) {
137
100
  throw new Error("not a WithTwoGenerics json object");
138
101
  }
139
- (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(Option.$typeName, (0, reified_1.extractType)(typeArg)), json.$typeArgs, [typeArg]);
102
+ assertReifiedTypeArgsMatch(composeSuiType(Option.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
140
103
  return Option.fromJSONField(typeArg, json);
141
104
  }
142
105
  static fromSuiParsedData(typeArg, content) {
@@ -153,16 +116,16 @@ class Option {
153
116
  if (data.bcs.dataType !== "moveObject" || !isOption(data.bcs.type)) {
154
117
  throw new Error(`object at is not a Option object`);
155
118
  }
156
- const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
119
+ const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
157
120
  if (gotTypeArgs.length !== 1) {
158
121
  throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
159
122
  }
160
- const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[0]);
161
- const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg));
162
- if (gotTypeArg !== (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArg))) {
123
+ const gotTypeArg = compressSuiType(gotTypeArgs[0]);
124
+ const expectedTypeArg = compressSuiType(extractType(typeArg));
125
+ if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
163
126
  throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
164
127
  }
165
- return Option.fromBcs(typeArg, (0, utils_1.fromB64)(data.bcs.bcsBytes));
128
+ return Option.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
166
129
  }
167
130
  if (data.content) {
168
131
  return Option.fromSuiParsedData(typeArg, data.content);
@@ -184,7 +147,6 @@ class Option {
184
147
  });
185
148
  }
186
149
  }
187
- exports.Option = Option;
188
- Option.$typeName = `${index_1.PKG_V13}::option::Option`;
150
+ Option.$typeName = `${PKG_V13}::option::Option`;
189
151
  Option.$numTypeParams = 1;
190
152
  Option.$isPhantom = [false];
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
2
2
  import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { String } from "../ascii/structs";
4
4
  import { PKG_V13 } from "../index";
5
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
5
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
6
6
  export declare function isTypeName(type: string): boolean;
7
7
  export interface TypeNameFields {
8
8
  name: ToField<String>;
@@ -23,9 +23,9 @@ export declare class TypeName implements StructClass {
23
23
  static get r(): import("../../../../_framework/reified").StructClassReified<TypeName, TypeNameFields>;
24
24
  static phantom(): PhantomReified<ToTypeStr<TypeName>>;
25
25
  static get p(): PhantomReified<"0x1::type_name::TypeName">;
26
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
27
- name: import("@mysten/sui/bcs").BcsStruct<{
28
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
26
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
27
+ name: import("@mysten/bcs").BcsStruct<{
28
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
29
29
  length: number;
30
30
  }, string>;
31
31
  }, string>;
@@ -45,5 +45,5 @@ export declare class TypeName implements StructClass {
45
45
  static fromJSON(json: Record<string, any>): TypeName;
46
46
  static fromSuiParsedData(content: SuiParsedData): TypeName;
47
47
  static fromSuiObjectData(data: SuiObjectData): TypeName;
48
- static fetch(client: SuiClient, id: string): Promise<TypeName>;
48
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<TypeName>;
49
49
  }
@@ -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,33 +7,30 @@ 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.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");
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
+ import { String } from "../ascii/structs";
13
+ import { PKG_V13 } from "../index";
14
+ import { bcs } from "@mysten/sui/bcs";
15
+ import { fromBase64 } from "@mysten/sui/utils";
20
16
  /* ============================== TypeName =============================== */
21
- function isTypeName(type) {
22
- type = (0, util_1.compressSuiType)(type);
23
- return type === `${index_1.PKG_V13}::type_name::TypeName`;
17
+ export function isTypeName(type) {
18
+ type = compressSuiType(type);
19
+ return type === `${PKG_V13}::type_name::TypeName`;
24
20
  }
25
- class TypeName {
21
+ export class TypeName {
26
22
  constructor(typeArgs, fields) {
27
23
  this.__StructClass = true;
28
24
  this.$typeName = TypeName.$typeName;
29
25
  this.$isPhantom = TypeName.$isPhantom;
30
- this.$fullTypeName = (0, util_1.composeSuiType)(TypeName.$typeName, ...typeArgs);
26
+ this.$fullTypeName = composeSuiType(TypeName.$typeName, ...typeArgs);
31
27
  this.$typeArgs = typeArgs;
32
28
  this.name = fields.name;
33
29
  }
34
30
  static reified() {
35
31
  return {
36
32
  typeName: TypeName.$typeName,
37
- fullTypeName: (0, util_1.composeSuiType)(TypeName.$typeName, ...[]),
33
+ fullTypeName: composeSuiType(TypeName.$typeName, ...[]),
38
34
  typeArgs: [],
39
35
  isPhantom: TypeName.$isPhantom,
40
36
  reifiedTypeArgs: [],
@@ -57,19 +53,19 @@ class TypeName {
57
53
  return TypeName.reified();
58
54
  }
59
55
  static phantom() {
60
- return (0, reified_1.phantom)(TypeName.reified());
56
+ return phantom(TypeName.reified());
61
57
  }
62
58
  static get p() {
63
59
  return TypeName.phantom();
64
60
  }
65
61
  static get bcs() {
66
- return bcs_1.bcs.struct("TypeName", {
67
- name: structs_1.String.bcs,
62
+ return bcs.struct("TypeName", {
63
+ name: String.bcs,
68
64
  });
69
65
  }
70
66
  static fromFields(fields) {
71
67
  return TypeName.reified().new({
72
- name: (0, reified_1.decodeFromFields)(structs_1.String.reified(), fields.name),
68
+ name: decodeFromFields(String.reified(), fields.name),
73
69
  });
74
70
  }
75
71
  static fromFieldsWithTypes(item) {
@@ -77,7 +73,7 @@ class TypeName {
77
73
  throw new Error("not a TypeName type");
78
74
  }
79
75
  return TypeName.reified().new({
80
- name: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.String.reified(), item.fields.name),
76
+ name: decodeFromFieldsWithTypes(String.reified(), item.fields.name),
81
77
  });
82
78
  }
83
79
  static fromBcs(data) {
@@ -93,7 +89,7 @@ class TypeName {
93
89
  }
94
90
  static fromJSONField(field) {
95
91
  return TypeName.reified().new({
96
- name: (0, reified_1.decodeFromJSONField)(structs_1.String.reified(), field.name),
92
+ name: decodeFromJSONField(String.reified(), field.name),
97
93
  });
98
94
  }
99
95
  static fromJSON(json) {
@@ -116,7 +112,7 @@ class TypeName {
116
112
  if (data.bcs.dataType !== "moveObject" || !isTypeName(data.bcs.type)) {
117
113
  throw new Error(`object at is not a TypeName object`);
118
114
  }
119
- return TypeName.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
115
+ return TypeName.fromBcs(fromBase64(data.bcs.bcsBytes));
120
116
  }
121
117
  if (data.content) {
122
118
  return TypeName.fromSuiParsedData(data.content);
@@ -138,7 +134,6 @@ class TypeName {
138
134
  });
139
135
  }
140
136
  }
141
- exports.TypeName = TypeName;
142
- TypeName.$typeName = `${index_1.PKG_V13}::type_name::TypeName`;
137
+ TypeName.$typeName = `${PKG_V13}::type_name::TypeName`;
143
138
  TypeName.$numTypeParams = 0;
144
139
  TypeName.$isPhantom = [];