@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,915 @@
|
|
|
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.StakingPool = exports.StakedSui = exports.PoolTokenExchangeRate = exports.FungibleStakedSuiDataKey = exports.FungibleStakedSuiData = exports.FungibleStakedSui = void 0;
|
|
36
|
+
exports.isFungibleStakedSui = isFungibleStakedSui;
|
|
37
|
+
exports.isFungibleStakedSuiData = isFungibleStakedSuiData;
|
|
38
|
+
exports.isFungibleStakedSuiDataKey = isFungibleStakedSuiDataKey;
|
|
39
|
+
exports.isPoolTokenExchangeRate = isPoolTokenExchangeRate;
|
|
40
|
+
exports.isStakedSui = isStakedSui;
|
|
41
|
+
exports.isStakingPool = isStakingPool;
|
|
42
|
+
const reified = __importStar(require("../../../../_framework/reified"));
|
|
43
|
+
const reified_1 = require("../../../../_framework/reified");
|
|
44
|
+
const util_1 = require("../../../../_framework/util");
|
|
45
|
+
const structs_1 = require("../../0x1/option/structs");
|
|
46
|
+
const structs_2 = require("../../0x2/bag/structs");
|
|
47
|
+
const structs_3 = require("../../0x2/balance/structs");
|
|
48
|
+
const structs_4 = require("../../0x2/object/structs");
|
|
49
|
+
const structs_5 = require("../../0x2/sui/structs");
|
|
50
|
+
const structs_6 = require("../../0x2/table/structs");
|
|
51
|
+
const index_1 = require("../index");
|
|
52
|
+
const bcs_1 = require("@mysten/sui/bcs");
|
|
53
|
+
const utils_1 = require("@mysten/sui/utils");
|
|
54
|
+
/* ============================== FungibleStakedSui =============================== */
|
|
55
|
+
function isFungibleStakedSui(type) {
|
|
56
|
+
type = (0, util_1.compressSuiType)(type);
|
|
57
|
+
return type === `${index_1.PKG_V16}::staking_pool::FungibleStakedSui`;
|
|
58
|
+
}
|
|
59
|
+
class FungibleStakedSui {
|
|
60
|
+
constructor(typeArgs, fields) {
|
|
61
|
+
this.__StructClass = true;
|
|
62
|
+
this.$typeName = FungibleStakedSui.$typeName;
|
|
63
|
+
this.$isPhantom = FungibleStakedSui.$isPhantom;
|
|
64
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(FungibleStakedSui.$typeName, ...typeArgs);
|
|
65
|
+
this.$typeArgs = typeArgs;
|
|
66
|
+
this.id = fields.id;
|
|
67
|
+
this.poolId = fields.poolId;
|
|
68
|
+
this.value = fields.value;
|
|
69
|
+
}
|
|
70
|
+
static reified() {
|
|
71
|
+
return {
|
|
72
|
+
typeName: FungibleStakedSui.$typeName,
|
|
73
|
+
fullTypeName: (0, util_1.composeSuiType)(FungibleStakedSui.$typeName, ...[]),
|
|
74
|
+
typeArgs: [],
|
|
75
|
+
isPhantom: FungibleStakedSui.$isPhantom,
|
|
76
|
+
reifiedTypeArgs: [],
|
|
77
|
+
fromFields: (fields) => FungibleStakedSui.fromFields(fields),
|
|
78
|
+
fromFieldsWithTypes: (item) => FungibleStakedSui.fromFieldsWithTypes(item),
|
|
79
|
+
fromBcs: (data) => FungibleStakedSui.fromBcs(data),
|
|
80
|
+
bcs: FungibleStakedSui.bcs,
|
|
81
|
+
fromJSONField: (field) => FungibleStakedSui.fromJSONField(field),
|
|
82
|
+
fromJSON: (json) => FungibleStakedSui.fromJSON(json),
|
|
83
|
+
fromSuiParsedData: (content) => FungibleStakedSui.fromSuiParsedData(content),
|
|
84
|
+
fromSuiObjectData: (content) => FungibleStakedSui.fromSuiObjectData(content),
|
|
85
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return FungibleStakedSui.fetch(client, id); }),
|
|
86
|
+
new: (fields) => {
|
|
87
|
+
return new FungibleStakedSui([], fields);
|
|
88
|
+
},
|
|
89
|
+
kind: "StructClassReified",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static get r() {
|
|
93
|
+
return FungibleStakedSui.reified();
|
|
94
|
+
}
|
|
95
|
+
static phantom() {
|
|
96
|
+
return (0, reified_1.phantom)(FungibleStakedSui.reified());
|
|
97
|
+
}
|
|
98
|
+
static get p() {
|
|
99
|
+
return FungibleStakedSui.phantom();
|
|
100
|
+
}
|
|
101
|
+
static get bcs() {
|
|
102
|
+
return bcs_1.bcs.struct("FungibleStakedSui", {
|
|
103
|
+
id: structs_4.UID.bcs,
|
|
104
|
+
pool_id: structs_4.ID.bcs,
|
|
105
|
+
value: bcs_1.bcs.u64(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
static fromFields(fields) {
|
|
109
|
+
return FungibleStakedSui.reified().new({
|
|
110
|
+
id: (0, reified_1.decodeFromFields)(structs_4.UID.reified(), fields.id),
|
|
111
|
+
poolId: (0, reified_1.decodeFromFields)(structs_4.ID.reified(), fields.pool_id),
|
|
112
|
+
value: (0, reified_1.decodeFromFields)("u64", fields.value),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
static fromFieldsWithTypes(item) {
|
|
116
|
+
if (!isFungibleStakedSui(item.type)) {
|
|
117
|
+
throw new Error("not a FungibleStakedSui type");
|
|
118
|
+
}
|
|
119
|
+
return FungibleStakedSui.reified().new({
|
|
120
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.UID.reified(), item.fields.id),
|
|
121
|
+
poolId: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.ID.reified(), item.fields.pool_id),
|
|
122
|
+
value: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.value),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
static fromBcs(data) {
|
|
126
|
+
return FungibleStakedSui.fromFields(FungibleStakedSui.bcs.parse(data));
|
|
127
|
+
}
|
|
128
|
+
toJSONField() {
|
|
129
|
+
return {
|
|
130
|
+
id: this.id,
|
|
131
|
+
poolId: this.poolId,
|
|
132
|
+
value: this.value.toString(),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
toJSON() {
|
|
136
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
137
|
+
}
|
|
138
|
+
static fromJSONField(field) {
|
|
139
|
+
return FungibleStakedSui.reified().new({
|
|
140
|
+
id: (0, reified_1.decodeFromJSONField)(structs_4.UID.reified(), field.id),
|
|
141
|
+
poolId: (0, reified_1.decodeFromJSONField)(structs_4.ID.reified(), field.poolId),
|
|
142
|
+
value: (0, reified_1.decodeFromJSONField)("u64", field.value),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
static fromJSON(json) {
|
|
146
|
+
if (json.$typeName !== FungibleStakedSui.$typeName) {
|
|
147
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
148
|
+
}
|
|
149
|
+
return FungibleStakedSui.fromJSONField(json);
|
|
150
|
+
}
|
|
151
|
+
static fromSuiParsedData(content) {
|
|
152
|
+
if (content.dataType !== "moveObject") {
|
|
153
|
+
throw new Error("not an object");
|
|
154
|
+
}
|
|
155
|
+
if (!isFungibleStakedSui(content.type)) {
|
|
156
|
+
throw new Error(`object at ${content.fields.id} is not a FungibleStakedSui object`);
|
|
157
|
+
}
|
|
158
|
+
return FungibleStakedSui.fromFieldsWithTypes(content);
|
|
159
|
+
}
|
|
160
|
+
static fromSuiObjectData(data) {
|
|
161
|
+
if (data.bcs) {
|
|
162
|
+
if (data.bcs.dataType !== "moveObject" ||
|
|
163
|
+
!isFungibleStakedSui(data.bcs.type)) {
|
|
164
|
+
throw new Error(`object at is not a FungibleStakedSui object`);
|
|
165
|
+
}
|
|
166
|
+
return FungibleStakedSui.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
167
|
+
}
|
|
168
|
+
if (data.content) {
|
|
169
|
+
return FungibleStakedSui.fromSuiParsedData(data.content);
|
|
170
|
+
}
|
|
171
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
172
|
+
}
|
|
173
|
+
static fetch(client, id) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
177
|
+
if (res.error) {
|
|
178
|
+
throw new Error(`error fetching FungibleStakedSui object at id ${id}: ${res.error.code}`);
|
|
179
|
+
}
|
|
180
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
181
|
+
!isFungibleStakedSui(res.data.bcs.type)) {
|
|
182
|
+
throw new Error(`object at id ${id} is not a FungibleStakedSui object`);
|
|
183
|
+
}
|
|
184
|
+
return FungibleStakedSui.fromSuiObjectData(res.data);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.FungibleStakedSui = FungibleStakedSui;
|
|
189
|
+
FungibleStakedSui.$typeName = `${index_1.PKG_V16}::staking_pool::FungibleStakedSui`;
|
|
190
|
+
FungibleStakedSui.$numTypeParams = 0;
|
|
191
|
+
FungibleStakedSui.$isPhantom = [];
|
|
192
|
+
/* ============================== FungibleStakedSuiData =============================== */
|
|
193
|
+
function isFungibleStakedSuiData(type) {
|
|
194
|
+
type = (0, util_1.compressSuiType)(type);
|
|
195
|
+
return type === `${index_1.PKG_V16}::staking_pool::FungibleStakedSuiData`;
|
|
196
|
+
}
|
|
197
|
+
class FungibleStakedSuiData {
|
|
198
|
+
constructor(typeArgs, fields) {
|
|
199
|
+
this.__StructClass = true;
|
|
200
|
+
this.$typeName = FungibleStakedSuiData.$typeName;
|
|
201
|
+
this.$isPhantom = FungibleStakedSuiData.$isPhantom;
|
|
202
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(FungibleStakedSuiData.$typeName, ...typeArgs);
|
|
203
|
+
this.$typeArgs = typeArgs;
|
|
204
|
+
this.id = fields.id;
|
|
205
|
+
this.totalSupply = fields.totalSupply;
|
|
206
|
+
this.principal = fields.principal;
|
|
207
|
+
}
|
|
208
|
+
static reified() {
|
|
209
|
+
return {
|
|
210
|
+
typeName: FungibleStakedSuiData.$typeName,
|
|
211
|
+
fullTypeName: (0, util_1.composeSuiType)(FungibleStakedSuiData.$typeName, ...[]),
|
|
212
|
+
typeArgs: [],
|
|
213
|
+
isPhantom: FungibleStakedSuiData.$isPhantom,
|
|
214
|
+
reifiedTypeArgs: [],
|
|
215
|
+
fromFields: (fields) => FungibleStakedSuiData.fromFields(fields),
|
|
216
|
+
fromFieldsWithTypes: (item) => FungibleStakedSuiData.fromFieldsWithTypes(item),
|
|
217
|
+
fromBcs: (data) => FungibleStakedSuiData.fromBcs(data),
|
|
218
|
+
bcs: FungibleStakedSuiData.bcs,
|
|
219
|
+
fromJSONField: (field) => FungibleStakedSuiData.fromJSONField(field),
|
|
220
|
+
fromJSON: (json) => FungibleStakedSuiData.fromJSON(json),
|
|
221
|
+
fromSuiParsedData: (content) => FungibleStakedSuiData.fromSuiParsedData(content),
|
|
222
|
+
fromSuiObjectData: (content) => FungibleStakedSuiData.fromSuiObjectData(content),
|
|
223
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return FungibleStakedSuiData.fetch(client, id); }),
|
|
224
|
+
new: (fields) => {
|
|
225
|
+
return new FungibleStakedSuiData([], fields);
|
|
226
|
+
},
|
|
227
|
+
kind: "StructClassReified",
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
static get r() {
|
|
231
|
+
return FungibleStakedSuiData.reified();
|
|
232
|
+
}
|
|
233
|
+
static phantom() {
|
|
234
|
+
return (0, reified_1.phantom)(FungibleStakedSuiData.reified());
|
|
235
|
+
}
|
|
236
|
+
static get p() {
|
|
237
|
+
return FungibleStakedSuiData.phantom();
|
|
238
|
+
}
|
|
239
|
+
static get bcs() {
|
|
240
|
+
return bcs_1.bcs.struct("FungibleStakedSuiData", {
|
|
241
|
+
id: structs_4.UID.bcs,
|
|
242
|
+
total_supply: bcs_1.bcs.u64(),
|
|
243
|
+
principal: structs_3.Balance.bcs,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
static fromFields(fields) {
|
|
247
|
+
return FungibleStakedSuiData.reified().new({
|
|
248
|
+
id: (0, reified_1.decodeFromFields)(structs_4.UID.reified(), fields.id),
|
|
249
|
+
totalSupply: (0, reified_1.decodeFromFields)("u64", fields.total_supply),
|
|
250
|
+
principal: (0, reified_1.decodeFromFields)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), fields.principal),
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
static fromFieldsWithTypes(item) {
|
|
254
|
+
if (!isFungibleStakedSuiData(item.type)) {
|
|
255
|
+
throw new Error("not a FungibleStakedSuiData type");
|
|
256
|
+
}
|
|
257
|
+
return FungibleStakedSuiData.reified().new({
|
|
258
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.UID.reified(), item.fields.id),
|
|
259
|
+
totalSupply: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.total_supply),
|
|
260
|
+
principal: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), item.fields.principal),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
static fromBcs(data) {
|
|
264
|
+
return FungibleStakedSuiData.fromFields(FungibleStakedSuiData.bcs.parse(data));
|
|
265
|
+
}
|
|
266
|
+
toJSONField() {
|
|
267
|
+
return {
|
|
268
|
+
id: this.id,
|
|
269
|
+
totalSupply: this.totalSupply.toString(),
|
|
270
|
+
principal: this.principal.toJSONField(),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
toJSON() {
|
|
274
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
275
|
+
}
|
|
276
|
+
static fromJSONField(field) {
|
|
277
|
+
return FungibleStakedSuiData.reified().new({
|
|
278
|
+
id: (0, reified_1.decodeFromJSONField)(structs_4.UID.reified(), field.id),
|
|
279
|
+
totalSupply: (0, reified_1.decodeFromJSONField)("u64", field.totalSupply),
|
|
280
|
+
principal: (0, reified_1.decodeFromJSONField)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), field.principal),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
static fromJSON(json) {
|
|
284
|
+
if (json.$typeName !== FungibleStakedSuiData.$typeName) {
|
|
285
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
286
|
+
}
|
|
287
|
+
return FungibleStakedSuiData.fromJSONField(json);
|
|
288
|
+
}
|
|
289
|
+
static fromSuiParsedData(content) {
|
|
290
|
+
if (content.dataType !== "moveObject") {
|
|
291
|
+
throw new Error("not an object");
|
|
292
|
+
}
|
|
293
|
+
if (!isFungibleStakedSuiData(content.type)) {
|
|
294
|
+
throw new Error(`object at ${content.fields.id} is not a FungibleStakedSuiData object`);
|
|
295
|
+
}
|
|
296
|
+
return FungibleStakedSuiData.fromFieldsWithTypes(content);
|
|
297
|
+
}
|
|
298
|
+
static fromSuiObjectData(data) {
|
|
299
|
+
if (data.bcs) {
|
|
300
|
+
if (data.bcs.dataType !== "moveObject" ||
|
|
301
|
+
!isFungibleStakedSuiData(data.bcs.type)) {
|
|
302
|
+
throw new Error(`object at is not a FungibleStakedSuiData object`);
|
|
303
|
+
}
|
|
304
|
+
return FungibleStakedSuiData.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
305
|
+
}
|
|
306
|
+
if (data.content) {
|
|
307
|
+
return FungibleStakedSuiData.fromSuiParsedData(data.content);
|
|
308
|
+
}
|
|
309
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
310
|
+
}
|
|
311
|
+
static fetch(client, id) {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
var _a, _b;
|
|
314
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
315
|
+
if (res.error) {
|
|
316
|
+
throw new Error(`error fetching FungibleStakedSuiData object at id ${id}: ${res.error.code}`);
|
|
317
|
+
}
|
|
318
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
319
|
+
!isFungibleStakedSuiData(res.data.bcs.type)) {
|
|
320
|
+
throw new Error(`object at id ${id} is not a FungibleStakedSuiData object`);
|
|
321
|
+
}
|
|
322
|
+
return FungibleStakedSuiData.fromSuiObjectData(res.data);
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
exports.FungibleStakedSuiData = FungibleStakedSuiData;
|
|
327
|
+
FungibleStakedSuiData.$typeName = `${index_1.PKG_V16}::staking_pool::FungibleStakedSuiData`;
|
|
328
|
+
FungibleStakedSuiData.$numTypeParams = 0;
|
|
329
|
+
FungibleStakedSuiData.$isPhantom = [];
|
|
330
|
+
/* ============================== FungibleStakedSuiDataKey =============================== */
|
|
331
|
+
function isFungibleStakedSuiDataKey(type) {
|
|
332
|
+
type = (0, util_1.compressSuiType)(type);
|
|
333
|
+
return type === `${index_1.PKG_V16}::staking_pool::FungibleStakedSuiDataKey`;
|
|
334
|
+
}
|
|
335
|
+
class FungibleStakedSuiDataKey {
|
|
336
|
+
constructor(typeArgs, fields) {
|
|
337
|
+
this.__StructClass = true;
|
|
338
|
+
this.$typeName = FungibleStakedSuiDataKey.$typeName;
|
|
339
|
+
this.$isPhantom = FungibleStakedSuiDataKey.$isPhantom;
|
|
340
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(FungibleStakedSuiDataKey.$typeName, ...typeArgs);
|
|
341
|
+
this.$typeArgs = typeArgs;
|
|
342
|
+
this.dummyField = fields.dummyField;
|
|
343
|
+
}
|
|
344
|
+
static reified() {
|
|
345
|
+
return {
|
|
346
|
+
typeName: FungibleStakedSuiDataKey.$typeName,
|
|
347
|
+
fullTypeName: (0, util_1.composeSuiType)(FungibleStakedSuiDataKey.$typeName, ...[]),
|
|
348
|
+
typeArgs: [],
|
|
349
|
+
isPhantom: FungibleStakedSuiDataKey.$isPhantom,
|
|
350
|
+
reifiedTypeArgs: [],
|
|
351
|
+
fromFields: (fields) => FungibleStakedSuiDataKey.fromFields(fields),
|
|
352
|
+
fromFieldsWithTypes: (item) => FungibleStakedSuiDataKey.fromFieldsWithTypes(item),
|
|
353
|
+
fromBcs: (data) => FungibleStakedSuiDataKey.fromBcs(data),
|
|
354
|
+
bcs: FungibleStakedSuiDataKey.bcs,
|
|
355
|
+
fromJSONField: (field) => FungibleStakedSuiDataKey.fromJSONField(field),
|
|
356
|
+
fromJSON: (json) => FungibleStakedSuiDataKey.fromJSON(json),
|
|
357
|
+
fromSuiParsedData: (content) => FungibleStakedSuiDataKey.fromSuiParsedData(content),
|
|
358
|
+
fromSuiObjectData: (content) => FungibleStakedSuiDataKey.fromSuiObjectData(content),
|
|
359
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return FungibleStakedSuiDataKey.fetch(client, id); }),
|
|
360
|
+
new: (fields) => {
|
|
361
|
+
return new FungibleStakedSuiDataKey([], fields);
|
|
362
|
+
},
|
|
363
|
+
kind: "StructClassReified",
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
static get r() {
|
|
367
|
+
return FungibleStakedSuiDataKey.reified();
|
|
368
|
+
}
|
|
369
|
+
static phantom() {
|
|
370
|
+
return (0, reified_1.phantom)(FungibleStakedSuiDataKey.reified());
|
|
371
|
+
}
|
|
372
|
+
static get p() {
|
|
373
|
+
return FungibleStakedSuiDataKey.phantom();
|
|
374
|
+
}
|
|
375
|
+
static get bcs() {
|
|
376
|
+
return bcs_1.bcs.struct("FungibleStakedSuiDataKey", {
|
|
377
|
+
dummy_field: bcs_1.bcs.bool(),
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
static fromFields(fields) {
|
|
381
|
+
return FungibleStakedSuiDataKey.reified().new({
|
|
382
|
+
dummyField: (0, reified_1.decodeFromFields)("bool", fields.dummy_field),
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
static fromFieldsWithTypes(item) {
|
|
386
|
+
if (!isFungibleStakedSuiDataKey(item.type)) {
|
|
387
|
+
throw new Error("not a FungibleStakedSuiDataKey type");
|
|
388
|
+
}
|
|
389
|
+
return FungibleStakedSuiDataKey.reified().new({
|
|
390
|
+
dummyField: (0, reified_1.decodeFromFieldsWithTypes)("bool", item.fields.dummy_field),
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
static fromBcs(data) {
|
|
394
|
+
return FungibleStakedSuiDataKey.fromFields(FungibleStakedSuiDataKey.bcs.parse(data));
|
|
395
|
+
}
|
|
396
|
+
toJSONField() {
|
|
397
|
+
return {
|
|
398
|
+
dummyField: this.dummyField,
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
toJSON() {
|
|
402
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
403
|
+
}
|
|
404
|
+
static fromJSONField(field) {
|
|
405
|
+
return FungibleStakedSuiDataKey.reified().new({
|
|
406
|
+
dummyField: (0, reified_1.decodeFromJSONField)("bool", field.dummyField),
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
static fromJSON(json) {
|
|
410
|
+
if (json.$typeName !== FungibleStakedSuiDataKey.$typeName) {
|
|
411
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
412
|
+
}
|
|
413
|
+
return FungibleStakedSuiDataKey.fromJSONField(json);
|
|
414
|
+
}
|
|
415
|
+
static fromSuiParsedData(content) {
|
|
416
|
+
if (content.dataType !== "moveObject") {
|
|
417
|
+
throw new Error("not an object");
|
|
418
|
+
}
|
|
419
|
+
if (!isFungibleStakedSuiDataKey(content.type)) {
|
|
420
|
+
throw new Error(`object at ${content.fields.id} is not a FungibleStakedSuiDataKey object`);
|
|
421
|
+
}
|
|
422
|
+
return FungibleStakedSuiDataKey.fromFieldsWithTypes(content);
|
|
423
|
+
}
|
|
424
|
+
static fromSuiObjectData(data) {
|
|
425
|
+
if (data.bcs) {
|
|
426
|
+
if (data.bcs.dataType !== "moveObject" ||
|
|
427
|
+
!isFungibleStakedSuiDataKey(data.bcs.type)) {
|
|
428
|
+
throw new Error(`object at is not a FungibleStakedSuiDataKey object`);
|
|
429
|
+
}
|
|
430
|
+
return FungibleStakedSuiDataKey.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
431
|
+
}
|
|
432
|
+
if (data.content) {
|
|
433
|
+
return FungibleStakedSuiDataKey.fromSuiParsedData(data.content);
|
|
434
|
+
}
|
|
435
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
436
|
+
}
|
|
437
|
+
static fetch(client, id) {
|
|
438
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
439
|
+
var _a, _b;
|
|
440
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
441
|
+
if (res.error) {
|
|
442
|
+
throw new Error(`error fetching FungibleStakedSuiDataKey object at id ${id}: ${res.error.code}`);
|
|
443
|
+
}
|
|
444
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
445
|
+
!isFungibleStakedSuiDataKey(res.data.bcs.type)) {
|
|
446
|
+
throw new Error(`object at id ${id} is not a FungibleStakedSuiDataKey object`);
|
|
447
|
+
}
|
|
448
|
+
return FungibleStakedSuiDataKey.fromSuiObjectData(res.data);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
exports.FungibleStakedSuiDataKey = FungibleStakedSuiDataKey;
|
|
453
|
+
FungibleStakedSuiDataKey.$typeName = `${index_1.PKG_V16}::staking_pool::FungibleStakedSuiDataKey`;
|
|
454
|
+
FungibleStakedSuiDataKey.$numTypeParams = 0;
|
|
455
|
+
FungibleStakedSuiDataKey.$isPhantom = [];
|
|
456
|
+
/* ============================== PoolTokenExchangeRate =============================== */
|
|
457
|
+
function isPoolTokenExchangeRate(type) {
|
|
458
|
+
type = (0, util_1.compressSuiType)(type);
|
|
459
|
+
return type === `${index_1.PKG_V16}::staking_pool::PoolTokenExchangeRate`;
|
|
460
|
+
}
|
|
461
|
+
class PoolTokenExchangeRate {
|
|
462
|
+
constructor(typeArgs, fields) {
|
|
463
|
+
this.__StructClass = true;
|
|
464
|
+
this.$typeName = PoolTokenExchangeRate.$typeName;
|
|
465
|
+
this.$isPhantom = PoolTokenExchangeRate.$isPhantom;
|
|
466
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(PoolTokenExchangeRate.$typeName, ...typeArgs);
|
|
467
|
+
this.$typeArgs = typeArgs;
|
|
468
|
+
this.suiAmount = fields.suiAmount;
|
|
469
|
+
this.poolTokenAmount = fields.poolTokenAmount;
|
|
470
|
+
}
|
|
471
|
+
static reified() {
|
|
472
|
+
return {
|
|
473
|
+
typeName: PoolTokenExchangeRate.$typeName,
|
|
474
|
+
fullTypeName: (0, util_1.composeSuiType)(PoolTokenExchangeRate.$typeName, ...[]),
|
|
475
|
+
typeArgs: [],
|
|
476
|
+
isPhantom: PoolTokenExchangeRate.$isPhantom,
|
|
477
|
+
reifiedTypeArgs: [],
|
|
478
|
+
fromFields: (fields) => PoolTokenExchangeRate.fromFields(fields),
|
|
479
|
+
fromFieldsWithTypes: (item) => PoolTokenExchangeRate.fromFieldsWithTypes(item),
|
|
480
|
+
fromBcs: (data) => PoolTokenExchangeRate.fromBcs(data),
|
|
481
|
+
bcs: PoolTokenExchangeRate.bcs,
|
|
482
|
+
fromJSONField: (field) => PoolTokenExchangeRate.fromJSONField(field),
|
|
483
|
+
fromJSON: (json) => PoolTokenExchangeRate.fromJSON(json),
|
|
484
|
+
fromSuiParsedData: (content) => PoolTokenExchangeRate.fromSuiParsedData(content),
|
|
485
|
+
fromSuiObjectData: (content) => PoolTokenExchangeRate.fromSuiObjectData(content),
|
|
486
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return PoolTokenExchangeRate.fetch(client, id); }),
|
|
487
|
+
new: (fields) => {
|
|
488
|
+
return new PoolTokenExchangeRate([], fields);
|
|
489
|
+
},
|
|
490
|
+
kind: "StructClassReified",
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
static get r() {
|
|
494
|
+
return PoolTokenExchangeRate.reified();
|
|
495
|
+
}
|
|
496
|
+
static phantom() {
|
|
497
|
+
return (0, reified_1.phantom)(PoolTokenExchangeRate.reified());
|
|
498
|
+
}
|
|
499
|
+
static get p() {
|
|
500
|
+
return PoolTokenExchangeRate.phantom();
|
|
501
|
+
}
|
|
502
|
+
static get bcs() {
|
|
503
|
+
return bcs_1.bcs.struct("PoolTokenExchangeRate", {
|
|
504
|
+
sui_amount: bcs_1.bcs.u64(),
|
|
505
|
+
pool_token_amount: bcs_1.bcs.u64(),
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
static fromFields(fields) {
|
|
509
|
+
return PoolTokenExchangeRate.reified().new({
|
|
510
|
+
suiAmount: (0, reified_1.decodeFromFields)("u64", fields.sui_amount),
|
|
511
|
+
poolTokenAmount: (0, reified_1.decodeFromFields)("u64", fields.pool_token_amount),
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
static fromFieldsWithTypes(item) {
|
|
515
|
+
if (!isPoolTokenExchangeRate(item.type)) {
|
|
516
|
+
throw new Error("not a PoolTokenExchangeRate type");
|
|
517
|
+
}
|
|
518
|
+
return PoolTokenExchangeRate.reified().new({
|
|
519
|
+
suiAmount: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.sui_amount),
|
|
520
|
+
poolTokenAmount: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.pool_token_amount),
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
static fromBcs(data) {
|
|
524
|
+
return PoolTokenExchangeRate.fromFields(PoolTokenExchangeRate.bcs.parse(data));
|
|
525
|
+
}
|
|
526
|
+
toJSONField() {
|
|
527
|
+
return {
|
|
528
|
+
suiAmount: this.suiAmount.toString(),
|
|
529
|
+
poolTokenAmount: this.poolTokenAmount.toString(),
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
toJSON() {
|
|
533
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
534
|
+
}
|
|
535
|
+
static fromJSONField(field) {
|
|
536
|
+
return PoolTokenExchangeRate.reified().new({
|
|
537
|
+
suiAmount: (0, reified_1.decodeFromJSONField)("u64", field.suiAmount),
|
|
538
|
+
poolTokenAmount: (0, reified_1.decodeFromJSONField)("u64", field.poolTokenAmount),
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
static fromJSON(json) {
|
|
542
|
+
if (json.$typeName !== PoolTokenExchangeRate.$typeName) {
|
|
543
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
544
|
+
}
|
|
545
|
+
return PoolTokenExchangeRate.fromJSONField(json);
|
|
546
|
+
}
|
|
547
|
+
static fromSuiParsedData(content) {
|
|
548
|
+
if (content.dataType !== "moveObject") {
|
|
549
|
+
throw new Error("not an object");
|
|
550
|
+
}
|
|
551
|
+
if (!isPoolTokenExchangeRate(content.type)) {
|
|
552
|
+
throw new Error(`object at ${content.fields.id} is not a PoolTokenExchangeRate object`);
|
|
553
|
+
}
|
|
554
|
+
return PoolTokenExchangeRate.fromFieldsWithTypes(content);
|
|
555
|
+
}
|
|
556
|
+
static fromSuiObjectData(data) {
|
|
557
|
+
if (data.bcs) {
|
|
558
|
+
if (data.bcs.dataType !== "moveObject" ||
|
|
559
|
+
!isPoolTokenExchangeRate(data.bcs.type)) {
|
|
560
|
+
throw new Error(`object at is not a PoolTokenExchangeRate object`);
|
|
561
|
+
}
|
|
562
|
+
return PoolTokenExchangeRate.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
563
|
+
}
|
|
564
|
+
if (data.content) {
|
|
565
|
+
return PoolTokenExchangeRate.fromSuiParsedData(data.content);
|
|
566
|
+
}
|
|
567
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
568
|
+
}
|
|
569
|
+
static fetch(client, id) {
|
|
570
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
571
|
+
var _a, _b;
|
|
572
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
573
|
+
if (res.error) {
|
|
574
|
+
throw new Error(`error fetching PoolTokenExchangeRate object at id ${id}: ${res.error.code}`);
|
|
575
|
+
}
|
|
576
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
577
|
+
!isPoolTokenExchangeRate(res.data.bcs.type)) {
|
|
578
|
+
throw new Error(`object at id ${id} is not a PoolTokenExchangeRate object`);
|
|
579
|
+
}
|
|
580
|
+
return PoolTokenExchangeRate.fromSuiObjectData(res.data);
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
exports.PoolTokenExchangeRate = PoolTokenExchangeRate;
|
|
585
|
+
PoolTokenExchangeRate.$typeName = `${index_1.PKG_V16}::staking_pool::PoolTokenExchangeRate`;
|
|
586
|
+
PoolTokenExchangeRate.$numTypeParams = 0;
|
|
587
|
+
PoolTokenExchangeRate.$isPhantom = [];
|
|
588
|
+
/* ============================== StakedSui =============================== */
|
|
589
|
+
function isStakedSui(type) {
|
|
590
|
+
type = (0, util_1.compressSuiType)(type);
|
|
591
|
+
return type === `${index_1.PKG_V16}::staking_pool::StakedSui`;
|
|
592
|
+
}
|
|
593
|
+
class StakedSui {
|
|
594
|
+
constructor(typeArgs, fields) {
|
|
595
|
+
this.__StructClass = true;
|
|
596
|
+
this.$typeName = StakedSui.$typeName;
|
|
597
|
+
this.$isPhantom = StakedSui.$isPhantom;
|
|
598
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(StakedSui.$typeName, ...typeArgs);
|
|
599
|
+
this.$typeArgs = typeArgs;
|
|
600
|
+
this.id = fields.id;
|
|
601
|
+
this.poolId = fields.poolId;
|
|
602
|
+
this.stakeActivationEpoch = fields.stakeActivationEpoch;
|
|
603
|
+
this.principal = fields.principal;
|
|
604
|
+
}
|
|
605
|
+
static reified() {
|
|
606
|
+
return {
|
|
607
|
+
typeName: StakedSui.$typeName,
|
|
608
|
+
fullTypeName: (0, util_1.composeSuiType)(StakedSui.$typeName, ...[]),
|
|
609
|
+
typeArgs: [],
|
|
610
|
+
isPhantom: StakedSui.$isPhantom,
|
|
611
|
+
reifiedTypeArgs: [],
|
|
612
|
+
fromFields: (fields) => StakedSui.fromFields(fields),
|
|
613
|
+
fromFieldsWithTypes: (item) => StakedSui.fromFieldsWithTypes(item),
|
|
614
|
+
fromBcs: (data) => StakedSui.fromBcs(data),
|
|
615
|
+
bcs: StakedSui.bcs,
|
|
616
|
+
fromJSONField: (field) => StakedSui.fromJSONField(field),
|
|
617
|
+
fromJSON: (json) => StakedSui.fromJSON(json),
|
|
618
|
+
fromSuiParsedData: (content) => StakedSui.fromSuiParsedData(content),
|
|
619
|
+
fromSuiObjectData: (content) => StakedSui.fromSuiObjectData(content),
|
|
620
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return StakedSui.fetch(client, id); }),
|
|
621
|
+
new: (fields) => {
|
|
622
|
+
return new StakedSui([], fields);
|
|
623
|
+
},
|
|
624
|
+
kind: "StructClassReified",
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
static get r() {
|
|
628
|
+
return StakedSui.reified();
|
|
629
|
+
}
|
|
630
|
+
static phantom() {
|
|
631
|
+
return (0, reified_1.phantom)(StakedSui.reified());
|
|
632
|
+
}
|
|
633
|
+
static get p() {
|
|
634
|
+
return StakedSui.phantom();
|
|
635
|
+
}
|
|
636
|
+
static get bcs() {
|
|
637
|
+
return bcs_1.bcs.struct("StakedSui", {
|
|
638
|
+
id: structs_4.UID.bcs,
|
|
639
|
+
pool_id: structs_4.ID.bcs,
|
|
640
|
+
stake_activation_epoch: bcs_1.bcs.u64(),
|
|
641
|
+
principal: structs_3.Balance.bcs,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
static fromFields(fields) {
|
|
645
|
+
return StakedSui.reified().new({
|
|
646
|
+
id: (0, reified_1.decodeFromFields)(structs_4.UID.reified(), fields.id),
|
|
647
|
+
poolId: (0, reified_1.decodeFromFields)(structs_4.ID.reified(), fields.pool_id),
|
|
648
|
+
stakeActivationEpoch: (0, reified_1.decodeFromFields)("u64", fields.stake_activation_epoch),
|
|
649
|
+
principal: (0, reified_1.decodeFromFields)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), fields.principal),
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
static fromFieldsWithTypes(item) {
|
|
653
|
+
if (!isStakedSui(item.type)) {
|
|
654
|
+
throw new Error("not a StakedSui type");
|
|
655
|
+
}
|
|
656
|
+
return StakedSui.reified().new({
|
|
657
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.UID.reified(), item.fields.id),
|
|
658
|
+
poolId: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.ID.reified(), item.fields.pool_id),
|
|
659
|
+
stakeActivationEpoch: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.stake_activation_epoch),
|
|
660
|
+
principal: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), item.fields.principal),
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
static fromBcs(data) {
|
|
664
|
+
return StakedSui.fromFields(StakedSui.bcs.parse(data));
|
|
665
|
+
}
|
|
666
|
+
toJSONField() {
|
|
667
|
+
return {
|
|
668
|
+
id: this.id,
|
|
669
|
+
poolId: this.poolId,
|
|
670
|
+
stakeActivationEpoch: this.stakeActivationEpoch.toString(),
|
|
671
|
+
principal: this.principal.toJSONField(),
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
toJSON() {
|
|
675
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
676
|
+
}
|
|
677
|
+
static fromJSONField(field) {
|
|
678
|
+
return StakedSui.reified().new({
|
|
679
|
+
id: (0, reified_1.decodeFromJSONField)(structs_4.UID.reified(), field.id),
|
|
680
|
+
poolId: (0, reified_1.decodeFromJSONField)(structs_4.ID.reified(), field.poolId),
|
|
681
|
+
stakeActivationEpoch: (0, reified_1.decodeFromJSONField)("u64", field.stakeActivationEpoch),
|
|
682
|
+
principal: (0, reified_1.decodeFromJSONField)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), field.principal),
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
static fromJSON(json) {
|
|
686
|
+
if (json.$typeName !== StakedSui.$typeName) {
|
|
687
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
688
|
+
}
|
|
689
|
+
return StakedSui.fromJSONField(json);
|
|
690
|
+
}
|
|
691
|
+
static fromSuiParsedData(content) {
|
|
692
|
+
if (content.dataType !== "moveObject") {
|
|
693
|
+
throw new Error("not an object");
|
|
694
|
+
}
|
|
695
|
+
if (!isStakedSui(content.type)) {
|
|
696
|
+
throw new Error(`object at ${content.fields.id} is not a StakedSui object`);
|
|
697
|
+
}
|
|
698
|
+
return StakedSui.fromFieldsWithTypes(content);
|
|
699
|
+
}
|
|
700
|
+
static fromSuiObjectData(data) {
|
|
701
|
+
if (data.bcs) {
|
|
702
|
+
if (data.bcs.dataType !== "moveObject" || !isStakedSui(data.bcs.type)) {
|
|
703
|
+
throw new Error(`object at is not a StakedSui object`);
|
|
704
|
+
}
|
|
705
|
+
return StakedSui.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
706
|
+
}
|
|
707
|
+
if (data.content) {
|
|
708
|
+
return StakedSui.fromSuiParsedData(data.content);
|
|
709
|
+
}
|
|
710
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
711
|
+
}
|
|
712
|
+
static fetch(client, id) {
|
|
713
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
714
|
+
var _a, _b;
|
|
715
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
716
|
+
if (res.error) {
|
|
717
|
+
throw new Error(`error fetching StakedSui object at id ${id}: ${res.error.code}`);
|
|
718
|
+
}
|
|
719
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
720
|
+
!isStakedSui(res.data.bcs.type)) {
|
|
721
|
+
throw new Error(`object at id ${id} is not a StakedSui object`);
|
|
722
|
+
}
|
|
723
|
+
return StakedSui.fromSuiObjectData(res.data);
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
exports.StakedSui = StakedSui;
|
|
728
|
+
StakedSui.$typeName = `${index_1.PKG_V16}::staking_pool::StakedSui`;
|
|
729
|
+
StakedSui.$numTypeParams = 0;
|
|
730
|
+
StakedSui.$isPhantom = [];
|
|
731
|
+
/* ============================== StakingPool =============================== */
|
|
732
|
+
function isStakingPool(type) {
|
|
733
|
+
type = (0, util_1.compressSuiType)(type);
|
|
734
|
+
return type === `${index_1.PKG_V16}::staking_pool::StakingPool`;
|
|
735
|
+
}
|
|
736
|
+
class StakingPool {
|
|
737
|
+
constructor(typeArgs, fields) {
|
|
738
|
+
this.__StructClass = true;
|
|
739
|
+
this.$typeName = StakingPool.$typeName;
|
|
740
|
+
this.$isPhantom = StakingPool.$isPhantom;
|
|
741
|
+
this.$fullTypeName = (0, util_1.composeSuiType)(StakingPool.$typeName, ...typeArgs);
|
|
742
|
+
this.$typeArgs = typeArgs;
|
|
743
|
+
this.id = fields.id;
|
|
744
|
+
this.activationEpoch = fields.activationEpoch;
|
|
745
|
+
this.deactivationEpoch = fields.deactivationEpoch;
|
|
746
|
+
this.suiBalance = fields.suiBalance;
|
|
747
|
+
this.rewardsPool = fields.rewardsPool;
|
|
748
|
+
this.poolTokenBalance = fields.poolTokenBalance;
|
|
749
|
+
this.exchangeRates = fields.exchangeRates;
|
|
750
|
+
this.pendingStake = fields.pendingStake;
|
|
751
|
+
this.pendingTotalSuiWithdraw = fields.pendingTotalSuiWithdraw;
|
|
752
|
+
this.pendingPoolTokenWithdraw = fields.pendingPoolTokenWithdraw;
|
|
753
|
+
this.extraFields = fields.extraFields;
|
|
754
|
+
}
|
|
755
|
+
static reified() {
|
|
756
|
+
return {
|
|
757
|
+
typeName: StakingPool.$typeName,
|
|
758
|
+
fullTypeName: (0, util_1.composeSuiType)(StakingPool.$typeName, ...[]),
|
|
759
|
+
typeArgs: [],
|
|
760
|
+
isPhantom: StakingPool.$isPhantom,
|
|
761
|
+
reifiedTypeArgs: [],
|
|
762
|
+
fromFields: (fields) => StakingPool.fromFields(fields),
|
|
763
|
+
fromFieldsWithTypes: (item) => StakingPool.fromFieldsWithTypes(item),
|
|
764
|
+
fromBcs: (data) => StakingPool.fromBcs(data),
|
|
765
|
+
bcs: StakingPool.bcs,
|
|
766
|
+
fromJSONField: (field) => StakingPool.fromJSONField(field),
|
|
767
|
+
fromJSON: (json) => StakingPool.fromJSON(json),
|
|
768
|
+
fromSuiParsedData: (content) => StakingPool.fromSuiParsedData(content),
|
|
769
|
+
fromSuiObjectData: (content) => StakingPool.fromSuiObjectData(content),
|
|
770
|
+
fetch: (client, id) => __awaiter(this, void 0, void 0, function* () { return StakingPool.fetch(client, id); }),
|
|
771
|
+
new: (fields) => {
|
|
772
|
+
return new StakingPool([], fields);
|
|
773
|
+
},
|
|
774
|
+
kind: "StructClassReified",
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
static get r() {
|
|
778
|
+
return StakingPool.reified();
|
|
779
|
+
}
|
|
780
|
+
static phantom() {
|
|
781
|
+
return (0, reified_1.phantom)(StakingPool.reified());
|
|
782
|
+
}
|
|
783
|
+
static get p() {
|
|
784
|
+
return StakingPool.phantom();
|
|
785
|
+
}
|
|
786
|
+
static get bcs() {
|
|
787
|
+
return bcs_1.bcs.struct("StakingPool", {
|
|
788
|
+
id: structs_4.UID.bcs,
|
|
789
|
+
activation_epoch: structs_1.Option.bcs(bcs_1.bcs.u64()),
|
|
790
|
+
deactivation_epoch: structs_1.Option.bcs(bcs_1.bcs.u64()),
|
|
791
|
+
sui_balance: bcs_1.bcs.u64(),
|
|
792
|
+
rewards_pool: structs_3.Balance.bcs,
|
|
793
|
+
pool_token_balance: bcs_1.bcs.u64(),
|
|
794
|
+
exchange_rates: structs_6.Table.bcs,
|
|
795
|
+
pending_stake: bcs_1.bcs.u64(),
|
|
796
|
+
pending_total_sui_withdraw: bcs_1.bcs.u64(),
|
|
797
|
+
pending_pool_token_withdraw: bcs_1.bcs.u64(),
|
|
798
|
+
extra_fields: structs_2.Bag.bcs,
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
static fromFields(fields) {
|
|
802
|
+
return StakingPool.reified().new({
|
|
803
|
+
id: (0, reified_1.decodeFromFields)(structs_4.UID.reified(), fields.id),
|
|
804
|
+
activationEpoch: (0, reified_1.decodeFromFields)(structs_1.Option.reified("u64"), fields.activation_epoch),
|
|
805
|
+
deactivationEpoch: (0, reified_1.decodeFromFields)(structs_1.Option.reified("u64"), fields.deactivation_epoch),
|
|
806
|
+
suiBalance: (0, reified_1.decodeFromFields)("u64", fields.sui_balance),
|
|
807
|
+
rewardsPool: (0, reified_1.decodeFromFields)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), fields.rewards_pool),
|
|
808
|
+
poolTokenBalance: (0, reified_1.decodeFromFields)("u64", fields.pool_token_balance),
|
|
809
|
+
exchangeRates: (0, reified_1.decodeFromFields)(structs_6.Table.reified(reified.phantom("u64"), reified.phantom(PoolTokenExchangeRate.reified())), fields.exchange_rates),
|
|
810
|
+
pendingStake: (0, reified_1.decodeFromFields)("u64", fields.pending_stake),
|
|
811
|
+
pendingTotalSuiWithdraw: (0, reified_1.decodeFromFields)("u64", fields.pending_total_sui_withdraw),
|
|
812
|
+
pendingPoolTokenWithdraw: (0, reified_1.decodeFromFields)("u64", fields.pending_pool_token_withdraw),
|
|
813
|
+
extraFields: (0, reified_1.decodeFromFields)(structs_2.Bag.reified(), fields.extra_fields),
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
static fromFieldsWithTypes(item) {
|
|
817
|
+
if (!isStakingPool(item.type)) {
|
|
818
|
+
throw new Error("not a StakingPool type");
|
|
819
|
+
}
|
|
820
|
+
return StakingPool.reified().new({
|
|
821
|
+
id: (0, reified_1.decodeFromFieldsWithTypes)(structs_4.UID.reified(), item.fields.id),
|
|
822
|
+
activationEpoch: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Option.reified("u64"), item.fields.activation_epoch),
|
|
823
|
+
deactivationEpoch: (0, reified_1.decodeFromFieldsWithTypes)(structs_1.Option.reified("u64"), item.fields.deactivation_epoch),
|
|
824
|
+
suiBalance: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.sui_balance),
|
|
825
|
+
rewardsPool: (0, reified_1.decodeFromFieldsWithTypes)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), item.fields.rewards_pool),
|
|
826
|
+
poolTokenBalance: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.pool_token_balance),
|
|
827
|
+
exchangeRates: (0, reified_1.decodeFromFieldsWithTypes)(structs_6.Table.reified(reified.phantom("u64"), reified.phantom(PoolTokenExchangeRate.reified())), item.fields.exchange_rates),
|
|
828
|
+
pendingStake: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.pending_stake),
|
|
829
|
+
pendingTotalSuiWithdraw: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.pending_total_sui_withdraw),
|
|
830
|
+
pendingPoolTokenWithdraw: (0, reified_1.decodeFromFieldsWithTypes)("u64", item.fields.pending_pool_token_withdraw),
|
|
831
|
+
extraFields: (0, reified_1.decodeFromFieldsWithTypes)(structs_2.Bag.reified(), item.fields.extra_fields),
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
static fromBcs(data) {
|
|
835
|
+
return StakingPool.fromFields(StakingPool.bcs.parse(data));
|
|
836
|
+
}
|
|
837
|
+
toJSONField() {
|
|
838
|
+
return {
|
|
839
|
+
id: this.id,
|
|
840
|
+
activationEpoch: (0, reified_1.fieldToJSON)(`${structs_1.Option.$typeName}<u64>`, this.activationEpoch),
|
|
841
|
+
deactivationEpoch: (0, reified_1.fieldToJSON)(`${structs_1.Option.$typeName}<u64>`, this.deactivationEpoch),
|
|
842
|
+
suiBalance: this.suiBalance.toString(),
|
|
843
|
+
rewardsPool: this.rewardsPool.toJSONField(),
|
|
844
|
+
poolTokenBalance: this.poolTokenBalance.toString(),
|
|
845
|
+
exchangeRates: this.exchangeRates.toJSONField(),
|
|
846
|
+
pendingStake: this.pendingStake.toString(),
|
|
847
|
+
pendingTotalSuiWithdraw: this.pendingTotalSuiWithdraw.toString(),
|
|
848
|
+
pendingPoolTokenWithdraw: this.pendingPoolTokenWithdraw.toString(),
|
|
849
|
+
extraFields: this.extraFields.toJSONField(),
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
toJSON() {
|
|
853
|
+
return Object.assign({ $typeName: this.$typeName, $typeArgs: this.$typeArgs }, this.toJSONField());
|
|
854
|
+
}
|
|
855
|
+
static fromJSONField(field) {
|
|
856
|
+
return StakingPool.reified().new({
|
|
857
|
+
id: (0, reified_1.decodeFromJSONField)(structs_4.UID.reified(), field.id),
|
|
858
|
+
activationEpoch: (0, reified_1.decodeFromJSONField)(structs_1.Option.reified("u64"), field.activationEpoch),
|
|
859
|
+
deactivationEpoch: (0, reified_1.decodeFromJSONField)(structs_1.Option.reified("u64"), field.deactivationEpoch),
|
|
860
|
+
suiBalance: (0, reified_1.decodeFromJSONField)("u64", field.suiBalance),
|
|
861
|
+
rewardsPool: (0, reified_1.decodeFromJSONField)(structs_3.Balance.reified(reified.phantom(structs_5.SUI.reified())), field.rewardsPool),
|
|
862
|
+
poolTokenBalance: (0, reified_1.decodeFromJSONField)("u64", field.poolTokenBalance),
|
|
863
|
+
exchangeRates: (0, reified_1.decodeFromJSONField)(structs_6.Table.reified(reified.phantom("u64"), reified.phantom(PoolTokenExchangeRate.reified())), field.exchangeRates),
|
|
864
|
+
pendingStake: (0, reified_1.decodeFromJSONField)("u64", field.pendingStake),
|
|
865
|
+
pendingTotalSuiWithdraw: (0, reified_1.decodeFromJSONField)("u64", field.pendingTotalSuiWithdraw),
|
|
866
|
+
pendingPoolTokenWithdraw: (0, reified_1.decodeFromJSONField)("u64", field.pendingPoolTokenWithdraw),
|
|
867
|
+
extraFields: (0, reified_1.decodeFromJSONField)(structs_2.Bag.reified(), field.extraFields),
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
static fromJSON(json) {
|
|
871
|
+
if (json.$typeName !== StakingPool.$typeName) {
|
|
872
|
+
throw new Error("not a WithTwoGenerics json object");
|
|
873
|
+
}
|
|
874
|
+
return StakingPool.fromJSONField(json);
|
|
875
|
+
}
|
|
876
|
+
static fromSuiParsedData(content) {
|
|
877
|
+
if (content.dataType !== "moveObject") {
|
|
878
|
+
throw new Error("not an object");
|
|
879
|
+
}
|
|
880
|
+
if (!isStakingPool(content.type)) {
|
|
881
|
+
throw new Error(`object at ${content.fields.id} is not a StakingPool object`);
|
|
882
|
+
}
|
|
883
|
+
return StakingPool.fromFieldsWithTypes(content);
|
|
884
|
+
}
|
|
885
|
+
static fromSuiObjectData(data) {
|
|
886
|
+
if (data.bcs) {
|
|
887
|
+
if (data.bcs.dataType !== "moveObject" || !isStakingPool(data.bcs.type)) {
|
|
888
|
+
throw new Error(`object at is not a StakingPool object`);
|
|
889
|
+
}
|
|
890
|
+
return StakingPool.fromBcs((0, utils_1.fromB64)(data.bcs.bcsBytes));
|
|
891
|
+
}
|
|
892
|
+
if (data.content) {
|
|
893
|
+
return StakingPool.fromSuiParsedData(data.content);
|
|
894
|
+
}
|
|
895
|
+
throw new Error("Both `bcs` and `content` fields are missing from the data. Include `showBcs` or `showContent` in the request.");
|
|
896
|
+
}
|
|
897
|
+
static fetch(client, id) {
|
|
898
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
899
|
+
var _a, _b;
|
|
900
|
+
const res = yield client.getObject({ id, options: { showBcs: true } });
|
|
901
|
+
if (res.error) {
|
|
902
|
+
throw new Error(`error fetching StakingPool object at id ${id}: ${res.error.code}`);
|
|
903
|
+
}
|
|
904
|
+
if (((_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject" ||
|
|
905
|
+
!isStakingPool(res.data.bcs.type)) {
|
|
906
|
+
throw new Error(`object at id ${id} is not a StakingPool object`);
|
|
907
|
+
}
|
|
908
|
+
return StakingPool.fromSuiObjectData(res.data);
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
exports.StakingPool = StakingPool;
|
|
913
|
+
StakingPool.$typeName = `${index_1.PKG_V16}::staking_pool::StakingPool`;
|
|
914
|
+
StakingPool.$numTypeParams = 0;
|
|
915
|
+
StakingPool.$isPhantom = [];
|