@suilend/sdk 1.1.99 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/_generated/_dependencies/source/0x1/index.js +3 -6
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/_generated/_dependencies/source/0x2/index.js +3 -6
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
- package/_generated/_framework/reified.d.ts +2 -2
- package/_generated/_framework/reified.js +27 -40
- package/_generated/_framework/util.js +26 -40
- package/_generated/_framework/vector.d.ts +4 -4
- package/_generated/_framework/vector.js +16 -21
- package/_generated/suilend/cell/structs.d.ts +4 -4
- package/_generated/suilend/cell/structs.js +31 -36
- package/_generated/suilend/decimal/structs.d.ts +4 -4
- package/_generated/suilend/decimal/structs.js +19 -24
- package/_generated/suilend/index.js +8 -12
- package/_generated/suilend/lending-market/functions.d.ts +1 -0
- package/_generated/suilend/lending-market/functions.js +271 -302
- package/_generated/suilend/lending-market/structs.d.ts +146 -146
- package/_generated/suilend/lending-market/structs.js +549 -617
- package/_generated/suilend/lending-market-registry/functions.js +7 -11
- package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
- package/_generated/suilend/liquidity-mining/structs.js +159 -205
- package/_generated/suilend/obligation/structs.d.ts +106 -106
- package/_generated/suilend/obligation/structs.js +313 -363
- package/_generated/suilend/rate-limiter/functions.js +23 -31
- package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
- package/_generated/suilend/rate-limiter/structs.js +49 -56
- package/_generated/suilend/reserve/structs.d.ts +139 -139
- package/_generated/suilend/reserve/structs.js +397 -451
- package/_generated/suilend/reserve-config/functions.js +149 -190
- package/_generated/suilend/reserve-config/structs.d.ts +33 -33
- package/_generated/suilend/reserve-config/structs.js +109 -149
- package/api/events.js +1 -5
- package/api/index.js +1 -17
- package/client.d.ts +10 -10
- package/client.js +118 -128
- package/index.js +7 -23
- package/lib/constants.js +3 -9
- package/lib/index.js +5 -21
- package/lib/initialize.d.ts +3 -3
- package/lib/initialize.js +103 -140
- package/lib/liquidityMining.d.ts +3 -3
- package/lib/liquidityMining.js +57 -72
- package/lib/pyth.js +9 -14
- package/lib/strategyOwnerCap.js +106 -119
- package/lib/transactions.js +2 -7
- package/lib/types.js +4 -7
- package/mmt.js +2 -5
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +25 -33
- package/parsers/index.js +5 -21
- package/parsers/lendingMarket.d.ts +1 -1
- package/parsers/lendingMarket.js +12 -19
- package/parsers/obligation.js +19 -26
- package/parsers/rateLimiter.js +11 -19
- package/parsers/reserve.d.ts +1 -1
- package/parsers/reserve.js +42 -85
- package/strategies.d.ts +11 -11
- package/strategies.js +547 -586
- package/swap/index.js +2 -18
- package/swap/quote.js +57 -65
- package/swap/transaction.d.ts +2 -2
- package/swap/transaction.js +40 -35
- package/utils/events.d.ts +3 -3
- package/utils/events.js +18 -35
- package/utils/index.js +16 -40
- package/utils/obligation.d.ts +4 -4
- package/utils/obligation.js +17 -60
- package/utils/simulate.js +118 -143
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,33 +7,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const util_1 = require("../../../../_framework/util");
|
|
17
|
-
const index_1 = require("../index");
|
|
18
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
19
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
|
|
12
|
+
import { PKG_V30 } from "../index";
|
|
13
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
14
|
+
import { fromBase64, fromHex, toHex } from "@mysten/sui/utils";
|
|
20
15
|
/* ============================== ID =============================== */
|
|
21
|
-
function isID(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type === `${
|
|
16
|
+
export function isID(type) {
|
|
17
|
+
type = compressSuiType(type);
|
|
18
|
+
return type === `${PKG_V30}::object::ID`;
|
|
24
19
|
}
|
|
25
|
-
class ID {
|
|
20
|
+
export class ID {
|
|
26
21
|
constructor(typeArgs, fields) {
|
|
27
22
|
this.__StructClass = true;
|
|
28
23
|
this.$typeName = ID.$typeName;
|
|
29
24
|
this.$isPhantom = ID.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
25
|
+
this.$fullTypeName = composeSuiType(ID.$typeName, ...typeArgs);
|
|
31
26
|
this.$typeArgs = typeArgs;
|
|
32
27
|
this.bytes = fields.bytes;
|
|
33
28
|
}
|
|
34
29
|
static reified() {
|
|
35
30
|
return {
|
|
36
31
|
typeName: ID.$typeName,
|
|
37
|
-
fullTypeName:
|
|
32
|
+
fullTypeName: composeSuiType(ID.$typeName, ...[]),
|
|
38
33
|
typeArgs: [],
|
|
39
34
|
isPhantom: ID.$isPhantom,
|
|
40
35
|
reifiedTypeArgs: [],
|
|
@@ -57,24 +52,24 @@ class ID {
|
|
|
57
52
|
return ID.reified();
|
|
58
53
|
}
|
|
59
54
|
static phantom() {
|
|
60
|
-
return
|
|
55
|
+
return phantom(ID.reified());
|
|
61
56
|
}
|
|
62
57
|
static get p() {
|
|
63
58
|
return ID.phantom();
|
|
64
59
|
}
|
|
65
60
|
static get bcs() {
|
|
66
|
-
return
|
|
67
|
-
bytes:
|
|
61
|
+
return bcs.struct("ID", {
|
|
62
|
+
bytes: bcs
|
|
68
63
|
.bytes(32)
|
|
69
64
|
.transform({
|
|
70
|
-
input: (val) => (
|
|
71
|
-
output: (val) => (
|
|
65
|
+
input: (val) => fromHex(val),
|
|
66
|
+
output: (val) => toHex(val),
|
|
72
67
|
}),
|
|
73
68
|
});
|
|
74
69
|
}
|
|
75
70
|
static fromFields(fields) {
|
|
76
71
|
return ID.reified().new({
|
|
77
|
-
bytes:
|
|
72
|
+
bytes: decodeFromFields("address", fields.bytes),
|
|
78
73
|
});
|
|
79
74
|
}
|
|
80
75
|
static fromFieldsWithTypes(item) {
|
|
@@ -82,7 +77,7 @@ class ID {
|
|
|
82
77
|
throw new Error("not a ID type");
|
|
83
78
|
}
|
|
84
79
|
return ID.reified().new({
|
|
85
|
-
bytes:
|
|
80
|
+
bytes: decodeFromFieldsWithTypes("address", item.fields.bytes),
|
|
86
81
|
});
|
|
87
82
|
}
|
|
88
83
|
static fromBcs(data) {
|
|
@@ -98,7 +93,7 @@ class ID {
|
|
|
98
93
|
}
|
|
99
94
|
static fromJSONField(field) {
|
|
100
95
|
return ID.reified().new({
|
|
101
|
-
bytes:
|
|
96
|
+
bytes: decodeFromJSONField("address", field.bytes),
|
|
102
97
|
});
|
|
103
98
|
}
|
|
104
99
|
static fromJSON(json) {
|
|
@@ -121,7 +116,7 @@ class ID {
|
|
|
121
116
|
if (data.bcs.dataType !== "moveObject" || !isID(data.bcs.type)) {
|
|
122
117
|
throw new Error(`object at is not a ID object`);
|
|
123
118
|
}
|
|
124
|
-
return ID.fromBcs((
|
|
119
|
+
return ID.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
125
120
|
}
|
|
126
121
|
if (data.content) {
|
|
127
122
|
return ID.fromSuiParsedData(data.content);
|
|
@@ -142,28 +137,27 @@ class ID {
|
|
|
142
137
|
});
|
|
143
138
|
}
|
|
144
139
|
}
|
|
145
|
-
|
|
146
|
-
ID.$typeName = `${index_1.PKG_V30}::object::ID`;
|
|
140
|
+
ID.$typeName = `${PKG_V30}::object::ID`;
|
|
147
141
|
ID.$numTypeParams = 0;
|
|
148
142
|
ID.$isPhantom = [];
|
|
149
143
|
/* ============================== UID =============================== */
|
|
150
|
-
function isUID(type) {
|
|
151
|
-
type =
|
|
152
|
-
return type === `${
|
|
144
|
+
export function isUID(type) {
|
|
145
|
+
type = compressSuiType(type);
|
|
146
|
+
return type === `${PKG_V30}::object::UID`;
|
|
153
147
|
}
|
|
154
|
-
class UID {
|
|
148
|
+
export class UID {
|
|
155
149
|
constructor(typeArgs, fields) {
|
|
156
150
|
this.__StructClass = true;
|
|
157
151
|
this.$typeName = UID.$typeName;
|
|
158
152
|
this.$isPhantom = UID.$isPhantom;
|
|
159
|
-
this.$fullTypeName =
|
|
153
|
+
this.$fullTypeName = composeSuiType(UID.$typeName, ...typeArgs);
|
|
160
154
|
this.$typeArgs = typeArgs;
|
|
161
155
|
this.id = fields.id;
|
|
162
156
|
}
|
|
163
157
|
static reified() {
|
|
164
158
|
return {
|
|
165
159
|
typeName: UID.$typeName,
|
|
166
|
-
fullTypeName:
|
|
160
|
+
fullTypeName: composeSuiType(UID.$typeName, ...[]),
|
|
167
161
|
typeArgs: [],
|
|
168
162
|
isPhantom: UID.$isPhantom,
|
|
169
163
|
reifiedTypeArgs: [],
|
|
@@ -186,25 +180,25 @@ class UID {
|
|
|
186
180
|
return UID.reified();
|
|
187
181
|
}
|
|
188
182
|
static phantom() {
|
|
189
|
-
return
|
|
183
|
+
return phantom(UID.reified());
|
|
190
184
|
}
|
|
191
185
|
static get p() {
|
|
192
186
|
return UID.phantom();
|
|
193
187
|
}
|
|
194
188
|
static get bcs() {
|
|
195
|
-
return
|
|
189
|
+
return bcs.struct("UID", {
|
|
196
190
|
id: ID.bcs,
|
|
197
191
|
});
|
|
198
192
|
}
|
|
199
193
|
static fromFields(fields) {
|
|
200
|
-
return UID.reified().new({ id:
|
|
194
|
+
return UID.reified().new({ id: decodeFromFields(ID.reified(), fields.id) });
|
|
201
195
|
}
|
|
202
196
|
static fromFieldsWithTypes(item) {
|
|
203
197
|
if (!isUID(item.type)) {
|
|
204
198
|
throw new Error("not a UID type");
|
|
205
199
|
}
|
|
206
200
|
return UID.reified().new({
|
|
207
|
-
id:
|
|
201
|
+
id: decodeFromFieldsWithTypes(ID.reified(), item.fields.id),
|
|
208
202
|
});
|
|
209
203
|
}
|
|
210
204
|
static fromBcs(data) {
|
|
@@ -220,7 +214,7 @@ class UID {
|
|
|
220
214
|
}
|
|
221
215
|
static fromJSONField(field) {
|
|
222
216
|
return UID.reified().new({
|
|
223
|
-
id:
|
|
217
|
+
id: decodeFromJSONField(ID.reified(), field.id),
|
|
224
218
|
});
|
|
225
219
|
}
|
|
226
220
|
static fromJSON(json) {
|
|
@@ -243,7 +237,7 @@ class UID {
|
|
|
243
237
|
if (data.bcs.dataType !== "moveObject" || !isUID(data.bcs.type)) {
|
|
244
238
|
throw new Error(`object at is not a UID object`);
|
|
245
239
|
}
|
|
246
|
-
return UID.fromBcs((
|
|
240
|
+
return UID.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
247
241
|
}
|
|
248
242
|
if (data.content) {
|
|
249
243
|
return UID.fromSuiParsedData(data.content);
|
|
@@ -264,7 +258,6 @@ class UID {
|
|
|
264
258
|
});
|
|
265
259
|
}
|
|
266
260
|
}
|
|
267
|
-
|
|
268
|
-
UID.$typeName = `${index_1.PKG_V30}::object::UID`;
|
|
261
|
+
UID.$typeName = `${PKG_V30}::object::UID`;
|
|
269
262
|
UID.$numTypeParams = 0;
|
|
270
263
|
UID.$isPhantom = [];
|
|
@@ -2,7 +2,7 @@ import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructC
|
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { PKG_V30 } from "../index";
|
|
4
4
|
import { UID } from "../object/structs";
|
|
5
|
-
import {
|
|
5
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
6
6
|
export declare function isObjectTable(type: string): boolean;
|
|
7
7
|
export interface ObjectTableFields<K extends PhantomTypeArgument, V extends PhantomTypeArgument> {
|
|
8
8
|
id: ToField<UID>;
|
|
@@ -25,13 +25,13 @@ export declare class ObjectTable<K extends PhantomTypeArgument, V extends Phanto
|
|
|
25
25
|
static get r(): typeof ObjectTable.reified;
|
|
26
26
|
static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): PhantomReified<ToTypeStr<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>>;
|
|
27
27
|
static get p(): typeof ObjectTable.phantom;
|
|
28
|
-
static get bcs(): import("@mysten/
|
|
29
|
-
id: import("@mysten/
|
|
30
|
-
id: import("@mysten/
|
|
31
|
-
bytes: import("@mysten/
|
|
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/
|
|
34
|
+
size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
35
35
|
}, string>;
|
|
36
36
|
static fromFields<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], fields: Record<string, any>): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
37
37
|
static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], item: FieldsWithTypes): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
@@ -50,5 +50,5 @@ export declare class ObjectTable<K extends PhantomTypeArgument, V extends Phanto
|
|
|
50
50
|
static fromJSON<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], json: Record<string, any>): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
51
51
|
static fromSuiParsedData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], content: SuiParsedData): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
52
52
|
static fromSuiObjectData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: SuiObjectData): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
53
|
-
static fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(client:
|
|
53
|
+
static fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(client: SuiJsonRpcClient, typeArgs: [K, V], id: string): Promise<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>;
|
|
54
54
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,26 +7,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const structs_1 = require("../object/structs");
|
|
18
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
19
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, parseTypeName, } from "../../../../_framework/util";
|
|
12
|
+
import { PKG_V30 } from "../index";
|
|
13
|
+
import { UID } from "../object/structs";
|
|
14
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
20
16
|
/* ============================== ObjectTable =============================== */
|
|
21
|
-
function isObjectTable(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type.startsWith(`${
|
|
17
|
+
export function isObjectTable(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type.startsWith(`${PKG_V30}::object_table::ObjectTable` + "<");
|
|
24
20
|
}
|
|
25
|
-
class ObjectTable {
|
|
21
|
+
export class ObjectTable {
|
|
26
22
|
constructor(typeArgs, fields) {
|
|
27
23
|
this.__StructClass = true;
|
|
28
24
|
this.$typeName = ObjectTable.$typeName;
|
|
29
25
|
this.$isPhantom = ObjectTable.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(ObjectTable.$typeName, ...typeArgs);
|
|
31
27
|
this.$typeArgs = typeArgs;
|
|
32
28
|
this.id = fields.id;
|
|
33
29
|
this.size = fields.size;
|
|
@@ -35,8 +31,8 @@ class ObjectTable {
|
|
|
35
31
|
static reified(K, V) {
|
|
36
32
|
return {
|
|
37
33
|
typeName: ObjectTable.$typeName,
|
|
38
|
-
fullTypeName:
|
|
39
|
-
typeArgs: [
|
|
34
|
+
fullTypeName: composeSuiType(ObjectTable.$typeName, ...[extractType(K), extractType(V)]),
|
|
35
|
+
typeArgs: [extractType(K), extractType(V)],
|
|
40
36
|
isPhantom: ObjectTable.$isPhantom,
|
|
41
37
|
reifiedTypeArgs: [K, V],
|
|
42
38
|
fromFields: (fields) => ObjectTable.fromFields([K, V], fields),
|
|
@@ -49,7 +45,7 @@ class ObjectTable {
|
|
|
49
45
|
fromSuiObjectData: (content) => ObjectTable.fromSuiObjectData([K, V], content),
|
|
50
46
|
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ObjectTable.fetch(client, [K, V], id); }),
|
|
51
47
|
new: (fields) => {
|
|
52
|
-
return new ObjectTable([
|
|
48
|
+
return new ObjectTable([extractType(K), extractType(V)], fields);
|
|
53
49
|
},
|
|
54
50
|
kind: "StructClassReified",
|
|
55
51
|
};
|
|
@@ -58,31 +54,31 @@ class ObjectTable {
|
|
|
58
54
|
return ObjectTable.reified;
|
|
59
55
|
}
|
|
60
56
|
static phantom(K, V) {
|
|
61
|
-
return
|
|
57
|
+
return phantom(ObjectTable.reified(K, V));
|
|
62
58
|
}
|
|
63
59
|
static get p() {
|
|
64
60
|
return ObjectTable.phantom;
|
|
65
61
|
}
|
|
66
62
|
static get bcs() {
|
|
67
|
-
return
|
|
68
|
-
id:
|
|
69
|
-
size:
|
|
63
|
+
return bcs.struct("ObjectTable", {
|
|
64
|
+
id: UID.bcs,
|
|
65
|
+
size: bcs.u64(),
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
68
|
static fromFields(typeArgs, fields) {
|
|
73
69
|
return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
|
|
74
|
-
id:
|
|
75
|
-
size:
|
|
70
|
+
id: decodeFromFields(UID.reified(), fields.id),
|
|
71
|
+
size: decodeFromFields("u64", fields.size),
|
|
76
72
|
});
|
|
77
73
|
}
|
|
78
74
|
static fromFieldsWithTypes(typeArgs, item) {
|
|
79
75
|
if (!isObjectTable(item.type)) {
|
|
80
76
|
throw new Error("not a ObjectTable type");
|
|
81
77
|
}
|
|
82
|
-
|
|
78
|
+
assertFieldsWithTypesArgsMatch(item, typeArgs);
|
|
83
79
|
return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
|
|
84
|
-
id:
|
|
85
|
-
size:
|
|
80
|
+
id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
|
|
81
|
+
size: decodeFromFieldsWithTypes("u64", item.fields.size),
|
|
86
82
|
});
|
|
87
83
|
}
|
|
88
84
|
static fromBcs(typeArgs, data) {
|
|
@@ -99,15 +95,15 @@ class ObjectTable {
|
|
|
99
95
|
}
|
|
100
96
|
static fromJSONField(typeArgs, field) {
|
|
101
97
|
return ObjectTable.reified(typeArgs[0], typeArgs[1]).new({
|
|
102
|
-
id:
|
|
103
|
-
size:
|
|
98
|
+
id: decodeFromJSONField(UID.reified(), field.id),
|
|
99
|
+
size: decodeFromJSONField("u64", field.size),
|
|
104
100
|
});
|
|
105
101
|
}
|
|
106
102
|
static fromJSON(typeArgs, json) {
|
|
107
103
|
if (json.$typeName !== ObjectTable.$typeName) {
|
|
108
104
|
throw new Error("not a WithTwoGenerics json object");
|
|
109
105
|
}
|
|
110
|
-
|
|
106
|
+
assertReifiedTypeArgsMatch(composeSuiType(ObjectTable.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
|
|
111
107
|
return ObjectTable.fromJSONField(typeArgs, json);
|
|
112
108
|
}
|
|
113
109
|
static fromSuiParsedData(typeArgs, content) {
|
|
@@ -124,18 +120,18 @@ class ObjectTable {
|
|
|
124
120
|
if (data.bcs.dataType !== "moveObject" || !isObjectTable(data.bcs.type)) {
|
|
125
121
|
throw new Error(`object at is not a ObjectTable object`);
|
|
126
122
|
}
|
|
127
|
-
const gotTypeArgs =
|
|
123
|
+
const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
|
|
128
124
|
if (gotTypeArgs.length !== 2) {
|
|
129
125
|
throw new Error(`type argument mismatch: expected 2 type arguments but got ${gotTypeArgs.length}`);
|
|
130
126
|
}
|
|
131
127
|
for (let i = 0; i < 2; i++) {
|
|
132
|
-
const gotTypeArg =
|
|
133
|
-
const expectedTypeArg =
|
|
128
|
+
const gotTypeArg = compressSuiType(gotTypeArgs[i]);
|
|
129
|
+
const expectedTypeArg = compressSuiType(extractType(typeArgs[i]));
|
|
134
130
|
if (gotTypeArg !== expectedTypeArg) {
|
|
135
131
|
throw new Error(`type argument mismatch at position ${i}: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
|
|
136
132
|
}
|
|
137
133
|
}
|
|
138
|
-
return ObjectTable.fromBcs(typeArgs, (
|
|
134
|
+
return ObjectTable.fromBcs(typeArgs, fromBase64(data.bcs.bcsBytes));
|
|
139
135
|
}
|
|
140
136
|
if (data.content) {
|
|
141
137
|
return ObjectTable.fromSuiParsedData(typeArgs, data.content);
|
|
@@ -157,7 +153,6 @@ class ObjectTable {
|
|
|
157
153
|
});
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
|
-
|
|
161
|
-
ObjectTable.$typeName = `${index_1.PKG_V30}::object_table::ObjectTable`;
|
|
156
|
+
ObjectTable.$typeName = `${PKG_V30}::object_table::ObjectTable`;
|
|
162
157
|
ObjectTable.$numTypeParams = 2;
|
|
163
158
|
ObjectTable.$isPhantom = [true, true];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { PKG_V1 } from "../index";
|
|
4
|
-
import {
|
|
4
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
5
5
|
export declare function isI64(type: string): boolean;
|
|
6
6
|
export interface I64Fields {
|
|
7
7
|
negative: ToField<"bool">;
|
|
@@ -24,9 +24,9 @@ export declare class I64 implements StructClass {
|
|
|
24
24
|
static get r(): import("../../../../_framework/reified").StructClassReified<I64, I64Fields>;
|
|
25
25
|
static phantom(): PhantomReified<ToTypeStr<I64>>;
|
|
26
26
|
static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::i64::I64">;
|
|
27
|
-
static get bcs(): import("@mysten/
|
|
28
|
-
negative: import("@mysten/
|
|
29
|
-
magnitude: import("@mysten/
|
|
27
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
28
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
29
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
30
30
|
}, string>;
|
|
31
31
|
static fromFields(fields: Record<string, any>): I64;
|
|
32
32
|
static fromFieldsWithTypes(item: FieldsWithTypes): I64;
|
|
@@ -45,5 +45,5 @@ export declare class I64 implements StructClass {
|
|
|
45
45
|
static fromJSON(json: Record<string, any>): I64;
|
|
46
46
|
static fromSuiParsedData(content: SuiParsedData): I64;
|
|
47
47
|
static fromSuiObjectData(data: SuiObjectData): I64;
|
|
48
|
-
static fetch(client:
|
|
48
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<I64>;
|
|
49
49
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,25 +7,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const index_1 = require("../index");
|
|
17
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
18
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
10
|
+
import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
|
|
12
|
+
import { PKG_V1 } from "../index";
|
|
13
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
14
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
19
15
|
/* ============================== I64 =============================== */
|
|
20
|
-
function isI64(type) {
|
|
21
|
-
type =
|
|
22
|
-
return type === `${
|
|
16
|
+
export function isI64(type) {
|
|
17
|
+
type = compressSuiType(type);
|
|
18
|
+
return type === `${PKG_V1}::i64::I64`;
|
|
23
19
|
}
|
|
24
|
-
class I64 {
|
|
20
|
+
export class I64 {
|
|
25
21
|
constructor(typeArgs, fields) {
|
|
26
22
|
this.__StructClass = true;
|
|
27
23
|
this.$typeName = I64.$typeName;
|
|
28
24
|
this.$isPhantom = I64.$isPhantom;
|
|
29
|
-
this.$fullTypeName =
|
|
25
|
+
this.$fullTypeName = composeSuiType(I64.$typeName, ...typeArgs);
|
|
30
26
|
this.$typeArgs = typeArgs;
|
|
31
27
|
this.negative = fields.negative;
|
|
32
28
|
this.magnitude = fields.magnitude;
|
|
@@ -34,7 +30,7 @@ class I64 {
|
|
|
34
30
|
static reified() {
|
|
35
31
|
return {
|
|
36
32
|
typeName: I64.$typeName,
|
|
37
|
-
fullTypeName:
|
|
33
|
+
fullTypeName: composeSuiType(I64.$typeName, ...[]),
|
|
38
34
|
typeArgs: [],
|
|
39
35
|
isPhantom: I64.$isPhantom,
|
|
40
36
|
reifiedTypeArgs: [],
|
|
@@ -57,21 +53,21 @@ class I64 {
|
|
|
57
53
|
return I64.reified();
|
|
58
54
|
}
|
|
59
55
|
static phantom() {
|
|
60
|
-
return
|
|
56
|
+
return phantom(I64.reified());
|
|
61
57
|
}
|
|
62
58
|
static get p() {
|
|
63
59
|
return I64.phantom();
|
|
64
60
|
}
|
|
65
61
|
static get bcs() {
|
|
66
|
-
return
|
|
67
|
-
negative:
|
|
68
|
-
magnitude:
|
|
62
|
+
return bcs.struct("I64", {
|
|
63
|
+
negative: bcs.bool(),
|
|
64
|
+
magnitude: bcs.u64(),
|
|
69
65
|
});
|
|
70
66
|
}
|
|
71
67
|
static fromFields(fields) {
|
|
72
68
|
return I64.reified().new({
|
|
73
|
-
negative:
|
|
74
|
-
magnitude:
|
|
69
|
+
negative: decodeFromFields("bool", fields.negative),
|
|
70
|
+
magnitude: decodeFromFields("u64", fields.magnitude),
|
|
75
71
|
});
|
|
76
72
|
}
|
|
77
73
|
static fromFieldsWithTypes(item) {
|
|
@@ -79,8 +75,8 @@ class I64 {
|
|
|
79
75
|
throw new Error("not a I64 type");
|
|
80
76
|
}
|
|
81
77
|
return I64.reified().new({
|
|
82
|
-
negative:
|
|
83
|
-
magnitude:
|
|
78
|
+
negative: decodeFromFieldsWithTypes("bool", item.fields.negative),
|
|
79
|
+
magnitude: decodeFromFieldsWithTypes("u64", item.fields.magnitude),
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
82
|
static fromBcs(data) {
|
|
@@ -97,8 +93,8 @@ class I64 {
|
|
|
97
93
|
}
|
|
98
94
|
static fromJSONField(field) {
|
|
99
95
|
return I64.reified().new({
|
|
100
|
-
negative:
|
|
101
|
-
magnitude:
|
|
96
|
+
negative: decodeFromJSONField("bool", field.negative),
|
|
97
|
+
magnitude: decodeFromJSONField("u64", field.magnitude),
|
|
102
98
|
});
|
|
103
99
|
}
|
|
104
100
|
static fromJSON(json) {
|
|
@@ -121,7 +117,7 @@ class I64 {
|
|
|
121
117
|
if (data.bcs.dataType !== "moveObject" || !isI64(data.bcs.type)) {
|
|
122
118
|
throw new Error(`object at is not a I64 object`);
|
|
123
119
|
}
|
|
124
|
-
return I64.fromBcs((
|
|
120
|
+
return I64.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
125
121
|
}
|
|
126
122
|
if (data.content) {
|
|
127
123
|
return I64.fromSuiParsedData(data.content);
|
|
@@ -142,7 +138,6 @@ class I64 {
|
|
|
142
138
|
});
|
|
143
139
|
}
|
|
144
140
|
}
|
|
145
|
-
|
|
146
|
-
I64.$typeName = `${index_1.PKG_V1}::i64::I64`;
|
|
141
|
+
I64.$typeName = `${PKG_V1}::i64::I64`;
|
|
147
142
|
I64.$numTypeParams = 0;
|
|
148
143
|
I64.$isPhantom = [];
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.PUBLISHED_AT = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
|
|
6
|
-
exports.PKG_V2 = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
|
|
7
|
-
exports.PKG_V1 = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
|
|
1
|
+
export const PACKAGE_ID = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
|
|
2
|
+
export const PUBLISHED_AT = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
|
|
3
|
+
export const PKG_V2 = "0x4e20ddf36af412a4096f9014f4a565af9e812db9a05cc40254846cf6ed0ad91";
|
|
4
|
+
export const PKG_V1 = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e";
|
|
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { I64 } from "../i64/structs";
|
|
4
4
|
import { PKG_V1 } from "../index";
|
|
5
|
-
import {
|
|
5
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
6
6
|
export declare function isPrice(type: string): boolean;
|
|
7
7
|
export interface PriceFields {
|
|
8
8
|
price: ToField<I64>;
|
|
@@ -29,17 +29,17 @@ export declare class Price implements StructClass {
|
|
|
29
29
|
static get r(): import("../../../../_framework/reified").StructClassReified<Price, PriceFields>;
|
|
30
30
|
static phantom(): PhantomReified<ToTypeStr<Price>>;
|
|
31
31
|
static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price::Price">;
|
|
32
|
-
static get bcs(): import("@mysten/
|
|
33
|
-
price: import("@mysten/
|
|
34
|
-
negative: import("@mysten/
|
|
35
|
-
magnitude: import("@mysten/
|
|
32
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
33
|
+
price: import("@mysten/bcs").BcsStruct<{
|
|
34
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
35
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
36
36
|
}, string>;
|
|
37
|
-
conf: import("@mysten/
|
|
38
|
-
expo: import("@mysten/
|
|
39
|
-
negative: import("@mysten/
|
|
40
|
-
magnitude: import("@mysten/
|
|
37
|
+
conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
38
|
+
expo: import("@mysten/bcs").BcsStruct<{
|
|
39
|
+
negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
40
|
+
magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
41
41
|
}, string>;
|
|
42
|
-
timestamp: import("@mysten/
|
|
42
|
+
timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
43
43
|
}, string>;
|
|
44
44
|
static fromFields(fields: Record<string, any>): Price;
|
|
45
45
|
static fromFieldsWithTypes(item: FieldsWithTypes): Price;
|
|
@@ -74,5 +74,5 @@ export declare class Price implements StructClass {
|
|
|
74
74
|
static fromJSON(json: Record<string, any>): Price;
|
|
75
75
|
static fromSuiParsedData(content: SuiParsedData): Price;
|
|
76
76
|
static fromSuiObjectData(data: SuiObjectData): Price;
|
|
77
|
-
static fetch(client:
|
|
77
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<Price>;
|
|
78
78
|
}
|