@suilend/sdk 3.0.8 → 4.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.
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x1/ascii/structs.js +42 -41
- package/_generated/_dependencies/source/0x1/option/structs.js +22 -26
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x1/type-name/structs.js +21 -25
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x2/bag/structs.js +22 -25
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x2/balance/structs.js +42 -41
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x2/object/structs.js +42 -41
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x2/object-table/structs.js +22 -25
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +22 -25
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +9 -9
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +24 -25
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +21 -21
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +23 -25
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +2 -2
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -25
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +52 -52
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +45 -41
- package/_generated/_framework/vector.js +9 -6
- package/_generated/suilend/cell/structs.d.ts +1 -1
- package/_generated/suilend/cell/structs.js +21 -25
- package/_generated/suilend/decimal/structs.d.ts +2 -2
- package/_generated/suilend/decimal/structs.js +21 -25
- package/_generated/suilend/lending-market/structs.d.ts +129 -129
- package/_generated/suilend/lending-market/structs.js +391 -265
- package/_generated/suilend/liquidity-mining/structs.d.ts +44 -44
- package/_generated/suilend/liquidity-mining/structs.js +122 -89
- package/_generated/suilend/obligation/structs.d.ts +98 -98
- package/_generated/suilend/obligation/structs.js +194 -121
- package/_generated/suilend/rate-limiter/structs.d.ts +12 -12
- package/_generated/suilend/rate-limiter/structs.js +46 -41
- package/_generated/suilend/reserve/structs.d.ts +128 -128
- package/_generated/suilend/reserve/structs.js +243 -153
- package/_generated/suilend/reserve-config/structs.d.ts +30 -30
- package/_generated/suilend/reserve-config/structs.js +60 -41
- package/api/events.js +5 -14
- package/client.js +267 -319
- package/lib/initialize.d.ts +2 -2
- package/lib/initialize.js +26 -31
- package/lib/liquidityMining.js +15 -19
- package/lib/pyth.js +6 -15
- package/lib/pythAdapter.js +96 -112
- package/lib/strategyOwnerCap.js +8 -17
- package/margin/margin/admin_cap.d.ts +2 -2
- package/margin/margin/deps/std/type_name.d.ts +1 -1
- package/margin/margin/deps/suilend/lending_market.d.ts +2 -2
- package/margin/margin/market.d.ts +11 -11
- package/margin/margin/market.js +22 -22
- package/margin/margin/permissions.js +14 -14
- package/margin/margin/position.d.ts +47 -47
- package/margin/margin/position.js +10 -10
- package/margin/margin/router.d.ts +5 -5
- package/margin/margin/router.js +16 -16
- package/margin/margin/version.d.ts +1 -1
- package/margin/utils/index.js +22 -36
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +4 -1
- package/parsers/lendingMarket.js +3 -4
- package/parsers/reserve.js +4 -1
- package/strategies.js +188 -204
- package/swap/quote.d.ts +1 -1
- package/swap/quote.js +28 -39
- package/swap/transaction.js +17 -26
- package/utils/events.js +20 -32
- package/utils/obligation.js +111 -135
- package/utils/simulate.js +16 -24
|
@@ -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 isPriceIdentifier(type) {
|
|
|
18
9
|
return type === `${PKG_V1}::price_identifier::PriceIdentifier`;
|
|
19
10
|
}
|
|
20
11
|
export class PriceIdentifier {
|
|
12
|
+
__StructClass = true;
|
|
13
|
+
static $typeName = `${PKG_V1}::price_identifier::PriceIdentifier`;
|
|
14
|
+
static $numTypeParams = 0;
|
|
15
|
+
static $isPhantom = [];
|
|
16
|
+
$typeName = PriceIdentifier.$typeName;
|
|
17
|
+
$fullTypeName;
|
|
18
|
+
$typeArgs;
|
|
19
|
+
$isPhantom = PriceIdentifier.$isPhantom;
|
|
20
|
+
bytes;
|
|
21
21
|
constructor(typeArgs, fields) {
|
|
22
|
-
this.__StructClass = true;
|
|
23
|
-
this.$typeName = PriceIdentifier.$typeName;
|
|
24
|
-
this.$isPhantom = PriceIdentifier.$isPhantom;
|
|
25
22
|
this.$fullTypeName = composeSuiType(PriceIdentifier.$typeName, ...typeArgs);
|
|
26
23
|
this.$typeArgs = typeArgs;
|
|
27
24
|
this.bytes = fields.bytes;
|
|
@@ -39,7 +36,7 @@ export class PriceIdentifier {
|
|
|
39
36
|
bcs: PriceIdentifier.bcs,
|
|
40
37
|
fromJSONField: (field) => PriceIdentifier.fromJSONField(field),
|
|
41
38
|
fromJSON: (json) => PriceIdentifier.fromJSON(json),
|
|
42
|
-
fetch: (client, id) =>
|
|
39
|
+
fetch: async (client, id) => PriceIdentifier.fetch(client, id),
|
|
43
40
|
new: (fields) => {
|
|
44
41
|
return new PriceIdentifier([], fields);
|
|
45
42
|
},
|
|
@@ -82,7 +79,11 @@ export class PriceIdentifier {
|
|
|
82
79
|
};
|
|
83
80
|
}
|
|
84
81
|
toJSON() {
|
|
85
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
$typeName: this.$typeName,
|
|
84
|
+
$typeArgs: this.$typeArgs,
|
|
85
|
+
...this.toJSONField(),
|
|
86
|
+
};
|
|
86
87
|
}
|
|
87
88
|
static fromJSONField(field) {
|
|
88
89
|
return PriceIdentifier.reified().new({
|
|
@@ -95,16 +96,11 @@ export class PriceIdentifier {
|
|
|
95
96
|
}
|
|
96
97
|
return PriceIdentifier.fromJSONField(json);
|
|
97
98
|
}
|
|
98
|
-
static fetch(client, id) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return PriceIdentifier.fromBcs(object.content);
|
|
105
|
-
});
|
|
99
|
+
static async fetch(client, id) {
|
|
100
|
+
const { object } = await client.getObject({ objectId: id, include: { content: true } });
|
|
101
|
+
if (!isPriceIdentifier(object.type)) {
|
|
102
|
+
throw new Error(`object at id ${id} is not a PriceIdentifier object`);
|
|
103
|
+
}
|
|
104
|
+
return PriceIdentifier.fromBcs(object.content);
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
PriceIdentifier.$typeName = `${PKG_V1}::price_identifier::PriceIdentifier`;
|
|
109
|
-
PriceIdentifier.$numTypeParams = 0;
|
|
110
|
-
PriceIdentifier.$isPhantom = [];
|
|
@@ -28,38 +28,38 @@ export declare class PriceInfo implements StructClass {
|
|
|
28
28
|
static get r(): import("../../../../_framework/reified").StructClassReified<PriceInfo, PriceInfoFields>;
|
|
29
29
|
static phantom(): PhantomReified<ToTypeStr<PriceInfo>>;
|
|
30
30
|
static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfo">;
|
|
31
|
-
static get bcs(): import("@mysten/
|
|
32
|
-
attestation_time: import("@mysten/
|
|
33
|
-
arrival_time: import("@mysten/
|
|
34
|
-
price_feed: import("@mysten/
|
|
35
|
-
price_identifier: import("@mysten/
|
|
36
|
-
bytes: import("@mysten/
|
|
31
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
32
|
+
attestation_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
33
|
+
arrival_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
34
|
+
price_feed: import("@mysten/bcs").BcsStruct<{
|
|
35
|
+
price_identifier: import("@mysten/bcs").BcsStruct<{
|
|
36
|
+
bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
|
|
37
37
|
length: number;
|
|
38
38
|
}, string>;
|
|
39
39
|
}, string>;
|
|
40
|
-
price: import("@mysten/
|
|
41
|
-
price: import("@mysten/
|
|
42
|
-
negative: import("@mysten/
|
|
43
|
-
magnitude: import("@mysten/
|
|
40
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
41
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
42
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
43
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
44
44
|
}, string>;
|
|
45
|
-
conf: import("@mysten/
|
|
46
|
-
expo: import("@mysten/
|
|
47
|
-
negative: import("@mysten/
|
|
48
|
-
magnitude: import("@mysten/
|
|
45
|
+
conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
46
|
+
expo: import("@mysten/bcs").BcsStruct<{
|
|
47
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
48
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
49
49
|
}, string>;
|
|
50
|
-
timestamp: import("@mysten/
|
|
50
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
51
51
|
}, string>;
|
|
52
|
-
ema_price: import("@mysten/
|
|
53
|
-
price: import("@mysten/
|
|
54
|
-
negative: import("@mysten/
|
|
55
|
-
magnitude: import("@mysten/
|
|
52
|
+
ema_price: import("@mysten/bcs").BcsStruct<{
|
|
53
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
54
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
55
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
56
56
|
}, string>;
|
|
57
|
-
conf: import("@mysten/
|
|
58
|
-
expo: import("@mysten/
|
|
59
|
-
negative: import("@mysten/
|
|
60
|
-
magnitude: import("@mysten/
|
|
57
|
+
conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
58
|
+
expo: import("@mysten/bcs").BcsStruct<{
|
|
59
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
60
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
61
61
|
}, string>;
|
|
62
|
-
timestamp: import("@mysten/
|
|
62
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
63
63
|
}, string>;
|
|
64
64
|
}, string>;
|
|
65
65
|
}, string>;
|
|
@@ -160,44 +160,44 @@ export declare class PriceInfoObject implements StructClass {
|
|
|
160
160
|
static get r(): import("../../../../_framework/reified").StructClassReified<PriceInfoObject, PriceInfoObjectFields>;
|
|
161
161
|
static phantom(): PhantomReified<ToTypeStr<PriceInfoObject>>;
|
|
162
162
|
static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfoObject">;
|
|
163
|
-
static get bcs(): import("@mysten/
|
|
164
|
-
id: import("@mysten/
|
|
165
|
-
id: import("@mysten/
|
|
166
|
-
bytes: import("@mysten/
|
|
163
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
164
|
+
id: import("@mysten/bcs").BcsStruct<{
|
|
165
|
+
id: import("@mysten/bcs").BcsStruct<{
|
|
166
|
+
bytes: import("@mysten/bcs").BcsType<string, string, string>;
|
|
167
167
|
}, string>;
|
|
168
168
|
}, string>;
|
|
169
|
-
price_info: import("@mysten/
|
|
170
|
-
attestation_time: import("@mysten/
|
|
171
|
-
arrival_time: import("@mysten/
|
|
172
|
-
price_feed: import("@mysten/
|
|
173
|
-
price_identifier: import("@mysten/
|
|
174
|
-
bytes: import("@mysten/
|
|
169
|
+
price_info: import("@mysten/bcs").BcsStruct<{
|
|
170
|
+
attestation_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
171
|
+
arrival_time: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
172
|
+
price_feed: import("@mysten/bcs").BcsStruct<{
|
|
173
|
+
price_identifier: import("@mysten/bcs").BcsStruct<{
|
|
174
|
+
bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
|
|
175
175
|
length: number;
|
|
176
176
|
}, string>;
|
|
177
177
|
}, string>;
|
|
178
|
-
price: import("@mysten/
|
|
179
|
-
price: import("@mysten/
|
|
180
|
-
negative: import("@mysten/
|
|
181
|
-
magnitude: import("@mysten/
|
|
178
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
179
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
180
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
181
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
182
182
|
}, string>;
|
|
183
|
-
conf: import("@mysten/
|
|
184
|
-
expo: import("@mysten/
|
|
185
|
-
negative: import("@mysten/
|
|
186
|
-
magnitude: import("@mysten/
|
|
183
|
+
conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
184
|
+
expo: import("@mysten/bcs").BcsStruct<{
|
|
185
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
186
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
187
187
|
}, string>;
|
|
188
|
-
timestamp: import("@mysten/
|
|
188
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
189
189
|
}, string>;
|
|
190
|
-
ema_price: import("@mysten/
|
|
191
|
-
price: import("@mysten/
|
|
192
|
-
negative: import("@mysten/
|
|
193
|
-
magnitude: import("@mysten/
|
|
190
|
+
ema_price: import("@mysten/bcs").BcsStruct<{
|
|
191
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
192
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
193
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
194
194
|
}, string>;
|
|
195
|
-
conf: import("@mysten/
|
|
196
|
-
expo: import("@mysten/
|
|
197
|
-
negative: import("@mysten/
|
|
198
|
-
magnitude: import("@mysten/
|
|
195
|
+
conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
196
|
+
expo: import("@mysten/bcs").BcsStruct<{
|
|
197
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
198
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
199
199
|
}, string>;
|
|
200
|
-
timestamp: import("@mysten/
|
|
200
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
201
201
|
}, string>;
|
|
202
202
|
}, string>;
|
|
203
203
|
}, 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 { UID } from "../../0x2/object/structs.js";
|
|
@@ -19,10 +10,18 @@ export function isPriceInfo(type) {
|
|
|
19
10
|
return type === `${PKG_V1}::price_info::PriceInfo`;
|
|
20
11
|
}
|
|
21
12
|
export class PriceInfo {
|
|
13
|
+
__StructClass = true;
|
|
14
|
+
static $typeName = `${PKG_V1}::price_info::PriceInfo`;
|
|
15
|
+
static $numTypeParams = 0;
|
|
16
|
+
static $isPhantom = [];
|
|
17
|
+
$typeName = PriceInfo.$typeName;
|
|
18
|
+
$fullTypeName;
|
|
19
|
+
$typeArgs;
|
|
20
|
+
$isPhantom = PriceInfo.$isPhantom;
|
|
21
|
+
attestationTime;
|
|
22
|
+
arrivalTime;
|
|
23
|
+
priceFeed;
|
|
22
24
|
constructor(typeArgs, fields) {
|
|
23
|
-
this.__StructClass = true;
|
|
24
|
-
this.$typeName = PriceInfo.$typeName;
|
|
25
|
-
this.$isPhantom = PriceInfo.$isPhantom;
|
|
26
25
|
this.$fullTypeName = composeSuiType(PriceInfo.$typeName, ...typeArgs);
|
|
27
26
|
this.$typeArgs = typeArgs;
|
|
28
27
|
this.attestationTime = fields.attestationTime;
|
|
@@ -42,7 +41,7 @@ export class PriceInfo {
|
|
|
42
41
|
bcs: PriceInfo.bcs,
|
|
43
42
|
fromJSONField: (field) => PriceInfo.fromJSONField(field),
|
|
44
43
|
fromJSON: (json) => PriceInfo.fromJSON(json),
|
|
45
|
-
fetch: (client, id) =>
|
|
44
|
+
fetch: async (client, id) => PriceInfo.fetch(client, id),
|
|
46
45
|
new: (fields) => {
|
|
47
46
|
return new PriceInfo([], fields);
|
|
48
47
|
},
|
|
@@ -93,7 +92,11 @@ export class PriceInfo {
|
|
|
93
92
|
};
|
|
94
93
|
}
|
|
95
94
|
toJSON() {
|
|
96
|
-
return
|
|
95
|
+
return {
|
|
96
|
+
$typeName: this.$typeName,
|
|
97
|
+
$typeArgs: this.$typeArgs,
|
|
98
|
+
...this.toJSONField(),
|
|
99
|
+
};
|
|
97
100
|
}
|
|
98
101
|
static fromJSONField(field) {
|
|
99
102
|
return PriceInfo.reified().new({
|
|
@@ -108,29 +111,31 @@ export class PriceInfo {
|
|
|
108
111
|
}
|
|
109
112
|
return PriceInfo.fromJSONField(json);
|
|
110
113
|
}
|
|
111
|
-
static fetch(client, id) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return PriceInfo.fromBcs(object.content);
|
|
118
|
-
});
|
|
114
|
+
static async fetch(client, id) {
|
|
115
|
+
const { object } = await client.getObject({ objectId: id, include: { content: true } });
|
|
116
|
+
if (!isPriceInfo(object.type)) {
|
|
117
|
+
throw new Error(`object at id ${id} is not a PriceInfo object`);
|
|
118
|
+
}
|
|
119
|
+
return PriceInfo.fromBcs(object.content);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
PriceInfo.$typeName = `${PKG_V1}::price_info::PriceInfo`;
|
|
122
|
-
PriceInfo.$numTypeParams = 0;
|
|
123
|
-
PriceInfo.$isPhantom = [];
|
|
124
122
|
/* ============================== PriceInfoObject =============================== */
|
|
125
123
|
export function isPriceInfoObject(type) {
|
|
126
124
|
type = compressSuiType(type);
|
|
127
125
|
return type === `${PKG_V1}::price_info::PriceInfoObject`;
|
|
128
126
|
}
|
|
129
127
|
export class PriceInfoObject {
|
|
128
|
+
__StructClass = true;
|
|
129
|
+
static $typeName = `${PKG_V1}::price_info::PriceInfoObject`;
|
|
130
|
+
static $numTypeParams = 0;
|
|
131
|
+
static $isPhantom = [];
|
|
132
|
+
$typeName = PriceInfoObject.$typeName;
|
|
133
|
+
$fullTypeName;
|
|
134
|
+
$typeArgs;
|
|
135
|
+
$isPhantom = PriceInfoObject.$isPhantom;
|
|
136
|
+
id;
|
|
137
|
+
priceInfo;
|
|
130
138
|
constructor(typeArgs, fields) {
|
|
131
|
-
this.__StructClass = true;
|
|
132
|
-
this.$typeName = PriceInfoObject.$typeName;
|
|
133
|
-
this.$isPhantom = PriceInfoObject.$isPhantom;
|
|
134
139
|
this.$fullTypeName = composeSuiType(PriceInfoObject.$typeName, ...typeArgs);
|
|
135
140
|
this.$typeArgs = typeArgs;
|
|
136
141
|
this.id = fields.id;
|
|
@@ -149,7 +154,7 @@ export class PriceInfoObject {
|
|
|
149
154
|
bcs: PriceInfoObject.bcs,
|
|
150
155
|
fromJSONField: (field) => PriceInfoObject.fromJSONField(field),
|
|
151
156
|
fromJSON: (json) => PriceInfoObject.fromJSON(json),
|
|
152
|
-
fetch: (client, id) =>
|
|
157
|
+
fetch: async (client, id) => PriceInfoObject.fetch(client, id),
|
|
153
158
|
new: (fields) => {
|
|
154
159
|
return new PriceInfoObject([], fields);
|
|
155
160
|
},
|
|
@@ -196,7 +201,11 @@ export class PriceInfoObject {
|
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
203
|
toJSON() {
|
|
199
|
-
return
|
|
204
|
+
return {
|
|
205
|
+
$typeName: this.$typeName,
|
|
206
|
+
$typeArgs: this.$typeArgs,
|
|
207
|
+
...this.toJSONField(),
|
|
208
|
+
};
|
|
200
209
|
}
|
|
201
210
|
static fromJSONField(field) {
|
|
202
211
|
return PriceInfoObject.reified().new({
|
|
@@ -210,16 +219,11 @@ export class PriceInfoObject {
|
|
|
210
219
|
}
|
|
211
220
|
return PriceInfoObject.fromJSONField(json);
|
|
212
221
|
}
|
|
213
|
-
static fetch(client, id) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return PriceInfoObject.fromBcs(object.content);
|
|
220
|
-
});
|
|
222
|
+
static async fetch(client, id) {
|
|
223
|
+
const { object } = await client.getObject({ objectId: id, include: { content: true } });
|
|
224
|
+
if (!isPriceInfoObject(object.type)) {
|
|
225
|
+
throw new Error(`object at id ${id} is not a PriceInfoObject object`);
|
|
226
|
+
}
|
|
227
|
+
return PriceInfoObject.fromBcs(object.content);
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
|
-
PriceInfoObject.$typeName = `${PKG_V1}::price_info::PriceInfoObject`;
|
|
224
|
-
PriceInfoObject.$numTypeParams = 0;
|
|
225
|
-
PriceInfoObject.$isPhantom = [];
|
|
@@ -2,10 +2,16 @@ import { bcs } from "@mysten/sui/bcs";
|
|
|
2
2
|
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, toBcs, fieldToJSON, } from "./reified.js";
|
|
3
3
|
import { composeSuiType } from "./util.js";
|
|
4
4
|
export class Vector {
|
|
5
|
+
__VectorClass = true;
|
|
6
|
+
static $typeName = "vector";
|
|
7
|
+
static $numTypeParams = 1;
|
|
8
|
+
static $isPhantom = [false];
|
|
9
|
+
$typeName = "vector";
|
|
10
|
+
$fullTypeName;
|
|
11
|
+
$typeArgs;
|
|
12
|
+
$isPhantom = [false];
|
|
13
|
+
elements;
|
|
5
14
|
constructor(typeArgs, elements) {
|
|
6
|
-
this.__VectorClass = true;
|
|
7
|
-
this.$typeName = "vector";
|
|
8
|
-
this.$isPhantom = [false];
|
|
9
15
|
this.$fullTypeName = composeSuiType(this.$typeName, ...typeArgs);
|
|
10
16
|
this.$typeArgs = typeArgs;
|
|
11
17
|
this.elements = elements;
|
|
@@ -64,9 +70,6 @@ export class Vector {
|
|
|
64
70
|
return Vector.fromJSONField(typeArg, json.elements);
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
|
-
Vector.$typeName = "vector";
|
|
68
|
-
Vector.$numTypeParams = 1;
|
|
69
|
-
Vector.$isPhantom = [false];
|
|
70
73
|
export function vector(T) {
|
|
71
74
|
return Vector.r(T);
|
|
72
75
|
}
|
|
@@ -24,7 +24,7 @@ export declare class Cell<Element extends TypeArgument> implements StructClass {
|
|
|
24
24
|
static get r(): typeof Cell.reified;
|
|
25
25
|
static phantom<Element extends Reified<TypeArgument, any>>(Element: Element): PhantomReified<ToTypeStr<Cell<ToTypeArgument<Element>>>>;
|
|
26
26
|
static get p(): typeof Cell.phantom;
|
|
27
|
-
static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/
|
|
27
|
+
static get bcs(): <Element extends BcsType<any>>(Element: Element) => import("@mysten/bcs").BcsStruct<{
|
|
28
28
|
element: BcsType<any, any, string>;
|
|
29
29
|
}, string>;
|
|
30
30
|
static fromFields<Element extends Reified<TypeArgument, any>>(typeArg: Element, fields: Record<string, any>): Cell<ToTypeArgument<Element>>;
|
|
@@ -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 { Option } from "../../_dependencies/source/0x1/option/structs.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,10 +9,16 @@ export function isCell(type) {
|
|
|
18
9
|
return type.startsWith(`${PKG_V1}::cell::Cell` + "<");
|
|
19
10
|
}
|
|
20
11
|
export class Cell {
|
|
12
|
+
__StructClass = true;
|
|
13
|
+
static $typeName = `${PKG_V1}::cell::Cell`;
|
|
14
|
+
static $numTypeParams = 1;
|
|
15
|
+
static $isPhantom = [false];
|
|
16
|
+
$typeName = Cell.$typeName;
|
|
17
|
+
$fullTypeName;
|
|
18
|
+
$typeArgs;
|
|
19
|
+
$isPhantom = Cell.$isPhantom;
|
|
20
|
+
element;
|
|
21
21
|
constructor(typeArgs, fields) {
|
|
22
|
-
this.__StructClass = true;
|
|
23
|
-
this.$typeName = Cell.$typeName;
|
|
24
|
-
this.$isPhantom = Cell.$isPhantom;
|
|
25
22
|
this.$fullTypeName = composeSuiType(Cell.$typeName, ...typeArgs);
|
|
26
23
|
this.$typeArgs = typeArgs;
|
|
27
24
|
this.element = fields.element;
|
|
@@ -39,7 +36,7 @@ export class Cell {
|
|
|
39
36
|
bcs: Cell.bcs(toBcs(Element)),
|
|
40
37
|
fromJSONField: (field) => Cell.fromJSONField(Element, field),
|
|
41
38
|
fromJSON: (json) => Cell.fromJSON(Element, json),
|
|
42
|
-
fetch: (client, id) =>
|
|
39
|
+
fetch: async (client, id) => Cell.fetch(client, Element, id),
|
|
43
40
|
new: (fields) => {
|
|
44
41
|
return new Cell([extractType(Element)], fields);
|
|
45
42
|
},
|
|
@@ -84,7 +81,11 @@ export class Cell {
|
|
|
84
81
|
};
|
|
85
82
|
}
|
|
86
83
|
toJSON() {
|
|
87
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
$typeName: this.$typeName,
|
|
86
|
+
$typeArgs: this.$typeArgs,
|
|
87
|
+
...this.toJSONField(),
|
|
88
|
+
};
|
|
88
89
|
}
|
|
89
90
|
static fromJSONField(typeArg, field) {
|
|
90
91
|
return Cell.reified(typeArg).new({
|
|
@@ -98,16 +99,11 @@ export class Cell {
|
|
|
98
99
|
assertReifiedTypeArgsMatch(composeSuiType(Cell.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
|
|
99
100
|
return Cell.fromJSONField(typeArg, json);
|
|
100
101
|
}
|
|
101
|
-
static fetch(client, typeArg, id) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return Cell.fromBcs(typeArg, object.content);
|
|
108
|
-
});
|
|
102
|
+
static async fetch(client, typeArg, id) {
|
|
103
|
+
const { object } = await client.getObject({ objectId: id, include: { content: true } });
|
|
104
|
+
if (!isCell(object.type)) {
|
|
105
|
+
throw new Error(`object at id ${id} is not a Cell object`);
|
|
106
|
+
}
|
|
107
|
+
return Cell.fromBcs(typeArg, object.content);
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
|
-
Cell.$typeName = `${PKG_V1}::cell::Cell`;
|
|
112
|
-
Cell.$numTypeParams = 1;
|
|
113
|
-
Cell.$isPhantom = [false];
|
|
@@ -22,8 +22,8 @@ export declare class Decimal implements StructClass {
|
|
|
22
22
|
static get r(): import("../../_framework/reified").StructClassReified<Decimal, DecimalFields>;
|
|
23
23
|
static phantom(): PhantomReified<ToTypeStr<Decimal>>;
|
|
24
24
|
static get p(): PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::decimal::Decimal" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::decimal::Decimal">;
|
|
25
|
-
static get bcs(): import("@mysten/
|
|
26
|
-
value: import("@mysten/
|
|
25
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
26
|
+
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u256">;
|
|
27
27
|
}, string>;
|
|
28
28
|
static fromFields(fields: Record<string, any>): Decimal;
|
|
29
29
|
static fromFieldsWithTypes(item: FieldsWithTypes): Decimal;
|
|
@@ -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_V1 } from "../index.js";
|
|
@@ -17,10 +8,16 @@ export function isDecimal(type) {
|
|
|
17
8
|
return type === `${PKG_V1}::decimal::Decimal`;
|
|
18
9
|
}
|
|
19
10
|
export class Decimal {
|
|
11
|
+
__StructClass = true;
|
|
12
|
+
static $typeName = `${PKG_V1}::decimal::Decimal`;
|
|
13
|
+
static $numTypeParams = 0;
|
|
14
|
+
static $isPhantom = [];
|
|
15
|
+
$typeName = Decimal.$typeName;
|
|
16
|
+
$fullTypeName;
|
|
17
|
+
$typeArgs;
|
|
18
|
+
$isPhantom = Decimal.$isPhantom;
|
|
19
|
+
value;
|
|
20
20
|
constructor(typeArgs, fields) {
|
|
21
|
-
this.__StructClass = true;
|
|
22
|
-
this.$typeName = Decimal.$typeName;
|
|
23
|
-
this.$isPhantom = Decimal.$isPhantom;
|
|
24
21
|
this.$fullTypeName = composeSuiType(Decimal.$typeName, ...typeArgs);
|
|
25
22
|
this.$typeArgs = typeArgs;
|
|
26
23
|
this.value = fields.value;
|
|
@@ -38,7 +35,7 @@ export class Decimal {
|
|
|
38
35
|
bcs: Decimal.bcs,
|
|
39
36
|
fromJSONField: (field) => Decimal.fromJSONField(field),
|
|
40
37
|
fromJSON: (json) => Decimal.fromJSON(json),
|
|
41
|
-
fetch: (client, id) =>
|
|
38
|
+
fetch: async (client, id) => Decimal.fetch(client, id),
|
|
42
39
|
new: (fields) => {
|
|
43
40
|
return new Decimal([], fields);
|
|
44
41
|
},
|
|
@@ -81,7 +78,11 @@ export class Decimal {
|
|
|
81
78
|
};
|
|
82
79
|
}
|
|
83
80
|
toJSON() {
|
|
84
|
-
return
|
|
81
|
+
return {
|
|
82
|
+
$typeName: this.$typeName,
|
|
83
|
+
$typeArgs: this.$typeArgs,
|
|
84
|
+
...this.toJSONField(),
|
|
85
|
+
};
|
|
85
86
|
}
|
|
86
87
|
static fromJSONField(field) {
|
|
87
88
|
return Decimal.reified().new({
|
|
@@ -94,16 +95,11 @@ export class Decimal {
|
|
|
94
95
|
}
|
|
95
96
|
return Decimal.fromJSONField(json);
|
|
96
97
|
}
|
|
97
|
-
static fetch(client, id) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return Decimal.fromBcs(object.content);
|
|
104
|
-
});
|
|
98
|
+
static async fetch(client, id) {
|
|
99
|
+
const { object } = await client.getObject({ objectId: id, include: { content: true } });
|
|
100
|
+
if (!isDecimal(object.type)) {
|
|
101
|
+
throw new Error(`object at id ${id} is not a Decimal object`);
|
|
102
|
+
}
|
|
103
|
+
return Decimal.fromBcs(object.content);
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
|
-
Decimal.$typeName = `${PKG_V1}::decimal::Decimal`;
|
|
108
|
-
Decimal.$numTypeParams = 0;
|
|
109
|
-
Decimal.$isPhantom = [];
|