@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
|
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { String } from "../ascii/structs";
|
|
4
4
|
import { PKG_V14 } from "../index";
|
|
5
|
-
import {
|
|
5
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
6
6
|
export declare function isTypeName(type: string): boolean;
|
|
7
7
|
export interface TypeNameFields {
|
|
8
8
|
name: ToField<String>;
|
|
@@ -23,9 +23,9 @@ export declare class TypeName implements StructClass {
|
|
|
23
23
|
static get r(): import("../../../../_framework/reified").StructClassReified<TypeName, TypeNameFields>;
|
|
24
24
|
static phantom(): PhantomReified<ToTypeStr<TypeName>>;
|
|
25
25
|
static get p(): PhantomReified<"0x1::type_name::TypeName">;
|
|
26
|
-
static get bcs(): import("@mysten/
|
|
27
|
-
name: import("@mysten/
|
|
28
|
-
bytes: import("@mysten/
|
|
26
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
27
|
+
name: import("@mysten/bcs").BcsStruct<{
|
|
28
|
+
bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
|
|
29
29
|
length: number;
|
|
30
30
|
}, string>;
|
|
31
31
|
}, string>;
|
|
@@ -45,5 +45,5 @@ export declare class TypeName implements StructClass {
|
|
|
45
45
|
static fromJSON(json: Record<string, any>): TypeName;
|
|
46
46
|
static fromSuiParsedData(content: SuiParsedData): TypeName;
|
|
47
47
|
static fromSuiObjectData(data: SuiObjectData): TypeName;
|
|
48
|
-
static fetch(client:
|
|
48
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<TypeName>;
|
|
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,33 +7,30 @@ 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 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 { String } from "../ascii/structs";
|
|
13
|
+
import { PKG_V14 } from "../index";
|
|
14
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
15
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
20
16
|
/* ============================== TypeName =============================== */
|
|
21
|
-
function isTypeName(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type === `${
|
|
17
|
+
export function isTypeName(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type === `${PKG_V14}::type_name::TypeName`;
|
|
24
20
|
}
|
|
25
|
-
class TypeName {
|
|
21
|
+
export class TypeName {
|
|
26
22
|
constructor(typeArgs, fields) {
|
|
27
23
|
this.__StructClass = true;
|
|
28
24
|
this.$typeName = TypeName.$typeName;
|
|
29
25
|
this.$isPhantom = TypeName.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(TypeName.$typeName, ...typeArgs);
|
|
31
27
|
this.$typeArgs = typeArgs;
|
|
32
28
|
this.name = fields.name;
|
|
33
29
|
}
|
|
34
30
|
static reified() {
|
|
35
31
|
return {
|
|
36
32
|
typeName: TypeName.$typeName,
|
|
37
|
-
fullTypeName:
|
|
33
|
+
fullTypeName: composeSuiType(TypeName.$typeName, ...[]),
|
|
38
34
|
typeArgs: [],
|
|
39
35
|
isPhantom: TypeName.$isPhantom,
|
|
40
36
|
reifiedTypeArgs: [],
|
|
@@ -57,19 +53,19 @@ class TypeName {
|
|
|
57
53
|
return TypeName.reified();
|
|
58
54
|
}
|
|
59
55
|
static phantom() {
|
|
60
|
-
return
|
|
56
|
+
return phantom(TypeName.reified());
|
|
61
57
|
}
|
|
62
58
|
static get p() {
|
|
63
59
|
return TypeName.phantom();
|
|
64
60
|
}
|
|
65
61
|
static get bcs() {
|
|
66
|
-
return
|
|
67
|
-
name:
|
|
62
|
+
return bcs.struct("TypeName", {
|
|
63
|
+
name: String.bcs,
|
|
68
64
|
});
|
|
69
65
|
}
|
|
70
66
|
static fromFields(fields) {
|
|
71
67
|
return TypeName.reified().new({
|
|
72
|
-
name:
|
|
68
|
+
name: decodeFromFields(String.reified(), fields.name),
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
71
|
static fromFieldsWithTypes(item) {
|
|
@@ -77,7 +73,7 @@ class TypeName {
|
|
|
77
73
|
throw new Error("not a TypeName type");
|
|
78
74
|
}
|
|
79
75
|
return TypeName.reified().new({
|
|
80
|
-
name:
|
|
76
|
+
name: decodeFromFieldsWithTypes(String.reified(), item.fields.name),
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
79
|
static fromBcs(data) {
|
|
@@ -93,7 +89,7 @@ class TypeName {
|
|
|
93
89
|
}
|
|
94
90
|
static fromJSONField(field) {
|
|
95
91
|
return TypeName.reified().new({
|
|
96
|
-
name:
|
|
92
|
+
name: decodeFromJSONField(String.reified(), field.name),
|
|
97
93
|
});
|
|
98
94
|
}
|
|
99
95
|
static fromJSON(json) {
|
|
@@ -116,7 +112,7 @@ class TypeName {
|
|
|
116
112
|
if (data.bcs.dataType !== "moveObject" || !isTypeName(data.bcs.type)) {
|
|
117
113
|
throw new Error(`object at is not a TypeName object`);
|
|
118
114
|
}
|
|
119
|
-
return TypeName.fromBcs((
|
|
115
|
+
return TypeName.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
120
116
|
}
|
|
121
117
|
if (data.content) {
|
|
122
118
|
return TypeName.fromSuiParsedData(data.content);
|
|
@@ -138,7 +134,6 @@ class TypeName {
|
|
|
138
134
|
});
|
|
139
135
|
}
|
|
140
136
|
}
|
|
141
|
-
|
|
142
|
-
TypeName.$typeName = `${index_1.PKG_V14}::type_name::TypeName`;
|
|
137
|
+
TypeName.$typeName = `${PKG_V14}::type_name::TypeName`;
|
|
143
138
|
TypeName.$numTypeParams = 0;
|
|
144
139
|
TypeName.$isPhantom = [];
|
|
@@ -2,7 +2,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
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 isBag(type: string): boolean;
|
|
7
7
|
export interface BagFields {
|
|
8
8
|
id: ToField<UID>;
|
|
@@ -25,13 +25,13 @@ export declare class Bag implements StructClass {
|
|
|
25
25
|
static get r(): import("../../../../_framework/reified").StructClassReified<Bag, BagFields>;
|
|
26
26
|
static phantom(): PhantomReified<ToTypeStr<Bag>>;
|
|
27
27
|
static get p(): PhantomReified<"0x2::bag::Bag">;
|
|
28
|
-
static get bcs(): import("@mysten/
|
|
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(fields: Record<string, any>): Bag;
|
|
37
37
|
static fromFieldsWithTypes(item: FieldsWithTypes): Bag;
|
|
@@ -50,5 +50,5 @@ export declare class Bag implements StructClass {
|
|
|
50
50
|
static fromJSON(json: Record<string, any>): Bag;
|
|
51
51
|
static fromSuiParsedData(content: SuiParsedData): Bag;
|
|
52
52
|
static fromSuiObjectData(data: SuiObjectData): Bag;
|
|
53
|
-
static fetch(client:
|
|
53
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<Bag>;
|
|
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 { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
|
|
11
|
+
import { composeSuiType, compressSuiType, } 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
|
/* ============================== Bag =============================== */
|
|
21
|
-
function isBag(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type === `${
|
|
17
|
+
export function isBag(type) {
|
|
18
|
+
type = compressSuiType(type);
|
|
19
|
+
return type === `${PKG_V31}::bag::Bag`;
|
|
24
20
|
}
|
|
25
|
-
class Bag {
|
|
21
|
+
export class Bag {
|
|
26
22
|
constructor(typeArgs, fields) {
|
|
27
23
|
this.__StructClass = true;
|
|
28
24
|
this.$typeName = Bag.$typeName;
|
|
29
25
|
this.$isPhantom = Bag.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
26
|
+
this.$fullTypeName = composeSuiType(Bag.$typeName, ...typeArgs);
|
|
31
27
|
this.$typeArgs = typeArgs;
|
|
32
28
|
this.id = fields.id;
|
|
33
29
|
this.size = fields.size;
|
|
@@ -35,7 +31,7 @@ class Bag {
|
|
|
35
31
|
static reified() {
|
|
36
32
|
return {
|
|
37
33
|
typeName: Bag.$typeName,
|
|
38
|
-
fullTypeName:
|
|
34
|
+
fullTypeName: composeSuiType(Bag.$typeName, ...[]),
|
|
39
35
|
typeArgs: [],
|
|
40
36
|
isPhantom: Bag.$isPhantom,
|
|
41
37
|
reifiedTypeArgs: [],
|
|
@@ -58,21 +54,21 @@ class Bag {
|
|
|
58
54
|
return Bag.reified();
|
|
59
55
|
}
|
|
60
56
|
static phantom() {
|
|
61
|
-
return
|
|
57
|
+
return phantom(Bag.reified());
|
|
62
58
|
}
|
|
63
59
|
static get p() {
|
|
64
60
|
return Bag.phantom();
|
|
65
61
|
}
|
|
66
62
|
static get bcs() {
|
|
67
|
-
return
|
|
68
|
-
id:
|
|
69
|
-
size:
|
|
63
|
+
return bcs.struct("Bag", {
|
|
64
|
+
id: UID.bcs,
|
|
65
|
+
size: bcs.u64(),
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
68
|
static fromFields(fields) {
|
|
73
69
|
return Bag.reified().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(item) {
|
|
@@ -80,8 +76,8 @@ class Bag {
|
|
|
80
76
|
throw new Error("not a Bag type");
|
|
81
77
|
}
|
|
82
78
|
return Bag.reified().new({
|
|
83
|
-
id:
|
|
84
|
-
size:
|
|
79
|
+
id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id),
|
|
80
|
+
size: decodeFromFieldsWithTypes("u64", item.fields.size),
|
|
85
81
|
});
|
|
86
82
|
}
|
|
87
83
|
static fromBcs(data) {
|
|
@@ -98,8 +94,8 @@ class Bag {
|
|
|
98
94
|
}
|
|
99
95
|
static fromJSONField(field) {
|
|
100
96
|
return Bag.reified().new({
|
|
101
|
-
id:
|
|
102
|
-
size:
|
|
97
|
+
id: decodeFromJSONField(UID.reified(), field.id),
|
|
98
|
+
size: decodeFromJSONField("u64", field.size),
|
|
103
99
|
});
|
|
104
100
|
}
|
|
105
101
|
static fromJSON(json) {
|
|
@@ -122,7 +118,7 @@ class Bag {
|
|
|
122
118
|
if (data.bcs.dataType !== "moveObject" || !isBag(data.bcs.type)) {
|
|
123
119
|
throw new Error(`object at is not a Bag object`);
|
|
124
120
|
}
|
|
125
|
-
return Bag.fromBcs((
|
|
121
|
+
return Bag.fromBcs(fromBase64(data.bcs.bcsBytes));
|
|
126
122
|
}
|
|
127
123
|
if (data.content) {
|
|
128
124
|
return Bag.fromSuiParsedData(data.content);
|
|
@@ -143,7 +139,6 @@ class Bag {
|
|
|
143
139
|
});
|
|
144
140
|
}
|
|
145
141
|
}
|
|
146
|
-
|
|
147
|
-
Bag.$typeName = `${index_1.PKG_V31}::bag::Bag`;
|
|
142
|
+
Bag.$typeName = `${PKG_V31}::bag::Bag`;
|
|
148
143
|
Bag.$numTypeParams = 0;
|
|
149
144
|
Bag.$isPhantom = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr } from "../../../../_framework/reified";
|
|
2
2
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
3
3
|
import { PKG_V31 } from "../index";
|
|
4
|
-
import {
|
|
4
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
5
5
|
export declare function isBalance(type: string): boolean;
|
|
6
6
|
export interface BalanceFields<T extends PhantomTypeArgument> {
|
|
7
7
|
value: ToField<"u64">;
|
|
@@ -22,8 +22,8 @@ export declare class Balance<T extends PhantomTypeArgument> implements StructCla
|
|
|
22
22
|
static get r(): typeof Balance.reified;
|
|
23
23
|
static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Balance<ToPhantomTypeArgument<T>>>>;
|
|
24
24
|
static get p(): typeof Balance.phantom;
|
|
25
|
-
static get bcs(): import("@mysten/
|
|
26
|
-
value: import("@mysten/
|
|
25
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
26
|
+
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
27
27
|
}, string>;
|
|
28
28
|
static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Balance<ToPhantomTypeArgument<T>>;
|
|
29
29
|
static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Balance<ToPhantomTypeArgument<T>>;
|
|
@@ -40,7 +40,7 @@ export declare class Balance<T extends PhantomTypeArgument> implements StructCla
|
|
|
40
40
|
static fromJSON<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, json: Record<string, any>): Balance<ToPhantomTypeArgument<T>>;
|
|
41
41
|
static fromSuiParsedData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, content: SuiParsedData): Balance<ToPhantomTypeArgument<T>>;
|
|
42
42
|
static fromSuiObjectData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: SuiObjectData): Balance<ToPhantomTypeArgument<T>>;
|
|
43
|
-
static fetch<T extends PhantomReified<PhantomTypeArgument>>(client:
|
|
43
|
+
static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiJsonRpcClient, typeArg: T, id: string): Promise<Balance<ToPhantomTypeArgument<T>>>;
|
|
44
44
|
}
|
|
45
45
|
export declare function isSupply(type: string): boolean;
|
|
46
46
|
export interface SupplyFields<T extends PhantomTypeArgument> {
|
|
@@ -62,8 +62,8 @@ export declare class Supply<T extends PhantomTypeArgument> implements StructClas
|
|
|
62
62
|
static get r(): typeof Supply.reified;
|
|
63
63
|
static phantom<T extends PhantomReified<PhantomTypeArgument>>(T: T): PhantomReified<ToTypeStr<Supply<ToPhantomTypeArgument<T>>>>;
|
|
64
64
|
static get p(): typeof Supply.phantom;
|
|
65
|
-
static get bcs(): import("@mysten/
|
|
66
|
-
value: import("@mysten/
|
|
65
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
66
|
+
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
67
67
|
}, string>;
|
|
68
68
|
static fromFields<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, fields: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
|
|
69
69
|
static fromFieldsWithTypes<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, item: FieldsWithTypes): Supply<ToPhantomTypeArgument<T>>;
|
|
@@ -80,5 +80,5 @@ export declare class Supply<T extends PhantomTypeArgument> implements StructClas
|
|
|
80
80
|
static fromJSON<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, json: Record<string, any>): Supply<ToPhantomTypeArgument<T>>;
|
|
81
81
|
static fromSuiParsedData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, content: SuiParsedData): Supply<ToPhantomTypeArgument<T>>;
|
|
82
82
|
static fromSuiObjectData<T extends PhantomReified<PhantomTypeArgument>>(typeArg: T, data: SuiObjectData): Supply<ToPhantomTypeArgument<T>>;
|
|
83
|
-
static fetch<T extends PhantomReified<PhantomTypeArgument>>(client:
|
|
83
|
+
static fetch<T extends PhantomReified<PhantomTypeArgument>>(client: SuiJsonRpcClient, typeArg: T, id: string): Promise<Supply<ToPhantomTypeArgument<T>>>;
|
|
84
84
|
}
|
|
@@ -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,34 +7,30 @@ 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 { 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 { bcs } from "@mysten/sui/bcs";
|
|
14
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
20
15
|
/* ============================== Balance =============================== */
|
|
21
|
-
function isBalance(type) {
|
|
22
|
-
type =
|
|
23
|
-
return type.startsWith(`${
|
|
16
|
+
export function isBalance(type) {
|
|
17
|
+
type = compressSuiType(type);
|
|
18
|
+
return type.startsWith(`${PKG_V31}::balance::Balance` + "<");
|
|
24
19
|
}
|
|
25
|
-
class Balance {
|
|
20
|
+
export class Balance {
|
|
26
21
|
constructor(typeArgs, fields) {
|
|
27
22
|
this.__StructClass = true;
|
|
28
23
|
this.$typeName = Balance.$typeName;
|
|
29
24
|
this.$isPhantom = Balance.$isPhantom;
|
|
30
|
-
this.$fullTypeName =
|
|
25
|
+
this.$fullTypeName = composeSuiType(Balance.$typeName, ...typeArgs);
|
|
31
26
|
this.$typeArgs = typeArgs;
|
|
32
27
|
this.value = fields.value;
|
|
33
28
|
}
|
|
34
29
|
static reified(T) {
|
|
35
30
|
return {
|
|
36
31
|
typeName: Balance.$typeName,
|
|
37
|
-
fullTypeName:
|
|
38
|
-
typeArgs: [
|
|
32
|
+
fullTypeName: composeSuiType(Balance.$typeName, ...[extractType(T)]),
|
|
33
|
+
typeArgs: [extractType(T)],
|
|
39
34
|
isPhantom: Balance.$isPhantom,
|
|
40
35
|
reifiedTypeArgs: [T],
|
|
41
36
|
fromFields: (fields) => Balance.fromFields(T, fields),
|
|
@@ -48,7 +43,7 @@ class Balance {
|
|
|
48
43
|
fromSuiObjectData: (content) => Balance.fromSuiObjectData(T, content),
|
|
49
44
|
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Balance.fetch(client, T, id); }),
|
|
50
45
|
new: (fields) => {
|
|
51
|
-
return new Balance([
|
|
46
|
+
return new Balance([extractType(T)], fields);
|
|
52
47
|
},
|
|
53
48
|
kind: "StructClassReified",
|
|
54
49
|
};
|
|
@@ -57,28 +52,28 @@ class Balance {
|
|
|
57
52
|
return Balance.reified;
|
|
58
53
|
}
|
|
59
54
|
static phantom(T) {
|
|
60
|
-
return
|
|
55
|
+
return phantom(Balance.reified(T));
|
|
61
56
|
}
|
|
62
57
|
static get p() {
|
|
63
58
|
return Balance.phantom;
|
|
64
59
|
}
|
|
65
60
|
static get bcs() {
|
|
66
|
-
return
|
|
67
|
-
value:
|
|
61
|
+
return bcs.struct("Balance", {
|
|
62
|
+
value: bcs.u64(),
|
|
68
63
|
});
|
|
69
64
|
}
|
|
70
65
|
static fromFields(typeArg, fields) {
|
|
71
66
|
return Balance.reified(typeArg).new({
|
|
72
|
-
value:
|
|
67
|
+
value: decodeFromFields("u64", fields.value),
|
|
73
68
|
});
|
|
74
69
|
}
|
|
75
70
|
static fromFieldsWithTypes(typeArg, item) {
|
|
76
71
|
if (!isBalance(item.type)) {
|
|
77
72
|
throw new Error("not a Balance type");
|
|
78
73
|
}
|
|
79
|
-
|
|
74
|
+
assertFieldsWithTypesArgsMatch(item, [typeArg]);
|
|
80
75
|
return Balance.reified(typeArg).new({
|
|
81
|
-
value:
|
|
76
|
+
value: decodeFromFieldsWithTypes("u64", item.fields.value),
|
|
82
77
|
});
|
|
83
78
|
}
|
|
84
79
|
static fromBcs(typeArg, data) {
|
|
@@ -94,14 +89,14 @@ class Balance {
|
|
|
94
89
|
}
|
|
95
90
|
static fromJSONField(typeArg, field) {
|
|
96
91
|
return Balance.reified(typeArg).new({
|
|
97
|
-
value:
|
|
92
|
+
value: decodeFromJSONField("u64", field.value),
|
|
98
93
|
});
|
|
99
94
|
}
|
|
100
95
|
static fromJSON(typeArg, json) {
|
|
101
96
|
if (json.$typeName !== Balance.$typeName) {
|
|
102
97
|
throw new Error("not a WithTwoGenerics json object");
|
|
103
98
|
}
|
|
104
|
-
|
|
99
|
+
assertReifiedTypeArgsMatch(composeSuiType(Balance.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
|
|
105
100
|
return Balance.fromJSONField(typeArg, json);
|
|
106
101
|
}
|
|
107
102
|
static fromSuiParsedData(typeArg, content) {
|
|
@@ -118,16 +113,16 @@ class Balance {
|
|
|
118
113
|
if (data.bcs.dataType !== "moveObject" || !isBalance(data.bcs.type)) {
|
|
119
114
|
throw new Error(`object at is not a Balance object`);
|
|
120
115
|
}
|
|
121
|
-
const gotTypeArgs =
|
|
116
|
+
const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
|
|
122
117
|
if (gotTypeArgs.length !== 1) {
|
|
123
118
|
throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
|
|
124
119
|
}
|
|
125
|
-
const gotTypeArg =
|
|
126
|
-
const expectedTypeArg =
|
|
127
|
-
if (gotTypeArg !==
|
|
120
|
+
const gotTypeArg = compressSuiType(gotTypeArgs[0]);
|
|
121
|
+
const expectedTypeArg = compressSuiType(extractType(typeArg));
|
|
122
|
+
if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
|
|
128
123
|
throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
|
|
129
124
|
}
|
|
130
|
-
return Balance.fromBcs(typeArg, (
|
|
125
|
+
return Balance.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
|
|
131
126
|
}
|
|
132
127
|
if (data.content) {
|
|
133
128
|
return Balance.fromSuiParsedData(typeArg, data.content);
|
|
@@ -149,29 +144,28 @@ class Balance {
|
|
|
149
144
|
});
|
|
150
145
|
}
|
|
151
146
|
}
|
|
152
|
-
|
|
153
|
-
Balance.$typeName = `${index_1.PKG_V31}::balance::Balance`;
|
|
147
|
+
Balance.$typeName = `${PKG_V31}::balance::Balance`;
|
|
154
148
|
Balance.$numTypeParams = 1;
|
|
155
149
|
Balance.$isPhantom = [true];
|
|
156
150
|
/* ============================== Supply =============================== */
|
|
157
|
-
function isSupply(type) {
|
|
158
|
-
type =
|
|
159
|
-
return type.startsWith(`${
|
|
151
|
+
export function isSupply(type) {
|
|
152
|
+
type = compressSuiType(type);
|
|
153
|
+
return type.startsWith(`${PKG_V31}::balance::Supply` + "<");
|
|
160
154
|
}
|
|
161
|
-
class Supply {
|
|
155
|
+
export class Supply {
|
|
162
156
|
constructor(typeArgs, fields) {
|
|
163
157
|
this.__StructClass = true;
|
|
164
158
|
this.$typeName = Supply.$typeName;
|
|
165
159
|
this.$isPhantom = Supply.$isPhantom;
|
|
166
|
-
this.$fullTypeName =
|
|
160
|
+
this.$fullTypeName = composeSuiType(Supply.$typeName, ...typeArgs);
|
|
167
161
|
this.$typeArgs = typeArgs;
|
|
168
162
|
this.value = fields.value;
|
|
169
163
|
}
|
|
170
164
|
static reified(T) {
|
|
171
165
|
return {
|
|
172
166
|
typeName: Supply.$typeName,
|
|
173
|
-
fullTypeName:
|
|
174
|
-
typeArgs: [
|
|
167
|
+
fullTypeName: composeSuiType(Supply.$typeName, ...[extractType(T)]),
|
|
168
|
+
typeArgs: [extractType(T)],
|
|
175
169
|
isPhantom: Supply.$isPhantom,
|
|
176
170
|
reifiedTypeArgs: [T],
|
|
177
171
|
fromFields: (fields) => Supply.fromFields(T, fields),
|
|
@@ -184,7 +178,7 @@ class Supply {
|
|
|
184
178
|
fromSuiObjectData: (content) => Supply.fromSuiObjectData(T, content),
|
|
185
179
|
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Supply.fetch(client, T, id); }),
|
|
186
180
|
new: (fields) => {
|
|
187
|
-
return new Supply([
|
|
181
|
+
return new Supply([extractType(T)], fields);
|
|
188
182
|
},
|
|
189
183
|
kind: "StructClassReified",
|
|
190
184
|
};
|
|
@@ -193,28 +187,28 @@ class Supply {
|
|
|
193
187
|
return Supply.reified;
|
|
194
188
|
}
|
|
195
189
|
static phantom(T) {
|
|
196
|
-
return
|
|
190
|
+
return phantom(Supply.reified(T));
|
|
197
191
|
}
|
|
198
192
|
static get p() {
|
|
199
193
|
return Supply.phantom;
|
|
200
194
|
}
|
|
201
195
|
static get bcs() {
|
|
202
|
-
return
|
|
203
|
-
value:
|
|
196
|
+
return bcs.struct("Supply", {
|
|
197
|
+
value: bcs.u64(),
|
|
204
198
|
});
|
|
205
199
|
}
|
|
206
200
|
static fromFields(typeArg, fields) {
|
|
207
201
|
return Supply.reified(typeArg).new({
|
|
208
|
-
value:
|
|
202
|
+
value: decodeFromFields("u64", fields.value),
|
|
209
203
|
});
|
|
210
204
|
}
|
|
211
205
|
static fromFieldsWithTypes(typeArg, item) {
|
|
212
206
|
if (!isSupply(item.type)) {
|
|
213
207
|
throw new Error("not a Supply type");
|
|
214
208
|
}
|
|
215
|
-
|
|
209
|
+
assertFieldsWithTypesArgsMatch(item, [typeArg]);
|
|
216
210
|
return Supply.reified(typeArg).new({
|
|
217
|
-
value:
|
|
211
|
+
value: decodeFromFieldsWithTypes("u64", item.fields.value),
|
|
218
212
|
});
|
|
219
213
|
}
|
|
220
214
|
static fromBcs(typeArg, data) {
|
|
@@ -230,14 +224,14 @@ class Supply {
|
|
|
230
224
|
}
|
|
231
225
|
static fromJSONField(typeArg, field) {
|
|
232
226
|
return Supply.reified(typeArg).new({
|
|
233
|
-
value:
|
|
227
|
+
value: decodeFromJSONField("u64", field.value),
|
|
234
228
|
});
|
|
235
229
|
}
|
|
236
230
|
static fromJSON(typeArg, json) {
|
|
237
231
|
if (json.$typeName !== Supply.$typeName) {
|
|
238
232
|
throw new Error("not a WithTwoGenerics json object");
|
|
239
233
|
}
|
|
240
|
-
|
|
234
|
+
assertReifiedTypeArgsMatch(composeSuiType(Supply.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg]);
|
|
241
235
|
return Supply.fromJSONField(typeArg, json);
|
|
242
236
|
}
|
|
243
237
|
static fromSuiParsedData(typeArg, content) {
|
|
@@ -254,16 +248,16 @@ class Supply {
|
|
|
254
248
|
if (data.bcs.dataType !== "moveObject" || !isSupply(data.bcs.type)) {
|
|
255
249
|
throw new Error(`object at is not a Supply object`);
|
|
256
250
|
}
|
|
257
|
-
const gotTypeArgs =
|
|
251
|
+
const gotTypeArgs = parseTypeName(data.bcs.type).typeArgs;
|
|
258
252
|
if (gotTypeArgs.length !== 1) {
|
|
259
253
|
throw new Error(`type argument mismatch: expected 1 type argument but got '${gotTypeArgs.length}'`);
|
|
260
254
|
}
|
|
261
|
-
const gotTypeArg =
|
|
262
|
-
const expectedTypeArg =
|
|
263
|
-
if (gotTypeArg !==
|
|
255
|
+
const gotTypeArg = compressSuiType(gotTypeArgs[0]);
|
|
256
|
+
const expectedTypeArg = compressSuiType(extractType(typeArg));
|
|
257
|
+
if (gotTypeArg !== compressSuiType(extractType(typeArg))) {
|
|
264
258
|
throw new Error(`type argument mismatch: expected '${expectedTypeArg}' but got '${gotTypeArg}'`);
|
|
265
259
|
}
|
|
266
|
-
return Supply.fromBcs(typeArg, (
|
|
260
|
+
return Supply.fromBcs(typeArg, fromBase64(data.bcs.bcsBytes));
|
|
267
261
|
}
|
|
268
262
|
if (data.content) {
|
|
269
263
|
return Supply.fromSuiParsedData(typeArg, data.content);
|
|
@@ -285,7 +279,6 @@ class Supply {
|
|
|
285
279
|
});
|
|
286
280
|
}
|
|
287
281
|
}
|
|
288
|
-
|
|
289
|
-
Supply.$typeName = `${index_1.PKG_V31}::balance::Supply`;
|
|
282
|
+
Supply.$typeName = `${PKG_V31}::balance::Supply`;
|
|
290
283
|
Supply.$numTypeParams = 1;
|
|
291
284
|
Supply.$isPhantom = [true];
|