aftermath-ts-sdk 2.1.0 → 2.2.0-dev.b73637d
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/README.md +32 -6
- package/dist/index.d.ts +4522 -3526
- package/dist/index.js +1120 -457
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -8,11 +8,229 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
// src/general/utils/grpcCasting.ts
|
|
12
|
+
import { fromBase64, toBase64 } from "@mysten/sui/utils";
|
|
13
|
+
var _GrpcCasting, GrpcCasting;
|
|
14
|
+
var init_grpcCasting = __esm({
|
|
15
|
+
"src/general/utils/grpcCasting.ts"() {
|
|
16
|
+
"use strict";
|
|
17
|
+
_GrpcCasting = class _GrpcCasting {
|
|
18
|
+
};
|
|
19
|
+
// =========================================================================
|
|
20
|
+
// Coins
|
|
21
|
+
// =========================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Reshapes a gRPC `Coin` into JSON-RPC's `CoinStruct`.
|
|
24
|
+
*
|
|
25
|
+
* Differences that callers may observe:
|
|
26
|
+
* - `coinType` is derived from the coin object's `type`
|
|
27
|
+
* (`0x2::coin::Coin<T>` -> `T`) and is therefore fully zero-padded, where
|
|
28
|
+
* JSON-RPC echoed the node's abbreviated form (e.g. `0x2::sui::SUI`).
|
|
29
|
+
* Compare coin types through `Helpers.addLeadingZeroesToType` — as this
|
|
30
|
+
* SDK already does everywhere — and the two are equal.
|
|
31
|
+
* - `previousTransaction` is **not returned by `listCoins`** and is set to
|
|
32
|
+
* the empty string. Nothing in this SDK reads it. Fetch the object with
|
|
33
|
+
* `include: { previousTransaction: true }` if you need it.
|
|
34
|
+
*/
|
|
35
|
+
_GrpcCasting.coinStructFromGrpcCoin = (coin) => ({
|
|
36
|
+
coinType: _GrpcCasting.innerCoinTypeFromCoinObjectType(coin.type),
|
|
37
|
+
coinObjectId: coin.objectId,
|
|
38
|
+
version: coin.version,
|
|
39
|
+
digest: coin.digest,
|
|
40
|
+
balance: coin.balance,
|
|
41
|
+
previousTransaction: ""
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Extracts `T` from a `0x2::coin::Coin<T>` object type. Returns the input
|
|
45
|
+
* unchanged when it is not a generic type.
|
|
46
|
+
*/
|
|
47
|
+
_GrpcCasting.innerCoinTypeFromCoinObjectType = (objectType) => {
|
|
48
|
+
const start = objectType.indexOf("<");
|
|
49
|
+
const end = objectType.lastIndexOf(">");
|
|
50
|
+
if (start < 0 || end < start) {
|
|
51
|
+
return objectType;
|
|
52
|
+
}
|
|
53
|
+
return objectType.slice(start + 1, end);
|
|
54
|
+
};
|
|
55
|
+
// =========================================================================
|
|
56
|
+
// Dynamic Fields
|
|
57
|
+
// =========================================================================
|
|
58
|
+
/**
|
|
59
|
+
* Reshapes a gRPC `DynamicFieldEntry` into JSON-RPC's `DynamicFieldInfo`.
|
|
60
|
+
*
|
|
61
|
+
* Field mapping (verified live against a real parent object):
|
|
62
|
+
* - `fieldId` -> `objectId`
|
|
63
|
+
* - `valueType` -> `objectType`
|
|
64
|
+
* - `$kind` -> `type` (`"DynamicField"` | `"DynamicObject"`)
|
|
65
|
+
* - `name.bcs` -> `bcsName` (base64), `bcsEncoding: "base64"`
|
|
66
|
+
*
|
|
67
|
+
* Differences that callers may observe:
|
|
68
|
+
* - `name.value` was the **parsed** field name under JSON-RPC. gRPC returns
|
|
69
|
+
* only its BCS bytes and this SDK does not carry Move type layouts, so
|
|
70
|
+
* `name.value` is the base64 of those bytes. `name.type` is unchanged.
|
|
71
|
+
* - `version` and `digest` are **not returned by `listDynamicFields`**.
|
|
72
|
+
* They are omitted rather than zero-filled. Nothing in this SDK reads
|
|
73
|
+
* them; fetch the field object if you need them.
|
|
74
|
+
*/
|
|
75
|
+
_GrpcCasting.dynamicFieldInfoFromGrpcEntry = (entry) => ({
|
|
76
|
+
name: {
|
|
77
|
+
type: entry.name.type,
|
|
78
|
+
value: toBase64(entry.name.bcs)
|
|
79
|
+
},
|
|
80
|
+
bcsEncoding: "base64",
|
|
81
|
+
bcsName: toBase64(entry.name.bcs),
|
|
82
|
+
type: entry.$kind,
|
|
83
|
+
objectType: entry.valueType,
|
|
84
|
+
objectId: entry.fieldId
|
|
85
|
+
});
|
|
86
|
+
// =========================================================================
|
|
87
|
+
// Objects
|
|
88
|
+
// =========================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Builds a `SuiObjectResponse` carrying only the fields available from a
|
|
91
|
+
* gRPC `getObject({ include: { content: true } })` — enough for
|
|
92
|
+
* {@link Casting.castObjectBcs}, which reads `data.bcs.bcsBytes`.
|
|
93
|
+
*
|
|
94
|
+
* The BCS bytes gRPC returns under `content` were verified byte-identical
|
|
95
|
+
* to JSON-RPC's `bcs.bcsBytes` for every object probed (a `SuiSystemState`,
|
|
96
|
+
* three Aftermath pools and three `Coin<SUI>` objects).
|
|
97
|
+
*
|
|
98
|
+
* `hasPublicTransfer` is not returned by gRPC. It is omitted; nothing in
|
|
99
|
+
* this SDK reads it.
|
|
100
|
+
*/
|
|
101
|
+
_GrpcCasting.suiObjectResponseFromGrpcObjectBcs = (object) => ({
|
|
102
|
+
data: {
|
|
103
|
+
objectId: object.objectId,
|
|
104
|
+
version: object.version,
|
|
105
|
+
digest: object.digest,
|
|
106
|
+
type: object.type,
|
|
107
|
+
owner: object.owner,
|
|
108
|
+
bcs: {
|
|
109
|
+
dataType: "moveObject",
|
|
110
|
+
type: object.type,
|
|
111
|
+
version: object.version,
|
|
112
|
+
bcsBytes: toBase64(object.content)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Reshapes a gRPC `Display` into JSON-RPC's `DisplayFieldsResponse`, so the
|
|
118
|
+
* NFT/SuiFren display casters keep reading `.data` / `.error` unchanged.
|
|
119
|
+
*
|
|
120
|
+
* Two shape differences are reconciled here:
|
|
121
|
+
* - `output` values are typed `unknown` (Display v2 templates can render
|
|
122
|
+
* structured JSON), where `data` was `Record<string, string>`. Non-string
|
|
123
|
+
* values are dropped rather than stringified — a caster that assigned an
|
|
124
|
+
* object into a `string` field would produce `"[object Object]"` in the UI.
|
|
125
|
+
* - `errors` is **per-field**, where `error` was whole-object. Surfacing a
|
|
126
|
+
* single bad field as a whole-object error would blank out an NFT's entire
|
|
127
|
+
* display, so `error` is only populated when `output` is absent entirely.
|
|
128
|
+
* Per-field failures simply do not appear in `data`.
|
|
129
|
+
*/
|
|
130
|
+
_GrpcCasting.displayFieldsResponseFromGrpcDisplay = (display) => {
|
|
131
|
+
const output = display?.output ?? null;
|
|
132
|
+
if (output === null) {
|
|
133
|
+
const errors = display?.errors ?? null;
|
|
134
|
+
return {
|
|
135
|
+
data: null,
|
|
136
|
+
error: errors ? {
|
|
137
|
+
code: "displayError",
|
|
138
|
+
error: Object.entries(errors).map(([field, message]) => `${field}: ${message}`).join("; ")
|
|
139
|
+
} : null
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const data = {};
|
|
143
|
+
for (const [key, value] of Object.entries(output)) {
|
|
144
|
+
if (typeof value === "string") {
|
|
145
|
+
data[key] = value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { data, error: null };
|
|
149
|
+
};
|
|
150
|
+
// =========================================================================
|
|
151
|
+
// Move Field Shapes
|
|
152
|
+
// =========================================================================
|
|
153
|
+
/**
|
|
154
|
+
* Decodes a `vector<u8>` Move field into a number array.
|
|
155
|
+
*
|
|
156
|
+
* gRPC's `json` view base64-encodes byte vectors (`"CQk="`), where JSON-RPC
|
|
157
|
+
* returned a number array (`[9, 9]`). Indexing the gRPC form directly yields
|
|
158
|
+
* a one-character **string**, so `Number(...)` of it is `NaN` — a silently
|
|
159
|
+
* wrong value rather than an error. Always route a byte vector through here.
|
|
160
|
+
*
|
|
161
|
+
* Total by design: a number array (or `Uint8Array`) passes through unchanged,
|
|
162
|
+
* so a caster that has been ported still works when handed a JSON-RPC-shaped
|
|
163
|
+
* fixture.
|
|
164
|
+
*/
|
|
165
|
+
_GrpcCasting.bytesFieldToNumbers = (value) => {
|
|
166
|
+
if (typeof value === "string") {
|
|
167
|
+
return Array.from(fromBase64(value));
|
|
168
|
+
}
|
|
169
|
+
return Array.from(value);
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Unwraps a nested Move struct out of JSON-RPC's `{ type, fields }` envelope.
|
|
173
|
+
*
|
|
174
|
+
* gRPC's `json` view returns nested structs bare — `{ value: "…" }` where
|
|
175
|
+
* JSON-RPC returned
|
|
176
|
+
* `{ type: "0x2::balance::Supply<…>", fields: { value: "…" } }`. The `type`
|
|
177
|
+
* gRPC drops is not recoverable from the nested value itself; where a caster
|
|
178
|
+
* needs it, take it from the **enclosing object's** own type parameters via
|
|
179
|
+
* {@link Helpers.getObjectType}.
|
|
180
|
+
*
|
|
181
|
+
* Total by design: a bare struct passes through unchanged.
|
|
182
|
+
*/
|
|
183
|
+
_GrpcCasting.unwrapStructField = (value) => {
|
|
184
|
+
if (value !== null && typeof value === "object" && "fields" in value && value.fields !== void 0) {
|
|
185
|
+
return value.fields;
|
|
186
|
+
}
|
|
187
|
+
return value;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Reads a Move `UID` as a bare object id.
|
|
191
|
+
*
|
|
192
|
+
* gRPC's `json` view flattens `UID` to a plain string, where JSON-RPC nested
|
|
193
|
+
* it as `{ id: "0x…" }` (and, one level up, `{ id: { id: "0x…" } }`).
|
|
194
|
+
* Resolves either shape, recursively, so it is total across both protocols.
|
|
195
|
+
*/
|
|
196
|
+
_GrpcCasting.unwrapUid = (value) => {
|
|
197
|
+
if (typeof value === "string") {
|
|
198
|
+
return value;
|
|
199
|
+
}
|
|
200
|
+
if (value !== null && typeof value === "object" && "id" in value) {
|
|
201
|
+
return _GrpcCasting.unwrapUid(value.id);
|
|
202
|
+
}
|
|
203
|
+
return value;
|
|
204
|
+
};
|
|
205
|
+
// =========================================================================
|
|
206
|
+
// Transactions
|
|
207
|
+
// =========================================================================
|
|
208
|
+
/**
|
|
209
|
+
* Reads the transaction out of a gRPC `simulateTransaction` /
|
|
210
|
+
* `executeTransaction` result.
|
|
211
|
+
*
|
|
212
|
+
* The result is a `$kind`-discriminated union: a simulation that **fails
|
|
213
|
+
* on-chain** still returns effects, but under `FailedTransaction` rather
|
|
214
|
+
* than `Transaction`. Reading only the success arm silently drops the gas
|
|
215
|
+
* estimate exactly when the caller most needs it, so always go through
|
|
216
|
+
* this helper.
|
|
217
|
+
*/
|
|
218
|
+
_GrpcCasting.transactionFromResult = (result) => result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
|
|
219
|
+
// =========================================================================
|
|
220
|
+
// Bytes
|
|
221
|
+
// =========================================================================
|
|
222
|
+
/** Decodes base64 BCS bytes, for symmetry with {@link toBase64}. */
|
|
223
|
+
_GrpcCasting.bytesFromBase64 = (base64) => fromBase64(base64);
|
|
224
|
+
GrpcCasting = _GrpcCasting;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
11
228
|
// src/general/apiHelpers/dynamicFieldsApiHelpers.ts
|
|
12
229
|
var _DynamicFieldsApiHelpers, DynamicFieldsApiHelpers;
|
|
13
230
|
var init_dynamicFieldsApiHelpers = __esm({
|
|
14
231
|
"src/general/apiHelpers/dynamicFieldsApiHelpers.ts"() {
|
|
15
232
|
"use strict";
|
|
233
|
+
init_grpcCasting();
|
|
16
234
|
_DynamicFieldsApiHelpers = class _DynamicFieldsApiHelpers {
|
|
17
235
|
// =========================================================================
|
|
18
236
|
// Constructor
|
|
@@ -90,15 +308,18 @@ var init_dynamicFieldsApiHelpers = __esm({
|
|
|
90
308
|
};
|
|
91
309
|
this.fetchDynamicFieldsOfTypeWithCursor = async (inputs) => {
|
|
92
310
|
const { parentObjectId, dynamicFieldType } = inputs;
|
|
93
|
-
const dynamicFieldsResponse = await this.api.client.
|
|
94
|
-
|
|
311
|
+
const dynamicFieldsResponse = await this.api.client.listDynamicFields({
|
|
312
|
+
cursor: inputs.cursor,
|
|
95
313
|
limit: inputs.limit ?? _DynamicFieldsApiHelpers.constants.defaultLimitStepSize,
|
|
96
314
|
parentId: parentObjectId
|
|
97
315
|
});
|
|
98
|
-
const
|
|
316
|
+
const allDynamicFields = dynamicFieldsResponse.dynamicFields.map(
|
|
317
|
+
GrpcCasting.dynamicFieldInfoFromGrpcEntry
|
|
318
|
+
);
|
|
319
|
+
const dynamicFields = dynamicFieldType === void 0 ? allDynamicFields : allDynamicFields.filter(
|
|
99
320
|
(dynamicField) => typeof dynamicFieldType === "string" ? dynamicField.objectType === dynamicFieldType : dynamicFieldType(dynamicField.objectType)
|
|
100
321
|
);
|
|
101
|
-
const nextCursor = dynamicFieldsResponse.
|
|
322
|
+
const nextCursor = dynamicFieldsResponse.cursor;
|
|
102
323
|
return {
|
|
103
324
|
dynamicFields,
|
|
104
325
|
nextCursor
|
|
@@ -107,8 +328,27 @@ var init_dynamicFieldsApiHelpers = __esm({
|
|
|
107
328
|
// =========================================================================
|
|
108
329
|
// Dynamic Field Objects
|
|
109
330
|
// =========================================================================
|
|
110
|
-
|
|
111
|
-
|
|
331
|
+
/**
|
|
332
|
+
* @remarks Ported to `client.core.getDynamicObjectField`.
|
|
333
|
+
*
|
|
334
|
+
* ⚠️ **Not** gRPC's `getDynamicField`, which is the obvious-looking target and
|
|
335
|
+
* the wrong one: it returns the field's value as `{ type, bcs }` only — no
|
|
336
|
+
* `json` view and no `objectId` — so it cannot feed an object caster.
|
|
337
|
+
* `getDynamicObjectField` returns `{ object }` in the same shape as
|
|
338
|
+
* `getObject`, which can. (It lives on `client.core`, not on the client root,
|
|
339
|
+
* which is why an earlier pass recorded it as unavailable.)
|
|
340
|
+
*
|
|
341
|
+
* The return type changes from `SuiObjectResponse` to {@link SuiObjectView},
|
|
342
|
+
* in step with every other object fetcher here. This helper has **zero
|
|
343
|
+
* internal callers**, so nothing inside the SDK is affected.
|
|
344
|
+
*/
|
|
345
|
+
this.fetchDynamicFieldObject = async (inputs) => {
|
|
346
|
+
const { object } = await this.api.client.core.getDynamicObjectField({
|
|
347
|
+
parentId: inputs.parentId,
|
|
348
|
+
name: inputs.name,
|
|
349
|
+
include: { json: true, display: true }
|
|
350
|
+
});
|
|
351
|
+
return object;
|
|
112
352
|
};
|
|
113
353
|
}
|
|
114
354
|
};
|
|
@@ -142,17 +382,36 @@ var init_eventsApiHelpers = __esm({
|
|
|
142
382
|
// TODO: make this filter by looking ONLY at all relevant AF packages
|
|
143
383
|
// TODO: move to wallet package ?
|
|
144
384
|
/**
|
|
145
|
-
* @deprecated
|
|
146
|
-
*
|
|
385
|
+
* @deprecated Not implemented. gRPC's
|
|
386
|
+
* `SubscriptionService.SubscribeEvents` is the replacement — reach it via
|
|
387
|
+
* `AftermathApi["client"].subscriptionService` — or poll
|
|
388
|
+
* {@link EventsApiHelpers.fetchCastEventsWithCursor}.
|
|
147
389
|
*/
|
|
148
390
|
this.fetchSubscribeToUserEvents = async (_inputs) => {
|
|
149
391
|
throw new Error(
|
|
150
|
-
"fetchSubscribeToUserEvents is not
|
|
392
|
+
"fetchSubscribeToUserEvents is not implemented. Use gRPC's SubscriptionService.SubscribeEvents (available on `AftermathApi.client.subscriptionService`), or poll fetchCastEventsWithCursor."
|
|
151
393
|
);
|
|
152
394
|
};
|
|
395
|
+
/**
|
|
396
|
+
* @remarks **Remaining JSON-RPC surface** — see
|
|
397
|
+
* {@link AftermathApi.jsonRpcClient}. `suix_queryEvents` has no
|
|
398
|
+
* `SuiGrpcClient` equivalent: the only gRPC path is the raw
|
|
399
|
+
* `ledgerService.ListEvents`, whose filter model and cursor differ from
|
|
400
|
+
* `SuiEventFilter` / `EventId`, and whose events carry BCS bytes instead of
|
|
401
|
+
* the `parsedJson` that every `eventFromEventOnChain` caster reads. Porting
|
|
402
|
+
* it would change this helper's semantics, so it still goes through
|
|
403
|
+
* JSON-RPC and will stop working when that is removed from fullnodes
|
|
404
|
+
* (scheduled for mid-October 2026).
|
|
405
|
+
*
|
|
406
|
+
* @throws If no `jsonRpcClient` was passed to {@link AftermathApi}, since it
|
|
407
|
+
* is optional there.
|
|
408
|
+
*/
|
|
153
409
|
this.fetchCastEventsWithCursor = async (inputs) => {
|
|
154
410
|
const { query, eventFromEventOnChain, cursor, limit } = inputs;
|
|
155
|
-
const
|
|
411
|
+
const jsonRpcClient = this.api.requireJsonRpcClient(
|
|
412
|
+
"Events().fetchCastEventsWithCursor"
|
|
413
|
+
);
|
|
414
|
+
const fetchedEvents = await jsonRpcClient.queryEvents({
|
|
156
415
|
query,
|
|
157
416
|
cursor: cursor ? { ...cursor, eventSeq: cursor.eventSeq.toString() } : void 0,
|
|
158
417
|
limit
|
|
@@ -269,10 +528,12 @@ var init_eventsApiHelpers = __esm({
|
|
|
269
528
|
});
|
|
270
529
|
|
|
271
530
|
// src/general/apiHelpers/inspectionsApiHelpers.ts
|
|
531
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
272
532
|
var _InspectionsApiHelpers, InspectionsApiHelpers;
|
|
273
533
|
var init_inspectionsApiHelpers = __esm({
|
|
274
534
|
"src/general/apiHelpers/inspectionsApiHelpers.ts"() {
|
|
275
535
|
"use strict";
|
|
536
|
+
init_grpcCasting();
|
|
276
537
|
_InspectionsApiHelpers = class _InspectionsApiHelpers {
|
|
277
538
|
// =========================================================================
|
|
278
539
|
// Constructor
|
|
@@ -293,26 +554,48 @@ var init_inspectionsApiHelpers = __esm({
|
|
|
293
554
|
const { allBytes } = await this.fetchAllBytesFromTx(inputs);
|
|
294
555
|
return allBytes[allBytes.length - 1];
|
|
295
556
|
};
|
|
557
|
+
/**
|
|
558
|
+
* Simulates `tx` and returns the BCS bytes each command returned.
|
|
559
|
+
*
|
|
560
|
+
* @remarks Ported from JSON-RPC's `devInspectTransactionBlock` to gRPC's
|
|
561
|
+
* `simulateTransaction`. Three things differ:
|
|
562
|
+
* - the sender is taken from the transaction (`tx.setSenderIfNotSet`), not
|
|
563
|
+
* passed as a separate option;
|
|
564
|
+
* - `checksEnabled: false` is what makes inspecting non-entry / non-public
|
|
565
|
+
* Move functions possible (with checks on, the node rejects an unsigned
|
|
566
|
+
* transaction touching objects the sender does not own);
|
|
567
|
+
* - return values arrive as `commandResults[i].returnValues[j].bcs`
|
|
568
|
+
* (`Uint8Array`) instead of JSON-RPC's `[number[], type]` tuples. Note
|
|
569
|
+
* `commandResults` is requested **inside** `include`.
|
|
570
|
+
*
|
|
571
|
+
* `events` and `effects` are now gRPC-shaped (`SuiClientTypes.Event` /
|
|
572
|
+
* `SuiClientTypes.TransactionEffects`) rather than the JSON-RPC types — a
|
|
573
|
+
* `success: boolean` status instead of `status: "success" | "failure"`, and
|
|
574
|
+
* BCS bytes rather than `parsedJson` on events. Nothing in this SDK reads
|
|
575
|
+
* either field.
|
|
576
|
+
*/
|
|
296
577
|
this.fetchAllBytesFromTx = async (inputs) => {
|
|
297
578
|
const sender = inputs.sender ?? _InspectionsApiHelpers.constants.devInspectSigner;
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
|
|
579
|
+
const tx = Transaction.from(inputs.tx.serialize());
|
|
580
|
+
tx.setSenderIfNotSet(sender);
|
|
581
|
+
const simulation = await this.api.client.simulateTransaction({
|
|
582
|
+
transaction: tx,
|
|
583
|
+
include: { effects: true, events: true, commandResults: true },
|
|
584
|
+
checksEnabled: false
|
|
301
585
|
});
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
);
|
|
586
|
+
const { effects, events, status } = GrpcCasting.transactionFromResult(simulation);
|
|
587
|
+
if (!status.success) {
|
|
588
|
+
throw new Error(status.error?.message ?? "dev inspect failed");
|
|
306
589
|
}
|
|
307
|
-
if (!
|
|
590
|
+
if (!simulation.commandResults) {
|
|
308
591
|
throw new Error("dev inspect move call returned no results");
|
|
309
592
|
}
|
|
310
|
-
const resultBytes =
|
|
311
|
-
(result) => result.returnValues
|
|
593
|
+
const resultBytes = simulation.commandResults.map(
|
|
594
|
+
(result) => result.returnValues.map((val) => Array.from(val.bcs))
|
|
312
595
|
);
|
|
313
596
|
return {
|
|
314
|
-
events
|
|
315
|
-
effects
|
|
597
|
+
events,
|
|
598
|
+
effects,
|
|
316
599
|
allBytes: resultBytes
|
|
317
600
|
};
|
|
318
601
|
};
|
|
@@ -326,11 +609,16 @@ var init_inspectionsApiHelpers = __esm({
|
|
|
326
609
|
});
|
|
327
610
|
|
|
328
611
|
// src/general/apiHelpers/objectsApiHelpers.ts
|
|
329
|
-
var _ObjectsApiHelpers, ObjectsApiHelpers;
|
|
612
|
+
var casterInclude, _ObjectsApiHelpers, ObjectsApiHelpers;
|
|
330
613
|
var init_objectsApiHelpers = __esm({
|
|
331
614
|
"src/general/apiHelpers/objectsApiHelpers.ts"() {
|
|
332
615
|
"use strict";
|
|
616
|
+
init_grpcCasting();
|
|
333
617
|
init_helpers();
|
|
618
|
+
casterInclude = (withDisplay) => ({
|
|
619
|
+
json: true,
|
|
620
|
+
display: withDisplay === true
|
|
621
|
+
});
|
|
334
622
|
_ObjectsApiHelpers = class _ObjectsApiHelpers {
|
|
335
623
|
// =========================================================================
|
|
336
624
|
// Constructor
|
|
@@ -344,13 +632,17 @@ var init_objectsApiHelpers = __esm({
|
|
|
344
632
|
// Fetching
|
|
345
633
|
// =========================================================================
|
|
346
634
|
this.fetchDoesObjectExist = async (objectId) => {
|
|
347
|
-
|
|
348
|
-
|
|
635
|
+
try {
|
|
636
|
+
await this.api.client.getObject({ objectId });
|
|
637
|
+
return true;
|
|
638
|
+
} catch (_e) {
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
349
641
|
};
|
|
350
642
|
this.fetchIsObjectOwnedByAddress = async (inputs) => {
|
|
351
643
|
const { objectId, walletAddress } = inputs;
|
|
352
644
|
const object = await this.fetchObject({ objectId });
|
|
353
|
-
const objectOwner = object.
|
|
645
|
+
const objectOwner = object.owner;
|
|
354
646
|
if (!objectOwner || typeof objectOwner !== "object") {
|
|
355
647
|
return false;
|
|
356
648
|
}
|
|
@@ -363,74 +655,71 @@ var init_objectsApiHelpers = __esm({
|
|
|
363
655
|
return false;
|
|
364
656
|
};
|
|
365
657
|
this.fetchObjectsOfTypeOwnedByAddress = async (inputs) => {
|
|
366
|
-
return this.fetchOwnedObjects(
|
|
367
|
-
...inputs,
|
|
368
|
-
filter: {
|
|
369
|
-
StructType: Helpers.stripLeadingZeroesFromType(inputs.objectType)
|
|
370
|
-
}
|
|
371
|
-
});
|
|
658
|
+
return this.fetchOwnedObjects(inputs);
|
|
372
659
|
};
|
|
373
660
|
this.fetchOwnedObjects = async (inputs) => {
|
|
374
|
-
const { walletAddress, withDisplay,
|
|
661
|
+
const { walletAddress, withDisplay, objectType } = inputs;
|
|
375
662
|
let allObjectData = [];
|
|
376
663
|
let cursor;
|
|
377
664
|
do {
|
|
378
|
-
const paginatedObjects = await this.api.client.
|
|
665
|
+
const paginatedObjects = await this.api.client.listOwnedObjects({
|
|
379
666
|
owner: walletAddress,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
showDisplay: withDisplay,
|
|
383
|
-
showOwner: true,
|
|
384
|
-
showType: true
|
|
385
|
-
},
|
|
667
|
+
type: objectType,
|
|
668
|
+
include: casterInclude(withDisplay),
|
|
386
669
|
limit: _ObjectsApiHelpers.constants.maxObjectFetchingLimit,
|
|
387
|
-
cursor
|
|
388
|
-
filter
|
|
670
|
+
cursor
|
|
389
671
|
});
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
if (paginatedObjects.data.length === 0 || !paginatedObjects.hasNextPage || !paginatedObjects.nextCursor) {
|
|
672
|
+
allObjectData = [...allObjectData, ...paginatedObjects.objects];
|
|
673
|
+
if (paginatedObjects.objects.length === 0 || !paginatedObjects.hasNextPage || !paginatedObjects.cursor) {
|
|
393
674
|
return allObjectData;
|
|
394
675
|
}
|
|
395
|
-
cursor = paginatedObjects.
|
|
676
|
+
cursor = paginatedObjects.cursor;
|
|
396
677
|
} while (true);
|
|
397
678
|
};
|
|
398
679
|
this.fetchObject = async (inputs) => {
|
|
399
680
|
const { objectId, withDisplay } = inputs;
|
|
400
681
|
return await this.fetchObjectGeneral({
|
|
401
682
|
objectId,
|
|
402
|
-
|
|
403
|
-
showContent: true,
|
|
404
|
-
showDisplay: withDisplay,
|
|
405
|
-
showOwner: true,
|
|
406
|
-
showType: true
|
|
407
|
-
}
|
|
683
|
+
include: casterInclude(withDisplay)
|
|
408
684
|
});
|
|
409
685
|
};
|
|
410
686
|
this.fetchObjectGeneral = async (inputs) => {
|
|
411
|
-
const { objectId,
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
687
|
+
const { objectId, include } = inputs;
|
|
688
|
+
try {
|
|
689
|
+
const { object } = await this.api.client.getObject({
|
|
690
|
+
objectId,
|
|
691
|
+
include: include ?? casterInclude()
|
|
692
|
+
});
|
|
693
|
+
return object;
|
|
694
|
+
} catch (e) {
|
|
417
695
|
throw new Error(
|
|
418
|
-
`an error occured fetching object: ${
|
|
696
|
+
`an error occured fetching object: ${e instanceof Error ? e.message : String(e)}`
|
|
419
697
|
);
|
|
420
698
|
}
|
|
421
|
-
return object;
|
|
422
699
|
};
|
|
423
700
|
this.fetchCastObject = async (inputs) => {
|
|
424
701
|
return inputs.objectFromSuiObjectResponse(await this.fetchObject(inputs));
|
|
425
702
|
};
|
|
426
703
|
this.fetchCastObjectGeneral = async (inputs) => {
|
|
427
|
-
const { objectId, objectFromSuiObjectResponse,
|
|
704
|
+
const { objectId, objectFromSuiObjectResponse, include } = inputs;
|
|
428
705
|
return objectFromSuiObjectResponse(
|
|
429
|
-
await this.fetchObjectGeneral({ objectId,
|
|
706
|
+
await this.fetchObjectGeneral({ objectId, include })
|
|
430
707
|
);
|
|
431
708
|
};
|
|
709
|
+
/**
|
|
710
|
+
* @remarks gRPC's `getObjects` returns `(Object | Error)[]` — a **per-object
|
|
711
|
+
* error arm JSON-RPC's `multiGetObjects` did not have**, delivered as real
|
|
712
|
+
* `Error` instances. Those entries are dropped rather than handed to a caster:
|
|
713
|
+
* spreading one into `objectFromSuiObjectResponse` would throw deep inside the
|
|
714
|
+
* cast with a message that names neither the batch nor the missing id.
|
|
715
|
+
*
|
|
716
|
+
* This is a deliberate behaviour change and the more forgiving one. Previously
|
|
717
|
+
* a single missing object in a batch threw from inside the caster and lost the
|
|
718
|
+
* whole batch; now the surviving objects are returned. `nftsFromSuiObjects`
|
|
719
|
+
* already filtered its input, so the app-visible result is unchanged.
|
|
720
|
+
*/
|
|
432
721
|
this.fetchObjectBatch = async (inputs) => {
|
|
433
|
-
const { objectIds,
|
|
722
|
+
const { objectIds, include, withDisplay } = inputs;
|
|
434
723
|
const objectIdsBatches = [];
|
|
435
724
|
let endIndex = 0;
|
|
436
725
|
while (true) {
|
|
@@ -444,51 +733,43 @@ var init_objectsApiHelpers = __esm({
|
|
|
444
733
|
}
|
|
445
734
|
const objectBatches = await Promise.all(
|
|
446
735
|
objectIdsBatches.map(
|
|
447
|
-
(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
showContent: true,
|
|
451
|
-
showOwner: true,
|
|
452
|
-
showType: true
|
|
453
|
-
} : options
|
|
736
|
+
(batchIds) => this.api.client.getObjects({
|
|
737
|
+
objectIds: batchIds,
|
|
738
|
+
include: include ?? casterInclude(withDisplay)
|
|
454
739
|
})
|
|
455
740
|
)
|
|
456
741
|
);
|
|
457
|
-
|
|
458
|
-
(
|
|
459
|
-
|
|
742
|
+
return objectBatches.flatMap(
|
|
743
|
+
(batch) => batch.objects.filter(
|
|
744
|
+
(object) => !(object instanceof Error)
|
|
745
|
+
)
|
|
460
746
|
);
|
|
461
|
-
return objectBatch;
|
|
462
747
|
};
|
|
463
748
|
this.fetchCastObjectBatch = async (inputs) => {
|
|
464
749
|
return (await this.fetchObjectBatch(inputs)).map(
|
|
465
|
-
(
|
|
466
|
-
return inputs.objectFromSuiObjectResponse(SuiObjectResponse);
|
|
467
|
-
}
|
|
750
|
+
(object) => inputs.objectFromSuiObjectResponse(object)
|
|
468
751
|
);
|
|
469
752
|
};
|
|
470
753
|
this.fetchCastObjectsOwnedByAddressOfType = async (inputs) => {
|
|
471
|
-
|
|
472
|
-
(
|
|
473
|
-
return inputs.objectFromSuiObjectResponse(SuiObjectResponse);
|
|
474
|
-
}
|
|
754
|
+
return (await this.fetchObjectsOfTypeOwnedByAddress(inputs)).map(
|
|
755
|
+
(object) => inputs.objectFromSuiObjectResponse(object)
|
|
475
756
|
);
|
|
476
|
-
return objects;
|
|
477
757
|
};
|
|
478
758
|
// =========================================================================
|
|
479
759
|
// BCS
|
|
480
760
|
// =========================================================================
|
|
481
761
|
this.fetchObjectBcs = async (objectId) => {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
762
|
+
try {
|
|
763
|
+
const { object } = await this.api.client.getObject({
|
|
764
|
+
objectId,
|
|
765
|
+
include: { content: true }
|
|
766
|
+
});
|
|
767
|
+
return GrpcCasting.suiObjectResponseFromGrpcObjectBcs(object);
|
|
768
|
+
} catch (e) {
|
|
487
769
|
throw new Error(
|
|
488
|
-
`an error occured fetching object: ${
|
|
770
|
+
`an error occured fetching object: ${e instanceof Error ? e.message : String(e)}`
|
|
489
771
|
);
|
|
490
772
|
}
|
|
491
|
-
return objectResponse;
|
|
492
773
|
};
|
|
493
774
|
this.fetchCastObjectBcs = async (inputs) => {
|
|
494
775
|
const { objectId } = inputs;
|
|
@@ -539,12 +820,13 @@ var init_objectsApiHelpers = __esm({
|
|
|
539
820
|
|
|
540
821
|
// src/general/apiHelpers/transactionsApiHelpers.ts
|
|
541
822
|
import {
|
|
542
|
-
Transaction
|
|
823
|
+
Transaction as Transaction2
|
|
543
824
|
} from "@mysten/sui/transactions";
|
|
544
825
|
var _TransactionsApiHelpers, TransactionsApiHelpers;
|
|
545
826
|
var init_transactionsApiHelpers = __esm({
|
|
546
827
|
"src/general/apiHelpers/transactionsApiHelpers.ts"() {
|
|
547
828
|
"use strict";
|
|
829
|
+
init_grpcCasting();
|
|
548
830
|
init_helpers();
|
|
549
831
|
_TransactionsApiHelpers = class _TransactionsApiHelpers {
|
|
550
832
|
// =========================================================================
|
|
@@ -558,22 +840,34 @@ var init_transactionsApiHelpers = __esm({
|
|
|
558
840
|
// =========================================================================
|
|
559
841
|
// Fetching
|
|
560
842
|
// =========================================================================
|
|
843
|
+
/**
|
|
844
|
+
* @remarks **Remaining JSON-RPC surface.** `suix_queryTransactionBlocks` has
|
|
845
|
+
* no gRPC equivalent — Sui's own migration cookbook directs callers to
|
|
846
|
+
* GraphQL or an indexer — so this helper still goes through
|
|
847
|
+
* {@link AftermathApi.jsonRpcClient} and will stop working when JSON-RPC is
|
|
848
|
+
* removed from fullnodes (scheduled for mid-October 2026). Prefer the
|
|
849
|
+
* Aftermath API's transaction-history endpoints.
|
|
850
|
+
*
|
|
851
|
+
* @throws If no `jsonRpcClient` was passed to {@link AftermathApi}, since it
|
|
852
|
+
* is optional there.
|
|
853
|
+
*/
|
|
561
854
|
this.fetchTransactionsWithCursor = async (inputs) => {
|
|
562
855
|
const { query, cursor, limit } = inputs;
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
...query,
|
|
566
|
-
cursor,
|
|
567
|
-
limit,
|
|
568
|
-
options: {
|
|
569
|
-
showEvents: true,
|
|
570
|
-
showBalanceChanges: true,
|
|
571
|
-
showEffects: true,
|
|
572
|
-
showObjectChanges: true,
|
|
573
|
-
showInput: true
|
|
574
|
-
}
|
|
575
|
-
}
|
|
856
|
+
const jsonRpcClient = this.api.requireJsonRpcClient(
|
|
857
|
+
"Transactions().fetchTransactionsWithCursor"
|
|
576
858
|
);
|
|
859
|
+
const transactionsWithCursor = await jsonRpcClient.queryTransactionBlocks({
|
|
860
|
+
...query,
|
|
861
|
+
cursor,
|
|
862
|
+
limit,
|
|
863
|
+
options: {
|
|
864
|
+
showEvents: true,
|
|
865
|
+
showBalanceChanges: true,
|
|
866
|
+
showEffects: true,
|
|
867
|
+
showObjectChanges: true,
|
|
868
|
+
showInput: true
|
|
869
|
+
}
|
|
870
|
+
});
|
|
577
871
|
return {
|
|
578
872
|
transactions: transactionsWithCursor.data,
|
|
579
873
|
nextCursor: transactionsWithCursor.nextCursor ?? null
|
|
@@ -581,15 +875,17 @@ var init_transactionsApiHelpers = __esm({
|
|
|
581
875
|
};
|
|
582
876
|
this.fetchSetGasBudgetForTx = async (inputs) => {
|
|
583
877
|
const { tx } = inputs;
|
|
584
|
-
const [
|
|
585
|
-
this.api.client.
|
|
586
|
-
|
|
878
|
+
const [simulation, { referenceGasPrice }] = await Promise.all([
|
|
879
|
+
this.api.client.simulateTransaction({
|
|
880
|
+
transaction: await tx.build({
|
|
587
881
|
client: this.api.client
|
|
588
|
-
})
|
|
882
|
+
}),
|
|
883
|
+
include: { effects: true }
|
|
589
884
|
}),
|
|
590
885
|
this.api.client.getReferenceGasPrice()
|
|
591
886
|
]);
|
|
592
|
-
const
|
|
887
|
+
const { effects } = GrpcCasting.transactionFromResult(simulation);
|
|
888
|
+
const gasData = effects.gasUsed;
|
|
593
889
|
const gasUsed = BigInt(gasData.computationCost) + BigInt(gasData.storageCost);
|
|
594
890
|
const safeGasBudget = gasUsed + gasUsed / BigInt(10);
|
|
595
891
|
tx.setGasBudget(safeGasBudget);
|
|
@@ -643,7 +939,7 @@ var init_transactionsApiHelpers = __esm({
|
|
|
643
939
|
_TransactionsApiHelpers.createTxTarget = (packageAddress, packageName, functionName) => `${packageAddress}::${packageName}::${functionName}`;
|
|
644
940
|
_TransactionsApiHelpers.createBuildTxFunc = (func) => {
|
|
645
941
|
const builderFunc = (someInputs) => {
|
|
646
|
-
const tx = new
|
|
942
|
+
const tx = new Transaction2();
|
|
647
943
|
tx.setSender(someInputs.walletAddress);
|
|
648
944
|
func({
|
|
649
945
|
tx,
|
|
@@ -838,6 +1134,7 @@ var init_helpers = __esm({
|
|
|
838
1134
|
"src/general/utils/helpers.ts"() {
|
|
839
1135
|
"use strict";
|
|
840
1136
|
init_dynamicFieldsApiHelpers();
|
|
1137
|
+
init_grpcCasting();
|
|
841
1138
|
init_eventsApiHelpers();
|
|
842
1139
|
init_inspectionsApiHelpers();
|
|
843
1140
|
init_objectsApiHelpers();
|
|
@@ -915,63 +1212,113 @@ var init_helpers = __esm({
|
|
|
915
1212
|
// Sui Object Parsing
|
|
916
1213
|
// =========================================================================
|
|
917
1214
|
/**
|
|
918
|
-
* Extracts the fully qualified type (e.g., "0x2::coin::Coin<...>") from a
|
|
919
|
-
* normalizing it with leading zeroes if necessary.
|
|
920
|
-
*
|
|
921
|
-
*
|
|
1215
|
+
* Extracts the fully qualified type (e.g., "0x2::coin::Coin<...>") from a
|
|
1216
|
+
* gRPC object view, normalizing it with leading zeroes if necessary.
|
|
1217
|
+
*
|
|
1218
|
+
* ⚠️ **Not byte-invariant across protocols when the type has generic
|
|
1219
|
+
* parameters.** Measured on real mainnet objects:
|
|
1220
|
+
* - For a type with **no** generic parameters the two protocols agree after
|
|
1221
|
+
* normalization: gRPC serves `0x0000…0002::kiosk::KioskOwnerCap` and
|
|
1222
|
+
* JSON-RPC serves `0x2::kiosk::KioskOwnerCap`, and
|
|
1223
|
+
* {@link Helpers.addLeadingZeroesToType} maps both to the same string.
|
|
1224
|
+
* - **Inside** a generic parameter they differ: gRPC fully zero-pads every
|
|
1225
|
+
* address (`OneTimeAdminCap<0x0000…0002::sui::SUI>`) where JSON-RPC echoes
|
|
1226
|
+
* the node's abbreviated form (`OneTimeAdminCap<0x2::sui::SUI>`), and gRPC
|
|
1227
|
+
* emits no space after a generic's comma. `addLeadingZeroesToType`
|
|
1228
|
+
* normalizes only the **outer** address — and separately strips `0x` from
|
|
1229
|
+
* the first generic parameter — so the difference survives into this
|
|
1230
|
+
* accessor's output.
|
|
1231
|
+
*
|
|
1232
|
+
* That divergence is **cosmetic and accepted**: it is purely address padding
|
|
1233
|
+
* and comma spacing, semantically the same Move type. It is pinned by
|
|
1234
|
+
* `tests/objectCasters.test.ts` ("FINDING: generic `objectType` differs
|
|
1235
|
+
* across protocols"). The underlying `addLeadingZeroesToType` generics bug
|
|
1236
|
+
* pre-dates the gRPC migration and is filed as its own plan — do not fix it
|
|
1237
|
+
* here.
|
|
1238
|
+
*
|
|
1239
|
+
* Still **load-bearing**, and still safe for it: the type's *semantic* content
|
|
1240
|
+
* is protocol-invariant, which is what lets a caster recover the `type` of a
|
|
1241
|
+
* nested struct that gRPC's `json` view drops (see
|
|
1242
|
+
* {@link GrpcCasting.unwrapStructField}) from the enclosing object's own type
|
|
1243
|
+
* parameters — as `poolObjectFromSuiObject` does for its LP coin.
|
|
1244
|
+
*
|
|
1245
|
+
* @param data - The object view from Sui.
|
|
922
1246
|
* @returns The normalized object type string.
|
|
923
1247
|
* @throws If the type is not found.
|
|
924
1248
|
*/
|
|
925
1249
|
static getObjectType(data) {
|
|
926
|
-
const objectType = data
|
|
1250
|
+
const objectType = data?.type;
|
|
927
1251
|
if (objectType) {
|
|
928
1252
|
return _Helpers.addLeadingZeroesToType(objectType);
|
|
929
1253
|
}
|
|
930
|
-
throw new Error(`no object type found on ${data
|
|
1254
|
+
throw new Error(`no object type found on ${data?.objectId}`);
|
|
931
1255
|
}
|
|
932
1256
|
/**
|
|
933
|
-
* Extracts the object ID from a
|
|
1257
|
+
* Extracts the object ID from a gRPC object view, normalizing it with
|
|
1258
|
+
* leading zeroes.
|
|
934
1259
|
*
|
|
935
|
-
* @param data - The object
|
|
1260
|
+
* @param data - The object view from Sui.
|
|
936
1261
|
* @returns A zero-padded `ObjectId`.
|
|
937
1262
|
* @throws If the objectId is not found.
|
|
938
1263
|
*/
|
|
939
1264
|
static getObjectId(data) {
|
|
940
|
-
const objectId = data
|
|
1265
|
+
const objectId = data?.objectId;
|
|
941
1266
|
if (objectId) {
|
|
942
1267
|
return _Helpers.addLeadingZeroesToType(objectId);
|
|
943
1268
|
}
|
|
944
|
-
throw new Error(`no object id found on ${data
|
|
1269
|
+
throw new Error(`no object id found on ${data?.type}`);
|
|
945
1270
|
}
|
|
946
1271
|
/**
|
|
947
|
-
* Retrieves the fields of
|
|
1272
|
+
* Retrieves the Move fields of an object from a gRPC object view.
|
|
1273
|
+
*
|
|
1274
|
+
* ⚠️ This is the gRPC **`json` view**, which is *not* shape-identical to
|
|
1275
|
+
* JSON-RPC's `content.fields`: nested structs arrive without their
|
|
1276
|
+
* `{ type, fields }` envelope, `vector<u8>` arrives base64-encoded, and
|
|
1277
|
+
* `UID` arrives as a bare string. Route those through
|
|
1278
|
+
* {@link GrpcCasting.unwrapStructField}, {@link GrpcCasting.bytesFieldToNumbers}
|
|
1279
|
+
* and {@link GrpcCasting.unwrapUid} respectively.
|
|
948
1280
|
*
|
|
949
|
-
*
|
|
1281
|
+
* ⚠️ The return type is `Record<string, any>`, so **no field read below this
|
|
1282
|
+
* point is typechecked**. A wrong read is a silently wrong value, not a
|
|
1283
|
+
* build error. `tests/objectCasters.test.ts` is the only guard.
|
|
1284
|
+
*
|
|
1285
|
+
* `json` is `undefined` unless `include: { json: true }` was passed at the
|
|
1286
|
+
* fetch site.
|
|
1287
|
+
*
|
|
1288
|
+
* @param data - The Sui object view containing a Move object.
|
|
950
1289
|
* @returns A record of fields for that object.
|
|
951
1290
|
* @throws If no fields are found.
|
|
952
1291
|
*/
|
|
953
1292
|
// biome-ignore lint/suspicious/noExplicitAny: Move fields are dynamic — callers access nested properties directly; typing as `unknown` would cascade casts through dozens of call sites
|
|
954
1293
|
static getObjectFields(data) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
return
|
|
958
|
-
} catch (_e) {
|
|
959
|
-
throw new Error(`no object fields found on ${data.data?.objectId}`);
|
|
1294
|
+
const fields = data?.json;
|
|
1295
|
+
if (fields) {
|
|
1296
|
+
return fields;
|
|
960
1297
|
}
|
|
1298
|
+
throw new Error(`no object fields found on ${data?.objectId}`);
|
|
961
1299
|
}
|
|
962
1300
|
/**
|
|
963
|
-
* Retrieves display metadata from a
|
|
1301
|
+
* Retrieves display metadata from a gRPC object view, if present.
|
|
964
1302
|
*
|
|
965
|
-
*
|
|
1303
|
+
* Reshaped onto JSON-RPC's `DisplayFieldsResponse` so the display casters are
|
|
1304
|
+
* unaffected by the transport change — see
|
|
1305
|
+
* {@link GrpcCasting.displayFieldsResponseFromGrpcDisplay} for the two
|
|
1306
|
+
* semantic differences that reshape absorbs.
|
|
1307
|
+
*
|
|
1308
|
+
* `display` is `undefined` unless `include: { display: true }` was passed at
|
|
1309
|
+
* the fetch site (`withDisplay` on the `ObjectsApiHelpers` fetchers), and
|
|
1310
|
+
* `null` when the object's type has no Display template.
|
|
1311
|
+
*
|
|
1312
|
+
* @param data - The Sui object view.
|
|
966
1313
|
* @returns The display fields for that object.
|
|
967
|
-
* @throws If display
|
|
1314
|
+
* @throws If display was not requested at the fetch site.
|
|
968
1315
|
*/
|
|
969
1316
|
static getObjectDisplay(data) {
|
|
970
|
-
const display = data
|
|
971
|
-
if (display) {
|
|
972
|
-
|
|
1317
|
+
const display = data?.display;
|
|
1318
|
+
if (display === void 0) {
|
|
1319
|
+
throw new Error(`no object display found on ${data?.objectId}`);
|
|
973
1320
|
}
|
|
974
|
-
|
|
1321
|
+
return GrpcCasting.displayFieldsResponseFromGrpcDisplay(display);
|
|
975
1322
|
}
|
|
976
1323
|
// =========================================================================
|
|
977
1324
|
// Error Parsing
|
|
@@ -1522,7 +1869,7 @@ var init_helpers = __esm({
|
|
|
1522
1869
|
});
|
|
1523
1870
|
|
|
1524
1871
|
// src/general/utils/caller.ts
|
|
1525
|
-
import { Transaction as
|
|
1872
|
+
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
1526
1873
|
function bigIntReplacer(_key, value) {
|
|
1527
1874
|
if (typeof value === "bigint") {
|
|
1528
1875
|
return `${value.toString()}n`;
|
|
@@ -1544,7 +1891,8 @@ var init_caller = __esm({
|
|
|
1544
1891
|
throw new Error("no apiBaseUrl: unable to fetch data");
|
|
1545
1892
|
}
|
|
1546
1893
|
const safeUrl = this.apiBaseUrl.slice(-1) === "/" ? this.apiBaseUrl.slice(0, -1) : this.apiBaseUrl;
|
|
1547
|
-
|
|
1894
|
+
const endpointSegment = this.apiEndpoint ? `${this.apiEndpoint}/` : "";
|
|
1895
|
+
return `${safeUrl}/${endpointSegment}${this.apiUrlPrefix + (url === "" ? "" : "/")}${url}`;
|
|
1548
1896
|
};
|
|
1549
1897
|
this.setAccessToken = (accessToken) => {
|
|
1550
1898
|
this.config.accessToken = accessToken;
|
|
@@ -1612,7 +1960,7 @@ var init_caller = __esm({
|
|
|
1612
1960
|
signal,
|
|
1613
1961
|
options
|
|
1614
1962
|
);
|
|
1615
|
-
const tx = options?.txKind ?
|
|
1963
|
+
const tx = options?.txKind ? Transaction3.fromKind(txKind) : Transaction3.from(txKind);
|
|
1616
1964
|
if (body?.walletAddress) {
|
|
1617
1965
|
tx.setSender(body.walletAddress);
|
|
1618
1966
|
}
|
|
@@ -1625,7 +1973,7 @@ var init_caller = __esm({
|
|
|
1625
1973
|
signal,
|
|
1626
1974
|
options
|
|
1627
1975
|
);
|
|
1628
|
-
const tx = response.sponsorSignature ?
|
|
1976
|
+
const tx = response.sponsorSignature ? Transaction3.from(response.txKind) : Transaction3.fromKind(response.txKind);
|
|
1629
1977
|
const { txKind, ...rest } = response;
|
|
1630
1978
|
return { ...rest, tx };
|
|
1631
1979
|
}
|
|
@@ -1665,7 +2013,8 @@ var init_caller = __esm({
|
|
|
1665
2013
|
""
|
|
1666
2014
|
);
|
|
1667
2015
|
const baseWs = baseHttp.replace(_Caller.HTTP_PROTOCOL_REGEX, "ws$1://");
|
|
1668
|
-
const
|
|
2016
|
+
const endpointSegment = this.apiEndpoint ? `${this.apiEndpoint}/` : "";
|
|
2017
|
+
const prefix = `${endpointSegment}${this.apiUrlPrefix}`;
|
|
1669
2018
|
const normalizedPrefix = prefix.replace(
|
|
1670
2019
|
_Caller.TRAILING_SLASHES_REGEX,
|
|
1671
2020
|
""
|
|
@@ -2362,10 +2711,11 @@ var init_farmsApiCasting = __esm({
|
|
|
2362
2711
|
const fields = Helpers.getObjectFields(
|
|
2363
2712
|
data
|
|
2364
2713
|
);
|
|
2714
|
+
const cap = GrpcCasting.unwrapStructField(fields.cap);
|
|
2365
2715
|
return {
|
|
2366
2716
|
objectType,
|
|
2367
2717
|
objectId: Helpers.getObjectId(data),
|
|
2368
|
-
stakingPoolId:
|
|
2718
|
+
stakingPoolId: cap.for
|
|
2369
2719
|
};
|
|
2370
2720
|
};
|
|
2371
2721
|
// =========================================================================
|
|
@@ -2774,8 +3124,9 @@ var init_poolsApiCasting = __esm({
|
|
|
2774
3124
|
suiObject
|
|
2775
3125
|
);
|
|
2776
3126
|
const lpCoinType = Helpers.addLeadingZeroesToType(
|
|
2777
|
-
Coin.getInnerCoinType(
|
|
3127
|
+
Coin.getInnerCoinType(objectType)
|
|
2778
3128
|
);
|
|
3129
|
+
const coinDecimals = poolFieldsOnChain.coin_decimals === void 0 ? void 0 : GrpcCasting.bytesFieldToNumbers(poolFieldsOnChain.coin_decimals);
|
|
2779
3130
|
const coins = poolFieldsOnChain.type_names.reduce(
|
|
2780
3131
|
(acc, cur, index) => ({
|
|
2781
3132
|
...acc,
|
|
@@ -2790,9 +3141,7 @@ var init_poolsApiCasting = __esm({
|
|
|
2790
3141
|
poolFieldsOnChain.normalized_balances[index]
|
|
2791
3142
|
),
|
|
2792
3143
|
decimalsScalar: BigInt(poolFieldsOnChain.decimal_scalars[index]),
|
|
2793
|
-
...
|
|
2794
|
-
decimals: Number(poolFieldsOnChain.coin_decimals[index])
|
|
2795
|
-
} : {}
|
|
3144
|
+
...coinDecimals ? { decimals: coinDecimals[index] } : {}
|
|
2796
3145
|
}
|
|
2797
3146
|
}),
|
|
2798
3147
|
{}
|
|
@@ -2803,7 +3152,9 @@ var init_poolsApiCasting = __esm({
|
|
|
2803
3152
|
lpCoinType,
|
|
2804
3153
|
name: poolFieldsOnChain.name,
|
|
2805
3154
|
creator: poolFieldsOnChain.creator,
|
|
2806
|
-
lpCoinSupply: BigInt(
|
|
3155
|
+
lpCoinSupply: BigInt(
|
|
3156
|
+
GrpcCasting.unwrapStructField(poolFieldsOnChain.lp_supply).value
|
|
3157
|
+
),
|
|
2807
3158
|
illiquidLpCoinSupply: BigInt(poolFieldsOnChain.illiquid_lp_supply),
|
|
2808
3159
|
flatness: BigInt(poolFieldsOnChain.flatness),
|
|
2809
3160
|
lpCoinDecimals: Number(poolFieldsOnChain.lp_decimals),
|
|
@@ -2895,6 +3246,34 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2895
3246
|
// =========================================================================
|
|
2896
3247
|
// Objects
|
|
2897
3248
|
// =========================================================================
|
|
3249
|
+
/**
|
|
3250
|
+
* @remarks ⚠️ **Two of this caster's reads need a *nested* Move struct's own
|
|
3251
|
+
* `type`, which neither protocol supplies — so it throws, exactly as it did
|
|
3252
|
+
* before the gRPC port.** It is kept source-compatible (same signature, same
|
|
3253
|
+
* `NftAmmMarketObject` shape) rather than deleted, and the blocked reads are
|
|
3254
|
+
* marked inline.
|
|
3255
|
+
*
|
|
3256
|
+
* - `fields.pool` is a nested `Pool<L>` handed to
|
|
3257
|
+
* {@link PoolsApiCasting.poolObjectFromSuiObject}, which needs the pool's
|
|
3258
|
+
* Move type for `objectType` and `lpCoinType`.
|
|
3259
|
+
* - `fields.supply` is a nested `Supply<F>` whose `type` gave
|
|
3260
|
+
* `fractionalizedCoinType`.
|
|
3261
|
+
*
|
|
3262
|
+
* Under JSON-RPC a nested struct arrived as `{ type, fields }`, which is not
|
|
3263
|
+
* a `SuiObjectResponse`, so the pre-port code already threw
|
|
3264
|
+
* `no object id found on undefined` at its first nested read (verified
|
|
3265
|
+
* against the source at `d4706127`). Under gRPC nested structs lose `type`
|
|
3266
|
+
* outright, so the `lp_supply` recovery that fixed the *top-level* pool
|
|
3267
|
+
* caster does not apply: the market's own type parameters do not name the
|
|
3268
|
+
* pool's package. Recovering it needs the Move type layouts this SDK does not
|
|
3269
|
+
* carry, and guessing a generic's position would produce a silently wrong
|
|
3270
|
+
* `lpCoinType`, so the failure is left to surface.
|
|
3271
|
+
*
|
|
3272
|
+
* NftAmm is also **not deployed on mainnet** — `getAddresses()` returns empty
|
|
3273
|
+
* strings for every `nftAmm` package and object — which is why there is no
|
|
3274
|
+
* captured fixture for it. Fix the nested reads by fetching the pool as a
|
|
3275
|
+
* top-level object by id.
|
|
3276
|
+
*/
|
|
2898
3277
|
NftAmmApiCasting.marketObjectFromSuiObject = (suiObject) => {
|
|
2899
3278
|
const objectId = Helpers.getObjectId(suiObject);
|
|
2900
3279
|
const marketType = Helpers.getObjectType(suiObject);
|
|
@@ -2904,8 +3283,16 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2904
3283
|
const fields = Helpers.getObjectFields(
|
|
2905
3284
|
suiObject
|
|
2906
3285
|
);
|
|
2907
|
-
const
|
|
2908
|
-
const
|
|
3286
|
+
const nfts = GrpcCasting.unwrapStructField(fields.nfts);
|
|
3287
|
+
const supply = GrpcCasting.unwrapStructField(fields.supply);
|
|
3288
|
+
const pool = PoolsApiCasting.poolObjectFromSuiObject({
|
|
3289
|
+
...GrpcCasting.unwrapStructField(fields.pool),
|
|
3290
|
+
objectId: void 0,
|
|
3291
|
+
type: void 0
|
|
3292
|
+
});
|
|
3293
|
+
const fractionalizedCoinType = Coin.getInnerCoinType(
|
|
3294
|
+
fields.supply.type
|
|
3295
|
+
);
|
|
2909
3296
|
const innerMarketTypes = Coin.getInnerCoinType(marketType);
|
|
2910
3297
|
const genericTypes = innerMarketTypes.replaceAll(" ", "").split(",");
|
|
2911
3298
|
const assetCoinType = genericTypes[2];
|
|
@@ -2915,10 +3302,10 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2915
3302
|
pool,
|
|
2916
3303
|
objectType: marketType,
|
|
2917
3304
|
nftsTable: {
|
|
2918
|
-
objectId:
|
|
2919
|
-
size: BigInt(
|
|
3305
|
+
objectId: GrpcCasting.unwrapUid(nfts.id),
|
|
3306
|
+
size: BigInt(nfts.size)
|
|
2920
3307
|
},
|
|
2921
|
-
fractionalizedSupply: BigInt(
|
|
3308
|
+
fractionalizedSupply: BigInt(supply.value),
|
|
2922
3309
|
fractionalizedCoinAmount: BigInt(fields.fractions_amount),
|
|
2923
3310
|
fractionalizedCoinType,
|
|
2924
3311
|
assetCoinType,
|
|
@@ -2930,27 +3317,31 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2930
3317
|
});
|
|
2931
3318
|
|
|
2932
3319
|
// src/packages/perpetuals/perpetualsTypes.ts
|
|
2933
|
-
var PerpetualsOrderSide, PerpetualsOrderType, PerpetualsStopOrderType, isUpdatedMarketVersion, isWithdrewCollateralEvent, isDepositedCollateralEvent, isDeallocatedCollateralEvent, isAllocatedCollateralEvent, isSettledFundingEvent, isLiquidatedEvent, isCanceledOrderEvent, isPostedOrderEvent, isFilledMakerOrdersEvent, isFilledTakerOrderEvent, isReducedOrderEvent, isUpdatedPremiumTwapEvent, isUpdatedSpreadTwapEvent, isUpdatedFundingEvent;
|
|
3320
|
+
var PerpetualsOrderSide, PerpetualsOrderType, PerpetualsStopOrderType, PerpetualsStopOrderTriggerPriceType, isUpdatedMarketVersion, isWithdrewCollateralEvent, isDepositedCollateralEvent, isDeallocatedCollateralEvent, isAllocatedCollateralEvent, isSettledFundingEvent, isLiquidatedEvent, isCanceledOrderEvent, isPostedOrderEvent, isFilledMakerOrdersEvent, isFilledTakerOrderEvent, isReducedOrderEvent, isUpdatedPremiumTwapEvent, isUpdatedSpreadTwapEvent, isUpdatedFundingEvent;
|
|
2934
3321
|
var init_perpetualsTypes = __esm({
|
|
2935
3322
|
"src/packages/perpetuals/perpetualsTypes.ts"() {
|
|
2936
3323
|
"use strict";
|
|
2937
|
-
PerpetualsOrderSide =
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
}
|
|
2949
|
-
PerpetualsStopOrderType =
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
3324
|
+
PerpetualsOrderSide = {
|
|
3325
|
+
Ask: 1,
|
|
3326
|
+
// true
|
|
3327
|
+
Bid: 0
|
|
3328
|
+
// false
|
|
3329
|
+
};
|
|
3330
|
+
PerpetualsOrderType = {
|
|
3331
|
+
Standard: 0,
|
|
3332
|
+
FillOrKill: 1,
|
|
3333
|
+
PostOnly: 2,
|
|
3334
|
+
ImmediateOrCancel: 3
|
|
3335
|
+
};
|
|
3336
|
+
PerpetualsStopOrderType = {
|
|
3337
|
+
SlTp: 0,
|
|
3338
|
+
Standalone: 1
|
|
3339
|
+
};
|
|
3340
|
+
PerpetualsStopOrderTriggerPriceType = {
|
|
3341
|
+
IndexPrice: 0,
|
|
3342
|
+
BookMidPrice: 1,
|
|
3343
|
+
MarkPrice: 2
|
|
3344
|
+
};
|
|
2954
3345
|
isUpdatedMarketVersion = (event) => {
|
|
2955
3346
|
return event.type.toLowerCase().endsWith("::updatedclearinghouseversion");
|
|
2956
3347
|
};
|
|
@@ -3146,13 +3537,10 @@ var init_perpetualsApiCasting = __esm({
|
|
|
3146
3537
|
liquidationFeesUsd: Casting.IFixed.numberFromIFixed(
|
|
3147
3538
|
BigInt(fields.liquidation_fees)
|
|
3148
3539
|
),
|
|
3149
|
-
forceCancelFeesUsd: Casting.IFixed.numberFromIFixed(
|
|
3150
|
-
BigInt(fields.force_cancel_fees)
|
|
3151
|
-
),
|
|
3152
3540
|
insuranceFundFeesUsd: Casting.IFixed.numberFromIFixed(
|
|
3153
3541
|
BigInt(fields.insurance_fund_fees)
|
|
3154
3542
|
),
|
|
3155
|
-
side: fields.is_liqee_long ?
|
|
3543
|
+
side: fields.is_liqee_long ? PerpetualsOrderSide.Bid : PerpetualsOrderSide.Ask,
|
|
3156
3544
|
timestamp: Number(eventOnChain.timestampMs),
|
|
3157
3545
|
txnDigest: eventOnChain.id.txDigest,
|
|
3158
3546
|
type: eventOnChain.type
|
|
@@ -3634,19 +4022,21 @@ var init_stakingApiCasting = __esm({
|
|
|
3634
4022
|
const fields = Helpers.getObjectFields(
|
|
3635
4023
|
data
|
|
3636
4024
|
);
|
|
4025
|
+
const protocolConfig = GrpcCasting.unwrapStructField(
|
|
4026
|
+
fields.protocol_config
|
|
4027
|
+
);
|
|
4028
|
+
const atomicUnstakeProtocolFee = GrpcCasting.unwrapStructField(
|
|
4029
|
+
protocolConfig.atomic_unstake_protocol_fee
|
|
4030
|
+
);
|
|
3637
4031
|
return {
|
|
3638
4032
|
objectId,
|
|
3639
4033
|
objectType,
|
|
3640
4034
|
atomicUnstakeSuiReservesTargetValue: BigInt(
|
|
3641
|
-
|
|
4035
|
+
protocolConfig.atomic_unstake_sui_reserves_target_value
|
|
3642
4036
|
),
|
|
3643
4037
|
atomicUnstakeSuiReserves: BigInt(fields.atomic_unstake_sui_reserves),
|
|
3644
|
-
minAtomicUnstakeFee: BigInt(
|
|
3645
|
-
|
|
3646
|
-
),
|
|
3647
|
-
maxAtomicUnstakeFee: BigInt(
|
|
3648
|
-
fields.protocol_config.fields.atomic_unstake_protocol_fee.fields.max_fee
|
|
3649
|
-
),
|
|
4038
|
+
minAtomicUnstakeFee: BigInt(atomicUnstakeProtocolFee.min_fee),
|
|
4039
|
+
maxAtomicUnstakeFee: BigInt(atomicUnstakeProtocolFee.max_fee),
|
|
3650
4040
|
totalSuiAmount: BigInt(fields.total_sui_amount),
|
|
3651
4041
|
totalRewardsAmount: BigInt(fields.total_rewards_amount),
|
|
3652
4042
|
activeEpoch: BigInt(fields.active_epoch)
|
|
@@ -3822,11 +4212,14 @@ var init_suiFrensApiCasting = __esm({
|
|
|
3822
4212
|
const fields = Helpers.getObjectFields(
|
|
3823
4213
|
data
|
|
3824
4214
|
);
|
|
4215
|
+
const suiFrensMetadata = GrpcCasting.unwrapStructField(
|
|
4216
|
+
fields.suifrens_metadata
|
|
4217
|
+
);
|
|
3825
4218
|
return {
|
|
3826
4219
|
objectType,
|
|
3827
4220
|
objectId: Helpers.getObjectId(data),
|
|
3828
4221
|
totalMixes: BigInt(fields.mixed),
|
|
3829
|
-
stakedSuiFrens: BigInt(
|
|
4222
|
+
stakedSuiFrens: BigInt(suiFrensMetadata.size)
|
|
3830
4223
|
};
|
|
3831
4224
|
};
|
|
3832
4225
|
_SuiFrensApiCasting.accessoryObjectFromSuiObjectResponse = (data) => {
|
|
@@ -3901,6 +4294,7 @@ var _NftsApiCasting, NftsApiCasting;
|
|
|
3901
4294
|
var init_nftsApiCasting = __esm({
|
|
3902
4295
|
"src/general/nfts/nftsApiCasting.ts"() {
|
|
3903
4296
|
"use strict";
|
|
4297
|
+
init_grpcCasting();
|
|
3904
4298
|
init_helpers();
|
|
3905
4299
|
_NftsApiCasting = class _NftsApiCasting {
|
|
3906
4300
|
};
|
|
@@ -3911,7 +4305,7 @@ var init_nftsApiCasting = __esm({
|
|
|
3911
4305
|
// Objects
|
|
3912
4306
|
// =========================================================================
|
|
3913
4307
|
_NftsApiCasting.nftsFromSuiObjects = (objects) => {
|
|
3914
|
-
const nfts = objects.filter((object) => object.
|
|
4308
|
+
const nfts = objects.filter((object) => object.display);
|
|
3915
4309
|
return nfts.map((nft) => _NftsApiCasting.nftFromSuiObject(nft)).filter(
|
|
3916
4310
|
(nft) => Object.keys(nft.display.suggested).length > 0 || Object.keys(nft.display.other).length > 0
|
|
3917
4311
|
);
|
|
@@ -3939,10 +4333,11 @@ var init_nftsApiCasting = __esm({
|
|
|
3939
4333
|
const fields = Helpers.getObjectFields(object);
|
|
3940
4334
|
const objectId = Helpers.getObjectId(object);
|
|
3941
4335
|
const objectType = Helpers.getObjectType(object);
|
|
4336
|
+
const cap = GrpcCasting.unwrapStructField(fields.cap);
|
|
3942
4337
|
return {
|
|
3943
4338
|
objectId,
|
|
3944
4339
|
objectType,
|
|
3945
|
-
kioskObjectId: Helpers.addLeadingZeroesToType(
|
|
4340
|
+
kioskObjectId: Helpers.addLeadingZeroesToType(cap.for)
|
|
3946
4341
|
};
|
|
3947
4342
|
};
|
|
3948
4343
|
// =========================================================================
|
|
@@ -4397,6 +4792,7 @@ var init_utils = __esm({
|
|
|
4397
4792
|
"src/general/utils/index.ts"() {
|
|
4398
4793
|
"use strict";
|
|
4399
4794
|
init_casting();
|
|
4795
|
+
init_grpcCasting();
|
|
4400
4796
|
init_helpers();
|
|
4401
4797
|
}
|
|
4402
4798
|
});
|
|
@@ -4988,6 +5384,38 @@ var init_farmsStakingPool = __esm({
|
|
|
4988
5384
|
};
|
|
4989
5385
|
return this.version() === 1 ? this.farmsApi().buildSetStakingPoolMinStakeAmountTxV1(args) : this.farmsApi().buildSetStakingPoolMinStakeAmountTxV2(args);
|
|
4990
5386
|
}
|
|
5387
|
+
/**
|
|
5388
|
+
* Builds a transaction to set the pool's minimum lock duration (ms).
|
|
5389
|
+
* Owner-cap only. V2 pools only — V1 vaults do not expose this entry.
|
|
5390
|
+
*/
|
|
5391
|
+
getSetMinLockDurationMsTransaction(inputs) {
|
|
5392
|
+
if (this.version() === 1) {
|
|
5393
|
+
throw new Error(
|
|
5394
|
+
"set_min_lock_duration_ms is not supported on V1 staking pools"
|
|
5395
|
+
);
|
|
5396
|
+
}
|
|
5397
|
+
return this.farmsApi().buildSetStakingPoolMinLockDurationMsTxV2({
|
|
5398
|
+
...inputs,
|
|
5399
|
+
stakeCoinType: this.stakingPool.stakeCoinType,
|
|
5400
|
+
stakingPoolId: this.stakingPool.objectId
|
|
5401
|
+
});
|
|
5402
|
+
}
|
|
5403
|
+
/**
|
|
5404
|
+
* Builds a transaction to set the pool's maximum lock duration (ms).
|
|
5405
|
+
* Owner-cap only. V2 pools only.
|
|
5406
|
+
*/
|
|
5407
|
+
getSetMaxLockDurationMsTransaction(inputs) {
|
|
5408
|
+
if (this.version() === 1) {
|
|
5409
|
+
throw new Error(
|
|
5410
|
+
"set_max_lock_duration_ms is not supported on V1 staking pools"
|
|
5411
|
+
);
|
|
5412
|
+
}
|
|
5413
|
+
return this.farmsApi().buildSetStakingPoolMaxLockDurationMsTxV2({
|
|
5414
|
+
...inputs,
|
|
5415
|
+
stakeCoinType: this.stakingPool.stakeCoinType,
|
|
5416
|
+
stakingPoolId: this.stakingPool.objectId
|
|
5417
|
+
});
|
|
5418
|
+
}
|
|
4991
5419
|
/**
|
|
4992
5420
|
* Builds a transaction granting a one-time admin cap to another address, allowing them to perform specific
|
|
4993
5421
|
* one-time administrative actions (like initializing a reward).
|
|
@@ -5861,29 +6289,19 @@ var init_faucet = __esm({
|
|
|
5861
6289
|
// =========================================================================
|
|
5862
6290
|
// Inspections
|
|
5863
6291
|
// =========================================================================
|
|
5864
|
-
|
|
6292
|
+
getSupportedCoins() {
|
|
5865
6293
|
return this.fetchApi("supported-coins");
|
|
5866
6294
|
}
|
|
5867
6295
|
// =========================================================================
|
|
5868
|
-
// Events
|
|
5869
|
-
// =========================================================================
|
|
5870
|
-
// TODO: add mint coin event getter ?
|
|
5871
|
-
// =========================================================================
|
|
5872
6296
|
// Transactions
|
|
5873
6297
|
// =========================================================================
|
|
5874
|
-
|
|
6298
|
+
getRequestCoinTransaction(inputs) {
|
|
5875
6299
|
return this.faucetApi().buildRequestCoinTx(inputs);
|
|
5876
6300
|
}
|
|
5877
|
-
|
|
6301
|
+
getMintSuiFrenTransaction(inputs) {
|
|
5878
6302
|
return this.faucetApi().fetchBuildMintSuiFrenTx(inputs);
|
|
5879
6303
|
}
|
|
5880
6304
|
};
|
|
5881
|
-
// =========================================================================
|
|
5882
|
-
// Constants
|
|
5883
|
-
// =========================================================================
|
|
5884
|
-
Faucet.constants = {
|
|
5885
|
-
defaultRequestAmountUsd: 10
|
|
5886
|
-
};
|
|
5887
6305
|
}
|
|
5888
6306
|
});
|
|
5889
6307
|
|
|
@@ -6004,24 +6422,25 @@ var init_gasPools = __esm({
|
|
|
6004
6422
|
);
|
|
6005
6423
|
}
|
|
6006
6424
|
/**
|
|
6007
|
-
*
|
|
6008
|
-
*
|
|
6425
|
+
* Requests a gas-pool-sponsored transaction. Returns a complete transaction
|
|
6426
|
+
* with the gas payment and epoch bound attached, the sponsor's signature, and
|
|
6427
|
+
* the digest both signatures commit to — the caller signs `transaction` as the
|
|
6428
|
+
* sender and submits it together with `sponsorSignature`.
|
|
6009
6429
|
*
|
|
6010
|
-
* @param inputs.walletAddress - Wallet address
|
|
6011
|
-
* @param inputs.
|
|
6012
|
-
* @param inputs.
|
|
6013
|
-
* @
|
|
6430
|
+
* @param inputs.walletAddress - Wallet address requesting the sponsorship.
|
|
6431
|
+
* @param inputs.bytes - Base64 of the signed `SPONSOR_GAS` auth message.
|
|
6432
|
+
* @param inputs.signature - Signature over `bytes`.
|
|
6433
|
+
* @param inputs.tx - Optional transaction to sponsor (appended as a tx kind).
|
|
6434
|
+
* @returns {@link ApiGasPoolSponsorResponse}.
|
|
6014
6435
|
*/
|
|
6015
|
-
async
|
|
6436
|
+
async getSponsoredTransaction(inputs) {
|
|
6016
6437
|
const { tx, ...otherInputs } = inputs;
|
|
6017
|
-
return this.
|
|
6438
|
+
return this.fetchApi(
|
|
6018
6439
|
"transactions/sponsor",
|
|
6019
6440
|
{
|
|
6020
6441
|
...otherInputs,
|
|
6021
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
|
|
6022
|
-
}
|
|
6023
|
-
void 0,
|
|
6024
|
-
{ txKind: true }
|
|
6442
|
+
txKind: tx ? await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }) : void 0
|
|
6443
|
+
}
|
|
6025
6444
|
);
|
|
6026
6445
|
}
|
|
6027
6446
|
/**
|
|
@@ -8987,7 +9406,7 @@ var init_types2 = __esm({
|
|
|
8987
9406
|
|
|
8988
9407
|
// src/packages/perpetuals/perpetualsAccount.ts
|
|
8989
9408
|
import {
|
|
8990
|
-
Transaction as
|
|
9409
|
+
Transaction as Transaction4
|
|
8991
9410
|
} from "@mysten/sui/transactions";
|
|
8992
9411
|
var PerpetualsAccount;
|
|
8993
9412
|
var init_perpetualsAccount = __esm({
|
|
@@ -9068,7 +9487,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9068
9487
|
accountId: this.accountCap.accountId,
|
|
9069
9488
|
accountCapId: this.accountCap.objectId,
|
|
9070
9489
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
9071
|
-
tx: tx ?? new
|
|
9490
|
+
tx: tx ?? new Transaction4()
|
|
9072
9491
|
})
|
|
9073
9492
|
},
|
|
9074
9493
|
void 0,
|
|
@@ -9116,7 +9535,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9116
9535
|
walletAddress: this.ownerAddress(),
|
|
9117
9536
|
accountId: this.accountCap.accountId,
|
|
9118
9537
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
9119
|
-
tx: txFromInputs ?? new
|
|
9538
|
+
tx: txFromInputs ?? new Transaction4()
|
|
9120
9539
|
})
|
|
9121
9540
|
},
|
|
9122
9541
|
void 0,
|
|
@@ -9152,7 +9571,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9152
9571
|
vaultId: void 0
|
|
9153
9572
|
},
|
|
9154
9573
|
walletAddress: this.ownerAddress(),
|
|
9155
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new
|
|
9574
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
|
|
9156
9575
|
},
|
|
9157
9576
|
void 0,
|
|
9158
9577
|
{
|
|
@@ -9187,7 +9606,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9187
9606
|
vaultId: void 0
|
|
9188
9607
|
},
|
|
9189
9608
|
walletAddress: this.ownerAddress(),
|
|
9190
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new
|
|
9609
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
|
|
9191
9610
|
},
|
|
9192
9611
|
void 0,
|
|
9193
9612
|
{
|
|
@@ -9220,7 +9639,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9220
9639
|
walletAddress: this.ownerAddress(),
|
|
9221
9640
|
fromAccountId: this.accountCap.accountId,
|
|
9222
9641
|
fromAccountCapId: this.accountCap.objectId,
|
|
9223
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new
|
|
9642
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
|
|
9224
9643
|
},
|
|
9225
9644
|
void 0,
|
|
9226
9645
|
{
|
|
@@ -9268,7 +9687,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9268
9687
|
*/
|
|
9269
9688
|
async getPlaceMarketOrderTx(inputs) {
|
|
9270
9689
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9271
|
-
const tx = txFromInputs ?? new
|
|
9690
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9272
9691
|
return this.fetchApiTxObject(
|
|
9273
9692
|
`${this.vaultId ? "vault" : "account"}/transactions/place-market-order`,
|
|
9274
9693
|
{
|
|
@@ -9310,7 +9729,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9310
9729
|
*/
|
|
9311
9730
|
async getPlaceLimitOrderTx(inputs) {
|
|
9312
9731
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9313
|
-
const tx = txFromInputs ?? new
|
|
9732
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9314
9733
|
return this.fetchApiTxObject(
|
|
9315
9734
|
`${this.vaultId ? "vault" : "account"}/transactions/place-limit-order`,
|
|
9316
9735
|
{
|
|
@@ -9347,7 +9766,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9347
9766
|
*/
|
|
9348
9767
|
async getPlaceScaleOrderTx(inputs) {
|
|
9349
9768
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9350
|
-
const tx = txFromInputs ?? new
|
|
9769
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9351
9770
|
return this.fetchApiTxObject(
|
|
9352
9771
|
`${this.vaultId ? "vault" : "account"}/transactions/place-scale-order`,
|
|
9353
9772
|
{
|
|
@@ -9382,7 +9801,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9382
9801
|
*/
|
|
9383
9802
|
async getCancelAndPlaceOrdersTx(inputs) {
|
|
9384
9803
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9385
|
-
const tx = txFromInputs ?? new
|
|
9804
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9386
9805
|
return this.fetchApiTxObject(
|
|
9387
9806
|
`${this.vaultId ? "vault" : "account"}/transactions/cancel-and-place-orders`,
|
|
9388
9807
|
{
|
|
@@ -9497,7 +9916,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9497
9916
|
*/
|
|
9498
9917
|
async getPlaceStopOrdersTx(inputs) {
|
|
9499
9918
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9500
|
-
const tx = txFromInputs ?? new
|
|
9919
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9501
9920
|
return this.fetchApiTxObject(
|
|
9502
9921
|
`${this.vaultId ? "vault" : "account"}/transactions/place-stop-orders`,
|
|
9503
9922
|
{
|
|
@@ -9541,7 +9960,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9541
9960
|
if (!position) {
|
|
9542
9961
|
throw new Error("you have no position for this market");
|
|
9543
9962
|
}
|
|
9544
|
-
const tx = txFromInputs ?? new
|
|
9963
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9545
9964
|
return this.fetchApiTxObject(
|
|
9546
9965
|
`${this.vaultId ? "vault" : "account"}/transactions/place-sl-tp-orders`,
|
|
9547
9966
|
{
|
|
@@ -9577,16 +9996,110 @@ var init_perpetualsAccount = __esm({
|
|
|
9577
9996
|
* - This is typically used to adjust trigger prices, sizes, expiries, or the
|
|
9578
9997
|
* embedded limit-order parameters.
|
|
9579
9998
|
*
|
|
9580
|
-
* @param inputs.stopOrders - Full updated stop-order payloads to apply.
|
|
9999
|
+
* @param inputs.stopOrders - Full updated stop-order payloads to apply.
|
|
10000
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
10001
|
+
*
|
|
10002
|
+
* @returns Transaction response containing `tx`.
|
|
10003
|
+
*/
|
|
10004
|
+
async getEditStopOrdersTx(inputs) {
|
|
10005
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
10006
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
10007
|
+
return this.fetchApiTxObject(
|
|
10008
|
+
`${this.vaultId ? "vault" : "account"}/transactions/edit-stop-orders`,
|
|
10009
|
+
{
|
|
10010
|
+
...otherInputs,
|
|
10011
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
10012
|
+
walletAddress: this.ownerAddress(),
|
|
10013
|
+
..."vaultId" in this.accountCap ? {
|
|
10014
|
+
vaultId: this.accountCap.vaultId,
|
|
10015
|
+
accountId: void 0
|
|
10016
|
+
} : {
|
|
10017
|
+
accountId: this.accountCap.accountId,
|
|
10018
|
+
accountCapId: this.accountCap.objectId,
|
|
10019
|
+
vaultId: void 0
|
|
10020
|
+
}
|
|
10021
|
+
},
|
|
10022
|
+
void 0,
|
|
10023
|
+
{
|
|
10024
|
+
txKind: true
|
|
10025
|
+
}
|
|
10026
|
+
);
|
|
10027
|
+
}
|
|
10028
|
+
/**
|
|
10029
|
+
* Build a `create-twap-orders` transaction for this account.
|
|
10030
|
+
*
|
|
10031
|
+
* @param inputs - See {@link SdkPerpetualsCreateTwapOrdersInputs}.
|
|
10032
|
+
*
|
|
10033
|
+
* @returns Transaction response containing `tx`.
|
|
10034
|
+
*/
|
|
10035
|
+
async getCreateTwapOrdersTx(inputs) {
|
|
10036
|
+
const { tx, ...otherInputs } = inputs;
|
|
10037
|
+
return this.fetchApiTxObject(
|
|
10038
|
+
`${this.vaultId ? "vault" : "account"}/transactions/create-twap-orders`,
|
|
10039
|
+
{
|
|
10040
|
+
...otherInputs,
|
|
10041
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
10042
|
+
walletAddress: this.ownerAddress(),
|
|
10043
|
+
..."vaultId" in this.accountCap ? {
|
|
10044
|
+
vaultId: this.accountCap.vaultId,
|
|
10045
|
+
accountId: void 0
|
|
10046
|
+
} : {
|
|
10047
|
+
accountId: this.accountCap.accountId,
|
|
10048
|
+
accountCapId: this.accountCap.objectId,
|
|
10049
|
+
vaultId: void 0
|
|
10050
|
+
}
|
|
10051
|
+
},
|
|
10052
|
+
void 0,
|
|
10053
|
+
{
|
|
10054
|
+
txKind: true
|
|
10055
|
+
}
|
|
10056
|
+
);
|
|
10057
|
+
}
|
|
10058
|
+
/**
|
|
10059
|
+
* Build an `edit-twap-orders` transaction for this account.
|
|
10060
|
+
* `newTwapOrders` maps each TWAP order object id to the edit to apply.
|
|
10061
|
+
*
|
|
10062
|
+
* @param inputs.newTwapOrders - Map of TWAP order id to the edit to apply.
|
|
10063
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
10064
|
+
*
|
|
10065
|
+
* @returns Transaction response containing `tx`.
|
|
10066
|
+
*/
|
|
10067
|
+
async getEditTwapOrdersTx(inputs) {
|
|
10068
|
+
const { tx, ...otherInputs } = inputs;
|
|
10069
|
+
return this.fetchApiTxObject(
|
|
10070
|
+
`${this.vaultId ? "vault" : "account"}/transactions/edit-twap-orders`,
|
|
10071
|
+
{
|
|
10072
|
+
...otherInputs,
|
|
10073
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
10074
|
+
walletAddress: this.ownerAddress(),
|
|
10075
|
+
..."vaultId" in this.accountCap ? {
|
|
10076
|
+
vaultId: this.accountCap.vaultId,
|
|
10077
|
+
accountId: void 0
|
|
10078
|
+
} : {
|
|
10079
|
+
accountId: this.accountCap.accountId,
|
|
10080
|
+
accountCapId: this.accountCap.objectId,
|
|
10081
|
+
vaultId: void 0
|
|
10082
|
+
}
|
|
10083
|
+
},
|
|
10084
|
+
void 0,
|
|
10085
|
+
{
|
|
10086
|
+
txKind: true
|
|
10087
|
+
}
|
|
10088
|
+
);
|
|
10089
|
+
}
|
|
10090
|
+
/**
|
|
10091
|
+
* Build a `cancel-twap-orders` transaction for this account.
|
|
10092
|
+
* This cancels TWAP order objects by their object IDs.
|
|
10093
|
+
*
|
|
9581
10094
|
* @param inputs.tx - Optional transaction to extend.
|
|
10095
|
+
* @param inputs.twapOrderIds - Array of TWAP order object IDs to cancel.
|
|
9582
10096
|
*
|
|
9583
10097
|
* @returns Transaction response containing `tx`.
|
|
9584
10098
|
*/
|
|
9585
|
-
async
|
|
9586
|
-
const { tx
|
|
9587
|
-
const tx = txFromInputs ?? new Transaction3();
|
|
10099
|
+
async getCancelTwapOrdersTx(inputs) {
|
|
10100
|
+
const { tx, ...otherInputs } = inputs;
|
|
9588
10101
|
return this.fetchApiTxObject(
|
|
9589
|
-
`${this.vaultId ? "vault" : "account"}/transactions/
|
|
10102
|
+
`${this.vaultId ? "vault" : "account"}/transactions/cancel-twap-orders`,
|
|
9590
10103
|
{
|
|
9591
10104
|
...otherInputs,
|
|
9592
10105
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
@@ -9606,6 +10119,29 @@ var init_perpetualsAccount = __esm({
|
|
|
9606
10119
|
}
|
|
9607
10120
|
);
|
|
9608
10121
|
}
|
|
10122
|
+
/**
|
|
10123
|
+
* Fetch TWAP-order data for this account, using an off-chain signed payload.
|
|
10124
|
+
*
|
|
10125
|
+
* @param inputs.bytes - Serialized message that was signed.
|
|
10126
|
+
* @param inputs.signature - Signature over `bytes`.
|
|
10127
|
+
* @param inputs.marketIds - Optional subset of markets to filter results by.
|
|
10128
|
+
*
|
|
10129
|
+
* @returns {@link ApiPerpetualsTwapOrderDatasResponse} containing `twapOrderDatas`.
|
|
10130
|
+
*/
|
|
10131
|
+
async getTwapOrderDatas(inputs) {
|
|
10132
|
+
const { bytes, signature, marketIds } = inputs;
|
|
10133
|
+
return await this.fetchApi(`${this.vaultId ? "vault" : "account"}/twap-order-datas`, {
|
|
10134
|
+
bytes,
|
|
10135
|
+
signature,
|
|
10136
|
+
walletAddress: this.ownerAddress(),
|
|
10137
|
+
marketIds: marketIds ?? [],
|
|
10138
|
+
..."vaultId" in this.accountCap ? {
|
|
10139
|
+
vaultId: this.accountCap.vaultId
|
|
10140
|
+
} : {
|
|
10141
|
+
accountId: this.accountCap.accountId
|
|
10142
|
+
}
|
|
10143
|
+
});
|
|
10144
|
+
}
|
|
9609
10145
|
// public async getReduceOrderTx(inputs: {
|
|
9610
10146
|
// tx?: Transaction;
|
|
9611
10147
|
// collateralChange: number;
|
|
@@ -10174,7 +10710,7 @@ var init_perpetualsAccount = __esm({
|
|
|
10174
10710
|
recipientAddress,
|
|
10175
10711
|
accountId: this.accountCap.accountId,
|
|
10176
10712
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
10177
|
-
tx: tx ?? new
|
|
10713
|
+
tx: tx ?? new Transaction4()
|
|
10178
10714
|
})
|
|
10179
10715
|
},
|
|
10180
10716
|
void 0,
|
|
@@ -10206,7 +10742,7 @@ var init_perpetualsAccount = __esm({
|
|
|
10206
10742
|
accountCapId,
|
|
10207
10743
|
accountId: this.accountCap.accountId,
|
|
10208
10744
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
10209
|
-
tx: tx ?? new
|
|
10745
|
+
tx: tx ?? new Transaction4()
|
|
10210
10746
|
})
|
|
10211
10747
|
},
|
|
10212
10748
|
void 0,
|
|
@@ -10337,7 +10873,7 @@ var init_perpetualsAccount = __esm({
|
|
|
10337
10873
|
* - Market ID matches the input market.
|
|
10338
10874
|
* - `slTp` field is present.
|
|
10339
10875
|
* - Order side is opposite of the position side.
|
|
10340
|
-
* - At least a `
|
|
10876
|
+
* - At least a `stopLossPrice` or `takeProfitPrice` is set.
|
|
10341
10877
|
*
|
|
10342
10878
|
* Notes on matching:
|
|
10343
10879
|
* - The side comparison uses the current position side derived from the account snapshot.
|
|
@@ -10361,10 +10897,10 @@ var init_perpetualsAccount = __esm({
|
|
|
10361
10897
|
}
|
|
10362
10898
|
const side = position ? Perpetuals.positionSide(position) : void 0;
|
|
10363
10899
|
const fullSlTpOrder = stopOrderDatas.find(
|
|
10364
|
-
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.
|
|
10900
|
+
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size >= Casting.i64MaxBigInt && !order.limitOrder
|
|
10365
10901
|
);
|
|
10366
10902
|
const partialSlTpOrders = stopOrderDatas.filter(
|
|
10367
|
-
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.
|
|
10903
|
+
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size < Casting.i64MaxBigInt && !order.limitOrder
|
|
10368
10904
|
);
|
|
10369
10905
|
return {
|
|
10370
10906
|
fullSlTpOrder,
|
|
@@ -10374,10 +10910,10 @@ var init_perpetualsAccount = __esm({
|
|
|
10374
10910
|
slTpStopOrderDatasForLimitOrder(inputs) {
|
|
10375
10911
|
const { stopOrderDatas, limitOrderId } = inputs;
|
|
10376
10912
|
const fullSlTpOrder = stopOrderDatas.find(
|
|
10377
|
-
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.
|
|
10913
|
+
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size >= Casting.i64MaxBigInt
|
|
10378
10914
|
);
|
|
10379
10915
|
const partialSlTpOrders = stopOrderDatas.filter(
|
|
10380
|
-
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.
|
|
10916
|
+
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size < Casting.i64MaxBigInt
|
|
10381
10917
|
);
|
|
10382
10918
|
return {
|
|
10383
10919
|
fullSlTpOrder,
|
|
@@ -10562,12 +11098,13 @@ var init_perpetualsMarket = __esm({
|
|
|
10562
11098
|
* @param marketData - Snapshot of market configuration and state.
|
|
10563
11099
|
* @param config - Optional {@link CallerConfig} (network, base URL, etc.).
|
|
10564
11100
|
* @param api - Optional shared {@link AftermathApi} provider instance.
|
|
11101
|
+
* @param metadata - Optional display metadata for the market.
|
|
10565
11102
|
*
|
|
10566
11103
|
* @remarks
|
|
10567
11104
|
* This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning
|
|
10568
11105
|
* all HTTP requests resolve under `/perpetuals/...`.
|
|
10569
11106
|
*/
|
|
10570
|
-
constructor(marketData, config, api) {
|
|
11107
|
+
constructor(marketData, config, api, metadata) {
|
|
10571
11108
|
super(config, "perpetuals");
|
|
10572
11109
|
this.marketData = marketData;
|
|
10573
11110
|
this.api = api;
|
|
@@ -10765,10 +11302,6 @@ var init_perpetualsMarket = __esm({
|
|
|
10765
11302
|
asksQuantity: 0,
|
|
10766
11303
|
bidsQuantity: 0,
|
|
10767
11304
|
pendingOrders: [],
|
|
10768
|
-
makerFee: 1,
|
|
10769
|
-
// 100% (placeholder default)
|
|
10770
|
-
takerFee: 1,
|
|
10771
|
-
// 100% (placeholder default)
|
|
10772
11305
|
leverage: 1,
|
|
10773
11306
|
entryPrice: 0,
|
|
10774
11307
|
freeCollateral: 0,
|
|
@@ -10785,6 +11318,7 @@ var init_perpetualsMarket = __esm({
|
|
|
10785
11318
|
this.collateralCoinType = marketData.collateralCoinType;
|
|
10786
11319
|
this.marketParams = marketData.marketParams;
|
|
10787
11320
|
this.marketState = marketData.marketState;
|
|
11321
|
+
this.metadata = metadata ?? null;
|
|
10788
11322
|
}
|
|
10789
11323
|
// =========================================================================
|
|
10790
11324
|
// Inspections
|
|
@@ -10998,7 +11532,7 @@ var init_perpetualsMarket = __esm({
|
|
|
10998
11532
|
|
|
10999
11533
|
// src/packages/perpetuals/perpetualsVault.ts
|
|
11000
11534
|
import {
|
|
11001
|
-
Transaction as
|
|
11535
|
+
Transaction as Transaction5
|
|
11002
11536
|
} from "@mysten/sui/transactions";
|
|
11003
11537
|
var PerpetualsVault;
|
|
11004
11538
|
var init_perpetualsVault = __esm({
|
|
@@ -11051,7 +11585,7 @@ var init_perpetualsVault = __esm({
|
|
|
11051
11585
|
...otherInputs,
|
|
11052
11586
|
vaultId: this.vaultObject.objectId,
|
|
11053
11587
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11054
|
-
tx: tx ?? new
|
|
11588
|
+
tx: tx ?? new Transaction5()
|
|
11055
11589
|
})
|
|
11056
11590
|
},
|
|
11057
11591
|
void 0,
|
|
@@ -11067,7 +11601,7 @@ var init_perpetualsVault = __esm({
|
|
|
11067
11601
|
...otherInputs,
|
|
11068
11602
|
vaultId: this.vaultObject.objectId,
|
|
11069
11603
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11070
|
-
tx: tx ?? new
|
|
11604
|
+
tx: tx ?? new Transaction5()
|
|
11071
11605
|
})
|
|
11072
11606
|
},
|
|
11073
11607
|
void 0,
|
|
@@ -11093,7 +11627,7 @@ var init_perpetualsVault = __esm({
|
|
|
11093
11627
|
...otherInputs,
|
|
11094
11628
|
vaultId: this.vaultObject.objectId,
|
|
11095
11629
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11096
|
-
tx: tx ?? new
|
|
11630
|
+
tx: tx ?? new Transaction5()
|
|
11097
11631
|
})
|
|
11098
11632
|
},
|
|
11099
11633
|
void 0,
|
|
@@ -11119,7 +11653,7 @@ var init_perpetualsVault = __esm({
|
|
|
11119
11653
|
...otherInputs,
|
|
11120
11654
|
vaultId: this.vaultObject.objectId,
|
|
11121
11655
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11122
|
-
tx: tx ?? new
|
|
11656
|
+
tx: tx ?? new Transaction5()
|
|
11123
11657
|
})
|
|
11124
11658
|
},
|
|
11125
11659
|
void 0,
|
|
@@ -11142,7 +11676,7 @@ var init_perpetualsVault = __esm({
|
|
|
11142
11676
|
...otherInputs,
|
|
11143
11677
|
vaultId: this.vaultObject.objectId,
|
|
11144
11678
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11145
|
-
tx: tx ?? new
|
|
11679
|
+
tx: tx ?? new Transaction5()
|
|
11146
11680
|
})
|
|
11147
11681
|
},
|
|
11148
11682
|
void 0,
|
|
@@ -11166,7 +11700,7 @@ var init_perpetualsVault = __esm({
|
|
|
11166
11700
|
...otherInputs,
|
|
11167
11701
|
vaultId: this.vaultObject.objectId,
|
|
11168
11702
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11169
|
-
tx: tx ?? new
|
|
11703
|
+
tx: tx ?? new Transaction5()
|
|
11170
11704
|
})
|
|
11171
11705
|
},
|
|
11172
11706
|
void 0,
|
|
@@ -11195,7 +11729,7 @@ var init_perpetualsVault = __esm({
|
|
|
11195
11729
|
...otherInputs,
|
|
11196
11730
|
vaultId: this.vaultObject.objectId,
|
|
11197
11731
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11198
|
-
tx: tx ?? new
|
|
11732
|
+
tx: tx ?? new Transaction5()
|
|
11199
11733
|
})
|
|
11200
11734
|
},
|
|
11201
11735
|
void 0,
|
|
@@ -11220,7 +11754,7 @@ var init_perpetualsVault = __esm({
|
|
|
11220
11754
|
...otherInputs,
|
|
11221
11755
|
vaultId: this.vaultObject.objectId,
|
|
11222
11756
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11223
|
-
tx: txFromInputs ?? new
|
|
11757
|
+
tx: txFromInputs ?? new Transaction5()
|
|
11224
11758
|
})
|
|
11225
11759
|
},
|
|
11226
11760
|
void 0,
|
|
@@ -11246,7 +11780,7 @@ var init_perpetualsVault = __esm({
|
|
|
11246
11780
|
...otherInputs,
|
|
11247
11781
|
vaultId: this.vaultObject.objectId,
|
|
11248
11782
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11249
|
-
tx: tx ?? new
|
|
11783
|
+
tx: tx ?? new Transaction5()
|
|
11250
11784
|
})
|
|
11251
11785
|
},
|
|
11252
11786
|
void 0,
|
|
@@ -11277,7 +11811,7 @@ var init_perpetualsVault = __esm({
|
|
|
11277
11811
|
...otherInputs,
|
|
11278
11812
|
vaultId: this.vaultObject.objectId,
|
|
11279
11813
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11280
|
-
tx: tx ?? new
|
|
11814
|
+
tx: tx ?? new Transaction5()
|
|
11281
11815
|
})
|
|
11282
11816
|
},
|
|
11283
11817
|
void 0,
|
|
@@ -11308,7 +11842,7 @@ var init_perpetualsVault = __esm({
|
|
|
11308
11842
|
...otherInputs,
|
|
11309
11843
|
vaultId: this.vaultObject.objectId,
|
|
11310
11844
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11311
|
-
tx: tx ?? new
|
|
11845
|
+
tx: tx ?? new Transaction5()
|
|
11312
11846
|
})
|
|
11313
11847
|
},
|
|
11314
11848
|
void 0,
|
|
@@ -11331,7 +11865,7 @@ var init_perpetualsVault = __esm({
|
|
|
11331
11865
|
...otherInputs,
|
|
11332
11866
|
vaultId: this.vaultObject.objectId,
|
|
11333
11867
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11334
|
-
tx: tx ?? new
|
|
11868
|
+
tx: tx ?? new Transaction5()
|
|
11335
11869
|
})
|
|
11336
11870
|
},
|
|
11337
11871
|
void 0,
|
|
@@ -11377,7 +11911,7 @@ var init_perpetualsVault = __esm({
|
|
|
11377
11911
|
...depositInputs,
|
|
11378
11912
|
vaultId: this.vaultObject.objectId,
|
|
11379
11913
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11380
|
-
tx: tx ?? new
|
|
11914
|
+
tx: tx ?? new Transaction5()
|
|
11381
11915
|
})
|
|
11382
11916
|
},
|
|
11383
11917
|
void 0,
|
|
@@ -11692,7 +12226,7 @@ var init_perpetualsOrderUtils = __esm({
|
|
|
11692
12226
|
// Return price of given `order_id`, (works for ask or bid)
|
|
11693
12227
|
_PerpetualsOrderUtils.price = (orderId) => {
|
|
11694
12228
|
const side = Perpetuals.orderIdToSide(orderId);
|
|
11695
|
-
if (side ===
|
|
12229
|
+
if (side === PerpetualsOrderSide.Ask) {
|
|
11696
12230
|
return _PerpetualsOrderUtils.priceAsk(orderId);
|
|
11697
12231
|
}
|
|
11698
12232
|
return _PerpetualsOrderUtils.priceBid(orderId);
|
|
@@ -11725,7 +12259,7 @@ var init_utils2 = __esm({
|
|
|
11725
12259
|
|
|
11726
12260
|
// src/packages/perpetuals/perpetuals.ts
|
|
11727
12261
|
import {
|
|
11728
|
-
Transaction as
|
|
12262
|
+
Transaction as Transaction6
|
|
11729
12263
|
} from "@mysten/sui/transactions";
|
|
11730
12264
|
var _Perpetuals, Perpetuals;
|
|
11731
12265
|
var init_perpetuals = __esm({
|
|
@@ -11833,7 +12367,12 @@ var init_perpetuals = __esm({
|
|
|
11833
12367
|
const res = await this.fetchApi("markets", inputs);
|
|
11834
12368
|
return {
|
|
11835
12369
|
markets: res.marketDatas.map(
|
|
11836
|
-
(marketData) => new PerpetualsMarket(
|
|
12370
|
+
(marketData) => new PerpetualsMarket(
|
|
12371
|
+
marketData.market,
|
|
12372
|
+
this.config,
|
|
12373
|
+
this.api,
|
|
12374
|
+
marketData.metadata
|
|
12375
|
+
)
|
|
11837
12376
|
)
|
|
11838
12377
|
};
|
|
11839
12378
|
}
|
|
@@ -12095,12 +12634,12 @@ var init_perpetuals = __esm({
|
|
|
12095
12634
|
*/
|
|
12096
12635
|
// TODO: move to market class ?
|
|
12097
12636
|
getMarketCandleHistory(inputs) {
|
|
12098
|
-
const { marketId, fromTimestamp, toTimestamp,
|
|
12637
|
+
const { marketId, fromTimestamp, toTimestamp, resolution } = inputs;
|
|
12099
12638
|
return this.fetchApi("market/candle-history", {
|
|
12100
12639
|
marketId,
|
|
12101
12640
|
fromTimestamp,
|
|
12102
12641
|
toTimestamp,
|
|
12103
|
-
|
|
12642
|
+
resolution
|
|
12104
12643
|
});
|
|
12105
12644
|
}
|
|
12106
12645
|
/**
|
|
@@ -12194,7 +12733,7 @@ var init_perpetuals = __esm({
|
|
|
12194
12733
|
{
|
|
12195
12734
|
...otherInputs,
|
|
12196
12735
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
12197
|
-
tx: tx ?? new
|
|
12736
|
+
tx: tx ?? new Transaction6()
|
|
12198
12737
|
})
|
|
12199
12738
|
},
|
|
12200
12739
|
void 0,
|
|
@@ -12253,7 +12792,7 @@ var init_perpetuals = __esm({
|
|
|
12253
12792
|
{
|
|
12254
12793
|
...otherInputs,
|
|
12255
12794
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
12256
|
-
tx: tx ?? new
|
|
12795
|
+
tx: tx ?? new Transaction6()
|
|
12257
12796
|
})
|
|
12258
12797
|
},
|
|
12259
12798
|
void 0,
|
|
@@ -12288,7 +12827,7 @@ var init_perpetuals = __esm({
|
|
|
12288
12827
|
{
|
|
12289
12828
|
...otherInputs,
|
|
12290
12829
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
12291
|
-
tx: tx ?? new
|
|
12830
|
+
tx: tx ?? new Transaction6()
|
|
12292
12831
|
})
|
|
12293
12832
|
},
|
|
12294
12833
|
void 0,
|
|
@@ -12418,8 +12957,8 @@ var init_perpetuals = __esm({
|
|
|
12418
12957
|
*
|
|
12419
12958
|
* This endpoint creates a transaction that allows a user to grant permission to an
|
|
12420
12959
|
* integrator to receive fees on orders placed on their behalf. The user specifies
|
|
12421
|
-
* a maximum
|
|
12422
|
-
* include their
|
|
12960
|
+
* a maximum integrator fee that the integrator can charge. The integrator can then
|
|
12961
|
+
* include their id and fee (up to the maximum) when placing orders for the user.
|
|
12423
12962
|
*
|
|
12424
12963
|
* The resulting transaction must be signed by the account owner and executed on-chain.
|
|
12425
12964
|
*
|
|
@@ -12430,8 +12969,8 @@ var init_perpetuals = __esm({
|
|
|
12430
12969
|
* ```ts
|
|
12431
12970
|
* const tx = await perps.getCreateBuilderCodeIntegratorConfigTx({
|
|
12432
12971
|
* accountId: 123n,
|
|
12433
|
-
*
|
|
12434
|
-
*
|
|
12972
|
+
* integratorId: 7,
|
|
12973
|
+
* maxIntegratorFee: 0.001, // 0.1% max fee
|
|
12435
12974
|
* });
|
|
12436
12975
|
* ```
|
|
12437
12976
|
*/
|
|
@@ -12467,7 +13006,7 @@ var init_perpetuals = __esm({
|
|
|
12467
13006
|
* ```ts
|
|
12468
13007
|
* const tx = await perps.getRemoveBuilderCodeIntegratorConfigTx({
|
|
12469
13008
|
* accountId: 123n,
|
|
12470
|
-
*
|
|
13009
|
+
* integratorId: 7,
|
|
12471
13010
|
* });
|
|
12472
13011
|
* ```
|
|
12473
13012
|
*/
|
|
@@ -12486,13 +13025,12 @@ var init_perpetuals = __esm({
|
|
|
12486
13025
|
);
|
|
12487
13026
|
}
|
|
12488
13027
|
/**
|
|
12489
|
-
* Build a transaction to initialize an integrator fee vault
|
|
13028
|
+
* Build a transaction to initialize an integrator's global fee vault.
|
|
12490
13029
|
*
|
|
12491
|
-
* This endpoint creates a transaction that initializes
|
|
12492
|
-
* fees
|
|
12493
|
-
*
|
|
12494
|
-
*
|
|
12495
|
-
* integrator submits orders on behalf of users in that market.
|
|
13030
|
+
* This endpoint creates a transaction that initializes the global vault where an
|
|
13031
|
+
* integrator's fees accumulate across all markets. This is a one-time setup that
|
|
13032
|
+
* must be performed before the integrator can claim fees. The integrator's identity
|
|
13033
|
+
* is taken from the transaction sender on-chain.
|
|
12496
13034
|
*
|
|
12497
13035
|
* The resulting transaction must be signed by the integrator and executed on-chain.
|
|
12498
13036
|
*
|
|
@@ -12501,10 +13039,7 @@ var init_perpetuals = __esm({
|
|
|
12501
13039
|
*
|
|
12502
13040
|
* @example
|
|
12503
13041
|
* ```ts
|
|
12504
|
-
* const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({
|
|
12505
|
-
* marketId: "0x...",
|
|
12506
|
-
* integratorAddress: "0x...",
|
|
12507
|
-
* });
|
|
13042
|
+
* const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({});
|
|
12508
13043
|
* ```
|
|
12509
13044
|
*/
|
|
12510
13045
|
async getCreateBuilderCodeIntegratorVaultTx(inputs) {
|
|
@@ -12525,36 +13060,34 @@ var init_perpetuals = __esm({
|
|
|
12525
13060
|
* Build a transaction to claim accumulated integrator fees from a vault.
|
|
12526
13061
|
*
|
|
12527
13062
|
* This endpoint creates a transaction that allows an integrator to claim the fees
|
|
12528
|
-
* they have earned from orders placed on behalf of users. Fees accumulate in
|
|
12529
|
-
*
|
|
12530
|
-
*
|
|
12531
|
-
*
|
|
13063
|
+
* they have earned from orders placed on behalf of users. Fees accumulate in the
|
|
13064
|
+
* integrator's global vault (across all markets) and can be claimed at any moment.
|
|
13065
|
+
* The fees are proportional to the taker volume generated by the users' orders that
|
|
13066
|
+
* the integrator submitted.
|
|
12532
13067
|
*
|
|
12533
13068
|
* If a `recipientAddress` is provided, the claimed fees will be automatically
|
|
12534
|
-
* transferred to that address. Otherwise, the coin
|
|
12535
|
-
*
|
|
13069
|
+
* transferred to that address. Otherwise, the coin outputs are exposed as transaction
|
|
13070
|
+
* arguments for further use in the transaction (one per non-zero collateral balance).
|
|
12536
13071
|
*
|
|
12537
13072
|
* The resulting transaction must be signed by the integrator and executed on-chain.
|
|
12538
13073
|
*
|
|
12539
13074
|
* @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
|
|
12540
13075
|
* @returns {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse} containing
|
|
12541
|
-
* `txKind` and optionally `
|
|
13076
|
+
* `txKind` and optionally `coinOutArgs`.
|
|
12542
13077
|
*
|
|
12543
13078
|
* @example
|
|
12544
13079
|
* ```ts
|
|
12545
13080
|
* // Claim with automatic transfer to recipient
|
|
12546
13081
|
* const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
|
|
12547
|
-
*
|
|
12548
|
-
* integratorAddress: "0x...",
|
|
13082
|
+
* integratorId: 7,
|
|
12549
13083
|
* recipientAddress: "0x...",
|
|
12550
13084
|
* });
|
|
12551
13085
|
*
|
|
12552
|
-
* // Claim with coin
|
|
13086
|
+
* // Claim with coin outputs for further use
|
|
12553
13087
|
* const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
|
|
12554
|
-
*
|
|
12555
|
-
* integratorAddress: "0x...",
|
|
13088
|
+
* integratorId: 7,
|
|
12556
13089
|
* });
|
|
12557
|
-
* // response.
|
|
13090
|
+
* // response.coinOutArgs can be used in subsequent transaction commands
|
|
12558
13091
|
* ```
|
|
12559
13092
|
*/
|
|
12560
13093
|
async getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
|
|
@@ -12579,24 +13112,24 @@ var init_perpetuals = __esm({
|
|
|
12579
13112
|
*
|
|
12580
13113
|
* This endpoint queries whether an integrator has been approved by an account to collect
|
|
12581
13114
|
* fees on orders placed on behalf of the account. If approved, it returns the maximum
|
|
12582
|
-
*
|
|
13115
|
+
* integrator fee the integrator is authorized to charge. This information is useful for:
|
|
12583
13116
|
* - Verifying integrator permissions before placing orders
|
|
12584
13117
|
* - Displaying authorized integrators and their fee limits in UIs
|
|
12585
13118
|
* - Validating that an integrator's requested fee doesn't exceed the approved maximum
|
|
12586
13119
|
*
|
|
12587
13120
|
* @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorConfigBody}.
|
|
12588
13121
|
* @returns {@link ApiPerpetualsBuilderCodesIntegratorConfigResponse} containing
|
|
12589
|
-
* `
|
|
13122
|
+
* `maxIntegratorFee` and `exists` flag.
|
|
12590
13123
|
*
|
|
12591
13124
|
* @example
|
|
12592
13125
|
* ```ts
|
|
12593
13126
|
* const config = await perps.getBuilderCodeIntegratorConfig({
|
|
12594
13127
|
* accountId: 123n,
|
|
12595
|
-
*
|
|
13128
|
+
* integratorId: 7,
|
|
12596
13129
|
* });
|
|
12597
13130
|
*
|
|
12598
13131
|
* if (config.exists) {
|
|
12599
|
-
* console.log(`Integrator is approved with max fee: ${config.
|
|
13132
|
+
* console.log(`Integrator is approved with max fee: ${config.maxIntegratorFee}`);
|
|
12600
13133
|
* } else {
|
|
12601
13134
|
* console.log("Integrator is not approved for this account");
|
|
12602
13135
|
* }
|
|
@@ -12606,36 +13139,35 @@ var init_perpetuals = __esm({
|
|
|
12606
13139
|
return this.fetchApi("builder-codes/integrator-config", inputs);
|
|
12607
13140
|
}
|
|
12608
13141
|
/**
|
|
12609
|
-
* Fetch accumulated integrator vault fees
|
|
13142
|
+
* Fetch accumulated integrator vault fees.
|
|
12610
13143
|
*
|
|
12611
|
-
* This endpoint queries the total fees an integrator has earned and accumulated in
|
|
12612
|
-
*
|
|
12613
|
-
* to the taker volume generated by orders they submit on behalf of
|
|
12614
|
-
*
|
|
12615
|
-
* {@link
|
|
13144
|
+
* This endpoint queries the total fees an integrator has earned and accumulated in
|
|
13145
|
+
* their global vault, grouped by collateral coin type. Integrators earn fees
|
|
13146
|
+
* proportional to the taker volume generated by orders they submit on behalf of
|
|
13147
|
+
* users. These fees can be claimed at any time using
|
|
13148
|
+
* {@link getClaimBuilderCodeIntegratorVaultFeesTx}.
|
|
12616
13149
|
*
|
|
12617
13150
|
* This information is useful for:
|
|
12618
13151
|
* - Displaying total claimable fees to integrators in dashboards
|
|
12619
|
-
* - Monitoring fee accrual across
|
|
12620
|
-
* - Determining
|
|
13152
|
+
* - Monitoring fee accrual across collateral types
|
|
13153
|
+
* - Determining whether fees are ready to be claimed
|
|
12621
13154
|
*
|
|
12622
13155
|
* @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
|
|
12623
13156
|
* @returns {@link ApiPerpetualsBuilderCodesIntegratorVaultsResponse} containing
|
|
12624
|
-
* a vector of
|
|
13157
|
+
* a vector of per-collateral vault data with accumulated fees.
|
|
12625
13158
|
*
|
|
12626
13159
|
* @example
|
|
12627
13160
|
* ```ts
|
|
12628
13161
|
* const vaultFees = await perps.getBuilderCodeIntegratorVaults({
|
|
12629
|
-
*
|
|
12630
|
-
* integratorAddress: "0x...",
|
|
13162
|
+
* integratorId: 7,
|
|
12631
13163
|
* });
|
|
12632
13164
|
*
|
|
12633
13165
|
* for (const vault of vaultFees.integratorVaults) {
|
|
12634
|
-
* console.log(
|
|
13166
|
+
* console.log(`${vault.collateralCoinType}: ${vault.fees} collateral units claimable`);
|
|
12635
13167
|
* }
|
|
12636
13168
|
*
|
|
12637
|
-
* const
|
|
12638
|
-
* console.log(`Total claimable: ${
|
|
13169
|
+
* const totalFeesUsd = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.feesUsd, 0);
|
|
13170
|
+
* console.log(`Total claimable (USD): ${totalFeesUsd}`);
|
|
12639
13171
|
* ```
|
|
12640
13172
|
*/
|
|
12641
13173
|
async getBuilderCodeIntegratorVaults(inputs) {
|
|
@@ -12653,7 +13185,7 @@ var init_perpetuals = __esm({
|
|
|
12653
13185
|
static positionSide(inputs) {
|
|
12654
13186
|
const baseAmount = inputs.baseAssetAmount;
|
|
12655
13187
|
const isLong = Math.sign(baseAmount);
|
|
12656
|
-
const side = isLong >= 0 ?
|
|
13188
|
+
const side = isLong >= 0 ? PerpetualsOrderSide.Bid : PerpetualsOrderSide.Ask;
|
|
12657
13189
|
return side;
|
|
12658
13190
|
}
|
|
12659
13191
|
/**
|
|
@@ -12849,6 +13381,20 @@ var init_perpetuals = __esm({
|
|
|
12849
13381
|
}
|
|
12850
13382
|
}
|
|
12851
13383
|
});
|
|
13384
|
+
const subscribeMarketCandles = ({
|
|
13385
|
+
marketId,
|
|
13386
|
+
interval
|
|
13387
|
+
}) => ctl.send({
|
|
13388
|
+
action: "subscribe",
|
|
13389
|
+
subscriptionType: { marketCandles: { marketId, interval } }
|
|
13390
|
+
});
|
|
13391
|
+
const unsubscribeMarketCandles = ({
|
|
13392
|
+
marketId,
|
|
13393
|
+
interval
|
|
13394
|
+
}) => ctl.send({
|
|
13395
|
+
action: "unsubscribe",
|
|
13396
|
+
subscriptionType: { marketCandles: { marketId, interval } }
|
|
13397
|
+
});
|
|
12852
13398
|
return {
|
|
12853
13399
|
ws: ctl.ws,
|
|
12854
13400
|
subscribeMarket,
|
|
@@ -12867,6 +13413,8 @@ var init_perpetuals = __esm({
|
|
|
12867
13413
|
unsubscribeUserCollateralChanges,
|
|
12868
13414
|
subscribeTopOfOrderbook,
|
|
12869
13415
|
unsubscribeTopOfOrderbook,
|
|
13416
|
+
subscribeMarketCandles,
|
|
13417
|
+
unsubscribeMarketCandles,
|
|
12870
13418
|
close: ctl.close
|
|
12871
13419
|
};
|
|
12872
13420
|
}
|
|
@@ -12896,19 +13444,27 @@ var init_perpetuals = __esm({
|
|
|
12896
13444
|
* ```
|
|
12897
13445
|
*/
|
|
12898
13446
|
openMarketCandlesWebsocketStream(args) {
|
|
12899
|
-
const { marketId,
|
|
12900
|
-
const
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
13447
|
+
const { marketId, interval, onMessage, onOpen, onError, onClose } = args;
|
|
13448
|
+
const ctl = this.openWsStream({
|
|
13449
|
+
path: "ws/updates",
|
|
13450
|
+
onMessage: (env) => {
|
|
13451
|
+
if ("marketCandles" in env) {
|
|
13452
|
+
onMessage({
|
|
13453
|
+
marketId: env.marketCandles.marketId,
|
|
13454
|
+
lastCandle: env.marketCandles.lastCandle
|
|
13455
|
+
});
|
|
13456
|
+
}
|
|
13457
|
+
},
|
|
13458
|
+
onOpen: (ev) => {
|
|
13459
|
+
ctl.send({
|
|
13460
|
+
action: "subscribe",
|
|
13461
|
+
subscriptionType: { marketCandles: { marketId, interval } }
|
|
13462
|
+
});
|
|
13463
|
+
onOpen?.(ev);
|
|
13464
|
+
},
|
|
13465
|
+
onError,
|
|
13466
|
+
onClose
|
|
13467
|
+
});
|
|
12912
13468
|
return {
|
|
12913
13469
|
ws: ctl.ws,
|
|
12914
13470
|
close: ctl.close
|
|
@@ -12953,7 +13509,7 @@ var init_perpetuals = __esm({
|
|
|
12953
13509
|
* @returns {@link PerpetualsOrderSide}.
|
|
12954
13510
|
*/
|
|
12955
13511
|
_Perpetuals.orderIdToSide = (orderId) => {
|
|
12956
|
-
return _Perpetuals.OrderUtils.isAsk(orderId) ?
|
|
13512
|
+
return _Perpetuals.OrderUtils.isAsk(orderId) ? PerpetualsOrderSide.Ask : PerpetualsOrderSide.Bid;
|
|
12957
13513
|
};
|
|
12958
13514
|
/**
|
|
12959
13515
|
* Construct a collateral-specialized Move event type string.
|
|
@@ -13048,7 +13604,7 @@ var init_referralVault2 = __esm({
|
|
|
13048
13604
|
});
|
|
13049
13605
|
|
|
13050
13606
|
// src/packages/router/router.ts
|
|
13051
|
-
import { Transaction as
|
|
13607
|
+
import { Transaction as Transaction7 } from "@mysten/sui/transactions";
|
|
13052
13608
|
var Router;
|
|
13053
13609
|
var init_router = __esm({
|
|
13054
13610
|
"src/packages/router/router.ts"() {
|
|
@@ -13249,7 +13805,7 @@ var init_router = __esm({
|
|
|
13249
13805
|
serializedTx: tx.serialize()
|
|
13250
13806
|
});
|
|
13251
13807
|
return {
|
|
13252
|
-
tx:
|
|
13808
|
+
tx: Transaction7.from(newTx),
|
|
13253
13809
|
coinOutId
|
|
13254
13810
|
};
|
|
13255
13811
|
}
|
|
@@ -14808,7 +15364,7 @@ var init_referrals = __esm({
|
|
|
14808
15364
|
});
|
|
14809
15365
|
|
|
14810
15366
|
// src/packages/rewards/rewards.ts
|
|
14811
|
-
import { Transaction as
|
|
15367
|
+
import { Transaction as Transaction8 } from "@mysten/sui/transactions";
|
|
14812
15368
|
var Rewards;
|
|
14813
15369
|
var init_rewards = __esm({
|
|
14814
15370
|
"src/packages/rewards/rewards.ts"() {
|
|
@@ -14837,6 +15393,15 @@ var init_rewards = __esm({
|
|
|
14837
15393
|
async getClaimable(inputs) {
|
|
14838
15394
|
return this.fetchApi("claimable", inputs);
|
|
14839
15395
|
}
|
|
15396
|
+
/**
|
|
15397
|
+
* Preview a single account's expected rewards for an epoch, broken down by
|
|
15398
|
+
* domain (trading, referral, AFLP, integrator) plus totals. Backed by the
|
|
15399
|
+
* newer `rewards/expectedRewards` endpoint. Provide exactly one of `address`
|
|
15400
|
+
* or `accountId`; omit `epoch` for the current epoch.
|
|
15401
|
+
*/
|
|
15402
|
+
async getExpectedRewards(inputs) {
|
|
15403
|
+
return this.fetchApi("expectedRewards", inputs);
|
|
15404
|
+
}
|
|
14840
15405
|
// =========================================================================
|
|
14841
15406
|
// Transactions
|
|
14842
15407
|
// =========================================================================
|
|
@@ -14847,7 +15412,7 @@ var init_rewards = __esm({
|
|
|
14847
15412
|
{
|
|
14848
15413
|
...otherInputs,
|
|
14849
15414
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
14850
|
-
tx: tx ?? new
|
|
15415
|
+
tx: tx ?? new Transaction8()
|
|
14851
15416
|
})
|
|
14852
15417
|
},
|
|
14853
15418
|
void 0,
|
|
@@ -14899,7 +15464,7 @@ var init_userData = __esm({
|
|
|
14899
15464
|
*/
|
|
14900
15465
|
async getUserPublicKey(inputs) {
|
|
14901
15466
|
return this.fetchApi(
|
|
14902
|
-
|
|
15467
|
+
"public-key",
|
|
14903
15468
|
inputs
|
|
14904
15469
|
);
|
|
14905
15470
|
}
|
|
@@ -14922,7 +15487,7 @@ var init_userData = __esm({
|
|
|
14922
15487
|
*/
|
|
14923
15488
|
async createUserPublicKey(inputs) {
|
|
14924
15489
|
return this.fetchApi(
|
|
14925
|
-
|
|
15490
|
+
"save-public-key",
|
|
14926
15491
|
inputs
|
|
14927
15492
|
);
|
|
14928
15493
|
}
|
|
@@ -14942,7 +15507,7 @@ var init_userData = __esm({
|
|
|
14942
15507
|
*/
|
|
14943
15508
|
createUserAccountMessageToSign() {
|
|
14944
15509
|
return {
|
|
14945
|
-
action:
|
|
15510
|
+
action: "CREATE_USER_ACCOUNT"
|
|
14946
15511
|
};
|
|
14947
15512
|
}
|
|
14948
15513
|
/**
|
|
@@ -14961,7 +15526,7 @@ var init_userData = __esm({
|
|
|
14961
15526
|
*/
|
|
14962
15527
|
createSignTermsAndConditionsMessageToSign() {
|
|
14963
15528
|
return {
|
|
14964
|
-
action:
|
|
15529
|
+
action: "SIGN_TERMS_AND_CONDITIONS"
|
|
14965
15530
|
};
|
|
14966
15531
|
}
|
|
14967
15532
|
};
|
|
@@ -15136,6 +15701,7 @@ var init_coinApi = __esm({
|
|
|
15136
15701
|
"src/packages/coin/api/coinApi.ts"() {
|
|
15137
15702
|
"use strict";
|
|
15138
15703
|
init_transactionsApiHelpers();
|
|
15704
|
+
init_grpcCasting();
|
|
15139
15705
|
init_helpers();
|
|
15140
15706
|
init_coin();
|
|
15141
15707
|
_CoinApi = class _CoinApi {
|
|
@@ -15188,14 +15754,16 @@ var init_coinApi = __esm({
|
|
|
15188
15754
|
let allCoinData = [];
|
|
15189
15755
|
let cursor;
|
|
15190
15756
|
do {
|
|
15191
|
-
const paginatedCoins = await this.api.client.
|
|
15192
|
-
|
|
15757
|
+
const paginatedCoins = await this.api.client.listCoins({
|
|
15758
|
+
coinType: inputs.coinType,
|
|
15193
15759
|
owner: inputs.walletAddress,
|
|
15194
15760
|
cursor
|
|
15195
15761
|
});
|
|
15196
|
-
const coinData = paginatedCoins.
|
|
15762
|
+
const coinData = paginatedCoins.objects.map(
|
|
15763
|
+
GrpcCasting.coinStructFromGrpcCoin
|
|
15764
|
+
);
|
|
15197
15765
|
allCoinData = [...allCoinData, ...coinData];
|
|
15198
|
-
if (paginatedCoins.
|
|
15766
|
+
if (paginatedCoins.objects.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.cursor) {
|
|
15199
15767
|
allCoinData.sort(
|
|
15200
15768
|
(b, a) => Number(BigInt(a.balance) - BigInt(b.balance))
|
|
15201
15769
|
);
|
|
@@ -15210,7 +15778,7 @@ var init_coinApi = __esm({
|
|
|
15210
15778
|
}
|
|
15211
15779
|
throw new Error("wallet does not have coins of sufficient balance");
|
|
15212
15780
|
}
|
|
15213
|
-
cursor = paginatedCoins.
|
|
15781
|
+
cursor = paginatedCoins.cursor;
|
|
15214
15782
|
} while (true);
|
|
15215
15783
|
};
|
|
15216
15784
|
// fetchCoinsUntilAmountReachedOrEnd
|
|
@@ -15218,19 +15786,21 @@ var init_coinApi = __esm({
|
|
|
15218
15786
|
let allCoinData = [];
|
|
15219
15787
|
let cursor;
|
|
15220
15788
|
do {
|
|
15221
|
-
const paginatedCoins = await this.api.client.
|
|
15222
|
-
|
|
15789
|
+
const paginatedCoins = await this.api.client.listCoins({
|
|
15790
|
+
coinType: inputs.coinType,
|
|
15223
15791
|
owner: inputs.walletAddress,
|
|
15224
15792
|
cursor
|
|
15225
15793
|
});
|
|
15226
|
-
const coinData = paginatedCoins.
|
|
15794
|
+
const coinData = paginatedCoins.objects.map(
|
|
15795
|
+
GrpcCasting.coinStructFromGrpcCoin
|
|
15796
|
+
);
|
|
15227
15797
|
allCoinData = [...allCoinData, ...coinData];
|
|
15228
|
-
if (paginatedCoins.
|
|
15798
|
+
if (paginatedCoins.objects.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.cursor) {
|
|
15229
15799
|
return allCoinData.sort(
|
|
15230
15800
|
(b, a) => Number(BigInt(b.coinObjectId) - BigInt(a.coinObjectId))
|
|
15231
15801
|
);
|
|
15232
15802
|
}
|
|
15233
|
-
cursor = paginatedCoins.
|
|
15803
|
+
cursor = paginatedCoins.cursor;
|
|
15234
15804
|
} while (true);
|
|
15235
15805
|
};
|
|
15236
15806
|
}
|
|
@@ -15377,7 +15947,7 @@ var init_dcaApi = __esm({
|
|
|
15377
15947
|
|
|
15378
15948
|
// src/packages/farms/api/farmsApi.ts
|
|
15379
15949
|
import {
|
|
15380
|
-
Transaction as
|
|
15950
|
+
Transaction as Transaction9
|
|
15381
15951
|
} from "@mysten/sui/transactions";
|
|
15382
15952
|
var _FarmsApi, FarmsApi;
|
|
15383
15953
|
var init_farmsApi = __esm({
|
|
@@ -16439,6 +17009,49 @@ var init_farmsApi = __esm({
|
|
|
16439
17009
|
]
|
|
16440
17010
|
});
|
|
16441
17011
|
};
|
|
17012
|
+
/**
|
|
17013
|
+
* Creates a transaction command to set the minimum lock duration (ms) for a
|
|
17014
|
+
* staking pool. Owner-cap only; V2 vault module. Mirrors
|
|
17015
|
+
* `setStakingPoolMinStakeAmountTxV2`.
|
|
17016
|
+
*/
|
|
17017
|
+
this.setStakingPoolMinLockDurationMsTxV2 = (inputs) => {
|
|
17018
|
+
const { tx } = inputs;
|
|
17019
|
+
return tx.moveCall({
|
|
17020
|
+
target: Helpers.transactions.createTxTarget(
|
|
17021
|
+
this.addresses.packages.vaultsV2,
|
|
17022
|
+
_FarmsApi.constants.moduleNames.vaultV2,
|
|
17023
|
+
"set_min_lock_duration_ms"
|
|
17024
|
+
),
|
|
17025
|
+
typeArguments: [inputs.stakeCoinType],
|
|
17026
|
+
arguments: [
|
|
17027
|
+
tx.object(inputs.ownerCapId),
|
|
17028
|
+
tx.object(inputs.stakingPoolId),
|
|
17029
|
+
tx.object(this.addresses.objects.version),
|
|
17030
|
+
tx.pure.u64(inputs.lockDurationMs)
|
|
17031
|
+
]
|
|
17032
|
+
});
|
|
17033
|
+
};
|
|
17034
|
+
/**
|
|
17035
|
+
* Creates a transaction command to set the maximum lock duration (ms) for a
|
|
17036
|
+
* staking pool. Owner-cap only; V2 vault module.
|
|
17037
|
+
*/
|
|
17038
|
+
this.setStakingPoolMaxLockDurationMsTxV2 = (inputs) => {
|
|
17039
|
+
const { tx } = inputs;
|
|
17040
|
+
return tx.moveCall({
|
|
17041
|
+
target: Helpers.transactions.createTxTarget(
|
|
17042
|
+
this.addresses.packages.vaultsV2,
|
|
17043
|
+
_FarmsApi.constants.moduleNames.vaultV2,
|
|
17044
|
+
"set_max_lock_duration_ms"
|
|
17045
|
+
),
|
|
17046
|
+
typeArguments: [inputs.stakeCoinType],
|
|
17047
|
+
arguments: [
|
|
17048
|
+
tx.object(inputs.ownerCapId),
|
|
17049
|
+
tx.object(inputs.stakingPoolId),
|
|
17050
|
+
tx.object(this.addresses.objects.version),
|
|
17051
|
+
tx.pure.u64(inputs.lockDurationMs)
|
|
17052
|
+
]
|
|
17053
|
+
});
|
|
17054
|
+
};
|
|
16442
17055
|
/**
|
|
16443
17056
|
* Creates a Move call (V1) to **remove undistributed reward coins** from a staking pool.
|
|
16444
17057
|
* Only callable by the pool **owner** (validated via `ownerCapId`). This does not claw back
|
|
@@ -16563,7 +17176,7 @@ var init_farmsApi = __esm({
|
|
|
16563
17176
|
*/
|
|
16564
17177
|
this.fetchBuildStakeTxV1 = async (inputs) => {
|
|
16565
17178
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16566
|
-
const tx = new
|
|
17179
|
+
const tx = new Transaction9();
|
|
16567
17180
|
tx.setSender(walletAddress);
|
|
16568
17181
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16569
17182
|
tx,
|
|
@@ -16587,7 +17200,7 @@ var init_farmsApi = __esm({
|
|
|
16587
17200
|
*/
|
|
16588
17201
|
this.fetchBuildStakeTxV2 = async (inputs) => {
|
|
16589
17202
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16590
|
-
const tx = new
|
|
17203
|
+
const tx = new Transaction9();
|
|
16591
17204
|
tx.setSender(walletAddress);
|
|
16592
17205
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16593
17206
|
tx,
|
|
@@ -16613,7 +17226,7 @@ var init_farmsApi = __esm({
|
|
|
16613
17226
|
*/
|
|
16614
17227
|
this.fetchBuildDepositPrincipalTxV1 = async (inputs) => {
|
|
16615
17228
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16616
|
-
const tx = new
|
|
17229
|
+
const tx = new Transaction9();
|
|
16617
17230
|
tx.setSender(walletAddress);
|
|
16618
17231
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16619
17232
|
tx,
|
|
@@ -16636,7 +17249,7 @@ var init_farmsApi = __esm({
|
|
|
16636
17249
|
*/
|
|
16637
17250
|
this.fetchBuildDepositPrincipalTxV2 = async (inputs) => {
|
|
16638
17251
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16639
|
-
const tx = new
|
|
17252
|
+
const tx = new Transaction9();
|
|
16640
17253
|
tx.setSender(walletAddress);
|
|
16641
17254
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16642
17255
|
tx,
|
|
@@ -16660,7 +17273,7 @@ var init_farmsApi = __esm({
|
|
|
16660
17273
|
*/
|
|
16661
17274
|
this.buildWithdrawPrincipalTxV1 = (inputs) => {
|
|
16662
17275
|
const { walletAddress } = inputs;
|
|
16663
|
-
const tx = new
|
|
17276
|
+
const tx = new Transaction9();
|
|
16664
17277
|
tx.setSender(walletAddress);
|
|
16665
17278
|
const withdrawnCoin = this.withdrawPrincipalTxV1({
|
|
16666
17279
|
...inputs,
|
|
@@ -16676,7 +17289,7 @@ var init_farmsApi = __esm({
|
|
|
16676
17289
|
*/
|
|
16677
17290
|
this.buildWithdrawPrincipalTxV2 = (inputs) => {
|
|
16678
17291
|
const { walletAddress } = inputs;
|
|
16679
|
-
const tx = new
|
|
17292
|
+
const tx = new Transaction9();
|
|
16680
17293
|
tx.setSender(walletAddress);
|
|
16681
17294
|
const withdrawnCoin = this.withdrawPrincipalTxV2({
|
|
16682
17295
|
...inputs,
|
|
@@ -16700,7 +17313,7 @@ var init_farmsApi = __esm({
|
|
|
16700
17313
|
stakedPositionIds: [inputs.stakedPositionId]
|
|
16701
17314
|
});
|
|
16702
17315
|
} else {
|
|
16703
|
-
tx = new
|
|
17316
|
+
tx = new Transaction9();
|
|
16704
17317
|
tx.setSender(walletAddress);
|
|
16705
17318
|
}
|
|
16706
17319
|
const withdrawnCoin = this.withdrawPrincipalTxV1({
|
|
@@ -16730,7 +17343,7 @@ var init_farmsApi = __esm({
|
|
|
16730
17343
|
stakedPositionIds: [inputs.stakedPositionId]
|
|
16731
17344
|
});
|
|
16732
17345
|
} else {
|
|
16733
|
-
tx = new
|
|
17346
|
+
tx = new Transaction9();
|
|
16734
17347
|
tx.setSender(walletAddress);
|
|
16735
17348
|
}
|
|
16736
17349
|
const withdrawnCoin = this.withdrawPrincipalTxV2({
|
|
@@ -16823,7 +17436,7 @@ var init_farmsApi = __esm({
|
|
|
16823
17436
|
*/
|
|
16824
17437
|
this.buildHarvestRewardsTxV1 = (inputs) => {
|
|
16825
17438
|
const { walletAddress, stakedPositionIds } = inputs;
|
|
16826
|
-
const tx = inputs.tx ?? new
|
|
17439
|
+
const tx = inputs.tx ?? new Transaction9();
|
|
16827
17440
|
tx.setSender(walletAddress);
|
|
16828
17441
|
const harvestRewardsCap = this.beginHarvestTxV1({
|
|
16829
17442
|
...inputs,
|
|
@@ -16875,7 +17488,7 @@ var init_farmsApi = __esm({
|
|
|
16875
17488
|
*/
|
|
16876
17489
|
this.buildHarvestRewardsTxV2 = (inputs) => {
|
|
16877
17490
|
const { walletAddress, stakedPositionIds } = inputs;
|
|
16878
|
-
const tx = inputs.tx ?? new
|
|
17491
|
+
const tx = inputs.tx ?? new Transaction9();
|
|
16879
17492
|
tx.setSender(walletAddress);
|
|
16880
17493
|
const firstPositionId = stakedPositionIds[0];
|
|
16881
17494
|
const harvestRewardsCap = this.beginHarvestTxV2({
|
|
@@ -16933,7 +17546,7 @@ var init_farmsApi = __esm({
|
|
|
16933
17546
|
*/
|
|
16934
17547
|
this.buildCreateStakingPoolTxV1 = (inputs) => {
|
|
16935
17548
|
const { walletAddress } = inputs;
|
|
16936
|
-
const tx = new
|
|
17549
|
+
const tx = new Transaction9();
|
|
16937
17550
|
tx.setSender(walletAddress);
|
|
16938
17551
|
const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV1({
|
|
16939
17552
|
...inputs,
|
|
@@ -16959,7 +17572,7 @@ var init_farmsApi = __esm({
|
|
|
16959
17572
|
*/
|
|
16960
17573
|
this.buildCreateStakingPoolTxV2 = (inputs) => {
|
|
16961
17574
|
const { walletAddress } = inputs;
|
|
16962
|
-
const tx = new
|
|
17575
|
+
const tx = new Transaction9();
|
|
16963
17576
|
tx.setSender(walletAddress);
|
|
16964
17577
|
const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV2({
|
|
16965
17578
|
...inputs,
|
|
@@ -16985,7 +17598,7 @@ var init_farmsApi = __esm({
|
|
|
16985
17598
|
*/
|
|
16986
17599
|
this.fetchBuildInitializeStakingPoolRewardTxV1 = async (inputs) => {
|
|
16987
17600
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16988
|
-
const tx = new
|
|
17601
|
+
const tx = new Transaction9();
|
|
16989
17602
|
tx.setSender(walletAddress);
|
|
16990
17603
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16991
17604
|
tx,
|
|
@@ -17004,7 +17617,7 @@ var init_farmsApi = __esm({
|
|
|
17004
17617
|
*/
|
|
17005
17618
|
this.fetchBuildInitializeStakingPoolRewardTxV2 = async (inputs) => {
|
|
17006
17619
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
17007
|
-
const tx = new
|
|
17620
|
+
const tx = new Transaction9();
|
|
17008
17621
|
tx.setSender(walletAddress);
|
|
17009
17622
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
17010
17623
|
tx,
|
|
@@ -17024,7 +17637,7 @@ var init_farmsApi = __esm({
|
|
|
17024
17637
|
*/
|
|
17025
17638
|
this.fetchBuildTopUpStakingPoolRewardsTxV1 = async (inputs) => {
|
|
17026
17639
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
17027
|
-
const tx = new
|
|
17640
|
+
const tx = new Transaction9();
|
|
17028
17641
|
tx.setSender(walletAddress);
|
|
17029
17642
|
for (const reward of inputs.rewards) {
|
|
17030
17643
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
@@ -17050,7 +17663,7 @@ var init_farmsApi = __esm({
|
|
|
17050
17663
|
*/
|
|
17051
17664
|
this.fetchBuildTopUpStakingPoolRewardsTxV2 = async (inputs) => {
|
|
17052
17665
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
17053
|
-
const tx = new
|
|
17666
|
+
const tx = new Transaction9();
|
|
17054
17667
|
tx.setSender(walletAddress);
|
|
17055
17668
|
for (const reward of inputs.rewards) {
|
|
17056
17669
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
@@ -17077,7 +17690,7 @@ var init_farmsApi = __esm({
|
|
|
17077
17690
|
*/
|
|
17078
17691
|
this.buildIncreaseStakingPoolRewardsEmissionsTxV1 = (inputs) => {
|
|
17079
17692
|
const { walletAddress } = inputs;
|
|
17080
|
-
const tx = new
|
|
17693
|
+
const tx = new Transaction9();
|
|
17081
17694
|
tx.setSender(walletAddress);
|
|
17082
17695
|
for (const reward of inputs.rewards) {
|
|
17083
17696
|
this.increaseStakingPoolRewardEmissionsTxV1({
|
|
@@ -17095,7 +17708,7 @@ var init_farmsApi = __esm({
|
|
|
17095
17708
|
*/
|
|
17096
17709
|
this.buildIncreaseStakingPoolRewardsEmissionsTxV2 = (inputs) => {
|
|
17097
17710
|
const { walletAddress } = inputs;
|
|
17098
|
-
const tx = new
|
|
17711
|
+
const tx = new Transaction9();
|
|
17099
17712
|
tx.setSender(walletAddress);
|
|
17100
17713
|
for (const reward of inputs.rewards) {
|
|
17101
17714
|
this.increaseStakingPoolRewardEmissionsTxV2({
|
|
@@ -17123,6 +17736,12 @@ var init_farmsApi = __esm({
|
|
|
17123
17736
|
this.buildSetStakingPoolMinStakeAmountTxV2 = Helpers.transactions.createBuildTxFunc(
|
|
17124
17737
|
this.setStakingPoolMinStakeAmountTxV2
|
|
17125
17738
|
);
|
|
17739
|
+
this.buildSetStakingPoolMinLockDurationMsTxV2 = Helpers.transactions.createBuildTxFunc(
|
|
17740
|
+
this.setStakingPoolMinLockDurationMsTxV2
|
|
17741
|
+
);
|
|
17742
|
+
this.buildSetStakingPoolMaxLockDurationMsTxV2 = Helpers.transactions.createBuildTxFunc(
|
|
17743
|
+
this.setStakingPoolMaxLockDurationMsTxV2
|
|
17744
|
+
);
|
|
17126
17745
|
/**
|
|
17127
17746
|
* Builds a transaction for **removing undistributed reward coins** from a staking pool (V1).
|
|
17128
17747
|
* Requires the pool **OwnerCap**. The removal is specific to a `rewardCoinType`.
|
|
@@ -17132,7 +17751,7 @@ var init_farmsApi = __esm({
|
|
|
17132
17751
|
*/
|
|
17133
17752
|
this.buildRemoveStakingPoolRewardTxV1 = (inputs) => {
|
|
17134
17753
|
const { walletAddress } = inputs;
|
|
17135
|
-
const tx = new
|
|
17754
|
+
const tx = new Transaction9();
|
|
17136
17755
|
tx.setSender(walletAddress);
|
|
17137
17756
|
for (const reward of inputs.rewards) {
|
|
17138
17757
|
this.removeStakingPoolRewardTxV1({
|
|
@@ -17152,7 +17771,7 @@ var init_farmsApi = __esm({
|
|
|
17152
17771
|
*/
|
|
17153
17772
|
this.buildRemoveStakingPoolRewardTxV2 = (inputs) => {
|
|
17154
17773
|
const { walletAddress } = inputs;
|
|
17155
|
-
const tx = new
|
|
17774
|
+
const tx = new Transaction9();
|
|
17156
17775
|
tx.setSender(walletAddress);
|
|
17157
17776
|
for (const reward of inputs.rewards) {
|
|
17158
17777
|
this.removeStakingPoolRewardTxV2({
|
|
@@ -17561,7 +18180,7 @@ var init_farmsApi = __esm({
|
|
|
17561
18180
|
|
|
17562
18181
|
// src/packages/faucet/api/faucetApi.ts
|
|
17563
18182
|
import {
|
|
17564
|
-
Transaction as
|
|
18183
|
+
Transaction as Transaction10
|
|
17565
18184
|
} from "@mysten/sui/transactions";
|
|
17566
18185
|
var _FaucetApi, FaucetApi;
|
|
17567
18186
|
var init_faucetApi = __esm({
|
|
@@ -17569,7 +18188,6 @@ var init_faucetApi = __esm({
|
|
|
17569
18188
|
"use strict";
|
|
17570
18189
|
init_eventsApiHelpers();
|
|
17571
18190
|
init_transactionsApiHelpers();
|
|
17572
|
-
init_utils();
|
|
17573
18191
|
init_coin2();
|
|
17574
18192
|
init_sui2();
|
|
17575
18193
|
init_faucetApiCasting();
|
|
@@ -17590,35 +18208,24 @@ var init_faucetApi = __esm({
|
|
|
17590
18208
|
// =========================================================================
|
|
17591
18209
|
// Transaction Commands
|
|
17592
18210
|
// =========================================================================
|
|
17593
|
-
|
|
17594
|
-
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
|
|
17598
|
-
// const { tx, treasuryCapId, treasuryCapType } = inputs;
|
|
17599
|
-
// return tx.moveCall({
|
|
17600
|
-
// target: TransactionsApiHelpers.createTxTarget(
|
|
17601
|
-
// this.addresses.packages.faucet,
|
|
17602
|
-
// FaucetApi.constants.moduleNames.faucet,
|
|
17603
|
-
// "add_coin"
|
|
17604
|
-
// ),
|
|
17605
|
-
// typeArguments: [treasuryCapType],
|
|
17606
|
-
// arguments: [
|
|
17607
|
-
// tx.object(this.addresses.objects.faucet),
|
|
17608
|
-
// tx.object(treasuryCapId),
|
|
17609
|
-
// ],
|
|
17610
|
-
// });
|
|
17611
|
-
// };
|
|
18211
|
+
/**
|
|
18212
|
+
* Mints `coinType`'s configured default amount and returns the resulting
|
|
18213
|
+
* `Coin<T>`. Use {@link buildRequestCoinTx} to mint and transfer it to a
|
|
18214
|
+
* wallet in one transaction.
|
|
18215
|
+
*/
|
|
17612
18216
|
this.requestCoinTx = (inputs) => {
|
|
17613
18217
|
const { tx, coinType } = inputs;
|
|
17614
18218
|
return tx.moveCall({
|
|
17615
18219
|
target: TransactionsApiHelpers.createTxTarget(
|
|
17616
18220
|
this.addresses.packages.faucet,
|
|
17617
18221
|
_FaucetApi.constants.moduleNames.faucet,
|
|
17618
|
-
"
|
|
18222
|
+
"mint"
|
|
17619
18223
|
),
|
|
17620
18224
|
typeArguments: [coinType],
|
|
17621
|
-
arguments: [
|
|
18225
|
+
arguments: [
|
|
18226
|
+
tx.object(this.addresses.objects.faucet),
|
|
18227
|
+
tx.object(this.addresses.objects.config)
|
|
18228
|
+
]
|
|
17622
18229
|
});
|
|
17623
18230
|
};
|
|
17624
18231
|
this.mintSuiFrenTx = (inputs) => {
|
|
@@ -17643,12 +18250,17 @@ var init_faucetApi = __esm({
|
|
|
17643
18250
|
// =========================================================================
|
|
17644
18251
|
// Transaction Builders
|
|
17645
18252
|
// =========================================================================
|
|
17646
|
-
this.buildRequestCoinTx =
|
|
17647
|
-
|
|
17648
|
-
|
|
18253
|
+
this.buildRequestCoinTx = (inputs) => {
|
|
18254
|
+
const { walletAddress, coinType } = inputs;
|
|
18255
|
+
const tx = new Transaction10();
|
|
18256
|
+
tx.setSender(walletAddress);
|
|
18257
|
+
const coin = this.requestCoinTx({ tx, coinType });
|
|
18258
|
+
tx.transferObjects([coin], walletAddress);
|
|
18259
|
+
return tx;
|
|
18260
|
+
};
|
|
17649
18261
|
this.fetchBuildMintSuiFrenTx = async (inputs) => {
|
|
17650
18262
|
const { walletAddress, mintFee, suiFrenType } = inputs;
|
|
17651
|
-
const tx = new
|
|
18263
|
+
const tx = new Transaction10();
|
|
17652
18264
|
tx.setSender(walletAddress);
|
|
17653
18265
|
const suiPaymentCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
17654
18266
|
tx,
|
|
@@ -17662,7 +18274,6 @@ var init_faucetApi = __esm({
|
|
|
17662
18274
|
// =========================================================================
|
|
17663
18275
|
// Events
|
|
17664
18276
|
// =========================================================================
|
|
17665
|
-
// TODO: add to indexer
|
|
17666
18277
|
this.fetchMintCoinEvents = async (inputs) => await this.api.Events().fetchCastEventsWithCursor({
|
|
17667
18278
|
...inputs,
|
|
17668
18279
|
query: {
|
|
@@ -17670,7 +18281,6 @@ var init_faucetApi = __esm({
|
|
|
17670
18281
|
},
|
|
17671
18282
|
eventFromEventOnChain: FaucetApiCasting.faucetMintCoinEventFromOnChain
|
|
17672
18283
|
});
|
|
17673
|
-
// TODO: add to indexer
|
|
17674
18284
|
this.fetchAddCoinEvents = async (inputs) => await this.api.Events().fetchCastEventsWithCursor(
|
|
17675
18285
|
{
|
|
17676
18286
|
...inputs,
|
|
@@ -17721,7 +18331,7 @@ var init_faucetApi = __esm({
|
|
|
17721
18331
|
},
|
|
17722
18332
|
eventNames: {
|
|
17723
18333
|
mintCoin: "MintedCoin",
|
|
17724
|
-
addCoin: "
|
|
18334
|
+
addCoin: "AddedCoin"
|
|
17725
18335
|
}
|
|
17726
18336
|
};
|
|
17727
18337
|
FaucetApi = _FaucetApi;
|
|
@@ -17812,7 +18422,7 @@ var init_multisigApi = __esm({
|
|
|
17812
18422
|
|
|
17813
18423
|
// src/packages/nftAmm/api/nftAmmApi.ts
|
|
17814
18424
|
import {
|
|
17815
|
-
Transaction as
|
|
18425
|
+
Transaction as Transaction11
|
|
17816
18426
|
} from "@mysten/sui/transactions";
|
|
17817
18427
|
var _NftAmmApi, NftAmmApi;
|
|
17818
18428
|
var init_nftAmmApi = __esm({
|
|
@@ -17857,7 +18467,7 @@ var init_nftAmmApi = __esm({
|
|
|
17857
18467
|
// Transaction Builders
|
|
17858
18468
|
// =========================================================================
|
|
17859
18469
|
this.fetchBuildBuyTx = async (inputs) => {
|
|
17860
|
-
const tx = new
|
|
18470
|
+
const tx = new Transaction11();
|
|
17861
18471
|
tx.setSender(inputs.walletAddress);
|
|
17862
18472
|
const { market } = inputs;
|
|
17863
18473
|
const marketObject = market.market;
|
|
@@ -17883,7 +18493,7 @@ var init_nftAmmApi = __esm({
|
|
|
17883
18493
|
return tx;
|
|
17884
18494
|
};
|
|
17885
18495
|
this.fetchBuildSellTx = async (inputs) => {
|
|
17886
|
-
const tx = new
|
|
18496
|
+
const tx = new Transaction11();
|
|
17887
18497
|
tx.setSender(inputs.walletAddress);
|
|
17888
18498
|
const { market } = inputs;
|
|
17889
18499
|
const marketObject = market.market;
|
|
@@ -17903,7 +18513,7 @@ var init_nftAmmApi = __esm({
|
|
|
17903
18513
|
return tx;
|
|
17904
18514
|
};
|
|
17905
18515
|
this.fetchBuildDepositTx = async (inputs) => {
|
|
17906
|
-
const tx = new
|
|
18516
|
+
const tx = new Transaction11();
|
|
17907
18517
|
tx.setSender(inputs.walletAddress);
|
|
17908
18518
|
const { market } = inputs;
|
|
17909
18519
|
const marketObject = market.market;
|
|
@@ -17930,7 +18540,7 @@ var init_nftAmmApi = __esm({
|
|
|
17930
18540
|
return tx;
|
|
17931
18541
|
};
|
|
17932
18542
|
this.fetchBuildWithdrawTx = async (inputs) => {
|
|
17933
|
-
const tx = new
|
|
18543
|
+
const tx = new Transaction11();
|
|
17934
18544
|
tx.setSender(inputs.walletAddress);
|
|
17935
18545
|
const { market } = inputs;
|
|
17936
18546
|
const marketObject = market.market;
|
|
@@ -19547,9 +20157,9 @@ var init_perpetualsApi = __esm({
|
|
|
19547
20157
|
// src/packages/pools/api/poolsApi.ts
|
|
19548
20158
|
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
19549
20159
|
import {
|
|
19550
|
-
Transaction as
|
|
20160
|
+
Transaction as Transaction12
|
|
19551
20161
|
} from "@mysten/sui/transactions";
|
|
19552
|
-
import { fromBase64, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
20162
|
+
import { fromBase64 as fromBase642, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
19553
20163
|
var _PoolsApi, PoolsApi;
|
|
19554
20164
|
var init_poolsApi = __esm({
|
|
19555
20165
|
"src/packages/pools/api/poolsApi.ts"() {
|
|
@@ -19754,7 +20364,7 @@ var init_poolsApi = __esm({
|
|
|
19754
20364
|
const compiledModulesAndDeps = JSON.parse(compilations[lpCoinDecimals]);
|
|
19755
20365
|
return tx.publish({
|
|
19756
20366
|
modules: compiledModulesAndDeps.modules.map(
|
|
19757
|
-
(m) => Array.from(
|
|
20367
|
+
(m) => Array.from(fromBase642(m))
|
|
19758
20368
|
),
|
|
19759
20369
|
dependencies: compiledModulesAndDeps.dependencies.map(
|
|
19760
20370
|
(addr) => normalizeSuiObjectId(addr)
|
|
@@ -20072,7 +20682,7 @@ var init_poolsApi = __esm({
|
|
|
20072
20682
|
referrer,
|
|
20073
20683
|
isSponsoredTx
|
|
20074
20684
|
} = inputs;
|
|
20075
|
-
const tx = new
|
|
20685
|
+
const tx = new Transaction12();
|
|
20076
20686
|
tx.setSender(walletAddress);
|
|
20077
20687
|
if (referrer) {
|
|
20078
20688
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20168,7 +20778,7 @@ var init_poolsApi = __esm({
|
|
|
20168
20778
|
referrer,
|
|
20169
20779
|
isSponsoredTx
|
|
20170
20780
|
} = inputs;
|
|
20171
|
-
const tx = new
|
|
20781
|
+
const tx = new Transaction12();
|
|
20172
20782
|
tx.setSender(walletAddress);
|
|
20173
20783
|
if (referrer) {
|
|
20174
20784
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20234,7 +20844,7 @@ var init_poolsApi = __esm({
|
|
|
20234
20844
|
slippage,
|
|
20235
20845
|
referrer
|
|
20236
20846
|
} = inputs;
|
|
20237
|
-
const tx = new
|
|
20847
|
+
const tx = new Transaction12();
|
|
20238
20848
|
tx.setSender(walletAddress);
|
|
20239
20849
|
if (referrer) {
|
|
20240
20850
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20279,7 +20889,7 @@ var init_poolsApi = __esm({
|
|
|
20279
20889
|
*/
|
|
20280
20890
|
this.fetchBuildAllCoinWithdrawTx = async (inputs) => {
|
|
20281
20891
|
const { walletAddress, pool, lpCoinAmount, referrer } = inputs;
|
|
20282
|
-
const tx = new
|
|
20892
|
+
const tx = new Transaction12();
|
|
20283
20893
|
tx.setSender(walletAddress);
|
|
20284
20894
|
if (referrer) {
|
|
20285
20895
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20325,7 +20935,7 @@ var init_poolsApi = __esm({
|
|
|
20325
20935
|
*/
|
|
20326
20936
|
this.buildPublishLpCoinTx = (inputs) => {
|
|
20327
20937
|
const { lpCoinDecimals } = inputs;
|
|
20328
|
-
const tx = new
|
|
20938
|
+
const tx = new Transaction12();
|
|
20329
20939
|
tx.setSender(inputs.walletAddress);
|
|
20330
20940
|
const upgradeCap = this.publishLpCoinTx({ tx, lpCoinDecimals });
|
|
20331
20941
|
tx.transferObjects([upgradeCap], inputs.walletAddress);
|
|
@@ -20567,7 +21177,7 @@ var init_poolsApi = __esm({
|
|
|
20567
21177
|
|
|
20568
21178
|
// src/packages/referralVault/api/referralVaultApi.ts
|
|
20569
21179
|
import { bcs as bcs3 } from "@mysten/sui/bcs";
|
|
20570
|
-
import { Transaction as
|
|
21180
|
+
import { Transaction as Transaction13 } from "@mysten/sui/transactions";
|
|
20571
21181
|
var _ReferralVaultApi, ReferralVaultApi;
|
|
20572
21182
|
var init_referralVaultApi = __esm({
|
|
20573
21183
|
"src/packages/referralVault/api/referralVaultApi.ts"() {
|
|
@@ -20668,7 +21278,7 @@ var init_referralVaultApi = __esm({
|
|
|
20668
21278
|
// Inspections
|
|
20669
21279
|
// =========================================================================
|
|
20670
21280
|
this.fetchBalanceOfRebate = async (inputs) => {
|
|
20671
|
-
const tx = new
|
|
21281
|
+
const tx = new Transaction13();
|
|
20672
21282
|
this.balanceOfRebateTx({ ...inputs, tx });
|
|
20673
21283
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
|
|
20674
21284
|
tx
|
|
@@ -20676,7 +21286,7 @@ var init_referralVaultApi = __esm({
|
|
|
20676
21286
|
return Casting.bigIntFromBytes(bytes);
|
|
20677
21287
|
};
|
|
20678
21288
|
this.fetchReferrer = async (inputs) => {
|
|
20679
|
-
const tx = new
|
|
21289
|
+
const tx = new Transaction13();
|
|
20680
21290
|
this.referrerForTx({ ...inputs, tx });
|
|
20681
21291
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
|
|
20682
21292
|
tx
|
|
@@ -20799,7 +21409,7 @@ var init_routerApi = __esm({
|
|
|
20799
21409
|
|
|
20800
21410
|
// src/packages/staking/api/stakingApi.ts
|
|
20801
21411
|
import {
|
|
20802
|
-
Transaction as
|
|
21412
|
+
Transaction as Transaction14
|
|
20803
21413
|
} from "@mysten/sui/transactions";
|
|
20804
21414
|
var _StakingApi, StakingApi;
|
|
20805
21415
|
var init_stakingApi = __esm({
|
|
@@ -21083,7 +21693,7 @@ var init_stakingApi = __esm({
|
|
|
21083
21693
|
if (externalFee) {
|
|
21084
21694
|
_StakingApi.assertValidExternalFee(externalFee);
|
|
21085
21695
|
}
|
|
21086
|
-
const tx = new
|
|
21696
|
+
const tx = new Transaction14();
|
|
21087
21697
|
tx.setSender(inputs.walletAddress);
|
|
21088
21698
|
if (referrer) {
|
|
21089
21699
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -21124,7 +21734,7 @@ var init_stakingApi = __esm({
|
|
|
21124
21734
|
if (externalFee) {
|
|
21125
21735
|
_StakingApi.assertValidExternalFee(externalFee);
|
|
21126
21736
|
}
|
|
21127
|
-
const tx = new
|
|
21737
|
+
const tx = new Transaction14();
|
|
21128
21738
|
tx.setSender(inputs.walletAddress);
|
|
21129
21739
|
if (referrer) {
|
|
21130
21740
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -21172,7 +21782,7 @@ var init_stakingApi = __esm({
|
|
|
21172
21782
|
*/
|
|
21173
21783
|
this.fetchBuildStakeStakedSuiTx = async (inputs) => {
|
|
21174
21784
|
const { referrer } = inputs;
|
|
21175
|
-
const tx = new
|
|
21785
|
+
const tx = new Transaction14();
|
|
21176
21786
|
tx.setSender(inputs.walletAddress);
|
|
21177
21787
|
if (referrer) {
|
|
21178
21788
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -21189,7 +21799,7 @@ var init_stakingApi = __esm({
|
|
|
21189
21799
|
return tx;
|
|
21190
21800
|
};
|
|
21191
21801
|
this.buildUpdateValidatorFeeTx = async (inputs) => {
|
|
21192
|
-
const tx = new
|
|
21802
|
+
const tx = new Transaction14();
|
|
21193
21803
|
tx.setSender(inputs.walletAddress);
|
|
21194
21804
|
this.updateValidatorFeeTx({
|
|
21195
21805
|
...inputs,
|
|
@@ -21434,6 +22044,28 @@ var init_suiApi = __esm({
|
|
|
21434
22044
|
/**
|
|
21435
22045
|
* @deprecated Use `getSystemState()` method instead.
|
|
21436
22046
|
* This method will be removed in a future release.
|
|
22047
|
+
*
|
|
22048
|
+
* @remarks **Remaining JSON-RPC surface** — see
|
|
22049
|
+
* {@link AftermathApi.jsonRpcClient}. gRPC has no `SuiSystemStateSummary`
|
|
22050
|
+
* equivalent. `client.core.getCurrentSystemState()` carries no validators at
|
|
22051
|
+
* all, and while `client.ledgerService.getEpoch({ readMask: { paths:
|
|
22052
|
+
* ["system_state"] } })` does return them (verified: 125 active validators on
|
|
22053
|
+
* mainnet, under the runtime key `validators`, not the generated
|
|
22054
|
+
* `validatorSet`), its validator shape is not a superset of
|
|
22055
|
+
* `SuiValidatorSummary`: keys are renamed (`address`/`p2PAddress`/
|
|
22056
|
+
* `networkAddress`/`protocolPublicKey` vs `suiAddress`/`p2pAddress`/
|
|
22057
|
+
* `netAddress`/`protocolPubkeyBytes`), the staking-pool fields are nested
|
|
22058
|
+
* rather than flattened, numbers are `bigint` rather than decimal strings,
|
|
22059
|
+
* public keys are `Uint8Array` rather than base64, and
|
|
22060
|
+
* `stakingPoolDeactivationEpoch` / `validatorVeryLowStakeThreshold` are
|
|
22061
|
+
* absent entirely. Remapping it would change what this method returns.
|
|
22062
|
+
*
|
|
22063
|
+
* Note `Sui().getSystemState()` — the public method — does not touch the
|
|
22064
|
+
* fullnode; it reads the Aftermath API. Only this deprecated helper does.
|
|
22065
|
+
*
|
|
22066
|
+
* @throws If no `jsonRpcClient` was passed to {@link AftermathApi}, since it
|
|
22067
|
+
* is optional there.
|
|
22068
|
+
*
|
|
21437
22069
|
* @example
|
|
21438
22070
|
* ```typescript
|
|
21439
22071
|
* const afSdk = await Aftermath.create({ network: "MAINNET" });
|
|
@@ -21444,7 +22076,10 @@ var init_suiApi = __esm({
|
|
|
21444
22076
|
* console.log(systemState.epoch, systemState.validators);
|
|
21445
22077
|
*/
|
|
21446
22078
|
this.fetchSystemState = async () => {
|
|
21447
|
-
const
|
|
22079
|
+
const jsonRpcClient = this.api.requireJsonRpcClient(
|
|
22080
|
+
"Sui().fetchSystemState"
|
|
22081
|
+
);
|
|
22082
|
+
const systemState = await jsonRpcClient.getLatestSuiSystemState();
|
|
21448
22083
|
const activeValidators = systemState.activeValidators.map((validator) => ({
|
|
21449
22084
|
...validator,
|
|
21450
22085
|
suiAddress: Helpers.addLeadingZeroesToType(validator.suiAddress)
|
|
@@ -21461,7 +22096,7 @@ var init_suiApi = __esm({
|
|
|
21461
22096
|
|
|
21462
22097
|
// src/packages/suiFrens/api/suiFrensApi.ts
|
|
21463
22098
|
import {
|
|
21464
|
-
Transaction as
|
|
22099
|
+
Transaction as Transaction15
|
|
21465
22100
|
} from "@mysten/sui/transactions";
|
|
21466
22101
|
import { bcs as bcs4 } from "@mysten/sui/bcs";
|
|
21467
22102
|
var _SuiFrensApi, SuiFrensApi;
|
|
@@ -21487,7 +22122,7 @@ var init_suiFrensApi = __esm({
|
|
|
21487
22122
|
// Inspections
|
|
21488
22123
|
// =========================================================================
|
|
21489
22124
|
this.fetchMixingLimitsAndLastEpochMixeds = async (inputs) => {
|
|
21490
|
-
const tx = new
|
|
22125
|
+
const tx = new Transaction15();
|
|
21491
22126
|
this.devInspectMixLimitAndLastEpochMixedMulTx({ ...inputs, tx });
|
|
21492
22127
|
const [mixLimitBytes, lastEpochMixedBytes] = await this.api.Inspections().fetchAllBytesFromTxOutput({
|
|
21493
22128
|
tx
|
|
@@ -21501,7 +22136,7 @@ var init_suiFrensApi = __esm({
|
|
|
21501
22136
|
};
|
|
21502
22137
|
this.fetchMixingLimit = async (inputs) => {
|
|
21503
22138
|
if (inputs.suiFrenType === this.objectTypes.bullshark) return void 0;
|
|
21504
|
-
const tx = new
|
|
22139
|
+
const tx = new Transaction15();
|
|
21505
22140
|
this.mixingLimitTx({ tx, ...inputs });
|
|
21506
22141
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput(
|
|
21507
22142
|
{
|
|
@@ -21513,7 +22148,7 @@ var init_suiFrensApi = __esm({
|
|
|
21513
22148
|
};
|
|
21514
22149
|
this.fetchLastEpochMixed = async (inputs) => {
|
|
21515
22150
|
if (inputs.suiFrenType === this.objectTypes.bullshark) return void 0;
|
|
21516
|
-
const tx = new
|
|
22151
|
+
const tx = new Transaction15();
|
|
21517
22152
|
this.lastEpochMixedTx({ tx, ...inputs });
|
|
21518
22153
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput(
|
|
21519
22154
|
{
|
|
@@ -21525,7 +22160,7 @@ var init_suiFrensApi = __esm({
|
|
|
21525
22160
|
};
|
|
21526
22161
|
this.fetchStakedSuiFrenMetadataIds = async (inputs) => {
|
|
21527
22162
|
const { suiFrenIds } = inputs;
|
|
21528
|
-
const tx = new
|
|
22163
|
+
const tx = new Transaction15();
|
|
21529
22164
|
this.devInspectMetadataObjectIdMulTx({ tx, suiFrenIds });
|
|
21530
22165
|
const idBytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
|
|
21531
22166
|
tx
|
|
@@ -21590,11 +22225,7 @@ var init_suiFrensApi = __esm({
|
|
|
21590
22225
|
const partialSuiFrens = await this.api.Objects().fetchCastObjectBatch({
|
|
21591
22226
|
objectIds: suiFrenIds,
|
|
21592
22227
|
objectFromSuiObjectResponse: Casting.suiFrens.partialSuiFrenObjectFromSuiObjectResponse,
|
|
21593
|
-
|
|
21594
|
-
showDisplay: true,
|
|
21595
|
-
showType: true,
|
|
21596
|
-
showContent: true
|
|
21597
|
-
}
|
|
22228
|
+
withDisplay: true
|
|
21598
22229
|
});
|
|
21599
22230
|
return this.fetchCompletePartialSuiFrenObjects({
|
|
21600
22231
|
partialSuiFrens,
|
|
@@ -21626,11 +22257,7 @@ var init_suiFrensApi = __esm({
|
|
|
21626
22257
|
const stakedSuiFrenData = await this.api.Objects().fetchCastObjectBatch({
|
|
21627
22258
|
objectIds: stakedSuiFrenIds,
|
|
21628
22259
|
objectFromSuiObjectResponse: Casting.suiFrens.partialSuiFrenAndStakedSuiFrenMetadataV1ObjectFromSuiObjectResponse,
|
|
21629
|
-
|
|
21630
|
-
showDisplay: true,
|
|
21631
|
-
showType: true,
|
|
21632
|
-
showContent: true
|
|
21633
|
-
}
|
|
22260
|
+
withDisplay: true
|
|
21634
22261
|
});
|
|
21635
22262
|
const suiFrens = await this.fetchCompletePartialSuiFrenObjects({
|
|
21636
22263
|
partialSuiFrens: stakedSuiFrenData.map((data) => data.partialSuiFren),
|
|
@@ -21675,11 +22302,7 @@ var init_suiFrensApi = __esm({
|
|
|
21675
22302
|
return this.api.Objects().fetchCastObjectBatch({
|
|
21676
22303
|
objectIds,
|
|
21677
22304
|
objectFromSuiObjectResponse: Casting.suiFrens.accessoryObjectFromSuiObjectResponse,
|
|
21678
|
-
|
|
21679
|
-
showDisplay: true,
|
|
21680
|
-
showType: true,
|
|
21681
|
-
showContent: true
|
|
21682
|
-
}
|
|
22305
|
+
withDisplay: true
|
|
21683
22306
|
});
|
|
21684
22307
|
};
|
|
21685
22308
|
// =========================================================================
|
|
@@ -22085,7 +22708,7 @@ var init_suiFrensApi = __esm({
|
|
|
22085
22708
|
baseFee,
|
|
22086
22709
|
isSponsoredTx
|
|
22087
22710
|
} = inputs;
|
|
22088
|
-
const tx = new
|
|
22711
|
+
const tx = new Transaction15();
|
|
22089
22712
|
tx.setSender(walletAddress);
|
|
22090
22713
|
const totalFee = baseFee + SuiFrens.calcTotalInternalMixFee({
|
|
22091
22714
|
mixFee1: suiFrenParentOne.mixFee,
|
|
@@ -22135,7 +22758,7 @@ var init_suiFrensApi = __esm({
|
|
|
22135
22758
|
// =========================================================================
|
|
22136
22759
|
this.fetchBuildHarvestFeesTx = async (inputs) => {
|
|
22137
22760
|
const { stakedPositionIds } = inputs;
|
|
22138
|
-
const tx = new
|
|
22761
|
+
const tx = new Transaction15();
|
|
22139
22762
|
tx.setSender(inputs.walletAddress);
|
|
22140
22763
|
const harvestFeesEventMetadataId = this.beginHarvestTx({ tx });
|
|
22141
22764
|
let harvestedCoins = [];
|
|
@@ -22398,26 +23021,17 @@ var init_nftsApi = __esm({
|
|
|
22398
23021
|
this.fetchOwnedNfts = async (inputs) => {
|
|
22399
23022
|
const objects = await this.api.Objects().fetchOwnedObjects({
|
|
22400
23023
|
...inputs,
|
|
22401
|
-
|
|
22402
|
-
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
showType: true,
|
|
22406
|
-
showDisplay: true
|
|
22407
|
-
}
|
|
23024
|
+
// @dev: `showDisplay` -> `withDisplay`, which becomes
|
|
23025
|
+
// `include: { display: true }`. `nftFromSuiObject` reads display, so
|
|
23026
|
+
// dropping this would leave every NFT with an empty one.
|
|
23027
|
+
withDisplay: true
|
|
22408
23028
|
});
|
|
22409
23029
|
return Casting.nfts.nftsFromSuiObjects(objects);
|
|
22410
23030
|
};
|
|
22411
23031
|
this.fetchNfts = async (inputs) => {
|
|
22412
23032
|
const objects = await this.api.Objects().fetchObjectBatch({
|
|
22413
23033
|
...inputs,
|
|
22414
|
-
|
|
22415
|
-
// NOTE: do we need all of this ?
|
|
22416
|
-
showContent: true,
|
|
22417
|
-
showOwner: true,
|
|
22418
|
-
showType: true,
|
|
22419
|
-
showDisplay: true
|
|
22420
|
-
}
|
|
23034
|
+
withDisplay: true
|
|
22421
23035
|
});
|
|
22422
23036
|
return Casting.nfts.nftsFromSuiObjects(objects);
|
|
22423
23037
|
};
|
|
@@ -22451,7 +23065,7 @@ var init_nftsApi = __esm({
|
|
|
22451
23065
|
const { kioskOwnerCapIds } = inputs;
|
|
22452
23066
|
return this.api.Objects().fetchCastObjectBatch({
|
|
22453
23067
|
objectIds: kioskOwnerCapIds,
|
|
22454
|
-
objectFromSuiObjectResponse: (
|
|
23068
|
+
objectFromSuiObjectResponse: (object) => object.type && Helpers.addLeadingZeroesToType(object.type) === this.objectTypes.personalKioskCap ? Casting.nfts.kioskOwnerCapFromPersonalKioskCapSuiObject(object) : Casting.nfts.kioskOwnerCapFromSuiObject(object)
|
|
22455
23069
|
});
|
|
22456
23070
|
};
|
|
22457
23071
|
this.fetchKiosks = async (inputs) => {
|
|
@@ -22524,25 +23138,35 @@ var init_walletApi = __esm({
|
|
|
22524
23138
|
// =========================================================================
|
|
22525
23139
|
this.fetchCoinBalance = async (inputs) => {
|
|
22526
23140
|
const { walletAddress, coin } = inputs;
|
|
22527
|
-
const
|
|
23141
|
+
const { balance } = await this.api.client.getBalance({
|
|
22528
23142
|
owner: walletAddress,
|
|
22529
23143
|
coinType: Helpers.stripLeadingZeroesFromType(coin)
|
|
22530
23144
|
});
|
|
22531
|
-
return BigInt(
|
|
23145
|
+
return BigInt(balance.balance);
|
|
22532
23146
|
};
|
|
22533
23147
|
// TODO: make toBigIntSafe function ?
|
|
22534
23148
|
// TODO: return prices here as well and sort ?
|
|
22535
23149
|
this.fetchAllCoinBalances = async (inputs) => {
|
|
22536
23150
|
const { walletAddress } = inputs;
|
|
22537
|
-
const allBalances =
|
|
22538
|
-
|
|
22539
|
-
|
|
23151
|
+
const allBalances = [];
|
|
23152
|
+
let cursor;
|
|
23153
|
+
do {
|
|
23154
|
+
const page = await this.api.client.listBalances({
|
|
23155
|
+
owner: walletAddress,
|
|
23156
|
+
cursor
|
|
23157
|
+
});
|
|
23158
|
+
allBalances.push(...page.balances);
|
|
23159
|
+
if (page.balances.length === 0 || !page.hasNextPage || !page.cursor) {
|
|
23160
|
+
break;
|
|
23161
|
+
}
|
|
23162
|
+
cursor = page.cursor;
|
|
23163
|
+
} while (true);
|
|
22540
23164
|
const coinsToBalance = allBalances.reduce(
|
|
22541
23165
|
(acc, balance) => {
|
|
22542
23166
|
return {
|
|
22543
23167
|
...acc,
|
|
22544
23168
|
[Helpers.addLeadingZeroesToType(balance.coinType)]: BigInt(
|
|
22545
|
-
balance.
|
|
23169
|
+
balance.balance
|
|
22546
23170
|
)
|
|
22547
23171
|
};
|
|
22548
23172
|
},
|
|
@@ -22608,12 +23232,44 @@ var init_aftermathApi = __esm({
|
|
|
22608
23232
|
* Constructs a new instance of the `AftermathApi`, binding the given Sui client
|
|
22609
23233
|
* to the known `addresses`.
|
|
22610
23234
|
*
|
|
22611
|
-
* @param client - A `
|
|
23235
|
+
* @param client - A `SuiGrpcClient` for on-chain queries and transactions.
|
|
22612
23236
|
* @param addresses - The config addresses (object IDs, package IDs, etc.) for the Aftermath protocol.
|
|
22613
|
-
|
|
22614
|
-
|
|
23237
|
+
* @param jsonRpcClient - **Optional.** A `SuiJsonRpcClient` pointed at the same
|
|
23238
|
+
* fullnode. Only used by the three legacy helpers listed on
|
|
23239
|
+
* {@link AftermathApi.jsonRpcClient}; every other call goes over gRPC via
|
|
23240
|
+
* `client`. Omit it unless you call one of those three — they then throw a
|
|
23241
|
+
* descriptive error instead of failing against a deprecated protocol. See
|
|
23242
|
+
* {@link AftermathApi.requireJsonRpcClient}.
|
|
23243
|
+
*/
|
|
23244
|
+
constructor(client, addresses, jsonRpcClient) {
|
|
22615
23245
|
this.client = client;
|
|
22616
23246
|
this.addresses = addresses;
|
|
23247
|
+
this.jsonRpcClient = jsonRpcClient;
|
|
23248
|
+
// =========================================================================
|
|
23249
|
+
// Legacy JSON-RPC Access
|
|
23250
|
+
// =========================================================================
|
|
23251
|
+
/**
|
|
23252
|
+
* Returns the optional {@link AftermathApi.jsonRpcClient}, throwing a
|
|
23253
|
+
* descriptive error when it was not supplied.
|
|
23254
|
+
*
|
|
23255
|
+
* Used by the three helpers that have no `SuiGrpcClient` equivalent. The
|
|
23256
|
+
* throw is deliberate: these helpers cannot degrade to an empty result
|
|
23257
|
+
* without silently lying to their callers, and JSON-RPC is scheduled for
|
|
23258
|
+
* removal from Sui fullnodes in mid-October 2026, so a missing client is a
|
|
23259
|
+
* configuration error worth naming rather than hiding.
|
|
23260
|
+
*
|
|
23261
|
+
* @param methodName - The public helper the caller invoked, e.g.
|
|
23262
|
+
* `"Events().fetchCastEventsWithCursor"`. Named in the error message.
|
|
23263
|
+
* @throws If no `jsonRpcClient` was passed to the constructor.
|
|
23264
|
+
*/
|
|
23265
|
+
this.requireJsonRpcClient = (methodName) => {
|
|
23266
|
+
if (!this.jsonRpcClient) {
|
|
23267
|
+
throw new Error(
|
|
23268
|
+
`${methodName} requires a \`SuiJsonRpcClient\`, which was not provided to \`AftermathApi\`. It is one of three helpers with no \`SuiGrpcClient\` equivalent (alongside \`Transactions().fetchTransactionsWithCursor\` and the deprecated \`Sui().fetchSystemState\`); every other call in this SDK goes over gRPC. Either pass a \`SuiJsonRpcClient\` as \`AftermathApi\`'s third constructor argument, or use the Aftermath API's own endpoints \u2014 note that Sui JSON-RPC is deprecated and scheduled for removal from fullnodes in mid-October 2026.`
|
|
23269
|
+
);
|
|
23270
|
+
}
|
|
23271
|
+
return this.jsonRpcClient;
|
|
23272
|
+
};
|
|
22617
23273
|
// =========================================================================
|
|
22618
23274
|
// Class Object Creation
|
|
22619
23275
|
// =========================================================================
|
|
@@ -22789,6 +23445,7 @@ var init_aftermathApi = __esm({
|
|
|
22789
23445
|
});
|
|
22790
23446
|
|
|
22791
23447
|
// src/general/providers/aftermath.ts
|
|
23448
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
22792
23449
|
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
22793
23450
|
var _Aftermath, Aftermath;
|
|
22794
23451
|
var init_aftermath = __esm({
|
|
@@ -22912,11 +23569,15 @@ var init_aftermath = __esm({
|
|
|
22912
23569
|
const network = this.network;
|
|
22913
23570
|
const addresses = this.options.addresses ?? await this.getAddresses();
|
|
22914
23571
|
const fullnodeUrl = this.options.fullnodeUrl ?? Caller.defaultFullnodeUrl(network);
|
|
22915
|
-
const client = new
|
|
23572
|
+
const client = new SuiGrpcClient({
|
|
23573
|
+
network: network.toLowerCase(),
|
|
23574
|
+
baseUrl: fullnodeUrl
|
|
23575
|
+
});
|
|
23576
|
+
const jsonRpcClient = new SuiJsonRpcClient({
|
|
22916
23577
|
url: fullnodeUrl,
|
|
22917
23578
|
network: network.toLowerCase()
|
|
22918
23579
|
});
|
|
22919
|
-
this.api = new AftermathApi(client, addresses);
|
|
23580
|
+
this.api = new AftermathApi(client, addresses, jsonRpcClient);
|
|
22920
23581
|
}
|
|
22921
23582
|
// =========================================================================
|
|
22922
23583
|
// Public Accessors
|
|
@@ -22994,6 +23655,7 @@ export {
|
|
|
22994
23655
|
FarmsStakingPool,
|
|
22995
23656
|
Faucet,
|
|
22996
23657
|
GasPools,
|
|
23658
|
+
GrpcCasting,
|
|
22997
23659
|
Helpers,
|
|
22998
23660
|
NftAmm,
|
|
22999
23661
|
Perpetuals,
|
|
@@ -23001,6 +23663,7 @@ export {
|
|
|
23001
23663
|
PerpetualsMarket,
|
|
23002
23664
|
PerpetualsOrderSide,
|
|
23003
23665
|
PerpetualsOrderType,
|
|
23666
|
+
PerpetualsStopOrderTriggerPriceType,
|
|
23004
23667
|
PerpetualsStopOrderType,
|
|
23005
23668
|
PerpetualsVault,
|
|
23006
23669
|
Pool,
|