@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
@@ -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,29 @@ 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.UID = exports.ID = void 0;
13
- exports.isID = isID;
14
- exports.isUID = isUID;
15
- const reified_1 = require("../../../../_framework/reified");
16
- const util_1 = require("../../../../_framework/util");
17
- const index_1 = require("../index");
18
- const bcs_1 = require("@mysten/sui/bcs");
19
- const utils_1 = require("@mysten/sui/utils");
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
+ import { PKG_V30 } from "../index";
13
+ import { bcs } from "@mysten/sui/bcs";
14
+ import { fromBase64, fromHex, toHex } from "@mysten/sui/utils";
20
15
  /* ============================== ID =============================== */
21
- function isID(type) {
22
- type = (0, util_1.compressSuiType)(type);
23
- return type === `${index_1.PKG_V30}::object::ID`;
16
+ export function isID(type) {
17
+ type = compressSuiType(type);
18
+ return type === `${PKG_V30}::object::ID`;
24
19
  }
25
- class ID {
20
+ export class ID {
26
21
  constructor(typeArgs, fields) {
27
22
  this.__StructClass = true;
28
23
  this.$typeName = ID.$typeName;
29
24
  this.$isPhantom = ID.$isPhantom;
30
- this.$fullTypeName = (0, util_1.composeSuiType)(ID.$typeName, ...typeArgs);
25
+ this.$fullTypeName = composeSuiType(ID.$typeName, ...typeArgs);
31
26
  this.$typeArgs = typeArgs;
32
27
  this.bytes = fields.bytes;
33
28
  }
34
29
  static reified() {
35
30
  return {
36
31
  typeName: ID.$typeName,
37
- fullTypeName: (0, util_1.composeSuiType)(ID.$typeName, ...[]),
32
+ fullTypeName: composeSuiType(ID.$typeName, ...[]),
38
33
  typeArgs: [],
39
34
  isPhantom: ID.$isPhantom,
40
35
  reifiedTypeArgs: [],
@@ -57,24 +52,24 @@ class ID {
57
52
  return ID.reified();
58
53
  }
59
54
  static phantom() {
60
- return (0, reified_1.phantom)(ID.reified());
55
+ return phantom(ID.reified());
61
56
  }
62
57
  static get p() {
63
58
  return ID.phantom();
64
59
  }
65
60
  static get bcs() {
66
- return bcs_1.bcs.struct("ID", {
67
- bytes: bcs_1.bcs
61
+ return bcs.struct("ID", {
62
+ bytes: bcs
68
63
  .bytes(32)
69
64
  .transform({
70
- input: (val) => (0, utils_1.fromHEX)(val),
71
- output: (val) => (0, utils_1.toHEX)(val),
65
+ input: (val) => fromHex(val),
66
+ output: (val) => toHex(val),
72
67
  }),
73
68
  });
74
69
  }
75
70
  static fromFields(fields) {
76
71
  return ID.reified().new({
77
- bytes: (0, reified_1.decodeFromFields)("address", fields.bytes),
72
+ bytes: decodeFromFields("address", fields.bytes),
78
73
  });
79
74
  }
80
75
  static fromFieldsWithTypes(item) {
@@ -82,7 +77,7 @@ class ID {
82
77
  throw new Error("not a ID type");
83
78
  }
84
79
  return ID.reified().new({
85
- bytes: (0, reified_1.decodeFromFieldsWithTypes)("address", item.fields.bytes),
80
+ bytes: decodeFromFieldsWithTypes("address", item.fields.bytes),
86
81
  });
87
82
  }
88
83
  static fromBcs(data) {
@@ -98,7 +93,7 @@ class ID {
98
93
  }
99
94
  static fromJSONField(field) {
100
95
  return ID.reified().new({
101
- bytes: (0, reified_1.decodeFromJSONField)("address", field.bytes),
96
+ bytes: decodeFromJSONField("address", field.bytes),
102
97
  });
103
98
  }
104
99
  static fromJSON(json) {
@@ -121,7 +116,7 @@ class ID {
121
116
  if (data.bcs.dataType !== "moveObject" || !isID(data.bcs.type)) {
122
117
  throw new Error(`object at is not a ID object`);
123
118
  }
124
- return ID.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
119
+ return ID.fromBcs(fromBase64(data.bcs.bcsBytes));
125
120
  }
126
121
  if (data.content) {
127
122
  return ID.fromSuiParsedData(data.content);
@@ -142,28 +137,27 @@ class ID {
142
137
  });
143
138
  }
144
139
  }
145
- exports.ID = ID;
146
- ID.$typeName = `${index_1.PKG_V30}::object::ID`;
140
+ ID.$typeName = `${PKG_V30}::object::ID`;
147
141
  ID.$numTypeParams = 0;
148
142
  ID.$isPhantom = [];
149
143
  /* ============================== UID =============================== */
150
- function isUID(type) {
151
- type = (0, util_1.compressSuiType)(type);
152
- return type === `${index_1.PKG_V30}::object::UID`;
144
+ export function isUID(type) {
145
+ type = compressSuiType(type);
146
+ return type === `${PKG_V30}::object::UID`;
153
147
  }
154
- class UID {
148
+ export class UID {
155
149
  constructor(typeArgs, fields) {
156
150
  this.__StructClass = true;
157
151
  this.$typeName = UID.$typeName;
158
152
  this.$isPhantom = UID.$isPhantom;
159
- this.$fullTypeName = (0, util_1.composeSuiType)(UID.$typeName, ...typeArgs);
153
+ this.$fullTypeName = composeSuiType(UID.$typeName, ...typeArgs);
160
154
  this.$typeArgs = typeArgs;
161
155
  this.id = fields.id;
162
156
  }
163
157
  static reified() {
164
158
  return {
165
159
  typeName: UID.$typeName,
166
- fullTypeName: (0, util_1.composeSuiType)(UID.$typeName, ...[]),
160
+ fullTypeName: composeSuiType(UID.$typeName, ...[]),
167
161
  typeArgs: [],
168
162
  isPhantom: UID.$isPhantom,
169
163
  reifiedTypeArgs: [],
@@ -186,25 +180,25 @@ class UID {
186
180
  return UID.reified();
187
181
  }
188
182
  static phantom() {
189
- return (0, reified_1.phantom)(UID.reified());
183
+ return phantom(UID.reified());
190
184
  }
191
185
  static get p() {
192
186
  return UID.phantom();
193
187
  }
194
188
  static get bcs() {
195
- return bcs_1.bcs.struct("UID", {
189
+ return bcs.struct("UID", {
196
190
  id: ID.bcs,
197
191
  });
198
192
  }
199
193
  static fromFields(fields) {
200
- return UID.reified().new({ id: (0, reified_1.decodeFromFields)(ID.reified(), fields.id) });
194
+ return UID.reified().new({ id: decodeFromFields(ID.reified(), fields.id) });
201
195
  }
202
196
  static fromFieldsWithTypes(item) {
203
197
  if (!isUID(item.type)) {
204
198
  throw new Error("not a UID type");
205
199
  }
206
200
  return UID.reified().new({
207
- id: (0, reified_1.decodeFromFieldsWithTypes)(ID.reified(), item.fields.id),
201
+ id: decodeFromFieldsWithTypes(ID.reified(), item.fields.id),
208
202
  });
209
203
  }
210
204
  static fromBcs(data) {
@@ -220,7 +214,7 @@ class UID {
220
214
  }
221
215
  static fromJSONField(field) {
222
216
  return UID.reified().new({
223
- id: (0, reified_1.decodeFromJSONField)(ID.reified(), field.id),
217
+ id: decodeFromJSONField(ID.reified(), field.id),
224
218
  });
225
219
  }
226
220
  static fromJSON(json) {
@@ -243,7 +237,7 @@ class UID {
243
237
  if (data.bcs.dataType !== "moveObject" || !isUID(data.bcs.type)) {
244
238
  throw new Error(`object at is not a UID object`);
245
239
  }
246
- return UID.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
240
+ return UID.fromBcs(fromBase64(data.bcs.bcsBytes));
247
241
  }
248
242
  if (data.content) {
249
243
  return UID.fromSuiParsedData(data.content);
@@ -264,7 +258,6 @@ class UID {
264
258
  });
265
259
  }
266
260
  }
267
- exports.UID = UID;
268
- UID.$typeName = `${index_1.PKG_V30}::object::UID`;
261
+ UID.$typeName = `${PKG_V30}::object::UID`;
269
262
  UID.$numTypeParams = 0;
270
263
  UID.$isPhantom = [];
@@ -2,7 +2,7 @@ import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructC
2
2
  import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { PKG_V30 } from "../index";
4
4
  import { UID } from "../object/structs";
5
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
5
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
6
6
  export declare function isObjectTable(type: string): boolean;
7
7
  export interface ObjectTableFields<K extends PhantomTypeArgument, V extends PhantomTypeArgument> {
8
8
  id: ToField<UID>;
@@ -25,13 +25,13 @@ export declare class ObjectTable<K extends PhantomTypeArgument, V extends Phanto
25
25
  static get r(): typeof ObjectTable.reified;
26
26
  static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): PhantomReified<ToTypeStr<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>>;
27
27
  static get p(): typeof ObjectTable.phantom;
28
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
29
- id: import("@mysten/sui/bcs").BcsStruct<{
30
- id: import("@mysten/sui/bcs").BcsStruct<{
31
- bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
28
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
29
+ id: import("@mysten/bcs").BcsStruct<{
30
+ id: import("@mysten/bcs").BcsStruct<{
31
+ bytes: import("@mysten/bcs").BcsType<string, string, string>;
32
32
  }, string>;
33
33
  }, string>;
34
- size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
34
+ size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
35
35
  }, string>;
36
36
  static fromFields<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], fields: Record<string, any>): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
37
37
  static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], item: FieldsWithTypes): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
@@ -50,5 +50,5 @@ export declare class ObjectTable<K extends PhantomTypeArgument, V extends Phanto
50
50
  static fromJSON<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], json: Record<string, any>): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
51
51
  static fromSuiParsedData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], content: SuiParsedData): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
52
52
  static fromSuiObjectData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: SuiObjectData): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
53
- static fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(client: SuiClient, typeArgs: [K, V], id: string): Promise<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>;
53
+ static fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(client: SuiJsonRpcClient, typeArgs: [K, V], id: string): Promise<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>;
54
54
  }
@@ -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,26 +7,23 @@ 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.ObjectTable = void 0;
13
- exports.isObjectTable = isObjectTable;
14
- const reified_1 = require("../../../../_framework/reified");
15
- const util_1 = require("../../../../_framework/util");
16
- const index_1 = require("../index");
17
- const structs_1 = require("../object/structs");
18
- const bcs_1 = require("@mysten/sui/bcs");
19
- const utils_1 = require("@mysten/sui/utils");
10
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified";
11
+ import { composeSuiType, compressSuiType, parseTypeName, } from "../../../../_framework/util";
12
+ import { PKG_V30 } from "../index";
13
+ import { UID } from "../object/structs";
14
+ import { bcs } from "@mysten/sui/bcs";
15
+ import { fromBase64 } from "@mysten/sui/utils";
20
16
  /* ============================== ObjectTable =============================== */
21
- function isObjectTable(type) {
22
- type = (0, util_1.compressSuiType)(type);
23
- return type.startsWith(`${index_1.PKG_V30}::object_table::ObjectTable` + "<");
17
+ export function isObjectTable(type) {
18
+ type = compressSuiType(type);
19
+ return type.startsWith(`${PKG_V30}::object_table::ObjectTable` + "<");
24
20
  }
25
- class ObjectTable {
21
+ export class ObjectTable {
26
22
  constructor(typeArgs, fields) {
27
23
  this.__StructClass = true;
28
24
  this.$typeName = ObjectTable.$typeName;
29
25
  this.$isPhantom = ObjectTable.$isPhantom;
30
- this.$fullTypeName = (0, util_1.composeSuiType)(ObjectTable.$typeName, ...typeArgs);
26
+ this.$fullTypeName = composeSuiType(ObjectTable.$typeName, ...typeArgs);
31
27
  this.$typeArgs = typeArgs;
32
28
  this.id = fields.id;
33
29
  this.size = fields.size;
@@ -35,8 +31,8 @@ class ObjectTable {
35
31
  static reified(K, V) {
36
32
  return {
37
33
  typeName: ObjectTable.$typeName,
38
- fullTypeName: (0, util_1.composeSuiType)(ObjectTable.$typeName, ...[(0, reified_1.extractType)(K), (0, reified_1.extractType)(V)]),
39
- typeArgs: [(0, reified_1.extractType)(K), (0, reified_1.extractType)(V)],
34
+ fullTypeName: composeSuiType(ObjectTable.$typeName, ...[extractType(K), extractType(V)]),
35
+ typeArgs: [extractType(K), extractType(V)],
40
36
  isPhantom: ObjectTable.$isPhantom,
41
37
  reifiedTypeArgs: [K, V],
42
38
  fromFields: (fields) => ObjectTable.fromFields([K, V], fields),
@@ -49,7 +45,7 @@ class ObjectTable {
49
45
  fromSuiObjectData: (content) => ObjectTable.fromSuiObjectData([K, V], content),
50
46
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ObjectTable.fetch(client, [K, V], id); }),
51
47
  new: (fields) => {
52
- return new ObjectTable([(0, reified_1.extractType)(K), (0, reified_1.extractType)(V)], fields);
48
+ return new ObjectTable([extractType(K), extractType(V)], fields);
53
49
  },
54
50
  kind: "StructClassReified",
55
51
  };
@@ -58,31 +54,31 @@ class ObjectTable {
58
54
  return ObjectTable.reified;
59
55
  }
60
56
  static phantom(K, V) {
61
- return (0, reified_1.phantom)(ObjectTable.reified(K, V));
57
+ return phantom(ObjectTable.reified(K, V));
62
58
  }
63
59
  static get p() {
64
60
  return ObjectTable.phantom;
65
61
  }
66
62
  static get bcs() {
67
- return bcs_1.bcs.struct("ObjectTable", {
68
- id: structs_1.UID.bcs,
69
- size: bcs_1.bcs.u64(),
63
+ return bcs.struct("ObjectTable", {
64
+ id: UID.bcs,
65
+ size: bcs.u64(),
70
66
  });
71
67
  }
72
68
  static fromFields(typeArgs, fields) {
73
69
  return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
74
- id: (0, reified_1.decodeFromFields)(structs_1.UID.reified(), fields.id),
75
- size: (0, reified_1.decodeFromFields)("u64", fields.size),
70
+ id: decodeFromFields(UID.reified(), fields.id),
71
+ size: decodeFromFields("u64", fields.size),
76
72
  });
77
73
  }
78
74
  static fromFieldsWithTypes(typeArgs, item) {
79
75
  if (!isObjectTable(item.type)) {
80
76
  throw new Error("not a ObjectTable type");
81
77
  }
82
- (0, reified_1.assertFieldsWithTypesArgsMatch)(item, typeArgs);
78
+ assertFieldsWithTypesArgsMatch(item, typeArgs);
83
79
  return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
84
- id: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.UID.reified(), item.fields.id),
85
- size: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.size),
80
+ id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
81
+ size: decodeFromFieldsWithTypes("u64", item.fields.size),
86
82
  });
87
83
  }
88
84
  static fromBcs(typeArgs, data) {
@@ -99,15 +95,15 @@ class ObjectTable {
99
95
  }
100
96
  static fromJSONField(typeArgs, field) {
101
97
  return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
102
- id: (0, reified_1.decodeFromJSONField)(structs_1.UID.reified(), field.id),
103
- size: (0, reified_1.decodeFromJSONField)("u64", field.size),
98
+ id: decodeFromJSONField(UID.reified(), field.id),
99
+ size: decodeFromJSONField("u64", field.size),
104
100
  });
105
101
  }
106
102
  static fromJSON(typeArgs, json) {
107
103
  if (json.$typeName !== ObjectTable.$typeName) {
108
104
  throw new Error("not a WithTwoGenerics json object");
109
105
  }
110
- (0, reified_1.assertReifiedTypeArgsMatch)((0, util_1.composeSuiType)(ObjectTable.$typeName, ...typeArgs.map(reified_1.extractType)), json.$typeArgs, typeArgs);
106
+ assertReifiedTypeArgsMatch(composeSuiType(ObjectTable.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
111
107
  return ObjectTable.fromJSONField(typeArgs, json);
112
108
  }
113
109
  static fromSuiParsedData(typeArgs, content) {
@@ -124,18 +120,18 @@ class ObjectTable {
124
120
  if (data.bcs.dataType !== "moveObject" || !isObjectTable(data.bcs.type)) {
125
121
  throw new Error(`object at is not a ObjectTable object`);
126
122
  }
127
- const gotTypeArgs = (0, util_1.parseTypeName)(data.bcs.type).typeArgs;
123
+ const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
128
124
  if (gotTypeArgs.length !== 2) {
129
125
  throw new Error(`type argument mismatch: expected 2 type arguments but got ${gotTypeArgs.length}`);
130
126
  }
131
127
  for (let i = 0; i < 2; i++) {
132
- const gotTypeArg = (0, util_1.compressSuiType)(gotTypeArgs[i]);
133
- const expectedTypeArg = (0, util_1.compressSuiType)((0, reified_1.extractType)(typeArgs[i]));
128
+ const gotTypeArg = compressSuiType(gotTypeArgs[i]);
129
+ const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
134
130
  if (gotTypeArg !== expectedTypeArg) {
135
131
  throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
136
132
  }
137
133
  }
138
- return ObjectTable.fromBcs(typeArgs, (0, utils_1.fromB64)(data.bcs.bcsBytes));
134
+ return ObjectTable.fromBcs(typeArgs, fromBase64(data.bcs.bcsBytes));
139
135
  }
140
136
  if (data.content) {
141
137
  return ObjectTable.fromSuiParsedData(typeArgs, data.content);
@@ -157,7 +153,6 @@ class ObjectTable {
157
153
  });
158
154
  }
159
155
  }
160
- exports.ObjectTable = ObjectTable;
161
- ObjectTable.$typeName = `${index_1.PKG_V30}::object_table::ObjectTable`;
156
+ ObjectTable.$typeName = `${PKG_V30}::object_table::ObjectTable`;
162
157
  ObjectTable.$numTypeParams = 2;
163
158
  ObjectTable.$isPhantom = [true, true];
@@ -1,7 +1,7 @@
1
1
  import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
2
  import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { PKG_V1 } from "../index";
4
- import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
4
+ import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
5
5
  export declare function isI64(type: string): boolean;
6
6
  export interface I64Fields {
7
7
  negative: ToField<"bool">;
@@ -24,9 +24,9 @@ export declare class I64 implements StructClass {
24
24
  static get r(): import("../../../../_framework/reified").StructClassReified<I64, I64Fields>;
25
25
  static phantom(): PhantomReified<ToTypeStr<I64>>;
26
26
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::i64::I64">;
27
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
28
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
29
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
27
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
28
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
29
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
30
30
  }, string>;
31
31
  static fromFields(fields: Record<string, any>): I64;
32
32
  static fromFieldsWithTypes(item: FieldsWithTypes): I64;
@@ -45,5 +45,5 @@ export declare class I64 implements StructClass {
45
45
  static fromJSON(json: Record<string, any>): I64;
46
46
  static fromSuiParsedData(content: SuiParsedData): I64;
47
47
  static fromSuiObjectData(data: SuiObjectData): I64;
48
- static fetch(client: SuiClient, id: string): Promise<I64>;
48
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<I64>;
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,25 +7,22 @@ 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.I64 = void 0;
13
- exports.isI64 = isI64;
14
- const reified_1 = require("../../../../_framework/reified");
15
- const util_1 = require("../../../../_framework/util");
16
- const index_1 = require("../index");
17
- const bcs_1 = require("@mysten/sui/bcs");
18
- const utils_1 = require("@mysten/sui/utils");
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
+ import { PKG_V1 } from "../index";
13
+ import { bcs } from "@mysten/sui/bcs";
14
+ import { fromBase64 } from "@mysten/sui/utils";
19
15
  /* ============================== I64 =============================== */
20
- function isI64(type) {
21
- type = (0, util_1.compressSuiType)(type);
22
- return type === `${index_1.PKG_V1}::i64::I64`;
16
+ export function isI64(type) {
17
+ type = compressSuiType(type);
18
+ return type === `${PKG_V1}::i64::I64`;
23
19
  }
24
- class I64 {
20
+ export class I64 {
25
21
  constructor(typeArgs, fields) {
26
22
  this.__StructClass = true;
27
23
  this.$typeName = I64.$typeName;
28
24
  this.$isPhantom = I64.$isPhantom;
29
- this.$fullTypeName = (0, util_1.composeSuiType)(I64.$typeName, ...typeArgs);
25
+ this.$fullTypeName = composeSuiType(I64.$typeName, ...typeArgs);
30
26
  this.$typeArgs = typeArgs;
31
27
  this.negative = fields.negative;
32
28
  this.magnitude = fields.magnitude;
@@ -34,7 +30,7 @@ class I64 {
34
30
  static reified() {
35
31
  return {
36
32
  typeName: I64.$typeName,
37
- fullTypeName: (0, util_1.composeSuiType)(I64.$typeName, ...[]),
33
+ fullTypeName: composeSuiType(I64.$typeName, ...[]),
38
34
  typeArgs: [],
39
35
  isPhantom: I64.$isPhantom,
40
36
  reifiedTypeArgs: [],
@@ -57,21 +53,21 @@ class I64 {
57
53
  return I64.reified();
58
54
  }
59
55
  static phantom() {
60
- return (0, reified_1.phantom)(I64.reified());
56
+ return phantom(I64.reified());
61
57
  }
62
58
  static get p() {
63
59
  return I64.phantom();
64
60
  }
65
61
  static get bcs() {
66
- return bcs_1.bcs.struct("I64", {
67
- negative: bcs_1.bcs.bool(),
68
- magnitude: bcs_1.bcs.u64(),
62
+ return bcs.struct("I64", {
63
+ negative: bcs.bool(),
64
+ magnitude: bcs.u64(),
69
65
  });
70
66
  }
71
67
  static fromFields(fields) {
72
68
  return I64.reified().new({
73
- negative: (0, reified_1.decodeFromFields)("bool", fields.negative),
74
- magnitude: (0, reified_1.decodeFromFields)("u64", fields.magnitude),
69
+ negative: decodeFromFields("bool", fields.negative),
70
+ magnitude: decodeFromFields("u64", fields.magnitude),
75
71
  });
76
72
  }
77
73
  static fromFieldsWithTypes(item) {
@@ -79,8 +75,8 @@ class I64 {
79
75
  throw new Error("not a I64 type");
80
76
  }
81
77
  return I64.reified().new({
82
- negative: (0, reified_1.decodeFromFieldsWithTypes)("bool", item.fields.negative),
83
- magnitude: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.magnitude),
78
+ negative: decodeFromFieldsWithTypes("bool", item.fields.negative),
79
+ magnitude: decodeFromFieldsWithTypes("u64", item.fields.magnitude),
84
80
  });
85
81
  }
86
82
  static fromBcs(data) {
@@ -97,8 +93,8 @@ class I64 {
97
93
  }
98
94
  static fromJSONField(field) {
99
95
  return I64.reified().new({
100
- negative: (0, reified_1.decodeFromJSONField)("bool", field.negative),
101
- magnitude: (0, reified_1.decodeFromJSONField)("u64", field.magnitude),
96
+ negative: decodeFromJSONField("bool", field.negative),
97
+ magnitude: decodeFromJSONField("u64", field.magnitude),
102
98
  });
103
99
  }
104
100
  static fromJSON(json) {
@@ -121,7 +117,7 @@ class I64 {
121
117
  if (data.bcs.dataType !== "moveObject" || !isI64(data.bcs.type)) {
122
118
  throw new Error(`object at is not a I64 object`);
123
119
  }
124
- return I64.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
120
+ return I64.fromBcs(fromBase64(data.bcs.bcsBytes));
125
121
  }
126
122
  if (data.content) {
127
123
  return I64.fromSuiParsedData(data.content);
@@ -142,7 +138,6 @@ class I64 {
142
138
  });
143
139
  }
144
140
  }
145
- exports.I64 = I64;
146
- I64.$typeName = `${index_1.PKG_V1}::i64::I64`;
141
+ I64.$typeName = `${PKG_V1}::i64::I64`;
147
142
  I64.$numTypeParams = 0;
148
143
  I64.$isPhantom = [];
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PKG_V1 = exports.PKG_V2 = exports.PUBLISHED_AT = exports.PACKAGE_ID = void 0;
4
- exports.PACKAGE_ID = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
5
- exports.PUBLISHED_AT = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
6
- exports.PKG_V2 = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
7
- exports.PKG_V1 = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
1
+ export const PACKAGE_ID = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
2
+ export const PUBLISHED_AT = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
3
+ export const PKG_V2 = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
4
+ export const PKG_V1 = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
2
2
  import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { I64 } from "../i64/structs";
4
4
  import { PKG_V1 } 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 isPrice(type: string): boolean;
7
7
  export interface PriceFields {
8
8
  price: ToField<I64>;
@@ -29,17 +29,17 @@ export declare class Price implements StructClass {
29
29
  static get r(): import("../../../../_framework/reified").StructClassReified<Price, PriceFields>;
30
30
  static phantom(): PhantomReified<ToTypeStr<Price>>;
31
31
  static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price::Price">;
32
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
33
- price: import("@mysten/sui/bcs").BcsStruct<{
34
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
35
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
32
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
33
+ price: import("@mysten/bcs").BcsStruct<{
34
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
35
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
36
36
  }, string>;
37
- conf: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
38
- expo: import("@mysten/sui/bcs").BcsStruct<{
39
- negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
40
- magnitude: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
37
+ conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
38
+ expo: import("@mysten/bcs").BcsStruct<{
39
+ negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
40
+ magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
41
41
  }, string>;
42
- timestamp: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
42
+ timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
43
43
  }, string>;
44
44
  static fromFields(fields: Record<string, any>): Price;
45
45
  static fromFieldsWithTypes(item: FieldsWithTypes): Price;
@@ -74,5 +74,5 @@ export declare class Price implements StructClass {
74
74
  static fromJSON(json: Record<string, any>): Price;
75
75
  static fromSuiParsedData(content: SuiParsedData): Price;
76
76
  static fromSuiObjectData(data: SuiObjectData): Price;
77
- static fetch(client: SuiClient, id: string): Promise<Price>;
77
+ static fetch(client: SuiJsonRpcClient, id: string): Promise<Price>;
78
78
  }