@suilend/springsui-cli 1.0.13 → 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/cli/src/bytecode.js +28 -30
- package/cli/src/index.js +51 -86
- package/package.json +1 -1
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/sdk/src/_generated/_dependencies/source/0x1/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +21 -59
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +52 -52
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +206 -223
- package/sdk/src/_generated/_dependencies/source/0x2/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +19 -24
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +31 -36
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +20 -25
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +57 -97
- package/sdk/src/_generated/_dependencies/source/0x3/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +60 -60
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +170 -218
- package/sdk/src/_generated/_framework/reified.d.ts +2 -2
- package/sdk/src/_generated/_framework/reified.js +27 -40
- package/sdk/src/_generated/_framework/util.d.ts +2 -14
- package/sdk/src/_generated/_framework/util.js +26 -40
- package/sdk/src/_generated/_framework/vector.d.ts +4 -4
- package/sdk/src/_generated/_framework/vector.js +16 -21
- package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +4 -4
- package/sdk/src/_generated/liquid_staking/cell/structs.js +31 -36
- package/sdk/src/_generated/liquid_staking/fees/functions.js +55 -75
- package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +21 -21
- package/sdk/src/_generated/liquid_staking/fees/structs.js +58 -65
- package/sdk/src/_generated/liquid_staking/index.js +6 -10
- package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +86 -107
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +98 -98
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +264 -320
- package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +31 -31
- package/sdk/src/_generated/liquid_staking/storage/structs.js +85 -125
- package/sdk/src/_generated/liquid_staking/version/structs.d.ts +4 -4
- package/sdk/src/_generated/liquid_staking/version/structs.js +19 -24
- package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -56
- package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +41 -41
- package/sdk/src/_generated/liquid_staking/weight/structs.js +128 -141
- package/sdk/src/client.d.ts +16 -16
- package/sdk/src/client.js +39 -82
- package/sdk/src/index.js +2 -18
- package/sdk/src/lib/index.js +1 -17
- package/sdk/src/lib/transactions.d.ts +1 -1
- package/sdk/src/lib/transactions.js +3 -8
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.PACKAGE_ID = "0x2";
|
|
5
|
-
exports.PUBLISHED_AT = "0x2";
|
|
6
|
-
exports.PKG_V31 = "0x2";
|
|
1
|
+
export const PACKAGE_ID = "0x2";
|
|
2
|
+
export const PUBLISHED_AT = "0x2";
|
|
3
|
+
export const PKG_V31 = "0x2";
|
|
@@ -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_V31 } from "../index";
|
|
4
|
-
import {
|
|
4
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
5
5
|
export declare function isID(type: string): boolean;
|
|
6
6
|
export interface IDFields {
|
|
7
7
|
bytes: ToField<"address">;
|
|
@@ -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/
|
|
26
|
-
bytes: import("@mysten/
|
|
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;
|
|
@@ -40,7 +40,7 @@ export declare class ID implements StructClass {
|
|
|
40
40
|
static fromJSON(json: Record<string, any>): ID;
|
|
41
41
|
static fromSuiParsedData(content: SuiParsedData): ID;
|
|
42
42
|
static fromSuiObjectData(data: SuiObjectData): ID;
|
|
43
|
-
static fetch(client:
|
|
43
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<ID>;
|
|
44
44
|
}
|
|
45
45
|
export declare function isUID(type: string): boolean;
|
|
46
46
|
export interface UIDFields {
|
|
@@ -62,9 +62,9 @@ export declare class UID implements StructClass {
|
|
|
62
62
|
static get r(): import("../../../../_framework/reified").StructClassReified<UID, UIDFields>;
|
|
63
63
|
static phantom(): PhantomReified<ToTypeStr<UID>>;
|
|
64
64
|
static get p(): PhantomReified<"0x2::object::UID">;
|
|
65
|
-
static get bcs(): import("@mysten/
|
|
66
|
-
id: import("@mysten/
|
|
67
|
-
bytes: import("@mysten/
|
|
65
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
66
|
+
id: import("@mysten/bcs").BcsStruct<{
|
|
67
|
+
bytes: import("@mysten/bcs").BcsType<string, string, string>;
|
|
68
68
|
}, string>;
|
|
69
69
|
}, string>;
|
|
70
70
|
static fromFields(fields: Record<string, any>): UID;
|
|
@@ -82,5 +82,5 @@ export declare class UID implements StructClass {
|
|
|
82
82
|
static fromJSON(json: Record<string, any>): UID;
|
|
83
83
|
static fromSuiParsedData(content: SuiParsedData): UID;
|
|
84
84
|
static fromSuiObjectData(data: SuiObjectData): UID;
|
|
85
|
-
static fetch(client:
|
|
85
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<UID>;
|
|
86
86
|
}
|
|
@@ -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_V31 } 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_V31}::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_V31}::object::ID`;
|
|
140
|
+
ID.$typeName = `${PKG_V31}::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_V31}::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_V31}::object::UID`;
|
|
261
|
+
UID.$typeName = `${PKG_V31}::object::UID`;
|
|
269
262
|
UID.$numTypeParams = 0;
|
|
270
263
|
UID.$isPhantom = [];
|
|
@@ -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_V31 } from "../index";
|
|
4
|
-
import {
|
|
4
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
5
5
|
export declare function isSUI(type: string): boolean;
|
|
6
6
|
export interface SUIFields {
|
|
7
7
|
dummyField: ToField<"bool">;
|
|
@@ -22,8 +22,8 @@ export declare class SUI implements StructClass {
|
|
|
22
22
|
static get r(): import("../../../../_framework/reified").StructClassReified<SUI, SUIFields>;
|
|
23
23
|
static phantom(): PhantomReified<ToTypeStr<SUI>>;
|
|
24
24
|
static get p(): PhantomReified<"0x2::sui::SUI">;
|
|
25
|
-
static get bcs(): import("@mysten/
|
|
26
|
-
dummy_field: import("@mysten/
|
|
25
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
26
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
27
27
|
}, string>;
|
|
28
28
|
static fromFields(fields: Record<string, any>): SUI;
|
|
29
29
|
static fromFieldsWithTypes(item: FieldsWithTypes): SUI;
|
|
@@ -40,5 +40,5 @@ export declare class SUI implements StructClass {
|
|
|
40
40
|
static fromJSON(json: Record<string, any>): SUI;
|
|
41
41
|
static fromSuiParsedData(content: SuiParsedData): SUI;
|
|
42
42
|
static fromSuiObjectData(data: SuiObjectData): SUI;
|
|
43
|
-
static fetch(client:
|
|
43
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<SUI>;
|
|
44
44
|
}
|
|
@@ -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,32 +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 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_V31 } from "../index";
|
|
13
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
14
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
19
15
|
/* ============================== SUI =============================== */
|
|
20
|
-
function isSUI(type) {
|
|
21
|
-
type =
|
|
22
|
-
return type === `${
|
|
16
|
+
export function isSUI(type) {
|
|
17
|
+
type = compressSuiType(type);
|
|
18
|
+
return type === `${PKG_V31}::sui::SUI`;
|
|
23
19
|
}
|
|
24
|
-
class SUI {
|
|
20
|
+
export class SUI {
|
|
25
21
|
constructor(typeArgs, fields) {
|
|
26
22
|
this.__StructClass = true;
|
|
27
23
|
this.$typeName = SUI.$typeName;
|
|
28
24
|
this.$isPhantom = SUI.$isPhantom;
|
|
29
|
-
this.$fullTypeName =
|
|
25
|
+
this.$fullTypeName = composeSuiType(SUI.$typeName, ...typeArgs);
|
|
30
26
|
this.$typeArgs = typeArgs;
|
|
31
27
|
this.dummyField = fields.dummyField;
|
|
32
28
|
}
|
|
33
29
|
static reified() {
|
|
34
30
|
return {
|
|
35
31
|
typeName: SUI.$typeName,
|
|
36
|
-
fullTypeName:
|
|
32
|
+
fullTypeName: composeSuiType(SUI.$typeName, ...[]),
|
|
37
33
|
typeArgs: [],
|
|
38
34
|
isPhantom: SUI.$isPhantom,
|
|
39
35
|
reifiedTypeArgs: [],
|
|
@@ -56,19 +52,19 @@ class SUI {
|
|
|
56
52
|
return SUI.reified();
|
|
57
53
|
}
|
|
58
54
|
static phantom() {
|
|
59
|
-
return
|
|
55
|
+
return phantom(SUI.reified());
|
|
60
56
|
}
|
|
61
57
|
static get p() {
|
|
62
58
|
return SUI.phantom();
|
|
63
59
|
}
|
|
64
60
|
static get bcs() {
|
|
65
|
-
return
|
|
66
|
-
dummy_field:
|
|
61
|
+
return bcs.struct("SUI", {
|
|
62
|
+
dummy_field: bcs.bool(),
|
|
67
63
|
});
|
|
68
64
|
}
|
|
69
65
|
static fromFields(fields) {
|
|
70
66
|
return SUI.reified().new({
|
|
71
|
-
dummyField:
|
|
67
|
+
dummyField: decodeFromFields("bool", fields.dummy_field),
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
70
|
static fromFieldsWithTypes(item) {
|
|
@@ -76,7 +72,7 @@ class SUI {
|
|
|
76
72
|
throw new Error("not a SUI type");
|
|
77
73
|
}
|
|
78
74
|
return SUI.reified().new({
|
|
79
|
-
dummyField:
|
|
75
|
+
dummyField: decodeFromFieldsWithTypes("bool", item.fields.dummy_field),
|
|
80
76
|
});
|
|
81
77
|
}
|
|
82
78
|
static fromBcs(data) {
|
|
@@ -92,7 +88,7 @@ class SUI {
|
|
|
92
88
|
}
|
|
93
89
|
static fromJSONField(field) {
|
|
94
90
|
return SUI.reified().new({
|
|
95
|
-
dummyField:
|
|
91
|
+
dummyField: decodeFromJSONField("bool", field.dummyField),
|
|
96
92
|
});
|
|
97
93
|
}
|
|
98
94
|
static fromJSON(json) {
|
|
@@ -115,7 +111,7 @@ class SUI {
|
|
|
115
111
|
if (data.bcs.dataType !== "moveObject" || !isSUI(data.bcs.type)) {
|
|
116
112
|
throw new Error(`object at is not a SUI object`);
|
|
117
113
|
}
|
|
118
|
-
return SUI.fromBcs((
|
|
114
|
+
return SUI.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
119
115
|
}
|
|
120
116
|
if (data.content) {
|
|
121
117
|
return SUI.fromSuiParsedData(data.content);
|
|
@@ -136,7 +132,6 @@ class SUI {
|
|
|
136
132
|
});
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
|
-
|
|
140
|
-
SUI.$typeName = `${index_1.PKG_V31}::sui::SUI`;
|
|
135
|
+
SUI.$typeName = `${PKG_V31}::sui::SUI`;
|
|
141
136
|
SUI.$numTypeParams = 0;
|
|
142
137
|
SUI.$isPhantom = [];
|
|
@@ -2,7 +2,7 @@ import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructC
|
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { PKG_V31 } 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 isTable(type: string): boolean;
|
|
7
7
|
export interface TableFields<K extends PhantomTypeArgument, V extends PhantomTypeArgument> {
|
|
8
8
|
id: ToField<UID>;
|
|
@@ -25,13 +25,13 @@ export declare class Table<K extends PhantomTypeArgument, V extends PhantomTypeA
|
|
|
25
25
|
static get r(): typeof Table.reified;
|
|
26
26
|
static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(K: K, V: V): PhantomReified<ToTypeStr<Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>>;
|
|
27
27
|
static get p(): typeof Table.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>): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
37
37
|
static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], item: FieldsWithTypes): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
@@ -50,5 +50,5 @@ export declare class Table<K extends PhantomTypeArgument, V extends PhantomTypeA
|
|
|
50
50
|
static fromJSON<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], json: Record<string, any>): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
51
51
|
static fromSuiParsedData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], content: SuiParsedData): Table<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>;
|
|
52
52
|
static fromSuiObjectData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>(typeArgs: [K, V], data: SuiObjectData): Table<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<Table<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_V31 } from "../index";
|
|
13
|
+
import { UID } from "../object/structs";
|
|
14
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
20
16
|
/* ============================== Table =============================== */
|
|
21
|
-
function isTable(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type.startsWith(`${
|
|
17
|
+
export function isTable(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type.startsWith(`${PKG_V31}::table::Table` + "<");
|
|
24
20
|
}
|
|
25
|
-
class Table {
|
|
21
|
+
export class Table {
|
|
26
22
|
constructor(typeArgs, fields) {
|
|
27
23
|
this.__StructClass = true;
|
|
28
24
|
this.$typeName = Table.$typeName;
|
|
29
25
|
this.$isPhantom = Table.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(Table.$typeName, ...typeArgs);
|
|
31
27
|
this.$typeArgs = typeArgs;
|
|
32
28
|
this.id = fields.id;
|
|
33
29
|
this.size = fields.size;
|
|
@@ -35,8 +31,8 @@ class Table {
|
|
|
35
31
|
static reified(K, V) {
|
|
36
32
|
return {
|
|
37
33
|
typeName: Table.$typeName,
|
|
38
|
-
fullTypeName:
|
|
39
|
-
typeArgs: [
|
|
34
|
+
fullTypeName: composeSuiType(Table.$typeName, ...[extractType(K), extractType(V)]),
|
|
35
|
+
typeArgs: [extractType(K), extractType(V)],
|
|
40
36
|
isPhantom: Table.$isPhantom,
|
|
41
37
|
reifiedTypeArgs: [K, V],
|
|
42
38
|
fromFields: (fields) => Table.fromFields([K, V], fields),
|
|
@@ -49,7 +45,7 @@ class Table {
|
|
|
49
45
|
fromSuiObjectData: (content) => Table.fromSuiObjectData([K, V], content),
|
|
50
46
|
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Table.fetch(client, [K, V], id); }),
|
|
51
47
|
new: (fields) => {
|
|
52
|
-
return new Table([
|
|
48
|
+
return new Table([extractType(K), extractType(V)], fields);
|
|
53
49
|
},
|
|
54
50
|
kind: "StructClassReified",
|
|
55
51
|
};
|
|
@@ -58,31 +54,31 @@ class Table {
|
|
|
58
54
|
return Table.reified;
|
|
59
55
|
}
|
|
60
56
|
static phantom(K, V) {
|
|
61
|
-
return
|
|
57
|
+
return phantom(Table.reified(K, V));
|
|
62
58
|
}
|
|
63
59
|
static get p() {
|
|
64
60
|
return Table.phantom;
|
|
65
61
|
}
|
|
66
62
|
static get bcs() {
|
|
67
|
-
return
|
|
68
|
-
id:
|
|
69
|
-
size:
|
|
63
|
+
return bcs.struct("Table", {
|
|
64
|
+
id: UID.bcs,
|
|
65
|
+
size: bcs.u64(),
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
68
|
static fromFields(typeArgs, fields) {
|
|
73
69
|
return Table.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 (!isTable(item.type)) {
|
|
80
76
|
throw new Error("not a Table type");
|
|
81
77
|
}
|
|
82
|
-
|
|
78
|
+
assertFieldsWithTypesArgsMatch(item, typeArgs);
|
|
83
79
|
return Table.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 Table {
|
|
|
99
95
|
}
|
|
100
96
|
static fromJSONField(typeArgs, field) {
|
|
101
97
|
return Table.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 !== Table.$typeName) {
|
|
108
104
|
throw new Error("not a WithTwoGenerics json object");
|
|
109
105
|
}
|
|
110
|
-
|
|
106
|
+
assertReifiedTypeArgsMatch(composeSuiType(Table.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs);
|
|
111
107
|
return Table.fromJSONField(typeArgs, json);
|
|
112
108
|
}
|
|
113
109
|
static fromSuiParsedData(typeArgs, content) {
|
|
@@ -124,18 +120,18 @@ class Table {
|
|
|
124
120
|
if (data.bcs.dataType !== "moveObject" || !isTable(data.bcs.type)) {
|
|
125
121
|
throw new Error(`object at is not a Table 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 Table.fromBcs(typeArgs, (
|
|
134
|
+
return Table.fromBcs(typeArgs, fromBase64(data.bcs.bcsBytes));
|
|
139
135
|
}
|
|
140
136
|
if (data.content) {
|
|
141
137
|
return Table.fromSuiParsedData(typeArgs, data.content);
|
|
@@ -157,7 +153,6 @@ class Table {
|
|
|
157
153
|
});
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
|
-
|
|
161
|
-
Table.$typeName = `${index_1.PKG_V31}::table::Table`;
|
|
156
|
+
Table.$typeName = `${PKG_V31}::table::Table`;
|
|
162
157
|
Table.$numTypeParams = 2;
|
|
163
158
|
Table.$isPhantom = [true, true];
|
|
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { String } from "../../0x1/ascii/structs";
|
|
4
4
|
import { PKG_V31 } from "../index";
|
|
5
|
-
import {
|
|
5
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
6
6
|
export declare function isUrl(type: string): boolean;
|
|
7
7
|
export interface UrlFields {
|
|
8
8
|
url: ToField<String>;
|
|
@@ -23,9 +23,9 @@ export declare class Url implements StructClass {
|
|
|
23
23
|
static get r(): import("../../../../_framework/reified").StructClassReified<Url, UrlFields>;
|
|
24
24
|
static phantom(): PhantomReified<ToTypeStr<Url>>;
|
|
25
25
|
static get p(): PhantomReified<"0x2::url::Url">;
|
|
26
|
-
static get bcs(): import("@mysten/
|
|
27
|
-
url: import("@mysten/
|
|
28
|
-
bytes: import("@mysten/
|
|
26
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
27
|
+
url: import("@mysten/bcs").BcsStruct<{
|
|
28
|
+
bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
|
|
29
29
|
length: number;
|
|
30
30
|
}, string>;
|
|
31
31
|
}, string>;
|
|
@@ -45,5 +45,5 @@ export declare class Url implements StructClass {
|
|
|
45
45
|
static fromJSON(json: Record<string, any>): Url;
|
|
46
46
|
static fromSuiParsedData(content: SuiParsedData): Url;
|
|
47
47
|
static fromSuiObjectData(data: SuiObjectData): Url;
|
|
48
|
-
static fetch(client:
|
|
48
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<Url>;
|
|
49
49
|
}
|