@suilend/springsui-cli 1.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/index.d.ts +1 -0
- package/cli/src/index.js +304 -0
- package/package.json +1 -0
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +92 -0
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +289 -0
- package/sdk/src/_generated/_dependencies/source/0x1/index.d.ts +3 -0
- package/sdk/src/_generated/_dependencies/source/0x1/index.js +6 -0
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +52 -0
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +180 -0
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +50 -0
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +167 -0
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +53 -0
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +144 -0
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +61 -0
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +149 -0
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +88 -0
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +291 -0
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +460 -0
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +1045 -0
- package/sdk/src/_generated/_dependencies/source/0x2/index.d.ts +3 -0
- package/sdk/src/_generated/_dependencies/source/0x2/index.js +6 -0
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +92 -0
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +270 -0
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +46 -0
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +142 -0
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +61 -0
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +163 -0
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +53 -0
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +143 -0
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +111 -0
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +325 -0
- package/sdk/src/_generated/_dependencies/source/0x3/index.d.ts +3 -0
- package/sdk/src/_generated/_dependencies/source/0x3/index.js +6 -0
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +487 -0
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +915 -0
- package/sdk/src/_generated/_framework/reified.d.ts +108 -0
- package/sdk/src/_generated/_framework/reified.js +240 -0
- package/sdk/src/_generated/_framework/util.d.ts +35 -0
- package/sdk/src/_generated/_framework/util.js +334 -0
- package/sdk/src/_generated/_framework/vector.d.ts +35 -0
- package/sdk/src/_generated/_framework/vector.js +77 -0
- package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +54 -0
- package/sdk/src/_generated/liquid_staking/cell/structs.js +156 -0
- package/sdk/src/_generated/liquid_staking/fees/functions.d.ts +51 -0
- package/sdk/src/_generated/liquid_staking/fees/functions.js +130 -0
- package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +165 -0
- package/sdk/src/_generated/liquid_staking/fees/structs.js +307 -0
- package/sdk/src/_generated/liquid_staking/index.d.ts +4 -0
- package/sdk/src/_generated/liquid_staking/index.js +10 -0
- package/sdk/src/_generated/liquid_staking/liquid-staking/functions.d.ts +88 -0
- package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +199 -0
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +955 -0
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +1477 -0
- package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +358 -0
- package/sdk/src/_generated/liquid_staking/storage/structs.js +365 -0
- package/sdk/src/_generated/liquid_staking/version/structs.d.ts +46 -0
- package/sdk/src/_generated/liquid_staking/version/structs.js +143 -0
- package/sdk/src/_generated/liquid_staking/weight/functions.d.ts +19 -0
- package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -0
- package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +205 -0
- package/sdk/src/_generated/liquid_staking/weight/structs.js +332 -0
- package/sdk/src/index.d.ts +44 -0
- package/sdk/src/index.js +234 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.ValidatorInfo = exports.Storage = void 0;
|
|
36
|
+
exports.isStorage = isStorage;
|
|
37
|
+
exports.isValidatorInfo = isValidatorInfo;
|
|
38
|
+
const reified = __importStar(require("../../_framework/reified"));
|
|
39
|
+
const structs_1 = require("../../_dependencies/source/0x1/option/structs");
|
|
40
|
+
const structs_2 = require("../../_dependencies/source/0x2/bag/structs");
|
|
41
|
+
const structs_3 = require("../../_dependencies/source/0x2/balance/structs");
|
|
42
|
+
const structs_4 = require("../../_dependencies/source/0x2/object/structs");
|
|
43
|
+
const structs_5 = require("../../_dependencies/source/0x2/sui/structs");
|
|
44
|
+
const structs_6 = require("../../_dependencies/source/0x3/staking-pool/structs");
|
|
45
|
+
const reified_1 = require("../../_framework/reified");
|
|
46
|
+
const util_1 = require("../../_framework/util");
|
|
47
|
+
const index_1 = require("../index");
|
|
48
|
+
const bcs_1 = require("@mysten/sui/bcs");
|
|
49
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
50
|
+
/* ============================== Storage =============================== */
|
|
51
|
+
function isStorage(type) {
|
|
52
|
+
type = (0, util_1.compressSuiType)(type);
|
|
53
|
+
return type === `${index_1.PKG_V1}::storage::Storage`;
|
|
54
|
+
}
|
|
55
|
+
class Storage {
|
|
56
|
+
constructor(typeArgs, fields) {
|
|
57
|
+
this.__StructClass = true;
|
|
58
|
+
this.$typeName = Storage.$typeName;
|
|
59
|
+
this.$isPhantom = Storage.$isPhantom;
|
|
60
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(Storage.$typeName, ...typeArgs);
|
|
61
|
+
this.$typeArgs = typeArgs;
|
|
62
|
+
this.suiPool = fields.suiPool;
|
|
63
|
+
this.validatorInfos = fields.validatorInfos;
|
|
64
|
+
this.totalSuiSupply = fields.totalSuiSupply;
|
|
65
|
+
this.lastRefreshEpoch = fields.lastRefreshEpoch;
|
|
66
|
+
this.extraFields = fields.extraFields;
|
|
67
|
+
}
|
|
68
|
+
static reified() {
|
|
69
|
+
return {
|
|
70
|
+
typeName: Storage.$typeName,
|
|
71
|
+
fullTypeName: (0, util_1.composeSuiType)(Storage.$typeName, ...[]),
|
|
72
|
+
typeArgs: [],
|
|
73
|
+
isPhantom: Storage.$isPhantom,
|
|
74
|
+
reifiedTypeArgs: [],
|
|
75
|
+
fromFields: (fields) => Storage.fromFields(fields),
|
|
76
|
+
fromFieldsWithTypes: (item) => Storage.fromFieldsWithTypes(item),
|
|
77
|
+
fromBcs: (data) => Storage.fromBcs(data),
|
|
78
|
+
bcs: Storage.bcs,
|
|
79
|
+
fromJSONField: (field) => Storage.fromJSONField(field),
|
|
80
|
+
fromJSON: (json) => Storage.fromJSON(json),
|
|
81
|
+
fromSuiParsedData: (content) => Storage.fromSuiParsedData(content),
|
|
82
|
+
fromSuiObjectData: (content) => Storage.fromSuiObjectData(content),
|
|
83
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Storage.fetch(client, id); }),
|
|
84
|
+
new: (fields) => {
|
|
85
|
+
return new Storage([], fields);
|
|
86
|
+
},
|
|
87
|
+
kind: "StructClassReified",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
static get r() {
|
|
91
|
+
return Storage.reified();
|
|
92
|
+
}
|
|
93
|
+
static phantom() {
|
|
94
|
+
return (0, reified_1.phantom)(Storage.reified());
|
|
95
|
+
}
|
|
96
|
+
static get p() {
|
|
97
|
+
return Storage.phantom();
|
|
98
|
+
}
|
|
99
|
+
static get bcs() {
|
|
100
|
+
return bcs_1.bcs.struct("Storage", {
|
|
101
|
+
sui_pool: structs_3.Balance.bcs,
|
|
102
|
+
validator_infos: bcs_1.bcs.vector(ValidatorInfo.bcs),
|
|
103
|
+
total_sui_supply: bcs_1.bcs.u64(),
|
|
104
|
+
last_refresh_epoch: bcs_1.bcs.u64(),
|
|
105
|
+
extra_fields: structs_2.Bag.bcs,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
static fromFields(fields) {
|
|
109
|
+
return Storage.reified().new({
|
|
110
|
+
suiPool: (0, reified_1.decodeFromFields)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), fields.sui_pool),
|
|
111
|
+
validatorInfos: (0, reified_1.decodeFromFields)(reified.vector(ValidatorInfo.reified()), fields.validator_infos),
|
|
112
|
+
totalSuiSupply: (0, reified_1.decodeFromFields)("u64", fields.total_sui_supply),
|
|
113
|
+
lastRefreshEpoch: (0, reified_1.decodeFromFields)("u64", fields.last_refresh_epoch),
|
|
114
|
+
extraFields: (0, reified_1.decodeFromFields)(structs_2.Bag.reified(), fields.extra_fields),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
static fromFieldsWithTypes(item) {
|
|
118
|
+
if (!isStorage(item.type)) {
|
|
119
|
+
throw new Error("not a Storage type");
|
|
120
|
+
}
|
|
121
|
+
return Storage.reified().new({
|
|
122
|
+
suiPool: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), item.fields.sui_pool),
|
|
123
|
+
validatorInfos: (0, reified_1.decodeFromFieldsWithTypes)(reified.vector(ValidatorInfo.reified()), item.fields.validator_infos),
|
|
124
|
+
totalSuiSupply: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.total_sui_supply),
|
|
125
|
+
lastRefreshEpoch: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.last_refresh_epoch),
|
|
126
|
+
extraFields: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.Bag.reified(), item.fields.extra_fields),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
static fromBcs(data) {
|
|
130
|
+
return Storage.fromFields(Storage.bcs.parse(data));
|
|
131
|
+
}
|
|
132
|
+
toJSONField() {
|
|
133
|
+
return {
|
|
134
|
+
suiPool: this.suiPool.toJSONField(),
|
|
135
|
+
validatorInfos: (0, reified_1.fieldToJSON)(`vector<${ValidatorInfo.$typeName}>`, this.validatorInfos),
|
|
136
|
+
totalSuiSupply: this.totalSuiSupply.toString(),
|
|
137
|
+
lastRefreshEpoch: this.lastRefreshEpoch.toString(),
|
|
138
|
+
extraFields: this.extraFields.toJSONField(),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
toJSON() {
|
|
142
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
143
|
+
}
|
|
144
|
+
static fromJSONField(field) {
|
|
145
|
+
return Storage.reified().new({
|
|
146
|
+
suiPool: (0, reified_1.decodeFromJSONField)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), field.suiPool),
|
|
147
|
+
validatorInfos: (0, reified_1.decodeFromJSONField)(reified.vector(ValidatorInfo.reified()), field.validatorInfos),
|
|
148
|
+
totalSuiSupply: (0, reified_1.decodeFromJSONField)("u64", field.totalSuiSupply),
|
|
149
|
+
lastRefreshEpoch: (0, reified_1.decodeFromJSONField)("u64", field.lastRefreshEpoch),
|
|
150
|
+
extraFields: (0, reified_1.decodeFromJSONField)(structs_2.Bag.reified(), field.extraFields),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
static fromJSON(json) {
|
|
154
|
+
if (json.$typeName !== Storage.$typeName) {
|
|
155
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
156
|
+
}
|
|
157
|
+
return Storage.fromJSONField(json);
|
|
158
|
+
}
|
|
159
|
+
static fromSuiParsedData(content) {
|
|
160
|
+
if (content.dataType !== "moveObject") {
|
|
161
|
+
throw new Error("not an object");
|
|
162
|
+
}
|
|
163
|
+
if (!isStorage(content.type)) {
|
|
164
|
+
throw new Error(`object at ${content.fields.id} is not a Storage object`);
|
|
165
|
+
}
|
|
166
|
+
return Storage.fromFieldsWithTypes(content);
|
|
167
|
+
}
|
|
168
|
+
static fromSuiObjectData(data) {
|
|
169
|
+
if (data.bcs) {
|
|
170
|
+
if (data.bcs.dataType !== "moveObject" || !isStorage(data.bcs.type)) {
|
|
171
|
+
throw new Error(`object at is not a Storage object`);
|
|
172
|
+
}
|
|
173
|
+
return Storage.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
174
|
+
}
|
|
175
|
+
if (data.content) {
|
|
176
|
+
return Storage.fromSuiParsedData(data.content);
|
|
177
|
+
}
|
|
178
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
179
|
+
}
|
|
180
|
+
static fetch(client, id) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
184
|
+
if (res.error) {
|
|
185
|
+
throw new Error(`error fetching Storage object at id ${id}: ${res.error.code}`);
|
|
186
|
+
}
|
|
187
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
188
|
+
!isStorage(res.data.bcs.type)) {
|
|
189
|
+
throw new Error(`object at id ${id} is not a Storage object`);
|
|
190
|
+
}
|
|
191
|
+
return Storage.fromSuiObjectData(res.data);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.Storage = Storage;
|
|
196
|
+
Storage.$typeName = `${index_1.PKG_V1}::storage::Storage`;
|
|
197
|
+
Storage.$numTypeParams = 0;
|
|
198
|
+
Storage.$isPhantom = [];
|
|
199
|
+
/* ============================== ValidatorInfo =============================== */
|
|
200
|
+
function isValidatorInfo(type) {
|
|
201
|
+
type = (0, util_1.compressSuiType)(type);
|
|
202
|
+
return type === `${index_1.PKG_V1}::storage::ValidatorInfo`;
|
|
203
|
+
}
|
|
204
|
+
class ValidatorInfo {
|
|
205
|
+
constructor(typeArgs, fields) {
|
|
206
|
+
this.__StructClass = true;
|
|
207
|
+
this.$typeName = ValidatorInfo.$typeName;
|
|
208
|
+
this.$isPhantom = ValidatorInfo.$isPhantom;
|
|
209
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(ValidatorInfo.$typeName, ...typeArgs);
|
|
210
|
+
this.$typeArgs = typeArgs;
|
|
211
|
+
this.stakingPoolId = fields.stakingPoolId;
|
|
212
|
+
this.validatorAddress = fields.validatorAddress;
|
|
213
|
+
this.activeStake = fields.activeStake;
|
|
214
|
+
this.inactiveStake = fields.inactiveStake;
|
|
215
|
+
this.exchangeRate = fields.exchangeRate;
|
|
216
|
+
this.totalSuiAmount = fields.totalSuiAmount;
|
|
217
|
+
this.extraFields = fields.extraFields;
|
|
218
|
+
}
|
|
219
|
+
static reified() {
|
|
220
|
+
return {
|
|
221
|
+
typeName: ValidatorInfo.$typeName,
|
|
222
|
+
fullTypeName: (0, util_1.composeSuiType)(ValidatorInfo.$typeName, ...[]),
|
|
223
|
+
typeArgs: [],
|
|
224
|
+
isPhantom: ValidatorInfo.$isPhantom,
|
|
225
|
+
reifiedTypeArgs: [],
|
|
226
|
+
fromFields: (fields) => ValidatorInfo.fromFields(fields),
|
|
227
|
+
fromFieldsWithTypes: (item) => ValidatorInfo.fromFieldsWithTypes(item),
|
|
228
|
+
fromBcs: (data) => ValidatorInfo.fromBcs(data),
|
|
229
|
+
bcs: ValidatorInfo.bcs,
|
|
230
|
+
fromJSONField: (field) => ValidatorInfo.fromJSONField(field),
|
|
231
|
+
fromJSON: (json) => ValidatorInfo.fromJSON(json),
|
|
232
|
+
fromSuiParsedData: (content) => ValidatorInfo.fromSuiParsedData(content),
|
|
233
|
+
fromSuiObjectData: (content) => ValidatorInfo.fromSuiObjectData(content),
|
|
234
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return ValidatorInfo.fetch(client, id); }),
|
|
235
|
+
new: (fields) => {
|
|
236
|
+
return new ValidatorInfo([], fields);
|
|
237
|
+
},
|
|
238
|
+
kind: "StructClassReified",
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
static get r() {
|
|
242
|
+
return ValidatorInfo.reified();
|
|
243
|
+
}
|
|
244
|
+
static phantom() {
|
|
245
|
+
return (0, reified_1.phantom)(ValidatorInfo.reified());
|
|
246
|
+
}
|
|
247
|
+
static get p() {
|
|
248
|
+
return ValidatorInfo.phantom();
|
|
249
|
+
}
|
|
250
|
+
static get bcs() {
|
|
251
|
+
return bcs_1.bcs.struct("ValidatorInfo", {
|
|
252
|
+
staking_pool_id: structs_4.ID.bcs,
|
|
253
|
+
validator_address: bcs_1.bcs
|
|
254
|
+
.bytes(32)
|
|
255
|
+
.transform({
|
|
256
|
+
input: (val) => (0, utils_1.fromHEX)(val),
|
|
257
|
+
output: (val) => (0, utils_1.toHEX)(val),
|
|
258
|
+
}),
|
|
259
|
+
active_stake: structs_1.Option.bcs(structs_6.FungibleStakedSui.bcs),
|
|
260
|
+
inactive_stake: structs_1.Option.bcs(structs_6.StakedSui.bcs),
|
|
261
|
+
exchange_rate: structs_6.PoolTokenExchangeRate.bcs,
|
|
262
|
+
total_sui_amount: bcs_1.bcs.u64(),
|
|
263
|
+
extra_fields: structs_2.Bag.bcs,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
static fromFields(fields) {
|
|
267
|
+
return ValidatorInfo.reified().new({
|
|
268
|
+
stakingPoolId: (0, reified_1.decodeFromFields)(structs_4.ID.reified(), fields.staking_pool_id),
|
|
269
|
+
validatorAddress: (0, reified_1.decodeFromFields)("address", fields.validator_address),
|
|
270
|
+
activeStake: (0, reified_1.decodeFromFields)(structs_1.Option.reified(structs_6.FungibleStakedSui.reified()), fields.active_stake),
|
|
271
|
+
inactiveStake: (0, reified_1.decodeFromFields)(structs_1.Option.reified(structs_6.StakedSui.reified()), fields.inactive_stake),
|
|
272
|
+
exchangeRate: (0, reified_1.decodeFromFields)(structs_6.PoolTokenExchangeRate.reified(), fields.exchange_rate),
|
|
273
|
+
totalSuiAmount: (0, reified_1.decodeFromFields)("u64", fields.total_sui_amount),
|
|
274
|
+
extraFields: (0, reified_1.decodeFromFields)(structs_2.Bag.reified(), fields.extra_fields),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
static fromFieldsWithTypes(item) {
|
|
278
|
+
if (!isValidatorInfo(item.type)) {
|
|
279
|
+
throw new Error("not a ValidatorInfo type");
|
|
280
|
+
}
|
|
281
|
+
return ValidatorInfo.reified().new({
|
|
282
|
+
stakingPoolId: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.ID.reified(), item.fields.staking_pool_id),
|
|
283
|
+
validatorAddress: (0, reified_1.decodeFromFieldsWithTypes)("address", item.fields.validator_address),
|
|
284
|
+
activeStake: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Option.reified(structs_6.FungibleStakedSui.reified()), item.fields.active_stake),
|
|
285
|
+
inactiveStake: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Option.reified(structs_6.StakedSui.reified()), item.fields.inactive_stake),
|
|
286
|
+
exchangeRate: (0, reified_1.decodeFromFieldsWithTypes)(structs_6.PoolTokenExchangeRate.reified(), item.fields.exchange_rate),
|
|
287
|
+
totalSuiAmount: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.total_sui_amount),
|
|
288
|
+
extraFields: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.Bag.reified(), item.fields.extra_fields),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
static fromBcs(data) {
|
|
292
|
+
return ValidatorInfo.fromFields(ValidatorInfo.bcs.parse(data));
|
|
293
|
+
}
|
|
294
|
+
toJSONField() {
|
|
295
|
+
return {
|
|
296
|
+
stakingPoolId: this.stakingPoolId,
|
|
297
|
+
validatorAddress: this.validatorAddress,
|
|
298
|
+
activeStake: (0, reified_1.fieldToJSON)(`${structs_1.Option.$typeName}<${structs_6.FungibleStakedSui.$typeName}>`, this.activeStake),
|
|
299
|
+
inactiveStake: (0, reified_1.fieldToJSON)(`${structs_1.Option.$typeName}<${structs_6.StakedSui.$typeName}>`, this.inactiveStake),
|
|
300
|
+
exchangeRate: this.exchangeRate.toJSONField(),
|
|
301
|
+
totalSuiAmount: this.totalSuiAmount.toString(),
|
|
302
|
+
extraFields: this.extraFields.toJSONField(),
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
toJSON() {
|
|
306
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
307
|
+
}
|
|
308
|
+
static fromJSONField(field) {
|
|
309
|
+
return ValidatorInfo.reified().new({
|
|
310
|
+
stakingPoolId: (0, reified_1.decodeFromJSONField)(structs_4.ID.reified(), field.stakingPoolId),
|
|
311
|
+
validatorAddress: (0, reified_1.decodeFromJSONField)("address", field.validatorAddress),
|
|
312
|
+
activeStake: (0, reified_1.decodeFromJSONField)(structs_1.Option.reified(structs_6.FungibleStakedSui.reified()), field.activeStake),
|
|
313
|
+
inactiveStake: (0, reified_1.decodeFromJSONField)(structs_1.Option.reified(structs_6.StakedSui.reified()), field.inactiveStake),
|
|
314
|
+
exchangeRate: (0, reified_1.decodeFromJSONField)(structs_6.PoolTokenExchangeRate.reified(), field.exchangeRate),
|
|
315
|
+
totalSuiAmount: (0, reified_1.decodeFromJSONField)("u64", field.totalSuiAmount),
|
|
316
|
+
extraFields: (0, reified_1.decodeFromJSONField)(structs_2.Bag.reified(), field.extraFields),
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
static fromJSON(json) {
|
|
320
|
+
if (json.$typeName !== ValidatorInfo.$typeName) {
|
|
321
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
322
|
+
}
|
|
323
|
+
return ValidatorInfo.fromJSONField(json);
|
|
324
|
+
}
|
|
325
|
+
static fromSuiParsedData(content) {
|
|
326
|
+
if (content.dataType !== "moveObject") {
|
|
327
|
+
throw new Error("not an object");
|
|
328
|
+
}
|
|
329
|
+
if (!isValidatorInfo(content.type)) {
|
|
330
|
+
throw new Error(`object at ${content.fields.id} is not a ValidatorInfo object`);
|
|
331
|
+
}
|
|
332
|
+
return ValidatorInfo.fromFieldsWithTypes(content);
|
|
333
|
+
}
|
|
334
|
+
static fromSuiObjectData(data) {
|
|
335
|
+
if (data.bcs) {
|
|
336
|
+
if (data.bcs.dataType !== "moveObject" ||
|
|
337
|
+
!isValidatorInfo(data.bcs.type)) {
|
|
338
|
+
throw new Error(`object at is not a ValidatorInfo object`);
|
|
339
|
+
}
|
|
340
|
+
return ValidatorInfo.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
341
|
+
}
|
|
342
|
+
if (data.content) {
|
|
343
|
+
return ValidatorInfo.fromSuiParsedData(data.content);
|
|
344
|
+
}
|
|
345
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
346
|
+
}
|
|
347
|
+
static fetch(client, id) {
|
|
348
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
351
|
+
if (res.error) {
|
|
352
|
+
throw new Error(`error fetching ValidatorInfo object at id ${id}: ${res.error.code}`);
|
|
353
|
+
}
|
|
354
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
355
|
+
!isValidatorInfo(res.data.bcs.type)) {
|
|
356
|
+
throw new Error(`object at id ${id} is not a ValidatorInfo object`);
|
|
357
|
+
}
|
|
358
|
+
return ValidatorInfo.fromSuiObjectData(res.data);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
exports.ValidatorInfo = ValidatorInfo;
|
|
363
|
+
ValidatorInfo.$typeName = `${index_1.PKG_V1}::storage::ValidatorInfo`;
|
|
364
|
+
ValidatorInfo.$numTypeParams = 0;
|
|
365
|
+
ValidatorInfo.$isPhantom = [];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../_framework/reified";
|
|
2
|
+
import { FieldsWithTypes } from "../../_framework/util";
|
|
3
|
+
import { PKG_V1 } from "../index";
|
|
4
|
+
import { SuiClient, SuiObjectData, SuiParsedData } from "@mysten/sui/client";
|
|
5
|
+
export declare function isVersion(type: string): boolean;
|
|
6
|
+
export interface VersionFields {
|
|
7
|
+
pos0: ToField<"u16">;
|
|
8
|
+
}
|
|
9
|
+
export type VersionReified = Reified<Version, VersionFields>;
|
|
10
|
+
export declare class Version implements StructClass {
|
|
11
|
+
__StructClass: true;
|
|
12
|
+
static readonly $typeName = "0xcfbcad8e0444ca85ad7ee28054585d12a7487bdbd83569ded988ca13441bf16e::version::Version";
|
|
13
|
+
static readonly $numTypeParams = 0;
|
|
14
|
+
static readonly $isPhantom: readonly [];
|
|
15
|
+
readonly $typeName = "0xcfbcad8e0444ca85ad7ee28054585d12a7487bdbd83569ded988ca13441bf16e::version::Version";
|
|
16
|
+
readonly $fullTypeName: `${typeof PKG_V1}::version::Version`;
|
|
17
|
+
readonly $typeArgs: [];
|
|
18
|
+
readonly $isPhantom: readonly [];
|
|
19
|
+
readonly pos0: ToField<"u16">;
|
|
20
|
+
private constructor();
|
|
21
|
+
static reified(): VersionReified;
|
|
22
|
+
static get r(): import("../../_framework/reified").StructClassReified<Version, VersionFields>;
|
|
23
|
+
static phantom(): PhantomReified<ToTypeStr<Version>>;
|
|
24
|
+
static get p(): PhantomReified<"0xcfbcad8e0444ca85ad7ee28054585d12a7487bdbd83569ded988ca13441bf16e::version::Version">;
|
|
25
|
+
static get bcs(): import("@mysten/sui/bcs").BcsType<{
|
|
26
|
+
pos0: number;
|
|
27
|
+
}, {
|
|
28
|
+
pos0: number;
|
|
29
|
+
}>;
|
|
30
|
+
static fromFields(fields: Record<string, any>): Version;
|
|
31
|
+
static fromFieldsWithTypes(item: FieldsWithTypes): Version;
|
|
32
|
+
static fromBcs(data: Uint8Array): Version;
|
|
33
|
+
toJSONField(): {
|
|
34
|
+
pos0: number;
|
|
35
|
+
};
|
|
36
|
+
toJSON(): {
|
|
37
|
+
pos0: number;
|
|
38
|
+
$typeName: string;
|
|
39
|
+
$typeArgs: [];
|
|
40
|
+
};
|
|
41
|
+
static fromJSONField(field: any): Version;
|
|
42
|
+
static fromJSON(json: Record<string, any>): Version;
|
|
43
|
+
static fromSuiParsedData(content: SuiParsedData): Version;
|
|
44
|
+
static fromSuiObjectData(data: SuiObjectData): Version;
|
|
45
|
+
static fetch(client: SuiClient, id: string): Promise<Version>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Version = void 0;
|
|
13
|
+
exports.isVersion = isVersion;
|
|
14
|
+
const reified_1 = require("../../_framework/reified");
|
|
15
|
+
const util_1 = require("../../_framework/util");
|
|
16
|
+
const index_1 = require("../index");
|
|
17
|
+
const bcs_1 = require("@mysten/sui/bcs");
|
|
18
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
19
|
+
/* ============================== Version =============================== */
|
|
20
|
+
function isVersion(type) {
|
|
21
|
+
type = (0, util_1.compressSuiType)(type);
|
|
22
|
+
return type === `${index_1.PKG_V1}::version::Version`;
|
|
23
|
+
}
|
|
24
|
+
class Version {
|
|
25
|
+
constructor(typeArgs, fields) {
|
|
26
|
+
this.__StructClass = true;
|
|
27
|
+
this.$typeName = Version.$typeName;
|
|
28
|
+
this.$isPhantom = Version.$isPhantom;
|
|
29
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(Version.$typeName, ...typeArgs);
|
|
30
|
+
this.$typeArgs = typeArgs;
|
|
31
|
+
this.pos0 = fields.pos0;
|
|
32
|
+
}
|
|
33
|
+
static reified() {
|
|
34
|
+
return {
|
|
35
|
+
typeName: Version.$typeName,
|
|
36
|
+
fullTypeName: (0, util_1.composeSuiType)(Version.$typeName, ...[]),
|
|
37
|
+
typeArgs: [],
|
|
38
|
+
isPhantom: Version.$isPhantom,
|
|
39
|
+
reifiedTypeArgs: [],
|
|
40
|
+
fromFields: (fields) => Version.fromFields(fields),
|
|
41
|
+
fromFieldsWithTypes: (item) => Version.fromFieldsWithTypes(item),
|
|
42
|
+
fromBcs: (data) => Version.fromBcs(data),
|
|
43
|
+
bcs: Version.bcs,
|
|
44
|
+
fromJSONField: (field) => Version.fromJSONField(field),
|
|
45
|
+
fromJSON: (json) => Version.fromJSON(json),
|
|
46
|
+
fromSuiParsedData: (content) => Version.fromSuiParsedData(content),
|
|
47
|
+
fromSuiObjectData: (content) => Version.fromSuiObjectData(content),
|
|
48
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return Version.fetch(client, id); }),
|
|
49
|
+
new: (fields) => {
|
|
50
|
+
return new Version([], fields);
|
|
51
|
+
},
|
|
52
|
+
kind: "StructClassReified",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
static get r() {
|
|
56
|
+
return Version.reified();
|
|
57
|
+
}
|
|
58
|
+
static phantom() {
|
|
59
|
+
return (0, reified_1.phantom)(Version.reified());
|
|
60
|
+
}
|
|
61
|
+
static get p() {
|
|
62
|
+
return Version.phantom();
|
|
63
|
+
}
|
|
64
|
+
static get bcs() {
|
|
65
|
+
return bcs_1.bcs.struct("Version", {
|
|
66
|
+
pos0: bcs_1.bcs.u16(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
static fromFields(fields) {
|
|
70
|
+
return Version.reified().new({
|
|
71
|
+
pos0: (0, reified_1.decodeFromFields)("u16", fields.pos0),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
static fromFieldsWithTypes(item) {
|
|
75
|
+
if (!isVersion(item.type)) {
|
|
76
|
+
throw new Error("not a Version type");
|
|
77
|
+
}
|
|
78
|
+
return Version.reified().new({
|
|
79
|
+
pos0: (0, reified_1.decodeFromFieldsWithTypes)("u16", item.fields.pos0),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
static fromBcs(data) {
|
|
83
|
+
return Version.fromFields(Version.bcs.parse(data));
|
|
84
|
+
}
|
|
85
|
+
toJSONField() {
|
|
86
|
+
return {
|
|
87
|
+
pos0: this.pos0,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
toJSON() {
|
|
91
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
92
|
+
}
|
|
93
|
+
static fromJSONField(field) {
|
|
94
|
+
return Version.reified().new({
|
|
95
|
+
pos0: (0, reified_1.decodeFromJSONField)("u16", field.pos0),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
static fromJSON(json) {
|
|
99
|
+
if (json.$typeName !== Version.$typeName) {
|
|
100
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
101
|
+
}
|
|
102
|
+
return Version.fromJSONField(json);
|
|
103
|
+
}
|
|
104
|
+
static fromSuiParsedData(content) {
|
|
105
|
+
if (content.dataType !== "moveObject") {
|
|
106
|
+
throw new Error("not an object");
|
|
107
|
+
}
|
|
108
|
+
if (!isVersion(content.type)) {
|
|
109
|
+
throw new Error(`object at ${content.fields.id} is not a Version object`);
|
|
110
|
+
}
|
|
111
|
+
return Version.fromFieldsWithTypes(content);
|
|
112
|
+
}
|
|
113
|
+
static fromSuiObjectData(data) {
|
|
114
|
+
if (data.bcs) {
|
|
115
|
+
if (data.bcs.dataType !== "moveObject" || !isVersion(data.bcs.type)) {
|
|
116
|
+
throw new Error(`object at is not a Version object`);
|
|
117
|
+
}
|
|
118
|
+
return Version.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
119
|
+
}
|
|
120
|
+
if (data.content) {
|
|
121
|
+
return Version.fromSuiParsedData(data.content);
|
|
122
|
+
}
|
|
123
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
124
|
+
}
|
|
125
|
+
static fetch(client, id) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
129
|
+
if (res.error) {
|
|
130
|
+
throw new Error(`error fetching Version object at id ${id}: ${res.error.code}`);
|
|
131
|
+
}
|
|
132
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
133
|
+
!isVersion(res.data.bcs.type)) {
|
|
134
|
+
throw new Error(`object at id ${id} is not a Version object`);
|
|
135
|
+
}
|
|
136
|
+
return Version.fromSuiObjectData(res.data);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.Version = Version;
|
|
141
|
+
Version.$typeName = `${index_1.PKG_V1}::version::Version`;
|
|
142
|
+
Version.$numTypeParams = 0;
|
|
143
|
+
Version.$isPhantom = [];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Transaction, TransactionObjectInput } from "@mysten/sui/transactions";
|
|
2
|
+
export declare function new_(tx: Transaction, typeArg: string, adminCap: TransactionObjectInput): import("@mysten/sui/transactions").TransactionResult;
|
|
3
|
+
export interface EjectArgs {
|
|
4
|
+
self: TransactionObjectInput;
|
|
5
|
+
adminCap: TransactionObjectInput;
|
|
6
|
+
}
|
|
7
|
+
export declare function eject(tx: Transaction, typeArg: string, args: EjectArgs): import("@mysten/sui/transactions").TransactionResult;
|
|
8
|
+
export interface RebalanceArgs {
|
|
9
|
+
self: TransactionObjectInput;
|
|
10
|
+
systemState: TransactionObjectInput;
|
|
11
|
+
liquidStakingInfo: TransactionObjectInput;
|
|
12
|
+
}
|
|
13
|
+
export declare function rebalance(tx: Transaction, typeArg: string, args: RebalanceArgs): import("@mysten/sui/transactions").TransactionResult;
|
|
14
|
+
export interface SetValidatorAddressesAndWeightsArgs {
|
|
15
|
+
self: TransactionObjectInput;
|
|
16
|
+
weightHookAdminCap: TransactionObjectInput;
|
|
17
|
+
validatorAddressesAndWeights: TransactionObjectInput;
|
|
18
|
+
}
|
|
19
|
+
export declare function setValidatorAddressesAndWeights(tx: Transaction, typeArg: string, args: SetValidatorAddressesAndWeightsArgs): import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.new_ = new_;
|
|
4
|
+
exports.eject = eject;
|
|
5
|
+
exports.rebalance = rebalance;
|
|
6
|
+
exports.setValidatorAddressesAndWeights = setValidatorAddressesAndWeights;
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
const util_1 = require("../../_framework/util");
|
|
9
|
+
function new_(tx, typeArg, adminCap) {
|
|
10
|
+
return tx.moveCall({
|
|
11
|
+
target: `${__1.PUBLISHED_AT}::weight::new`,
|
|
12
|
+
typeArguments: [typeArg],
|
|
13
|
+
arguments: [(0, util_1.obj)(tx, adminCap)],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function eject(tx, typeArg, args) {
|
|
17
|
+
return tx.moveCall({
|
|
18
|
+
target: `${__1.PUBLISHED_AT}::weight::eject`,
|
|
19
|
+
typeArguments: [typeArg],
|
|
20
|
+
arguments: [(0, util_1.obj)(tx, args.self), (0, util_1.obj)(tx, args.adminCap)],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function rebalance(tx, typeArg, args) {
|
|
24
|
+
return tx.moveCall({
|
|
25
|
+
target: `${__1.PUBLISHED_AT}::weight::rebalance`,
|
|
26
|
+
typeArguments: [typeArg],
|
|
27
|
+
arguments: [
|
|
28
|
+
(0, util_1.obj)(tx, args.self),
|
|
29
|
+
(0, util_1.obj)(tx, args.systemState),
|
|
30
|
+
(0, util_1.obj)(tx, args.liquidStakingInfo),
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function setValidatorAddressesAndWeights(tx, typeArg, args) {
|
|
35
|
+
return tx.moveCall({
|
|
36
|
+
target: `${__1.PUBLISHED_AT}::weight::set_validator_addresses_and_weights`,
|
|
37
|
+
typeArguments: [typeArg],
|
|
38
|
+
arguments: [
|
|
39
|
+
(0, util_1.obj)(tx, args.self),
|
|
40
|
+
(0, util_1.obj)(tx, args.weightHookAdminCap),
|
|
41
|
+
(0, util_1.obj)(tx, args.validatorAddressesAndWeights),
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
}
|