@suilend/sdk 3.0.8 → 5.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 (73) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +4 -4
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +42 -41
  3. package/_generated/_dependencies/source/0x1/option/structs.js +22 -26
  4. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +3 -3
  5. package/_generated/_dependencies/source/0x1/type-name/structs.js +21 -25
  6. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +5 -5
  7. package/_generated/_dependencies/source/0x2/bag/structs.js +22 -25
  8. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +4 -4
  9. package/_generated/_dependencies/source/0x2/balance/structs.js +42 -41
  10. package/_generated/_dependencies/source/0x2/object/structs.d.ts +5 -5
  11. package/_generated/_dependencies/source/0x2/object/structs.js +42 -41
  12. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +5 -5
  13. package/_generated/_dependencies/source/0x2/object-table/structs.js +22 -25
  14. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +3 -3
  15. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +22 -25
  16. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +9 -9
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +24 -25
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +21 -21
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +23 -25
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +2 -2
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -25
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +52 -52
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +45 -41
  24. package/_generated/_framework/vector.js +9 -6
  25. package/_generated/suilend/cell/structs.d.ts +1 -1
  26. package/_generated/suilend/cell/structs.js +21 -25
  27. package/_generated/suilend/decimal/structs.d.ts +2 -2
  28. package/_generated/suilend/decimal/structs.js +21 -25
  29. package/_generated/suilend/lending-market/structs.d.ts +129 -129
  30. package/_generated/suilend/lending-market/structs.js +391 -265
  31. package/_generated/suilend/liquidity-mining/structs.d.ts +44 -44
  32. package/_generated/suilend/liquidity-mining/structs.js +122 -89
  33. package/_generated/suilend/obligation/structs.d.ts +98 -98
  34. package/_generated/suilend/obligation/structs.js +194 -121
  35. package/_generated/suilend/rate-limiter/structs.d.ts +12 -12
  36. package/_generated/suilend/rate-limiter/structs.js +46 -41
  37. package/_generated/suilend/reserve/structs.d.ts +128 -128
  38. package/_generated/suilend/reserve/structs.js +243 -153
  39. package/_generated/suilend/reserve-config/structs.d.ts +30 -30
  40. package/_generated/suilend/reserve-config/structs.js +60 -41
  41. package/api/events.js +5 -14
  42. package/client.js +267 -319
  43. package/lib/initialize.d.ts +85 -3
  44. package/lib/initialize.js +119 -52
  45. package/lib/liquidityMining.js +15 -19
  46. package/lib/pyth.d.ts +16 -0
  47. package/lib/pyth.js +30 -15
  48. package/lib/pythAdapter.js +96 -112
  49. package/lib/strategyOwnerCap.js +8 -17
  50. package/margin/margin/admin_cap.d.ts +2 -2
  51. package/margin/margin/deps/std/type_name.d.ts +1 -1
  52. package/margin/margin/deps/suilend/lending_market.d.ts +2 -2
  53. package/margin/margin/market.d.ts +11 -11
  54. package/margin/margin/market.js +22 -22
  55. package/margin/margin/permissions.js +14 -14
  56. package/margin/margin/position.d.ts +47 -47
  57. package/margin/margin/position.js +10 -10
  58. package/margin/margin/router.d.ts +5 -5
  59. package/margin/margin/router.js +16 -16
  60. package/margin/margin/version.d.ts +1 -1
  61. package/margin/utils/index.js +22 -36
  62. package/package.json +1 -1
  63. package/parsers/apiReserveAssetDataEvent.js +4 -1
  64. package/parsers/lendingMarket.js +3 -4
  65. package/parsers/reserve.js +4 -1
  66. package/strategies.js +188 -204
  67. package/swap/quote.d.ts +1 -1
  68. package/swap/quote.js +28 -39
  69. package/swap/transaction.js +17 -26
  70. package/utils/events.js +20 -32
  71. package/utils/obligation.js +111 -135
  72. package/utils/simulate.d.ts +68 -1
  73. package/utils/simulate.js +149 -31
@@ -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;
@@ -62,8 +62,8 @@ export declare class String implements StructClass {
62
62
  static get r(): reified.StructClassReified<String, StringFields>;
63
63
  static phantom(): PhantomReified<ToTypeStr<String>>;
64
64
  static get p(): reified.PhantomReified<"0x1::ascii::String">;
65
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
66
- bytes: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
65
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
66
+ bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
67
67
  length: number;
68
68
  }, string>;
69
69
  }, string>;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import * as reified from "../../../../_framework/reified.js";
11
2
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified.js";
12
3
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
@@ -18,10 +9,16 @@ export function isChar(type) {
18
9
  return type === `${PKG_V13}::ascii::Char`;
19
10
  }
20
11
  export class Char {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V13}::ascii::Char`;
14
+ static $numTypeParams = 0;
15
+ static $isPhantom = [];
16
+ $typeName = Char.$typeName;
17
+ $fullTypeName;
18
+ $typeArgs;
19
+ $isPhantom = Char.$isPhantom;
20
+ byte;
21
21
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.$typeName = Char.$typeName;
24
- this.$isPhantom = Char.$isPhantom;
25
22
  this.$fullTypeName = composeSuiType(Char.$typeName, ...typeArgs);
26
23
  this.$typeArgs = typeArgs;
27
24
  this.byte = fields.byte;
@@ -39,7 +36,7 @@ export class Char {
39
36
  bcs: Char.bcs,
40
37
  fromJSONField: (field) => Char.fromJSONField(field),
41
38
  fromJSON: (json) => Char.fromJSON(json),
42
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Char.fetch(client, id); }),
39
+ fetch: async (client, id) => Char.fetch(client, id),
43
40
  new: (fields) => {
44
41
  return new Char([], fields);
45
42
  },
@@ -80,7 +77,11 @@ export class Char {
80
77
  };
81
78
  }
82
79
  toJSON() {
83
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
80
+ return {
81
+ $typeName: this.$typeName,
82
+ $typeArgs: this.$typeArgs,
83
+ ...this.toJSONField(),
84
+ };
84
85
  }
85
86
  static fromJSONField(field) {
86
87
  return Char.reified().new({ byte: decodeFromJSONField("u8", field.byte) });
@@ -91,29 +92,30 @@ export class Char {
91
92
  }
92
93
  return Char.fromJSONField(json);
93
94
  }
94
- static fetch(client, id) {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
97
- if (!isChar(object.type)) {
98
- throw new Error(`object at id ${id} is not a Char object`);
99
- }
100
- return Char.fromBcs(object.content);
101
- });
95
+ static async fetch(client, id) {
96
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
97
+ if (!isChar(object.type)) {
98
+ throw new Error(`object at id ${id} is not a Char object`);
99
+ }
100
+ return Char.fromBcs(object.content);
102
101
  }
103
102
  }
104
- Char.$typeName = `${PKG_V13}::ascii::Char`;
105
- Char.$numTypeParams = 0;
106
- Char.$isPhantom = [];
107
103
  /* ============================== String =============================== */
108
104
  export function isString(type) {
109
105
  type = compressSuiType(type);
110
106
  return type === `${PKG_V13}::ascii::String`;
111
107
  }
112
108
  export class String {
109
+ __StructClass = true;
110
+ static $typeName = `${PKG_V13}::ascii::String`;
111
+ static $numTypeParams = 0;
112
+ static $isPhantom = [];
113
+ $typeName = String.$typeName;
114
+ $fullTypeName;
115
+ $typeArgs;
116
+ $isPhantom = String.$isPhantom;
117
+ bytes;
113
118
  constructor(typeArgs, fields) {
114
- this.__StructClass = true;
115
- this.$typeName = String.$typeName;
116
- this.$isPhantom = String.$isPhantom;
117
119
  this.$fullTypeName = composeSuiType(String.$typeName, ...typeArgs);
118
120
  this.$typeArgs = typeArgs;
119
121
  this.bytes = fields.bytes;
@@ -131,7 +133,7 @@ export class String {
131
133
  bcs: String.bcs,
132
134
  fromJSONField: (field) => String.fromJSONField(field),
133
135
  fromJSON: (json) => String.fromJSON(json),
134
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return String.fetch(client, id); }),
136
+ fetch: async (client, id) => String.fetch(client, id),
135
137
  new: (fields) => {
136
138
  return new String([], fields);
137
139
  },
@@ -174,7 +176,11 @@ export class String {
174
176
  };
175
177
  }
176
178
  toJSON() {
177
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
179
+ return {
180
+ $typeName: this.$typeName,
181
+ $typeArgs: this.$typeArgs,
182
+ ...this.toJSONField(),
183
+ };
178
184
  }
179
185
  static fromJSONField(field) {
180
186
  return String.reified().new({
@@ -187,16 +193,11 @@ export class String {
187
193
  }
188
194
  return String.fromJSONField(json);
189
195
  }
190
- static fetch(client, id) {
191
- return __awaiter(this, void 0, void 0, function* () {
192
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
193
- if (!isString(object.type)) {
194
- throw new Error(`object at id ${id} is not a String object`);
195
- }
196
- return String.fromBcs(object.content);
197
- });
196
+ static async fetch(client, id) {
197
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
198
+ if (!isString(object.type)) {
199
+ throw new Error(`object at id ${id} is not a String object`);
200
+ }
201
+ return String.fromBcs(object.content);
198
202
  }
199
203
  }
200
- String.$typeName = `${PKG_V13}::ascii::String`;
201
- String.$numTypeParams = 0;
202
- String.$isPhantom = [];
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import * as reified from "../../../../_framework/reified.js";
11
2
  import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../../../_framework/reified.js";
12
3
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
@@ -18,11 +9,17 @@ export function isOption(type) {
18
9
  return type.startsWith(`${PKG_V13}::option::Option` + "<");
19
10
  }
20
11
  export class Option {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V13}::option::Option`;
14
+ static $numTypeParams = 1;
15
+ static $isPhantom = [false];
16
+ __inner = null; // for type checking in reified.ts
17
+ $typeName = Option.$typeName;
18
+ $fullTypeName;
19
+ $typeArgs;
20
+ $isPhantom = Option.$isPhantom;
21
+ vec;
21
22
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.__inner = null; // for type checking in reified.ts
24
- this.$typeName = Option.$typeName;
25
- this.$isPhantom = Option.$isPhantom;
26
23
  this.$fullTypeName = composeSuiType(Option.$typeName, ...typeArgs);
27
24
  this.$typeArgs = typeArgs;
28
25
  this.vec = fields.vec;
@@ -40,7 +37,7 @@ export class Option {
40
37
  bcs: Option.bcs(toBcs(Element)),
41
38
  fromJSONField: (field) => Option.fromJSONField(Element, field),
42
39
  fromJSON: (json) => Option.fromJSON(Element, json),
43
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Option.fetch(client, Element, id); }),
40
+ fetch: async (client, id) => Option.fetch(client, Element, id),
44
41
  new: (fields) => {
45
42
  return new Option([extractType(Element)], fields);
46
43
  },
@@ -85,7 +82,11 @@ export class Option {
85
82
  };
86
83
  }
87
84
  toJSON() {
88
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
85
+ return {
86
+ $typeName: this.$typeName,
87
+ $typeArgs: this.$typeArgs,
88
+ ...this.toJSONField(),
89
+ };
89
90
  }
90
91
  static fromJSONField(typeArg, field) {
91
92
  return Option.reified(typeArg).new({
@@ -99,16 +100,11 @@ export class Option {
99
100
  assertReifiedTypeArgsMatch(composeSuiType(Option.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
100
101
  return Option.fromJSONField(typeArg, json);
101
102
  }
102
- static fetch(client, typeArg, id) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
105
- if (!isOption(object.type)) {
106
- throw new Error(`object at id ${id} is not a Option object`);
107
- }
108
- return Option.fromBcs(typeArg, object.content);
109
- });
103
+ static async fetch(client, typeArg, id) {
104
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
105
+ if (!isOption(object.type)) {
106
+ throw new Error(`object at id ${id} is not a Option object`);
107
+ }
108
+ return Option.fromBcs(typeArg, object.content);
110
109
  }
111
110
  }
112
- Option.$typeName = `${PKG_V13}::option::Option`;
113
- Option.$numTypeParams = 1;
114
- Option.$isPhantom = [false];
@@ -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>;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { String } from "../ascii/structs.js";
@@ -18,10 +9,16 @@ export function isTypeName(type) {
18
9
  return type === `${PKG_V13}::type_name::TypeName`;
19
10
  }
20
11
  export class TypeName {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V13}::type_name::TypeName`;
14
+ static $numTypeParams = 0;
15
+ static $isPhantom = [];
16
+ $typeName = TypeName.$typeName;
17
+ $fullTypeName;
18
+ $typeArgs;
19
+ $isPhantom = TypeName.$isPhantom;
20
+ name;
21
21
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.$typeName = TypeName.$typeName;
24
- this.$isPhantom = TypeName.$isPhantom;
25
22
  this.$fullTypeName = composeSuiType(TypeName.$typeName, ...typeArgs);
26
23
  this.$typeArgs = typeArgs;
27
24
  this.name = fields.name;
@@ -39,7 +36,7 @@ export class TypeName {
39
36
  bcs: TypeName.bcs,
40
37
  fromJSONField: (field) => TypeName.fromJSONField(field),
41
38
  fromJSON: (json) => TypeName.fromJSON(json),
42
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return TypeName.fetch(client, id); }),
39
+ fetch: async (client, id) => TypeName.fetch(client, id),
43
40
  new: (fields) => {
44
41
  return new TypeName([], fields);
45
42
  },
@@ -82,7 +79,11 @@ export class TypeName {
82
79
  };
83
80
  }
84
81
  toJSON() {
85
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
82
+ return {
83
+ $typeName: this.$typeName,
84
+ $typeArgs: this.$typeArgs,
85
+ ...this.toJSONField(),
86
+ };
86
87
  }
87
88
  static fromJSONField(field) {
88
89
  return TypeName.reified().new({
@@ -95,16 +96,11 @@ export class TypeName {
95
96
  }
96
97
  return TypeName.fromJSONField(json);
97
98
  }
98
- static fetch(client, id) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
101
- if (!isTypeName(object.type)) {
102
- throw new Error(`object at id ${id} is not a TypeName object`);
103
- }
104
- return TypeName.fromBcs(object.content);
105
- });
99
+ static async fetch(client, id) {
100
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
101
+ if (!isTypeName(object.type)) {
102
+ throw new Error(`object at id ${id} is not a TypeName object`);
103
+ }
104
+ return TypeName.fromBcs(object.content);
106
105
  }
107
106
  }
108
- TypeName.$typeName = `${PKG_V13}::type_name::TypeName`;
109
- TypeName.$numTypeParams = 0;
110
- TypeName.$isPhantom = [];
@@ -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/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(fields: Record<string, any>): Bag;
37
37
  static fromFieldsWithTypes(item: FieldsWithTypes): Bag;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { PKG_V30 } from "../index.js";
@@ -18,10 +9,17 @@ export function isBag(type) {
18
9
  return type === `${PKG_V30}::bag::Bag`;
19
10
  }
20
11
  export class Bag {
12
+ __StructClass = true;
13
+ static $typeName = `${PKG_V30}::bag::Bag`;
14
+ static $numTypeParams = 0;
15
+ static $isPhantom = [];
16
+ $typeName = Bag.$typeName;
17
+ $fullTypeName;
18
+ $typeArgs;
19
+ $isPhantom = Bag.$isPhantom;
20
+ id;
21
+ size;
21
22
  constructor(typeArgs, fields) {
22
- this.__StructClass = true;
23
- this.$typeName = Bag.$typeName;
24
- this.$isPhantom = Bag.$isPhantom;
25
23
  this.$fullTypeName = composeSuiType(Bag.$typeName, ...typeArgs);
26
24
  this.$typeArgs = typeArgs;
27
25
  this.id = fields.id;
@@ -40,7 +38,7 @@ export class Bag {
40
38
  bcs: Bag.bcs,
41
39
  fromJSONField: (field) => Bag.fromJSONField(field),
42
40
  fromJSON: (json) => Bag.fromJSON(json),
43
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Bag.fetch(client, id); }),
41
+ fetch: async (client, id) => Bag.fetch(client, id),
44
42
  new: (fields) => {
45
43
  return new Bag([], fields);
46
44
  },
@@ -87,7 +85,11 @@ export class Bag {
87
85
  };
88
86
  }
89
87
  toJSON() {
90
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
88
+ return {
89
+ $typeName: this.$typeName,
90
+ $typeArgs: this.$typeArgs,
91
+ ...this.toJSONField(),
92
+ };
91
93
  }
92
94
  static fromJSONField(field) {
93
95
  return Bag.reified().new({
@@ -101,16 +103,11 @@ export class Bag {
101
103
  }
102
104
  return Bag.fromJSONField(json);
103
105
  }
104
- static fetch(client, id) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
107
- if (!isBag(object.type)) {
108
- throw new Error(`object at id ${id} is not a Bag object`);
109
- }
110
- return Bag.fromBcs(object.content);
111
- });
106
+ static async fetch(client, id) {
107
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
108
+ if (!isBag(object.type)) {
109
+ throw new Error(`object at id ${id} is not a Bag object`);
110
+ }
111
+ return Bag.fromBcs(object.content);
112
112
  }
113
113
  }
114
- Bag.$typeName = `${PKG_V30}::bag::Bag`;
115
- Bag.$numTypeParams = 0;
116
- Bag.$isPhantom = [];
@@ -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/sui/bcs").BcsStruct<{
26
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
25
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
26
+ value: import("@mysten/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>>;
@@ -60,8 +60,8 @@ export declare class Supply<T extends PhantomTypeArgument> implements StructClas
60
60
  static get r(): typeof Supply.reified;
61
61
  static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Supply<ToPhantomTypeArgument<T>>>>;
62
62
  static get p(): typeof Supply.phantom;
63
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
64
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
63
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
64
+ value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
65
65
  }, string>;
66
66
  static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
67
67
  static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Supply<ToPhantomTypeArgument<T>>;
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified.js";
11
2
  import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
3
  import { PKG_V30 } from "../index.js";
@@ -17,10 +8,16 @@ export function isBalance(type) {
17
8
  return type.startsWith(`${PKG_V30}::balance::Balance` + "<");
18
9
  }
19
10
  export class Balance {
11
+ __StructClass = true;
12
+ static $typeName = `${PKG_V30}::balance::Balance`;
13
+ static $numTypeParams = 1;
14
+ static $isPhantom = [true];
15
+ $typeName = Balance.$typeName;
16
+ $fullTypeName;
17
+ $typeArgs;
18
+ $isPhantom = Balance.$isPhantom;
19
+ value;
20
20
  constructor(typeArgs, fields) {
21
- this.__StructClass = true;
22
- this.$typeName = Balance.$typeName;
23
- this.$isPhantom = Balance.$isPhantom;
24
21
  this.$fullTypeName = composeSuiType(Balance.$typeName, ...typeArgs);
25
22
  this.$typeArgs = typeArgs;
26
23
  this.value = fields.value;
@@ -38,7 +35,7 @@ export class Balance {
38
35
  bcs: Balance.bcs,
39
36
  fromJSONField: (field) => Balance.fromJSONField(T, field),
40
37
  fromJSON: (json) => Balance.fromJSON(T, json),
41
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Balance.fetch(client, T, id); }),
38
+ fetch: async (client, id) => Balance.fetch(client, T, id),
42
39
  new: (fields) => {
43
40
  return new Balance([extractType(T)], fields);
44
41
  },
@@ -82,7 +79,11 @@ export class Balance {
82
79
  };
83
80
  }
84
81
  toJSON() {
85
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
82
+ return {
83
+ $typeName: this.$typeName,
84
+ $typeArgs: this.$typeArgs,
85
+ ...this.toJSONField(),
86
+ };
86
87
  }
87
88
  static fromJSONField(typeArg, field) {
88
89
  return Balance.reified(typeArg).new({
@@ -96,29 +97,30 @@ export class Balance {
96
97
  assertReifiedTypeArgsMatch(composeSuiType(Balance.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
97
98
  return Balance.fromJSONField(typeArg, json);
98
99
  }
99
- static fetch(client, typeArg, id) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
102
- if (!isBalance(object.type)) {
103
- throw new Error(`object at id ${id} is not a Balance object`);
104
- }
105
- return Balance.fromBcs(typeArg, object.content);
106
- });
100
+ static async fetch(client, typeArg, id) {
101
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
102
+ if (!isBalance(object.type)) {
103
+ throw new Error(`object at id ${id} is not a Balance object`);
104
+ }
105
+ return Balance.fromBcs(typeArg, object.content);
107
106
  }
108
107
  }
109
- Balance.$typeName = `${PKG_V30}::balance::Balance`;
110
- Balance.$numTypeParams = 1;
111
- Balance.$isPhantom = [true];
112
108
  /* ============================== Supply =============================== */
113
109
  export function isSupply(type) {
114
110
  type = compressSuiType(type);
115
111
  return type.startsWith(`${PKG_V30}::balance::Supply` + "<");
116
112
  }
117
113
  export class Supply {
114
+ __StructClass = true;
115
+ static $typeName = `${PKG_V30}::balance::Supply`;
116
+ static $numTypeParams = 1;
117
+ static $isPhantom = [true];
118
+ $typeName = Supply.$typeName;
119
+ $fullTypeName;
120
+ $typeArgs;
121
+ $isPhantom = Supply.$isPhantom;
122
+ value;
118
123
  constructor(typeArgs, fields) {
119
- this.__StructClass = true;
120
- this.$typeName = Supply.$typeName;
121
- this.$isPhantom = Supply.$isPhantom;
122
124
  this.$fullTypeName = composeSuiType(Supply.$typeName, ...typeArgs);
123
125
  this.$typeArgs = typeArgs;
124
126
  this.value = fields.value;
@@ -136,7 +138,7 @@ export class Supply {
136
138
  bcs: Supply.bcs,
137
139
  fromJSONField: (field) => Supply.fromJSONField(T, field),
138
140
  fromJSON: (json) => Supply.fromJSON(T, json),
139
- fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Supply.fetch(client, T, id); }),
141
+ fetch: async (client, id) => Supply.fetch(client, T, id),
140
142
  new: (fields) => {
141
143
  return new Supply([extractType(T)], fields);
142
144
  },
@@ -180,7 +182,11 @@ export class Supply {
180
182
  };
181
183
  }
182
184
  toJSON() {
183
- return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
185
+ return {
186
+ $typeName: this.$typeName,
187
+ $typeArgs: this.$typeArgs,
188
+ ...this.toJSONField(),
189
+ };
184
190
  }
185
191
  static fromJSONField(typeArg, field) {
186
192
  return Supply.reified(typeArg).new({
@@ -194,16 +200,11 @@ export class Supply {
194
200
  assertReifiedTypeArgsMatch(composeSuiType(Supply.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
195
201
  return Supply.fromJSONField(typeArg, json);
196
202
  }
197
- static fetch(client, typeArg, id) {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- const { object } = yield client.getObject({ objectId: id, include: { content: true } });
200
- if (!isSupply(object.type)) {
201
- throw new Error(`object at id ${id} is not a Supply object`);
202
- }
203
- return Supply.fromBcs(typeArg, object.content);
204
- });
203
+ static async fetch(client, typeArg, id) {
204
+ const { object } = await client.getObject({ objectId: id, include: { content: true } });
205
+ if (!isSupply(object.type)) {
206
+ throw new Error(`object at id ${id} is not a Supply object`);
207
+ }
208
+ return Supply.fromBcs(typeArg, object.content);
205
209
  }
206
210
  }
207
- Supply.$typeName = `${PKG_V30}::balance::Supply`;
208
- Supply.$numTypeParams = 1;
209
- Supply.$isPhantom = [true];
@@ -22,8 +22,8 @@ export declare class ID implements StructClass {
22
22
  static get r(): import("../../../../_framework/reified").StructClassReified<ID, IDFields>;
23
23
  static phantom(): PhantomReified<ToTypeStr<ID>>;
24
24
  static get p(): PhantomReified<"0x2::object::ID">;
25
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
26
- bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
25
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
26
+ bytes: import("@mysten/bcs").BcsType<string, string, string>;
27
27
  }, string>;
28
28
  static fromFields(fields: Record<string, any>): ID;
29
29
  static fromFieldsWithTypes(item: FieldsWithTypes): ID;
@@ -60,9 +60,9 @@ export declare class UID implements StructClass {
60
60
  static get r(): import("../../../../_framework/reified").StructClassReified<UID, UIDFields>;
61
61
  static phantom(): PhantomReified<ToTypeStr<UID>>;
62
62
  static get p(): PhantomReified<"0x2::object::UID">;
63
- static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
64
- id: import("@mysten/sui/bcs").BcsStruct<{
65
- bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
63
+ static get bcs(): import("@mysten/bcs").BcsStruct<{
64
+ id: import("@mysten/bcs").BcsStruct<{
65
+ bytes: import("@mysten/bcs").BcsType<string, string, string>;
66
66
  }, string>;
67
67
  }, string>;
68
68
  static fromFields(fields: Record<string, any>): UID;