@suilend/sdk 2.0.4 → 3.0.1

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 (73) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -11
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +6 -63
  3. package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -9
  4. package/_generated/_dependencies/source/0x1/option/structs.js +4 -42
  5. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -7
  6. package/_generated/_dependencies/source/0x1/type-name/structs.js +3 -32
  7. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -9
  8. package/_generated/_dependencies/source/0x2/bag/structs.js +3 -31
  9. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -11
  10. package/_generated/_dependencies/source/0x2/balance/structs.js +7 -82
  11. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -12
  12. package/_generated/_dependencies/source/0x2/object/structs.js +7 -61
  13. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -9
  14. package/_generated/_dependencies/source/0x2/object-table/structs.js +4 -44
  15. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -7
  16. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +3 -31
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -13
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +3 -32
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -25
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +3 -32
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -6
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +3 -33
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -59
  24. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +6 -64
  25. package/_generated/_framework/reified.d.ts +2 -4
  26. package/_generated/_framework/vector.d.ts +2 -12
  27. package/_generated/suilend/cell/structs.d.ts +4 -10
  28. package/_generated/suilend/cell/structs.js +4 -42
  29. package/_generated/suilend/decimal/structs.d.ts +4 -6
  30. package/_generated/suilend/decimal/structs.js +3 -32
  31. package/_generated/suilend/lending-market/structs.d.ts +152 -392
  32. package/_generated/suilend/lending-market/structs.js +50 -548
  33. package/_generated/suilend/liquidity-mining/structs.d.ts +50 -158
  34. package/_generated/suilend/liquidity-mining/structs.js +16 -169
  35. package/_generated/suilend/obligation/structs.d.ts +108 -148
  36. package/_generated/suilend/obligation/structs.js +23 -232
  37. package/_generated/suilend/rate-limiter/structs.d.ts +15 -19
  38. package/_generated/suilend/rate-limiter/structs.js +6 -64
  39. package/_generated/suilend/reserve/structs.d.ts +138 -362
  40. package/_generated/suilend/reserve/structs.js +29 -327
  41. package/_generated/suilend/reserve-config/structs.d.ts +33 -37
  42. package/_generated/suilend/reserve-config/structs.js +6 -65
  43. package/client.d.ts +8 -8
  44. package/client.js +55 -88
  45. package/lib/initialize.d.ts +29 -28
  46. package/lib/initialize.js +16 -12
  47. package/lib/liquidityMining.d.ts +3 -3
  48. package/lib/pythAdapter.d.ts +9 -0
  49. package/lib/pythAdapter.js +121 -0
  50. package/lib/strategyOwnerCap.d.ts +12 -7
  51. package/lib/strategyOwnerCap.js +159 -156
  52. package/margin/margin/admin_cap.d.ts +2 -2
  53. package/margin/margin/deps/std/type_name.d.ts +1 -1
  54. package/margin/margin/deps/sui/vec_set.d.ts +3 -5
  55. package/margin/margin/deps/suilend/lending_market.d.ts +2 -2
  56. package/margin/margin/market.d.ts +21 -38
  57. package/margin/margin/position.d.ts +47 -47
  58. package/margin/margin/router.d.ts +5 -5
  59. package/margin/margin/version.d.ts +1 -1
  60. package/package.json +1 -1
  61. package/parsers/lendingMarket.d.ts +6 -6
  62. package/parsers/obligation.d.ts +8 -8
  63. package/parsers/reserve.d.ts +8 -8
  64. package/strategies.d.ts +38 -21
  65. package/strategies.js +239 -79
  66. package/swap/quote.d.ts +1 -9
  67. package/swap/quote.js +1 -52
  68. package/swap/transaction.d.ts +2 -4
  69. package/swap/transaction.js +9 -25
  70. package/utils/events.d.ts +6 -5
  71. package/utils/events.js +11 -8
  72. package/utils/obligation.d.ts +6 -5
  73. package/utils/obligation.js +118 -117
@@ -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 { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
6
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
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/bcs").BcsStruct<{
28
- byte: import("@mysten/bcs").BcsType<number, number, "u8">;
27
+ static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
28
+ byte: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
29
29
  }, string>;
30
30
  static fromFields(fields: Record<string, any>): Char;
31
31
  static fromFieldsWithTypes(item: FieldsWithTypes): Char;
@@ -40,9 +40,7 @@ export declare class Char implements StructClass {
40
40
  };
41
41
  static fromJSONField(field: any): Char;
42
42
  static fromJSON(json: Record<string, any>): Char;
43
- static fromSuiParsedData(content: SuiParsedData): Char;
44
- static fromSuiObjectData(data: SuiObjectData): Char;
45
- static fetch(client: SuiJsonRpcClient, id: string): Promise<Char>;
43
+ static fetch(client: SuiGrpcClient, id: string): Promise<Char>;
46
44
  }
47
45
  export declare function isString(type: string): boolean;
48
46
  export interface StringFields {
@@ -64,8 +62,8 @@ export declare class String implements StructClass {
64
62
  static get r(): reified.StructClassReified<String, StringFields>;
65
63
  static phantom(): PhantomReified<ToTypeStr<String>>;
66
64
  static get p(): reified.PhantomReified<"0x1::ascii::String">;
67
- static get bcs(): import("@mysten/bcs").BcsStruct<{
68
- bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
65
+ static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
66
+ bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
69
67
  length: number;
70
68
  }, string>;
71
69
  }, string>;
@@ -82,7 +80,5 @@ export declare class String implements StructClass {
82
80
  };
83
81
  static fromJSONField(field: any): String;
84
82
  static fromJSON(json: Record<string, any>): String;
85
- static fromSuiParsedData(content: SuiParsedData): String;
86
- static fromSuiObjectData(data: SuiObjectData): String;
87
- static fetch(client: SuiJsonRpcClient, id: string): Promise<String>;
83
+ static fetch(client: SuiGrpcClient, id: string): Promise<String>;
88
84
  }
@@ -12,7 +12,6 @@ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, field
12
12
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
13
13
  import { PKG_V13 } from "../index";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
- import { fromBase64 } from "@mysten/sui/utils";
16
15
  /* ============================== Char =============================== */
17
16
  export function isChar(type) {
18
17
  type = compressSuiType(type);
@@ -40,8 +39,6 @@ export class Char {
40
39
  bcs: Char.bcs,
41
40
  fromJSONField: (field) => Char.fromJSONField(field),
42
41
  fromJSON: (json) => Char.fromJSON(json),
43
- fromSuiParsedData: (content) => Char.fromSuiParsedData(content),
44
- fromSuiObjectData: (content) => Char.fromSuiObjectData(content),
45
42
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Char.fetch(client, id); }),
46
43
  new: (fields) => {
47
44
  return new Char([], fields);
@@ -94,39 +91,13 @@ export class Char {
94
91
  }
95
92
  return Char.fromJSONField(json);
96
93
  }
97
- static fromSuiParsedData(content) {
98
- if (content.dataType !== "moveObject") {
99
- throw new Error("not an object");
100
- }
101
- if (!isChar(content.type)) {
102
- throw new Error(`object at ${content.fields.id} is not a Char object`);
103
- }
104
- return Char.fromFieldsWithTypes(content);
105
- }
106
- static fromSuiObjectData(data) {
107
- if (data.bcs) {
108
- if (data.bcs.dataType !== "moveObject" || !isChar(data.bcs.type)) {
109
- throw new Error(`object at is not a Char object`);
110
- }
111
- return Char.fromBcs(fromBase64(data.bcs.bcsBytes));
112
- }
113
- if (data.content) {
114
- return Char.fromSuiParsedData(data.content);
115
- }
116
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
117
- }
118
94
  static fetch(client, id) {
119
95
  return __awaiter(this, void 0, void 0, function* () {
120
- var _a, _b;
121
- const res = yield client.getObject({ id, options: { showBcs: true } });
122
- if (res.error) {
123
- throw new Error(`error fetching Char object at id ${id}: ${res.error.code}`);
124
- }
125
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
126
- !isChar(res.data.bcs.type)) {
96
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
97
+ if (!isChar(object.type)) {
127
98
  throw new Error(`object at id ${id} is not a Char object`);
128
99
  }
129
- return Char.fromSuiObjectData(res.data);
100
+ return Char.fromBcs(object.content);
130
101
  });
131
102
  }
132
103
  }
@@ -160,8 +131,6 @@ export class String {
160
131
  bcs: String.bcs,
161
132
  fromJSONField: (field) => String.fromJSONField(field),
162
133
  fromJSON: (json) => String.fromJSON(json),
163
- fromSuiParsedData: (content) => String.fromSuiParsedData(content),
164
- fromSuiObjectData: (content) => String.fromSuiObjectData(content),
165
134
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return String.fetch(client, id); }),
166
135
  new: (fields) => {
167
136
  return new String([], fields);
@@ -218,39 +187,13 @@ export class String {
218
187
  }
219
188
  return String.fromJSONField(json);
220
189
  }
221
- static fromSuiParsedData(content) {
222
- if (content.dataType !== "moveObject") {
223
- throw new Error("not an object");
224
- }
225
- if (!isString(content.type)) {
226
- throw new Error(`object at ${content.fields.id} is not a String object`);
227
- }
228
- return String.fromFieldsWithTypes(content);
229
- }
230
- static fromSuiObjectData(data) {
231
- if (data.bcs) {
232
- if (data.bcs.dataType !== "moveObject" || !isString(data.bcs.type)) {
233
- throw new Error(`object at is not a String object`);
234
- }
235
- return String.fromBcs(fromBase64(data.bcs.bcsBytes));
236
- }
237
- if (data.content) {
238
- return String.fromSuiParsedData(data.content);
239
- }
240
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
241
- }
242
190
  static fetch(client, id) {
243
191
  return __awaiter(this, void 0, void 0, function* () {
244
- var _a, _b;
245
- const res = yield client.getObject({ id, options: { showBcs: true } });
246
- if (res.error) {
247
- throw new Error(`error fetching String object at id ${id}: ${res.error.code}`);
248
- }
249
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
250
- !isString(res.data.bcs.type)) {
192
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
193
+ if (!isString(object.type)) {
251
194
  throw new Error(`object at id ${id} is not a String object`);
252
195
  }
253
- return String.fromSuiObjectData(res.data);
196
+ return String.fromBcs(object.content);
254
197
  });
255
198
  }
256
199
  }
@@ -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 { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
7
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
8
8
  export declare function isOption(type: string): boolean;
9
9
  export interface OptionFields<Element extends TypeArgument> {
10
10
  vec: ToField<Vector<Element>>;
@@ -26,11 +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/bcs").BcsStruct<{
30
- vec: BcsType<import("@mysten/bcs").InferBcsType<Element>[], Iterable<import("@mysten/bcs").InferBcsInput<Element>> & {
31
- length: number;
32
- }, string>;
33
- }, string>;
29
+ static get bcs(): <Element extends BcsType<any>>(Element: Element) => BcsType<any>;
34
30
  static fromFields<Element extends Reified<TypeArgument, any>>(typeArg: Element, fields: Record<string, any>): Option<ToTypeArgument<Element>>;
35
31
  static fromFieldsWithTypes<Element extends Reified<TypeArgument, any>>(typeArg: Element, item: FieldsWithTypes): Option<ToTypeArgument<Element>>;
36
32
  static fromBcs<Element extends Reified<TypeArgument, any>>(typeArg: Element, data: Uint8Array): Option<ToTypeArgument<Element>>;
@@ -44,7 +40,5 @@ export declare class Option<Element extends TypeArgument> implements StructClass
44
40
  };
45
41
  static fromJSONField<Element extends Reified<TypeArgument, any>>(typeArg: Element, field: any): Option<ToTypeArgument<Element>>;
46
42
  static fromJSON<Element extends Reified<TypeArgument, any>>(typeArg: Element, json: Record<string, any>): Option<ToTypeArgument<Element>>;
47
- static fromSuiParsedData<Element extends Reified<TypeArgument, any>>(typeArg: Element, content: SuiParsedData): Option<ToTypeArgument<Element>>;
48
- static fromSuiObjectData<Element extends Reified<TypeArgument, any>>(typeArg: Element, data: SuiObjectData): Option<ToTypeArgument<Element>>;
49
- static fetch<Element extends Reified<TypeArgument, any>>(client: SuiJsonRpcClient, typeArg: Element, id: string): Promise<Option<ToTypeArgument<Element>>>;
43
+ static fetch<Element extends Reified<TypeArgument, any>>(client: SuiGrpcClient, typeArg: Element, id: string): Promise<Option<ToTypeArgument<Element>>>;
50
44
  }
@@ -9,10 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import * as reified from "../../../../_framework/reified";
11
11
  import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../../../_framework/reified";
12
- import { composeSuiType, compressSuiType, parseTypeName, } from "../../../../_framework/util";
12
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
13
13
  import { PKG_V13 } from "../index";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
- import { fromBase64 } from "@mysten/sui/utils";
16
15
  /* ============================== Option =============================== */
17
16
  export function isOption(type) {
18
17
  type = compressSuiType(type);
@@ -41,8 +40,6 @@ export class Option {
41
40
  bcs: Option.bcs(toBcs(Element)),
42
41
  fromJSONField: (field) => Option.fromJSONField(Element, field),
43
42
  fromJSON: (json) => Option.fromJSON(Element, json),
44
- fromSuiParsedData: (content) => Option.fromSuiParsedData(Element, content),
45
- fromSuiObjectData: (content) => Option.fromSuiObjectData(Element, content),
46
43
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Option.fetch(client, Element, id); }),
47
44
  new: (fields) => {
48
45
  return new Option([extractType(Element)], fields);
@@ -102,48 +99,13 @@ export class Option {
102
99
  assertReifiedTypeArgsMatch(composeSuiType(Option.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
103
100
  return Option.fromJSONField(typeArg, json);
104
101
  }
105
- static fromSuiParsedData(typeArg, content) {
106
- if (content.dataType !== "moveObject") {
107
- throw new Error("not an object");
108
- }
109
- if (!isOption(content.type)) {
110
- throw new Error(`object at ${content.fields.id} is not a Option object`);
111
- }
112
- return Option.fromFieldsWithTypes(typeArg, content);
113
- }
114
- static fromSuiObjectData(typeArg, data) {
115
- if (data.bcs) {
116
- if (data.bcs.dataType !== "moveObject" || !isOption(data.bcs.type)) {
117
- throw new Error(`object at is not a Option object`);
118
- }
119
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
120
- if (gotTypeArgs.length !== 1) {
121
- throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
122
- }
123
- const gotTypeArg = compressSuiType(gotTypeArgs[0]);
124
- const expectedTypeArg = compressSuiType(extractType(typeArg));
125
- if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
126
- throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
127
- }
128
- return Option.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
129
- }
130
- if (data.content) {
131
- return Option.fromSuiParsedData(typeArg, data.content);
132
- }
133
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
134
- }
135
102
  static fetch(client, typeArg, id) {
136
103
  return __awaiter(this, void 0, void 0, function* () {
137
- var _a, _b;
138
- const res = yield client.getObject({ id, options: { showBcs: true } });
139
- if (res.error) {
140
- throw new Error(`error fetching Option object at id ${id}: ${res.error.code}`);
141
- }
142
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
143
- !isOption(res.data.bcs.type)) {
104
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
105
+ if (!isOption(object.type)) {
144
106
  throw new Error(`object at id ${id} is not a Option object`);
145
107
  }
146
- return Option.fromSuiObjectData(typeArg, res.data);
108
+ return Option.fromBcs(typeArg, object.content);
147
109
  });
148
110
  }
149
111
  }
@@ -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 { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
5
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
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/bcs").BcsStruct<{
27
- name: import("@mysten/bcs").BcsStruct<{
28
- bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
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> & {
29
29
  length: number;
30
30
  }, string>;
31
31
  }, string>;
@@ -43,7 +43,5 @@ export declare class TypeName implements StructClass {
43
43
  };
44
44
  static fromJSONField(field: any): TypeName;
45
45
  static fromJSON(json: Record<string, any>): TypeName;
46
- static fromSuiParsedData(content: SuiParsedData): TypeName;
47
- static fromSuiObjectData(data: SuiObjectData): TypeName;
48
- static fetch(client: SuiJsonRpcClient, id: string): Promise<TypeName>;
46
+ static fetch(client: SuiGrpcClient, id: string): Promise<TypeName>;
49
47
  }
@@ -12,7 +12,6 @@ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
12
  import { String } from "../ascii/structs";
13
13
  import { PKG_V13 } from "../index";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
- import { fromBase64 } from "@mysten/sui/utils";
16
15
  /* ============================== TypeName =============================== */
17
16
  export function isTypeName(type) {
18
17
  type = compressSuiType(type);
@@ -40,8 +39,6 @@ export class TypeName {
40
39
  bcs: TypeName.bcs,
41
40
  fromJSONField: (field) => TypeName.fromJSONField(field),
42
41
  fromJSON: (json) => TypeName.fromJSON(json),
43
- fromSuiParsedData: (content) => TypeName.fromSuiParsedData(content),
44
- fromSuiObjectData: (content) => TypeName.fromSuiObjectData(content),
45
42
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return TypeName.fetch(client, id); }),
46
43
  new: (fields) => {
47
44
  return new TypeName([], fields);
@@ -98,39 +95,13 @@ export class TypeName {
98
95
  }
99
96
  return TypeName.fromJSONField(json);
100
97
  }
101
- static fromSuiParsedData(content) {
102
- if (content.dataType !== "moveObject") {
103
- throw new Error("not an object");
104
- }
105
- if (!isTypeName(content.type)) {
106
- throw new Error(`object at ${content.fields.id} is not a TypeName object`);
107
- }
108
- return TypeName.fromFieldsWithTypes(content);
109
- }
110
- static fromSuiObjectData(data) {
111
- if (data.bcs) {
112
- if (data.bcs.dataType !== "moveObject" || !isTypeName(data.bcs.type)) {
113
- throw new Error(`object at is not a TypeName object`);
114
- }
115
- return TypeName.fromBcs(fromBase64(data.bcs.bcsBytes));
116
- }
117
- if (data.content) {
118
- return TypeName.fromSuiParsedData(data.content);
119
- }
120
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
121
- }
122
98
  static fetch(client, id) {
123
99
  return __awaiter(this, void 0, void 0, function* () {
124
- var _a, _b;
125
- const res = yield client.getObject({ id, options: { showBcs: true } });
126
- if (res.error) {
127
- throw new Error(`error fetching TypeName object at id ${id}: ${res.error.code}`);
128
- }
129
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
130
- !isTypeName(res.data.bcs.type)) {
100
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
101
+ if (!isTypeName(object.type)) {
131
102
  throw new Error(`object at id ${id} is not a TypeName object`);
132
103
  }
133
- return TypeName.fromSuiObjectData(res.data);
104
+ return TypeName.fromBcs(object.content);
134
105
  });
135
106
  }
136
107
  }
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
2
2
  import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { PKG_V30 } from "../index";
4
4
  import { UID } from "../object/structs";
5
- import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
5
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
6
6
  export declare function isBag(type: string): boolean;
7
7
  export interface BagFields {
8
8
  id: ToField<UID>;
@@ -25,13 +25,13 @@ export declare class Bag implements StructClass {
25
25
  static get r(): import("../../../../_framework/reified").StructClassReified<Bag, BagFields>;
26
26
  static phantom(): PhantomReified<ToTypeStr<Bag>>;
27
27
  static get p(): PhantomReified<"0x2::bag::Bag">;
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>;
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>;
32
32
  }, string>;
33
33
  }, string>;
34
- size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
34
+ size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
35
35
  }, string>;
36
36
  static fromFields(fields: Record<string, any>): Bag;
37
37
  static fromFieldsWithTypes(item: FieldsWithTypes): Bag;
@@ -48,7 +48,5 @@ export declare class Bag implements StructClass {
48
48
  };
49
49
  static fromJSONField(field: any): Bag;
50
50
  static fromJSON(json: Record<string, any>): Bag;
51
- static fromSuiParsedData(content: SuiParsedData): Bag;
52
- static fromSuiObjectData(data: SuiObjectData): Bag;
53
- static fetch(client: SuiJsonRpcClient, id: string): Promise<Bag>;
51
+ static fetch(client: SuiGrpcClient, id: string): Promise<Bag>;
54
52
  }
@@ -12,7 +12,6 @@ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
12
  import { PKG_V30 } from "../index";
13
13
  import { UID } from "../object/structs";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
- import { fromBase64 } from "@mysten/sui/utils";
16
15
  /* ============================== Bag =============================== */
17
16
  export function isBag(type) {
18
17
  type = compressSuiType(type);
@@ -41,8 +40,6 @@ export class Bag {
41
40
  bcs: Bag.bcs,
42
41
  fromJSONField: (field) => Bag.fromJSONField(field),
43
42
  fromJSON: (json) => Bag.fromJSON(json),
44
- fromSuiParsedData: (content) => Bag.fromSuiParsedData(content),
45
- fromSuiObjectData: (content) => Bag.fromSuiObjectData(content),
46
43
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Bag.fetch(client, id); }),
47
44
  new: (fields) => {
48
45
  return new Bag([], fields);
@@ -104,38 +101,13 @@ export class Bag {
104
101
  }
105
102
  return Bag.fromJSONField(json);
106
103
  }
107
- static fromSuiParsedData(content) {
108
- if (content.dataType !== "moveObject") {
109
- throw new Error("not an object");
110
- }
111
- if (!isBag(content.type)) {
112
- throw new Error(`object at ${content.fields.id} is not a Bag object`);
113
- }
114
- return Bag.fromFieldsWithTypes(content);
115
- }
116
- static fromSuiObjectData(data) {
117
- if (data.bcs) {
118
- if (data.bcs.dataType !== "moveObject" || !isBag(data.bcs.type)) {
119
- throw new Error(`object at is not a Bag object`);
120
- }
121
- return Bag.fromBcs(fromBase64(data.bcs.bcsBytes));
122
- }
123
- if (data.content) {
124
- return Bag.fromSuiParsedData(data.content);
125
- }
126
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
127
- }
128
104
  static fetch(client, id) {
129
105
  return __awaiter(this, void 0, void 0, function* () {
130
- var _a, _b;
131
- const res = yield client.getObject({ id, options: { showBcs: true } });
132
- if (res.error) {
133
- throw new Error(`error fetching Bag object at id ${id}: ${res.error.code}`);
134
- }
135
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" || !isBag(res.data.bcs.type)) {
106
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
107
+ if (!isBag(object.type)) {
136
108
  throw new Error(`object at id ${id} is not a Bag object`);
137
109
  }
138
- return Bag.fromSuiObjectData(res.data);
110
+ return Bag.fromBcs(object.content);
139
111
  });
140
112
  }
141
113
  }
@@ -1,7 +1,7 @@
1
1
  import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr } from "../../../../_framework/reified";
2
2
  import { FieldsWithTypes } from "../../../../_framework/util";
3
3
  import { PKG_V30 } from "../index";
4
- import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
4
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
5
5
  export declare function isBalance(type: string): boolean;
6
6
  export interface BalanceFields<T extends PhantomTypeArgument> {
7
7
  value: ToField<"u64">;
@@ -22,8 +22,8 @@ export declare class Balance<T extends PhantomTypeArgument> implements StructCla
22
22
  static get r(): typeof Balance.reified;
23
23
  static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Balance<ToPhantomTypeArgument<T>>>>;
24
24
  static get p(): typeof Balance.phantom;
25
- static get bcs(): import("@mysten/bcs").BcsStruct<{
26
- value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
25
+ static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
26
+ value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
27
27
  }, string>;
28
28
  static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Balance<ToPhantomTypeArgument<T>>;
29
29
  static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Balance<ToPhantomTypeArgument<T>>;
@@ -38,9 +38,7 @@ export declare class Balance<T extends PhantomTypeArgument> implements StructCla
38
38
  };
39
39
  static fromJSONField<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, field: any): Balance<ToPhantomTypeArgument<T>>;
40
40
  static fromJSON<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, json: Record<string, any>): Balance<ToPhantomTypeArgument<T>>;
41
- static fromSuiParsedData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, content: SuiParsedData): Balance<ToPhantomTypeArgument<T>>;
42
- static fromSuiObjectData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: SuiObjectData): Balance<ToPhantomTypeArgument<T>>;
43
- static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiJsonRpcClient, typeArg: T, id: string): Promise<Balance<ToPhantomTypeArgument<T>>>;
41
+ static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiGrpcClient, typeArg: T, id: string): Promise<Balance<ToPhantomTypeArgument<T>>>;
44
42
  }
45
43
  export declare function isSupply(type: string): boolean;
46
44
  export interface SupplyFields<T extends PhantomTypeArgument> {
@@ -62,8 +60,8 @@ export declare class Supply<T extends PhantomTypeArgument> implements StructClas
62
60
  static get r(): typeof Supply.reified;
63
61
  static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Supply<ToPhantomTypeArgument<T>>>>;
64
62
  static get p(): typeof Supply.phantom;
65
- static get bcs(): import("@mysten/bcs").BcsStruct<{
66
- value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
63
+ static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
64
+ value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
67
65
  }, string>;
68
66
  static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
69
67
  static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Supply<ToPhantomTypeArgument<T>>;
@@ -78,7 +76,5 @@ export declare class Supply<T extends PhantomTypeArgument> implements StructClas
78
76
  };
79
77
  static fromJSONField<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, field: any): Supply<ToPhantomTypeArgument<T>>;
80
78
  static fromJSON<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, json: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
81
- static fromSuiParsedData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, content: SuiParsedData): Supply<ToPhantomTypeArgument<T>>;
82
- static fromSuiObjectData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: SuiObjectData): Supply<ToPhantomTypeArgument<T>>;
83
- static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiJsonRpcClient, typeArg: T, id: string): Promise<Supply<ToPhantomTypeArgument<T>>>;
79
+ static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiGrpcClient, typeArg: T, id: string): Promise<Supply<ToPhantomTypeArgument<T>>>;
84
80
  }
@@ -8,10 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, parseTypeName, } from "../../../../_framework/util";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
12
  import { PKG_V30 } from "../index";
13
13
  import { bcs } from "@mysten/sui/bcs";
14
- import { fromBase64 } from "@mysten/sui/utils";
15
14
  /* ============================== Balance =============================== */
16
15
  export function isBalance(type) {
17
16
  type = compressSuiType(type);
@@ -39,8 +38,6 @@ export class Balance {
39
38
  bcs: Balance.bcs,
40
39
  fromJSONField: (field) => Balance.fromJSONField(T, field),
41
40
  fromJSON: (json) => Balance.fromJSON(T, json),
42
- fromSuiParsedData: (content) => Balance.fromSuiParsedData(T, content),
43
- fromSuiObjectData: (content) => Balance.fromSuiObjectData(T, content),
44
41
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Balance.fetch(client, T, id); }),
45
42
  new: (fields) => {
46
43
  return new Balance([extractType(T)], fields);
@@ -99,48 +96,13 @@ export class Balance {
99
96
  assertReifiedTypeArgsMatch(composeSuiType(Balance.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
100
97
  return Balance.fromJSONField(typeArg, json);
101
98
  }
102
- static fromSuiParsedData(typeArg, content) {
103
- if (content.dataType !== "moveObject") {
104
- throw new Error("not an object");
105
- }
106
- if (!isBalance(content.type)) {
107
- throw new Error(`object at ${content.fields.id} is not a Balance object`);
108
- }
109
- return Balance.fromFieldsWithTypes(typeArg, content);
110
- }
111
- static fromSuiObjectData(typeArg, data) {
112
- if (data.bcs) {
113
- if (data.bcs.dataType !== "moveObject" || !isBalance(data.bcs.type)) {
114
- throw new Error(`object at is not a Balance object`);
115
- }
116
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
117
- if (gotTypeArgs.length !== 1) {
118
- throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
119
- }
120
- const gotTypeArg = compressSuiType(gotTypeArgs[0]);
121
- const expectedTypeArg = compressSuiType(extractType(typeArg));
122
- if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
123
- throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
124
- }
125
- return Balance.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
126
- }
127
- if (data.content) {
128
- return Balance.fromSuiParsedData(typeArg, data.content);
129
- }
130
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
131
- }
132
99
  static fetch(client, typeArg, id) {
133
100
  return __awaiter(this, void 0, void 0, function* () {
134
- var _a, _b;
135
- const res = yield client.getObject({ id, options: { showBcs: true } });
136
- if (res.error) {
137
- throw new Error(`error fetching Balance object at id ${id}: ${res.error.code}`);
138
- }
139
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
140
- !isBalance(res.data.bcs.type)) {
101
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
102
+ if (!isBalance(object.type)) {
141
103
  throw new Error(`object at id ${id} is not a Balance object`);
142
104
  }
143
- return Balance.fromSuiObjectData(typeArg, res.data);
105
+ return Balance.fromBcs(typeArg, object.content);
144
106
  });
145
107
  }
146
108
  }
@@ -174,8 +136,6 @@ export class Supply {
174
136
  bcs: Supply.bcs,
175
137
  fromJSONField: (field) => Supply.fromJSONField(T, field),
176
138
  fromJSON: (json) => Supply.fromJSON(T, json),
177
- fromSuiParsedData: (content) => Supply.fromSuiParsedData(T, content),
178
- fromSuiObjectData: (content) => Supply.fromSuiObjectData(T, content),
179
139
  fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Supply.fetch(client, T, id); }),
180
140
  new: (fields) => {
181
141
  return new Supply([extractType(T)], fields);
@@ -234,48 +194,13 @@ export class Supply {
234
194
  assertReifiedTypeArgsMatch(composeSuiType(Supply.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
235
195
  return Supply.fromJSONField(typeArg, json);
236
196
  }
237
- static fromSuiParsedData(typeArg, content) {
238
- if (content.dataType !== "moveObject") {
239
- throw new Error("not an object");
240
- }
241
- if (!isSupply(content.type)) {
242
- throw new Error(`object at ${content.fields.id} is not a Supply object`);
243
- }
244
- return Supply.fromFieldsWithTypes(typeArg, content);
245
- }
246
- static fromSuiObjectData(typeArg, data) {
247
- if (data.bcs) {
248
- if (data.bcs.dataType !== "moveObject" || !isSupply(data.bcs.type)) {
249
- throw new Error(`object at is not a Supply object`);
250
- }
251
- const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
252
- if (gotTypeArgs.length !== 1) {
253
- throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
254
- }
255
- const gotTypeArg = compressSuiType(gotTypeArgs[0]);
256
- const expectedTypeArg = compressSuiType(extractType(typeArg));
257
- if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
258
- throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
259
- }
260
- return Supply.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
261
- }
262
- if (data.content) {
263
- return Supply.fromSuiParsedData(typeArg, data.content);
264
- }
265
- throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
266
- }
267
197
  static fetch(client, typeArg, id) {
268
198
  return __awaiter(this, void 0, void 0, function* () {
269
- var _a, _b;
270
- const res = yield client.getObject({ id, options: { showBcs: true } });
271
- if (res.error) {
272
- throw new Error(`error fetching Supply object at id ${id}: ${res.error.code}`);
273
- }
274
- if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
275
- !isSupply(res.data.bcs.type)) {
199
+ const { object } = yield client.getObject({ objectId: id, include: { content: true } });
200
+ if (!isSupply(object.type)) {
276
201
  throw new Error(`object at id ${id} is not a Supply object`);
277
202
  }
278
- return Supply.fromSuiObjectData(typeArg, res.data);
203
+ return Supply.fromBcs(typeArg, object.content);
279
204
  });
280
205
  }
281
206
  }