aftermath-ts-sdk 2.1.0 → 2.2.0-abort.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -6
- package/dist/index.d.ts +4584 -3567
- package/dist/index.js +1406 -538
- 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.
|
|
1302
|
+
*
|
|
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.
|
|
964
1311
|
*
|
|
965
|
-
* @param data - The Sui object
|
|
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
|
|
@@ -1521,8 +1868,150 @@ var init_helpers = __esm({
|
|
|
1521
1868
|
}
|
|
1522
1869
|
});
|
|
1523
1870
|
|
|
1871
|
+
// src/general/utils/transportError.ts
|
|
1872
|
+
function defaultMessage(kind, status) {
|
|
1873
|
+
if (kind === "http") {
|
|
1874
|
+
return status === void 0 ? "Aftermath HTTP request failed" : `Aftermath HTTP request failed with status ${status}`;
|
|
1875
|
+
}
|
|
1876
|
+
if (kind === "network") {
|
|
1877
|
+
return "Aftermath network request failed";
|
|
1878
|
+
}
|
|
1879
|
+
if (kind === "abort") {
|
|
1880
|
+
return "Aftermath request was aborted";
|
|
1881
|
+
}
|
|
1882
|
+
if (kind === "timeout") {
|
|
1883
|
+
return "Aftermath request timed out";
|
|
1884
|
+
}
|
|
1885
|
+
return "Aftermath response could not be decoded";
|
|
1886
|
+
}
|
|
1887
|
+
function isAftermathTransportError(error) {
|
|
1888
|
+
return error instanceof AftermathTransportError;
|
|
1889
|
+
}
|
|
1890
|
+
function getProperty(value, property) {
|
|
1891
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
1892
|
+
return void 0;
|
|
1893
|
+
}
|
|
1894
|
+
try {
|
|
1895
|
+
return value[property];
|
|
1896
|
+
} catch {
|
|
1897
|
+
return void 0;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
function getStringProperty(value, property) {
|
|
1901
|
+
const propertyValue = getProperty(value, property);
|
|
1902
|
+
return typeof propertyValue === "string" ? propertyValue : void 0;
|
|
1903
|
+
}
|
|
1904
|
+
function getStringCode(value) {
|
|
1905
|
+
return getStringProperty(value, "code");
|
|
1906
|
+
}
|
|
1907
|
+
function isTimeoutCode(code) {
|
|
1908
|
+
return code !== void 0 && TIMEOUT_CODES.has(code);
|
|
1909
|
+
}
|
|
1910
|
+
function isTimeoutReason(reason) {
|
|
1911
|
+
if (isAftermathTransportError(reason) && (reason.kind === "timeout" || reason.abortSource === "timeout")) {
|
|
1912
|
+
return true;
|
|
1913
|
+
}
|
|
1914
|
+
return getProperty(reason, "name") === "TimeoutError" || isTimeoutCode(getStringCode(reason));
|
|
1915
|
+
}
|
|
1916
|
+
function parseRetryAfter(headerValue, nowMs = Date.now()) {
|
|
1917
|
+
if (headerValue === null) {
|
|
1918
|
+
return void 0;
|
|
1919
|
+
}
|
|
1920
|
+
const value = headerValue.trim();
|
|
1921
|
+
if (value === "") {
|
|
1922
|
+
return void 0;
|
|
1923
|
+
}
|
|
1924
|
+
if (DELTA_SECONDS_REGEX.test(value)) {
|
|
1925
|
+
const milliseconds = BigInt(value) * 1000n;
|
|
1926
|
+
return milliseconds <= MAX_SAFE_INTEGER_BIGINT ? Number(milliseconds) : void 0;
|
|
1927
|
+
}
|
|
1928
|
+
if (!HTTP_DATE_REGEX.test(value)) {
|
|
1929
|
+
return void 0;
|
|
1930
|
+
}
|
|
1931
|
+
const dateMs = Date.parse(value);
|
|
1932
|
+
if (!Number.isFinite(dateMs)) {
|
|
1933
|
+
return void 0;
|
|
1934
|
+
}
|
|
1935
|
+
const retryAfterMs = dateMs - nowMs;
|
|
1936
|
+
return retryAfterMs >= 0 && Number.isSafeInteger(retryAfterMs) ? retryAfterMs : void 0;
|
|
1937
|
+
}
|
|
1938
|
+
function normalizeAftermathTransportError(error, signal) {
|
|
1939
|
+
if (isAftermathTransportError(error)) {
|
|
1940
|
+
return error;
|
|
1941
|
+
}
|
|
1942
|
+
const errorCode = getStringCode(error);
|
|
1943
|
+
const signalReason = signal?.aborted ? signal.reason : void 0;
|
|
1944
|
+
const signalReasonCode = getStringCode(signalReason);
|
|
1945
|
+
const code = errorCode ?? signalReasonCode;
|
|
1946
|
+
if (signal?.aborted) {
|
|
1947
|
+
const timeout = isTimeoutReason(signalReason) || isTimeoutReason(error);
|
|
1948
|
+
return new AftermathTransportError(timeout ? "timeout" : "abort", {
|
|
1949
|
+
abortSource: timeout ? "timeout" : "caller",
|
|
1950
|
+
cause: error,
|
|
1951
|
+
code
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
if (isTimeoutReason(error)) {
|
|
1955
|
+
return new AftermathTransportError("timeout", {
|
|
1956
|
+
abortSource: "timeout",
|
|
1957
|
+
cause: error,
|
|
1958
|
+
code: errorCode
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1961
|
+
return new AftermathTransportError("network", {
|
|
1962
|
+
cause: error,
|
|
1963
|
+
code: errorCode
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
var MAX_SAFE_INTEGER_BIGINT, DELTA_SECONDS_REGEX, HTTP_DATE_REGEX, TIMEOUT_CODES, AftermathTransportError;
|
|
1967
|
+
var init_transportError = __esm({
|
|
1968
|
+
"src/general/utils/transportError.ts"() {
|
|
1969
|
+
"use strict";
|
|
1970
|
+
MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
1971
|
+
DELTA_SECONDS_REGEX = /^\d+$/;
|
|
1972
|
+
HTTP_DATE_REGEX = /^(?:[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT|[A-Za-z]+, \d{2}-[A-Za-z]{3}-\d{2} \d{2}:\d{2}:\d{2} GMT|[A-Za-z]{3} [A-Za-z]{3} {1,2}\d{1,2} \d{2}:\d{2}:\d{2} \d{4})$/;
|
|
1973
|
+
TIMEOUT_CODES = /* @__PURE__ */ new Set([
|
|
1974
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
1975
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
1976
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
1977
|
+
"ETIMEDOUT"
|
|
1978
|
+
]);
|
|
1979
|
+
AftermathTransportError = class extends Error {
|
|
1980
|
+
constructor(kind, options = {}) {
|
|
1981
|
+
const causeMessage = getStringProperty(options.cause, "message");
|
|
1982
|
+
super(
|
|
1983
|
+
options.message ?? causeMessage ?? defaultMessage(kind, options.status)
|
|
1984
|
+
);
|
|
1985
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1986
|
+
this.name = options.name ?? getStringProperty(options.cause, "name") ?? "AftermathTransportError";
|
|
1987
|
+
this.kind = kind;
|
|
1988
|
+
if (options.status !== void 0) {
|
|
1989
|
+
this.status = options.status;
|
|
1990
|
+
}
|
|
1991
|
+
if (options.retryAfterMs !== void 0) {
|
|
1992
|
+
this.retryAfterMs = options.retryAfterMs;
|
|
1993
|
+
}
|
|
1994
|
+
if (options.code !== void 0) {
|
|
1995
|
+
this.code = options.code;
|
|
1996
|
+
}
|
|
1997
|
+
if (options.abortSource !== void 0) {
|
|
1998
|
+
this.abortSource = options.abortSource;
|
|
1999
|
+
}
|
|
2000
|
+
if (options.cause !== void 0) {
|
|
2001
|
+
Object.defineProperty(this, "cause", {
|
|
2002
|
+
configurable: true,
|
|
2003
|
+
enumerable: false,
|
|
2004
|
+
value: options.cause,
|
|
2005
|
+
writable: false
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
});
|
|
2012
|
+
|
|
1524
2013
|
// src/general/utils/caller.ts
|
|
1525
|
-
import { Transaction as
|
|
2014
|
+
import { Transaction as Transaction3 } from "@mysten/sui/transactions";
|
|
1526
2015
|
function bigIntReplacer(_key, value) {
|
|
1527
2016
|
if (typeof value === "bigint") {
|
|
1528
2017
|
return `${value.toString()}n`;
|
|
@@ -1534,6 +2023,7 @@ var init_caller = __esm({
|
|
|
1534
2023
|
"src/general/utils/caller.ts"() {
|
|
1535
2024
|
"use strict";
|
|
1536
2025
|
init_helpers();
|
|
2026
|
+
init_transportError();
|
|
1537
2027
|
_Caller = class _Caller {
|
|
1538
2028
|
// =========================================================================
|
|
1539
2029
|
// Constructor
|
|
@@ -1544,7 +2034,8 @@ var init_caller = __esm({
|
|
|
1544
2034
|
throw new Error("no apiBaseUrl: unable to fetch data");
|
|
1545
2035
|
}
|
|
1546
2036
|
const safeUrl = this.apiBaseUrl.slice(-1) === "/" ? this.apiBaseUrl.slice(0, -1) : this.apiBaseUrl;
|
|
1547
|
-
|
|
2037
|
+
const endpointSegment = this.apiEndpoint ? `${this.apiEndpoint}/` : "";
|
|
2038
|
+
return `${safeUrl}/${endpointSegment}${this.apiUrlPrefix + (url === "" ? "" : "/")}${url}`;
|
|
1548
2039
|
};
|
|
1549
2040
|
this.setAccessToken = (accessToken) => {
|
|
1550
2041
|
this.config.accessToken = accessToken;
|
|
@@ -1560,11 +2051,26 @@ var init_caller = __esm({
|
|
|
1560
2051
|
static async fetchResponseToType(response, disableBigIntJsonParsing) {
|
|
1561
2052
|
if (!response.ok) {
|
|
1562
2053
|
const status = response.status;
|
|
2054
|
+
const retryAfterMs = parseRetryAfter(response.headers.get("Retry-After"));
|
|
2055
|
+
const statusText = response.statusText;
|
|
1563
2056
|
const body = await response.text();
|
|
1564
|
-
throw new
|
|
2057
|
+
throw new AftermathTransportError("http", {
|
|
2058
|
+
message: `HTTP ${status} ${statusText}: ${body}`,
|
|
2059
|
+
name: "Error",
|
|
2060
|
+
retryAfterMs,
|
|
2061
|
+
status
|
|
2062
|
+
});
|
|
1565
2063
|
}
|
|
1566
2064
|
const text = await response.text();
|
|
1567
|
-
|
|
2065
|
+
let output;
|
|
2066
|
+
try {
|
|
2067
|
+
output = disableBigIntJsonParsing ? JSON.parse(
|
|
2068
|
+
text,
|
|
2069
|
+
(_key, value) => value === null ? void 0 : value
|
|
2070
|
+
) : Helpers.parseJsonWithBigint(text);
|
|
2071
|
+
} catch (cause) {
|
|
2072
|
+
throw new AftermathTransportError("decode", { cause });
|
|
2073
|
+
}
|
|
1568
2074
|
return output ?? void 0;
|
|
1569
2075
|
}
|
|
1570
2076
|
/**
|
|
@@ -1589,21 +2095,25 @@ var init_caller = __esm({
|
|
|
1589
2095
|
// Api Calling
|
|
1590
2096
|
// =========================================================================
|
|
1591
2097
|
async fetchApi(url, body, signal, options) {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
2098
|
+
try {
|
|
2099
|
+
const apiCallUrl = this.urlForApiCall(url);
|
|
2100
|
+
const headers = {
|
|
2101
|
+
"Content-Type": "application/json",
|
|
2102
|
+
...this.config.accessToken ? { Authorization: `Bearer ${this.config.accessToken}` } : {}
|
|
2103
|
+
};
|
|
2104
|
+
const uncastResponse = await (body === void 0 ? fetch(apiCallUrl, { headers, signal }) : fetch(apiCallUrl, {
|
|
2105
|
+
method: "POST",
|
|
2106
|
+
body: JSON.stringify(body, bigIntReplacer),
|
|
2107
|
+
headers,
|
|
2108
|
+
signal
|
|
2109
|
+
}));
|
|
2110
|
+
return await _Caller.fetchResponseToType(
|
|
2111
|
+
uncastResponse,
|
|
2112
|
+
!!options?.disableBigIntJsonParsing
|
|
2113
|
+
);
|
|
2114
|
+
} catch (error) {
|
|
2115
|
+
throw normalizeAftermathTransportError(error, signal);
|
|
2116
|
+
}
|
|
1607
2117
|
}
|
|
1608
2118
|
async fetchApiTransaction(url, body, signal, options) {
|
|
1609
2119
|
const txKind = await this.fetchApi(
|
|
@@ -1612,7 +2122,7 @@ var init_caller = __esm({
|
|
|
1612
2122
|
signal,
|
|
1613
2123
|
options
|
|
1614
2124
|
);
|
|
1615
|
-
const tx = options?.txKind ?
|
|
2125
|
+
const tx = options?.txKind ? Transaction3.fromKind(txKind) : Transaction3.from(txKind);
|
|
1616
2126
|
if (body?.walletAddress) {
|
|
1617
2127
|
tx.setSender(body.walletAddress);
|
|
1618
2128
|
}
|
|
@@ -1625,7 +2135,7 @@ var init_caller = __esm({
|
|
|
1625
2135
|
signal,
|
|
1626
2136
|
options
|
|
1627
2137
|
);
|
|
1628
|
-
const tx = response.sponsorSignature ?
|
|
2138
|
+
const tx = response.sponsorSignature ? Transaction3.from(response.txKind) : Transaction3.fromKind(response.txKind);
|
|
1629
2139
|
const { txKind, ...rest } = response;
|
|
1630
2140
|
return { ...rest, tx };
|
|
1631
2141
|
}
|
|
@@ -1665,7 +2175,8 @@ var init_caller = __esm({
|
|
|
1665
2175
|
""
|
|
1666
2176
|
);
|
|
1667
2177
|
const baseWs = baseHttp.replace(_Caller.HTTP_PROTOCOL_REGEX, "ws$1://");
|
|
1668
|
-
const
|
|
2178
|
+
const endpointSegment = this.apiEndpoint ? `${this.apiEndpoint}/` : "";
|
|
2179
|
+
const prefix = `${endpointSegment}${this.apiUrlPrefix}`;
|
|
1669
2180
|
const normalizedPrefix = prefix.replace(
|
|
1670
2181
|
_Caller.TRAILING_SLASHES_REGEX,
|
|
1671
2182
|
""
|
|
@@ -1768,10 +2279,13 @@ var init_prices = __esm({
|
|
|
1768
2279
|
* console.log(suiPriceInfo.price, suiPriceInfo.priceChange24HoursPercentage);
|
|
1769
2280
|
* ```
|
|
1770
2281
|
*/
|
|
1771
|
-
async getCoinPriceInfo(inputs) {
|
|
1772
|
-
const coinsToPriceInfo = await this.getCoinsToPriceInfo(
|
|
1773
|
-
|
|
1774
|
-
|
|
2282
|
+
async getCoinPriceInfo(inputs, abortSignal) {
|
|
2283
|
+
const coinsToPriceInfo = await this.getCoinsToPriceInfo(
|
|
2284
|
+
{
|
|
2285
|
+
coins: [inputs.coin]
|
|
2286
|
+
},
|
|
2287
|
+
abortSignal
|
|
2288
|
+
);
|
|
1775
2289
|
return Object.values(coinsToPriceInfo)[0];
|
|
1776
2290
|
}
|
|
1777
2291
|
/**
|
|
@@ -1790,8 +2304,8 @@ var init_prices = __esm({
|
|
|
1790
2304
|
* console.log(info);
|
|
1791
2305
|
* ```
|
|
1792
2306
|
*/
|
|
1793
|
-
async getCoinsToPriceInfo(inputs) {
|
|
1794
|
-
return this.fetchApi("", inputs);
|
|
2307
|
+
async getCoinsToPriceInfo(inputs, abortSignal) {
|
|
2308
|
+
return this.fetchApi("", inputs, abortSignal);
|
|
1795
2309
|
}
|
|
1796
2310
|
/**
|
|
1797
2311
|
* Fetches only the current price in USD for a single coin.
|
|
@@ -1806,8 +2320,8 @@ var init_prices = __esm({
|
|
|
1806
2320
|
* console.log("SUI price in USD:", suiPrice);
|
|
1807
2321
|
* ```
|
|
1808
2322
|
*/
|
|
1809
|
-
async getCoinPrice(inputs) {
|
|
1810
|
-
const priceInfo = await this.getCoinPriceInfo(inputs);
|
|
2323
|
+
async getCoinPrice(inputs, abortSignal) {
|
|
2324
|
+
const priceInfo = await this.getCoinPriceInfo(inputs, abortSignal);
|
|
1811
2325
|
return priceInfo.price;
|
|
1812
2326
|
}
|
|
1813
2327
|
/**
|
|
@@ -1823,8 +2337,11 @@ var init_prices = __esm({
|
|
|
1823
2337
|
* console.log(multiPrices["0x2::sui::SUI"]); // e.g. 1.23
|
|
1824
2338
|
* ```
|
|
1825
2339
|
*/
|
|
1826
|
-
async getCoinsToPrice(inputs) {
|
|
1827
|
-
const coinsToPriceInfo = await this.getCoinsToPriceInfo(
|
|
2340
|
+
async getCoinsToPrice(inputs, abortSignal) {
|
|
2341
|
+
const coinsToPriceInfo = await this.getCoinsToPriceInfo(
|
|
2342
|
+
inputs,
|
|
2343
|
+
abortSignal
|
|
2344
|
+
);
|
|
1828
2345
|
const coinsToPrice = Object.entries(coinsToPriceInfo).reduce(
|
|
1829
2346
|
(acc, [coinType, info]) => ({
|
|
1830
2347
|
...acc,
|
|
@@ -1885,9 +2402,9 @@ var init_coin = __esm({
|
|
|
1885
2402
|
* console.log(decimals); // { "0x2::sui::SUI": 9, "0x<...>": 6 }
|
|
1886
2403
|
* ```
|
|
1887
2404
|
*/
|
|
1888
|
-
async getCoinsToDecimals(inputs) {
|
|
2405
|
+
async getCoinsToDecimals(inputs, abortSignal) {
|
|
1889
2406
|
const { coins } = inputs;
|
|
1890
|
-
const metadatas = await this.getCoinMetadatas(inputs);
|
|
2407
|
+
const metadatas = await this.getCoinMetadatas(inputs, abortSignal);
|
|
1891
2408
|
const coinsToDecimals = metadatas.map((data) => data.decimals).reduce((acc, decimals, index) => {
|
|
1892
2409
|
return { ...acc, [coins[index]]: decimals };
|
|
1893
2410
|
}, {});
|
|
@@ -1907,7 +2424,7 @@ var init_coin = __esm({
|
|
|
1907
2424
|
* console.log(metadata.name, metadata.symbol, metadata.decimals);
|
|
1908
2425
|
* ```
|
|
1909
2426
|
*/
|
|
1910
|
-
async getCoinMetadata(coin) {
|
|
2427
|
+
async getCoinMetadata(coin, abortSignal) {
|
|
1911
2428
|
if (this.metadata) {
|
|
1912
2429
|
return this.metadata;
|
|
1913
2430
|
}
|
|
@@ -1915,7 +2432,10 @@ var init_coin = __esm({
|
|
|
1915
2432
|
if (!coinType) {
|
|
1916
2433
|
throw new Error("no valid coin type");
|
|
1917
2434
|
}
|
|
1918
|
-
const [metadata] = await this.getCoinMetadatas(
|
|
2435
|
+
const [metadata] = await this.getCoinMetadatas(
|
|
2436
|
+
{ coins: [coinType] },
|
|
2437
|
+
abortSignal
|
|
2438
|
+
);
|
|
1919
2439
|
this.setCoinMetadata(metadata);
|
|
1920
2440
|
return metadata;
|
|
1921
2441
|
}
|
|
@@ -1934,12 +2454,13 @@ var init_coin = __esm({
|
|
|
1934
2454
|
* console.log(metas[0].symbol, metas[1].symbol);
|
|
1935
2455
|
* ```
|
|
1936
2456
|
*/
|
|
1937
|
-
async getCoinMetadatas(inputs) {
|
|
2457
|
+
async getCoinMetadatas(inputs, abortSignal) {
|
|
1938
2458
|
return this.fetchApi(
|
|
1939
2459
|
"metadata",
|
|
1940
2460
|
{
|
|
1941
2461
|
coins: inputs.coins.map((coin) => Helpers.addLeadingZeroesToType(coin))
|
|
1942
|
-
}
|
|
2462
|
+
},
|
|
2463
|
+
abortSignal
|
|
1943
2464
|
);
|
|
1944
2465
|
}
|
|
1945
2466
|
/**
|
|
@@ -1964,7 +2485,7 @@ var init_coin = __esm({
|
|
|
1964
2485
|
* console.log(priceInfo.price, priceInfo.priceChange24HoursPercentage);
|
|
1965
2486
|
* ```
|
|
1966
2487
|
*/
|
|
1967
|
-
async getPrice(coin) {
|
|
2488
|
+
async getPrice(coin, abortSignal) {
|
|
1968
2489
|
if (this.priceInfo !== void 0) {
|
|
1969
2490
|
return this.priceInfo;
|
|
1970
2491
|
}
|
|
@@ -1972,9 +2493,12 @@ var init_coin = __esm({
|
|
|
1972
2493
|
if (!coinType) {
|
|
1973
2494
|
throw new Error("no valid coin type");
|
|
1974
2495
|
}
|
|
1975
|
-
const priceInfo = await new Prices(this.config).getCoinPriceInfo(
|
|
1976
|
-
|
|
1977
|
-
|
|
2496
|
+
const priceInfo = await new Prices(this.config).getCoinPriceInfo(
|
|
2497
|
+
{
|
|
2498
|
+
coin: coinType
|
|
2499
|
+
},
|
|
2500
|
+
abortSignal
|
|
2501
|
+
);
|
|
1978
2502
|
this.setPriceInfo(priceInfo);
|
|
1979
2503
|
return priceInfo;
|
|
1980
2504
|
}
|
|
@@ -2362,10 +2886,11 @@ var init_farmsApiCasting = __esm({
|
|
|
2362
2886
|
const fields = Helpers.getObjectFields(
|
|
2363
2887
|
data
|
|
2364
2888
|
);
|
|
2889
|
+
const cap = GrpcCasting.unwrapStructField(fields.cap);
|
|
2365
2890
|
return {
|
|
2366
2891
|
objectType,
|
|
2367
2892
|
objectId: Helpers.getObjectId(data),
|
|
2368
|
-
stakingPoolId:
|
|
2893
|
+
stakingPoolId: cap.for
|
|
2369
2894
|
};
|
|
2370
2895
|
};
|
|
2371
2896
|
// =========================================================================
|
|
@@ -2774,8 +3299,9 @@ var init_poolsApiCasting = __esm({
|
|
|
2774
3299
|
suiObject
|
|
2775
3300
|
);
|
|
2776
3301
|
const lpCoinType = Helpers.addLeadingZeroesToType(
|
|
2777
|
-
Coin.getInnerCoinType(
|
|
3302
|
+
Coin.getInnerCoinType(objectType)
|
|
2778
3303
|
);
|
|
3304
|
+
const coinDecimals = poolFieldsOnChain.coin_decimals === void 0 ? void 0 : GrpcCasting.bytesFieldToNumbers(poolFieldsOnChain.coin_decimals);
|
|
2779
3305
|
const coins = poolFieldsOnChain.type_names.reduce(
|
|
2780
3306
|
(acc, cur, index) => ({
|
|
2781
3307
|
...acc,
|
|
@@ -2790,9 +3316,7 @@ var init_poolsApiCasting = __esm({
|
|
|
2790
3316
|
poolFieldsOnChain.normalized_balances[index]
|
|
2791
3317
|
),
|
|
2792
3318
|
decimalsScalar: BigInt(poolFieldsOnChain.decimal_scalars[index]),
|
|
2793
|
-
...
|
|
2794
|
-
decimals: Number(poolFieldsOnChain.coin_decimals[index])
|
|
2795
|
-
} : {}
|
|
3319
|
+
...coinDecimals ? { decimals: coinDecimals[index] } : {}
|
|
2796
3320
|
}
|
|
2797
3321
|
}),
|
|
2798
3322
|
{}
|
|
@@ -2803,7 +3327,9 @@ var init_poolsApiCasting = __esm({
|
|
|
2803
3327
|
lpCoinType,
|
|
2804
3328
|
name: poolFieldsOnChain.name,
|
|
2805
3329
|
creator: poolFieldsOnChain.creator,
|
|
2806
|
-
lpCoinSupply: BigInt(
|
|
3330
|
+
lpCoinSupply: BigInt(
|
|
3331
|
+
GrpcCasting.unwrapStructField(poolFieldsOnChain.lp_supply).value
|
|
3332
|
+
),
|
|
2807
3333
|
illiquidLpCoinSupply: BigInt(poolFieldsOnChain.illiquid_lp_supply),
|
|
2808
3334
|
flatness: BigInt(poolFieldsOnChain.flatness),
|
|
2809
3335
|
lpCoinDecimals: Number(poolFieldsOnChain.lp_decimals),
|
|
@@ -2895,6 +3421,34 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2895
3421
|
// =========================================================================
|
|
2896
3422
|
// Objects
|
|
2897
3423
|
// =========================================================================
|
|
3424
|
+
/**
|
|
3425
|
+
* @remarks ⚠️ **Two of this caster's reads need a *nested* Move struct's own
|
|
3426
|
+
* `type`, which neither protocol supplies — so it throws, exactly as it did
|
|
3427
|
+
* before the gRPC port.** It is kept source-compatible (same signature, same
|
|
3428
|
+
* `NftAmmMarketObject` shape) rather than deleted, and the blocked reads are
|
|
3429
|
+
* marked inline.
|
|
3430
|
+
*
|
|
3431
|
+
* - `fields.pool` is a nested `Pool<L>` handed to
|
|
3432
|
+
* {@link PoolsApiCasting.poolObjectFromSuiObject}, which needs the pool's
|
|
3433
|
+
* Move type for `objectType` and `lpCoinType`.
|
|
3434
|
+
* - `fields.supply` is a nested `Supply<F>` whose `type` gave
|
|
3435
|
+
* `fractionalizedCoinType`.
|
|
3436
|
+
*
|
|
3437
|
+
* Under JSON-RPC a nested struct arrived as `{ type, fields }`, which is not
|
|
3438
|
+
* a `SuiObjectResponse`, so the pre-port code already threw
|
|
3439
|
+
* `no object id found on undefined` at its first nested read (verified
|
|
3440
|
+
* against the source at `d4706127`). Under gRPC nested structs lose `type`
|
|
3441
|
+
* outright, so the `lp_supply` recovery that fixed the *top-level* pool
|
|
3442
|
+
* caster does not apply: the market's own type parameters do not name the
|
|
3443
|
+
* pool's package. Recovering it needs the Move type layouts this SDK does not
|
|
3444
|
+
* carry, and guessing a generic's position would produce a silently wrong
|
|
3445
|
+
* `lpCoinType`, so the failure is left to surface.
|
|
3446
|
+
*
|
|
3447
|
+
* NftAmm is also **not deployed on mainnet** — `getAddresses()` returns empty
|
|
3448
|
+
* strings for every `nftAmm` package and object — which is why there is no
|
|
3449
|
+
* captured fixture for it. Fix the nested reads by fetching the pool as a
|
|
3450
|
+
* top-level object by id.
|
|
3451
|
+
*/
|
|
2898
3452
|
NftAmmApiCasting.marketObjectFromSuiObject = (suiObject) => {
|
|
2899
3453
|
const objectId = Helpers.getObjectId(suiObject);
|
|
2900
3454
|
const marketType = Helpers.getObjectType(suiObject);
|
|
@@ -2904,8 +3458,16 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2904
3458
|
const fields = Helpers.getObjectFields(
|
|
2905
3459
|
suiObject
|
|
2906
3460
|
);
|
|
2907
|
-
const
|
|
2908
|
-
const
|
|
3461
|
+
const nfts = GrpcCasting.unwrapStructField(fields.nfts);
|
|
3462
|
+
const supply = GrpcCasting.unwrapStructField(fields.supply);
|
|
3463
|
+
const pool = PoolsApiCasting.poolObjectFromSuiObject({
|
|
3464
|
+
...GrpcCasting.unwrapStructField(fields.pool),
|
|
3465
|
+
objectId: void 0,
|
|
3466
|
+
type: void 0
|
|
3467
|
+
});
|
|
3468
|
+
const fractionalizedCoinType = Coin.getInnerCoinType(
|
|
3469
|
+
fields.supply.type
|
|
3470
|
+
);
|
|
2909
3471
|
const innerMarketTypes = Coin.getInnerCoinType(marketType);
|
|
2910
3472
|
const genericTypes = innerMarketTypes.replaceAll(" ", "").split(",");
|
|
2911
3473
|
const assetCoinType = genericTypes[2];
|
|
@@ -2915,10 +3477,10 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2915
3477
|
pool,
|
|
2916
3478
|
objectType: marketType,
|
|
2917
3479
|
nftsTable: {
|
|
2918
|
-
objectId:
|
|
2919
|
-
size: BigInt(
|
|
3480
|
+
objectId: GrpcCasting.unwrapUid(nfts.id),
|
|
3481
|
+
size: BigInt(nfts.size)
|
|
2920
3482
|
},
|
|
2921
|
-
fractionalizedSupply: BigInt(
|
|
3483
|
+
fractionalizedSupply: BigInt(supply.value),
|
|
2922
3484
|
fractionalizedCoinAmount: BigInt(fields.fractions_amount),
|
|
2923
3485
|
fractionalizedCoinType,
|
|
2924
3486
|
assetCoinType,
|
|
@@ -2930,27 +3492,31 @@ var init_nftAmmApiCasting = __esm({
|
|
|
2930
3492
|
});
|
|
2931
3493
|
|
|
2932
3494
|
// 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;
|
|
3495
|
+
var PerpetualsOrderSide, PerpetualsOrderType, PerpetualsStopOrderType, PerpetualsStopOrderTriggerPriceType, isUpdatedMarketVersion, isWithdrewCollateralEvent, isDepositedCollateralEvent, isDeallocatedCollateralEvent, isAllocatedCollateralEvent, isSettledFundingEvent, isLiquidatedEvent, isCanceledOrderEvent, isPostedOrderEvent, isFilledMakerOrdersEvent, isFilledTakerOrderEvent, isReducedOrderEvent, isUpdatedPremiumTwapEvent, isUpdatedSpreadTwapEvent, isUpdatedFundingEvent;
|
|
2934
3496
|
var init_perpetualsTypes = __esm({
|
|
2935
3497
|
"src/packages/perpetuals/perpetualsTypes.ts"() {
|
|
2936
3498
|
"use strict";
|
|
2937
|
-
PerpetualsOrderSide =
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
}
|
|
2949
|
-
PerpetualsStopOrderType =
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
3499
|
+
PerpetualsOrderSide = {
|
|
3500
|
+
Ask: 1,
|
|
3501
|
+
// true
|
|
3502
|
+
Bid: 0
|
|
3503
|
+
// false
|
|
3504
|
+
};
|
|
3505
|
+
PerpetualsOrderType = {
|
|
3506
|
+
Standard: 0,
|
|
3507
|
+
FillOrKill: 1,
|
|
3508
|
+
PostOnly: 2,
|
|
3509
|
+
ImmediateOrCancel: 3
|
|
3510
|
+
};
|
|
3511
|
+
PerpetualsStopOrderType = {
|
|
3512
|
+
SlTp: 0,
|
|
3513
|
+
Standalone: 1
|
|
3514
|
+
};
|
|
3515
|
+
PerpetualsStopOrderTriggerPriceType = {
|
|
3516
|
+
IndexPrice: 0,
|
|
3517
|
+
BookMidPrice: 1,
|
|
3518
|
+
MarkPrice: 2
|
|
3519
|
+
};
|
|
2954
3520
|
isUpdatedMarketVersion = (event) => {
|
|
2955
3521
|
return event.type.toLowerCase().endsWith("::updatedclearinghouseversion");
|
|
2956
3522
|
};
|
|
@@ -3146,13 +3712,10 @@ var init_perpetualsApiCasting = __esm({
|
|
|
3146
3712
|
liquidationFeesUsd: Casting.IFixed.numberFromIFixed(
|
|
3147
3713
|
BigInt(fields.liquidation_fees)
|
|
3148
3714
|
),
|
|
3149
|
-
forceCancelFeesUsd: Casting.IFixed.numberFromIFixed(
|
|
3150
|
-
BigInt(fields.force_cancel_fees)
|
|
3151
|
-
),
|
|
3152
3715
|
insuranceFundFeesUsd: Casting.IFixed.numberFromIFixed(
|
|
3153
3716
|
BigInt(fields.insurance_fund_fees)
|
|
3154
3717
|
),
|
|
3155
|
-
side: fields.is_liqee_long ?
|
|
3718
|
+
side: fields.is_liqee_long ? PerpetualsOrderSide.Bid : PerpetualsOrderSide.Ask,
|
|
3156
3719
|
timestamp: Number(eventOnChain.timestampMs),
|
|
3157
3720
|
txnDigest: eventOnChain.id.txDigest,
|
|
3158
3721
|
type: eventOnChain.type
|
|
@@ -3634,19 +4197,21 @@ var init_stakingApiCasting = __esm({
|
|
|
3634
4197
|
const fields = Helpers.getObjectFields(
|
|
3635
4198
|
data
|
|
3636
4199
|
);
|
|
4200
|
+
const protocolConfig = GrpcCasting.unwrapStructField(
|
|
4201
|
+
fields.protocol_config
|
|
4202
|
+
);
|
|
4203
|
+
const atomicUnstakeProtocolFee = GrpcCasting.unwrapStructField(
|
|
4204
|
+
protocolConfig.atomic_unstake_protocol_fee
|
|
4205
|
+
);
|
|
3637
4206
|
return {
|
|
3638
4207
|
objectId,
|
|
3639
4208
|
objectType,
|
|
3640
4209
|
atomicUnstakeSuiReservesTargetValue: BigInt(
|
|
3641
|
-
|
|
4210
|
+
protocolConfig.atomic_unstake_sui_reserves_target_value
|
|
3642
4211
|
),
|
|
3643
4212
|
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
|
-
),
|
|
4213
|
+
minAtomicUnstakeFee: BigInt(atomicUnstakeProtocolFee.min_fee),
|
|
4214
|
+
maxAtomicUnstakeFee: BigInt(atomicUnstakeProtocolFee.max_fee),
|
|
3650
4215
|
totalSuiAmount: BigInt(fields.total_sui_amount),
|
|
3651
4216
|
totalRewardsAmount: BigInt(fields.total_rewards_amount),
|
|
3652
4217
|
activeEpoch: BigInt(fields.active_epoch)
|
|
@@ -3822,11 +4387,14 @@ var init_suiFrensApiCasting = __esm({
|
|
|
3822
4387
|
const fields = Helpers.getObjectFields(
|
|
3823
4388
|
data
|
|
3824
4389
|
);
|
|
4390
|
+
const suiFrensMetadata = GrpcCasting.unwrapStructField(
|
|
4391
|
+
fields.suifrens_metadata
|
|
4392
|
+
);
|
|
3825
4393
|
return {
|
|
3826
4394
|
objectType,
|
|
3827
4395
|
objectId: Helpers.getObjectId(data),
|
|
3828
4396
|
totalMixes: BigInt(fields.mixed),
|
|
3829
|
-
stakedSuiFrens: BigInt(
|
|
4397
|
+
stakedSuiFrens: BigInt(suiFrensMetadata.size)
|
|
3830
4398
|
};
|
|
3831
4399
|
};
|
|
3832
4400
|
_SuiFrensApiCasting.accessoryObjectFromSuiObjectResponse = (data) => {
|
|
@@ -3901,6 +4469,7 @@ var _NftsApiCasting, NftsApiCasting;
|
|
|
3901
4469
|
var init_nftsApiCasting = __esm({
|
|
3902
4470
|
"src/general/nfts/nftsApiCasting.ts"() {
|
|
3903
4471
|
"use strict";
|
|
4472
|
+
init_grpcCasting();
|
|
3904
4473
|
init_helpers();
|
|
3905
4474
|
_NftsApiCasting = class _NftsApiCasting {
|
|
3906
4475
|
};
|
|
@@ -3911,7 +4480,7 @@ var init_nftsApiCasting = __esm({
|
|
|
3911
4480
|
// Objects
|
|
3912
4481
|
// =========================================================================
|
|
3913
4482
|
_NftsApiCasting.nftsFromSuiObjects = (objects) => {
|
|
3914
|
-
const nfts = objects.filter((object) => object.
|
|
4483
|
+
const nfts = objects.filter((object) => object.display);
|
|
3915
4484
|
return nfts.map((nft) => _NftsApiCasting.nftFromSuiObject(nft)).filter(
|
|
3916
4485
|
(nft) => Object.keys(nft.display.suggested).length > 0 || Object.keys(nft.display.other).length > 0
|
|
3917
4486
|
);
|
|
@@ -3939,10 +4508,11 @@ var init_nftsApiCasting = __esm({
|
|
|
3939
4508
|
const fields = Helpers.getObjectFields(object);
|
|
3940
4509
|
const objectId = Helpers.getObjectId(object);
|
|
3941
4510
|
const objectType = Helpers.getObjectType(object);
|
|
4511
|
+
const cap = GrpcCasting.unwrapStructField(fields.cap);
|
|
3942
4512
|
return {
|
|
3943
4513
|
objectId,
|
|
3944
4514
|
objectType,
|
|
3945
|
-
kioskObjectId: Helpers.addLeadingZeroesToType(
|
|
4515
|
+
kioskObjectId: Helpers.addLeadingZeroesToType(cap.for)
|
|
3946
4516
|
};
|
|
3947
4517
|
};
|
|
3948
4518
|
// =========================================================================
|
|
@@ -4397,7 +4967,9 @@ var init_utils = __esm({
|
|
|
4397
4967
|
"src/general/utils/index.ts"() {
|
|
4398
4968
|
"use strict";
|
|
4399
4969
|
init_casting();
|
|
4970
|
+
init_grpcCasting();
|
|
4400
4971
|
init_helpers();
|
|
4972
|
+
init_transportError();
|
|
4401
4973
|
}
|
|
4402
4974
|
});
|
|
4403
4975
|
|
|
@@ -4896,10 +5468,13 @@ var init_farmsStakingPool = __esm({
|
|
|
4896
5468
|
* console.log(poolTvl);
|
|
4897
5469
|
* ```
|
|
4898
5470
|
*/
|
|
4899
|
-
async getTVL() {
|
|
4900
|
-
return new Farms(this.config, this.api).getTVL(
|
|
4901
|
-
|
|
4902
|
-
|
|
5471
|
+
async getTVL(abortSignal) {
|
|
5472
|
+
return new Farms(this.config, this.api).getTVL(
|
|
5473
|
+
{
|
|
5474
|
+
farmIds: [this.stakingPool.objectId]
|
|
5475
|
+
},
|
|
5476
|
+
abortSignal
|
|
5477
|
+
);
|
|
4903
5478
|
}
|
|
4904
5479
|
/**
|
|
4905
5480
|
* Fetches the total value locked (TVL) of the reward coins in this specific staking pool.
|
|
@@ -4912,10 +5487,13 @@ var init_farmsStakingPool = __esm({
|
|
|
4912
5487
|
* console.log(rewardTvl);
|
|
4913
5488
|
* ```
|
|
4914
5489
|
*/
|
|
4915
|
-
async getRewardsTVL() {
|
|
4916
|
-
return new Farms(this.config, this.api).getRewardsTVL(
|
|
4917
|
-
|
|
4918
|
-
|
|
5490
|
+
async getRewardsTVL(abortSignal) {
|
|
5491
|
+
return new Farms(this.config, this.api).getRewardsTVL(
|
|
5492
|
+
{
|
|
5493
|
+
farmIds: [this.stakingPool.objectId]
|
|
5494
|
+
},
|
|
5495
|
+
abortSignal
|
|
5496
|
+
);
|
|
4919
5497
|
}
|
|
4920
5498
|
// =========================================================================
|
|
4921
5499
|
// Transactions
|
|
@@ -4988,6 +5566,38 @@ var init_farmsStakingPool = __esm({
|
|
|
4988
5566
|
};
|
|
4989
5567
|
return this.version() === 1 ? this.farmsApi().buildSetStakingPoolMinStakeAmountTxV1(args) : this.farmsApi().buildSetStakingPoolMinStakeAmountTxV2(args);
|
|
4990
5568
|
}
|
|
5569
|
+
/**
|
|
5570
|
+
* Builds a transaction to set the pool's minimum lock duration (ms).
|
|
5571
|
+
* Owner-cap only. V2 pools only — V1 vaults do not expose this entry.
|
|
5572
|
+
*/
|
|
5573
|
+
getSetMinLockDurationMsTransaction(inputs) {
|
|
5574
|
+
if (this.version() === 1) {
|
|
5575
|
+
throw new Error(
|
|
5576
|
+
"set_min_lock_duration_ms is not supported on V1 staking pools"
|
|
5577
|
+
);
|
|
5578
|
+
}
|
|
5579
|
+
return this.farmsApi().buildSetStakingPoolMinLockDurationMsTxV2({
|
|
5580
|
+
...inputs,
|
|
5581
|
+
stakeCoinType: this.stakingPool.stakeCoinType,
|
|
5582
|
+
stakingPoolId: this.stakingPool.objectId
|
|
5583
|
+
});
|
|
5584
|
+
}
|
|
5585
|
+
/**
|
|
5586
|
+
* Builds a transaction to set the pool's maximum lock duration (ms).
|
|
5587
|
+
* Owner-cap only. V2 pools only.
|
|
5588
|
+
*/
|
|
5589
|
+
getSetMaxLockDurationMsTransaction(inputs) {
|
|
5590
|
+
if (this.version() === 1) {
|
|
5591
|
+
throw new Error(
|
|
5592
|
+
"set_max_lock_duration_ms is not supported on V1 staking pools"
|
|
5593
|
+
);
|
|
5594
|
+
}
|
|
5595
|
+
return this.farmsApi().buildSetStakingPoolMaxLockDurationMsTxV2({
|
|
5596
|
+
...inputs,
|
|
5597
|
+
stakeCoinType: this.stakingPool.stakeCoinType,
|
|
5598
|
+
stakingPoolId: this.stakingPool.objectId
|
|
5599
|
+
});
|
|
5600
|
+
}
|
|
4991
5601
|
/**
|
|
4992
5602
|
* Builds a transaction granting a one-time admin cap to another address, allowing them to perform specific
|
|
4993
5603
|
* one-time administrative actions (like initializing a reward).
|
|
@@ -5603,9 +6213,11 @@ var init_farms = __esm({
|
|
|
5603
6213
|
* console.log(pool.stakingPool);
|
|
5604
6214
|
* ```
|
|
5605
6215
|
*/
|
|
5606
|
-
async getStakingPool(inputs) {
|
|
6216
|
+
async getStakingPool(inputs, abortSignal) {
|
|
5607
6217
|
const stakingPool = await this.fetchApi(
|
|
5608
|
-
inputs.objectId
|
|
6218
|
+
inputs.objectId,
|
|
6219
|
+
void 0,
|
|
6220
|
+
abortSignal
|
|
5609
6221
|
);
|
|
5610
6222
|
return new FarmsStakingPool(stakingPool, this.config, this.api);
|
|
5611
6223
|
}
|
|
@@ -5623,10 +6235,14 @@ var init_farms = __esm({
|
|
|
5623
6235
|
* console.log(pools[0].stakingPool, pools[1].stakingPool);
|
|
5624
6236
|
* ```
|
|
5625
6237
|
*/
|
|
5626
|
-
async getStakingPools(inputs) {
|
|
5627
|
-
const stakingPools = await this.fetchApi(
|
|
5628
|
-
|
|
5629
|
-
|
|
6238
|
+
async getStakingPools(inputs, abortSignal) {
|
|
6239
|
+
const stakingPools = await this.fetchApi(
|
|
6240
|
+
"",
|
|
6241
|
+
{
|
|
6242
|
+
farmIds: inputs.objectIds
|
|
6243
|
+
},
|
|
6244
|
+
abortSignal
|
|
6245
|
+
);
|
|
5630
6246
|
return stakingPools.map(
|
|
5631
6247
|
(stakingPool) => new FarmsStakingPool(stakingPool, this.config, this.api)
|
|
5632
6248
|
);
|
|
@@ -5642,8 +6258,12 @@ var init_farms = __esm({
|
|
|
5642
6258
|
* console.log(allPools.map(pool => pool.stakingPool));
|
|
5643
6259
|
* ```
|
|
5644
6260
|
*/
|
|
5645
|
-
async getAllStakingPools() {
|
|
5646
|
-
const stakingPools = await this.fetchApi(
|
|
6261
|
+
async getAllStakingPools(abortSignal) {
|
|
6262
|
+
const stakingPools = await this.fetchApi(
|
|
6263
|
+
"",
|
|
6264
|
+
{},
|
|
6265
|
+
abortSignal
|
|
6266
|
+
);
|
|
5647
6267
|
return stakingPools.map(
|
|
5648
6268
|
(pool) => new FarmsStakingPool(pool, this.config, this.api)
|
|
5649
6269
|
);
|
|
@@ -5722,8 +6342,8 @@ var init_farms = __esm({
|
|
|
5722
6342
|
* console.log("Specific farm's TVL:", tvlForSpecificFarm);
|
|
5723
6343
|
* ```
|
|
5724
6344
|
*/
|
|
5725
|
-
async getTVL(inputs) {
|
|
5726
|
-
return this.fetchApi("tvl", inputs ?? {});
|
|
6345
|
+
async getTVL(inputs, abortSignal) {
|
|
6346
|
+
return this.fetchApi("tvl", inputs ?? {}, abortSignal);
|
|
5727
6347
|
}
|
|
5728
6348
|
/**
|
|
5729
6349
|
* Retrieves the total value locked (TVL) of reward coins across specified farm IDs or all farms if none are specified.
|
|
@@ -5740,8 +6360,8 @@ var init_farms = __esm({
|
|
|
5740
6360
|
* console.log("Single farm's rewards TVL:", singleFarmRewardsTvl);
|
|
5741
6361
|
* ```
|
|
5742
6362
|
*/
|
|
5743
|
-
async getRewardsTVL(inputs) {
|
|
5744
|
-
return this.fetchApi("rewards-tvl", inputs ?? {});
|
|
6363
|
+
async getRewardsTVL(inputs, abortSignal) {
|
|
6364
|
+
return this.fetchApi("rewards-tvl", inputs ?? {}, abortSignal);
|
|
5745
6365
|
}
|
|
5746
6366
|
// =========================================================================
|
|
5747
6367
|
// Transactions
|
|
@@ -5861,29 +6481,19 @@ var init_faucet = __esm({
|
|
|
5861
6481
|
// =========================================================================
|
|
5862
6482
|
// Inspections
|
|
5863
6483
|
// =========================================================================
|
|
5864
|
-
|
|
6484
|
+
getSupportedCoins() {
|
|
5865
6485
|
return this.fetchApi("supported-coins");
|
|
5866
6486
|
}
|
|
5867
6487
|
// =========================================================================
|
|
5868
|
-
// Events
|
|
5869
|
-
// =========================================================================
|
|
5870
|
-
// TODO: add mint coin event getter ?
|
|
5871
|
-
// =========================================================================
|
|
5872
6488
|
// Transactions
|
|
5873
6489
|
// =========================================================================
|
|
5874
|
-
|
|
6490
|
+
getRequestCoinTransaction(inputs) {
|
|
5875
6491
|
return this.faucetApi().buildRequestCoinTx(inputs);
|
|
5876
6492
|
}
|
|
5877
|
-
|
|
6493
|
+
getMintSuiFrenTransaction(inputs) {
|
|
5878
6494
|
return this.faucetApi().fetchBuildMintSuiFrenTx(inputs);
|
|
5879
6495
|
}
|
|
5880
6496
|
};
|
|
5881
|
-
// =========================================================================
|
|
5882
|
-
// Constants
|
|
5883
|
-
// =========================================================================
|
|
5884
|
-
Faucet.constants = {
|
|
5885
|
-
defaultRequestAmountUsd: 10
|
|
5886
|
-
};
|
|
5887
6497
|
}
|
|
5888
6498
|
});
|
|
5889
6499
|
|
|
@@ -6004,24 +6614,25 @@ var init_gasPools = __esm({
|
|
|
6004
6614
|
);
|
|
6005
6615
|
}
|
|
6006
6616
|
/**
|
|
6007
|
-
*
|
|
6008
|
-
*
|
|
6617
|
+
* Requests a gas-pool-sponsored transaction. Returns a complete transaction
|
|
6618
|
+
* with the gas payment and epoch bound attached, the sponsor's signature, and
|
|
6619
|
+
* the digest both signatures commit to — the caller signs `transaction` as the
|
|
6620
|
+
* sender and submits it together with `sponsorSignature`.
|
|
6009
6621
|
*
|
|
6010
|
-
* @param inputs.walletAddress - Wallet address
|
|
6011
|
-
* @param inputs.
|
|
6012
|
-
* @param inputs.
|
|
6013
|
-
* @
|
|
6622
|
+
* @param inputs.walletAddress - Wallet address requesting the sponsorship.
|
|
6623
|
+
* @param inputs.bytes - Base64 of the signed `SPONSOR_GAS` auth message.
|
|
6624
|
+
* @param inputs.signature - Signature over `bytes`.
|
|
6625
|
+
* @param inputs.tx - Optional transaction to sponsor (appended as a tx kind).
|
|
6626
|
+
* @returns {@link ApiGasPoolSponsorResponse}.
|
|
6014
6627
|
*/
|
|
6015
|
-
async
|
|
6628
|
+
async getSponsoredTransaction(inputs) {
|
|
6016
6629
|
const { tx, ...otherInputs } = inputs;
|
|
6017
|
-
return this.
|
|
6630
|
+
return this.fetchApi(
|
|
6018
6631
|
"transactions/sponsor",
|
|
6019
6632
|
{
|
|
6020
6633
|
...otherInputs,
|
|
6021
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
|
|
6022
|
-
}
|
|
6023
|
-
void 0,
|
|
6024
|
-
{ txKind: true }
|
|
6634
|
+
txKind: tx ? await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }) : void 0
|
|
6635
|
+
}
|
|
6025
6636
|
);
|
|
6026
6637
|
}
|
|
6027
6638
|
/**
|
|
@@ -8150,10 +8761,13 @@ var init_pools = __esm({
|
|
|
8150
8761
|
* console.log(poolId);
|
|
8151
8762
|
* ```
|
|
8152
8763
|
*/
|
|
8153
|
-
this.getPoolObjectIdForLpCoinType = (inputs) => {
|
|
8154
|
-
return this.getPoolObjectIdsForLpCoinTypes(
|
|
8155
|
-
|
|
8156
|
-
|
|
8764
|
+
this.getPoolObjectIdForLpCoinType = (inputs, abortSignal) => {
|
|
8765
|
+
return this.getPoolObjectIdsForLpCoinTypes(
|
|
8766
|
+
{
|
|
8767
|
+
lpCoinTypes: [inputs.lpCoinType]
|
|
8768
|
+
},
|
|
8769
|
+
abortSignal
|
|
8770
|
+
);
|
|
8157
8771
|
};
|
|
8158
8772
|
/**
|
|
8159
8773
|
* Checks if a given coin type is recognized as an LP coin.
|
|
@@ -8162,8 +8776,8 @@ var init_pools = __esm({
|
|
|
8162
8776
|
* @param inputs - Contains the `lpCoinType` to check.
|
|
8163
8777
|
* @returns `true` if the coin is an LP token, `false` otherwise.
|
|
8164
8778
|
*/
|
|
8165
|
-
this.isLpCoinType = async (inputs) => {
|
|
8166
|
-
const result = await this.getPoolObjectIdForLpCoinType(inputs);
|
|
8779
|
+
this.isLpCoinType = async (inputs, abortSignal) => {
|
|
8780
|
+
const result = await this.getPoolObjectIdForLpCoinType(inputs, abortSignal);
|
|
8167
8781
|
return result.some((id) => id !== void 0);
|
|
8168
8782
|
};
|
|
8169
8783
|
/**
|
|
@@ -8213,8 +8827,12 @@ var init_pools = __esm({
|
|
|
8213
8827
|
* console.log(pool.pool.lpCoinType, pool.pool.name);
|
|
8214
8828
|
* ```
|
|
8215
8829
|
*/
|
|
8216
|
-
async getPool(inputs) {
|
|
8217
|
-
const pool = await this.fetchApi(
|
|
8830
|
+
async getPool(inputs, abortSignal) {
|
|
8831
|
+
const pool = await this.fetchApi(
|
|
8832
|
+
inputs.objectId,
|
|
8833
|
+
void 0,
|
|
8834
|
+
abortSignal
|
|
8835
|
+
);
|
|
8218
8836
|
return new Pool(pool, this.config, this.api);
|
|
8219
8837
|
}
|
|
8220
8838
|
/**
|
|
@@ -8229,10 +8847,14 @@ var init_pools = __esm({
|
|
|
8229
8847
|
* console.log(poolArray.length);
|
|
8230
8848
|
* ```
|
|
8231
8849
|
*/
|
|
8232
|
-
async getPools(inputs) {
|
|
8233
|
-
const pools = await this.fetchApi(
|
|
8234
|
-
|
|
8235
|
-
|
|
8850
|
+
async getPools(inputs, abortSignal) {
|
|
8851
|
+
const pools = await this.fetchApi(
|
|
8852
|
+
"",
|
|
8853
|
+
{
|
|
8854
|
+
poolIds: inputs.objectIds
|
|
8855
|
+
},
|
|
8856
|
+
abortSignal
|
|
8857
|
+
);
|
|
8236
8858
|
return pools.map((pool) => new Pool(pool, this.config, this.api));
|
|
8237
8859
|
}
|
|
8238
8860
|
/**
|
|
@@ -8246,8 +8868,8 @@ var init_pools = __esm({
|
|
|
8246
8868
|
* console.log(allPools.map(p => p.pool.name));
|
|
8247
8869
|
* ```
|
|
8248
8870
|
*/
|
|
8249
|
-
async getAllPools() {
|
|
8250
|
-
const pools = await this.fetchApi("", {});
|
|
8871
|
+
async getAllPools(abortSignal) {
|
|
8872
|
+
const pools = await this.fetchApi("", {}, abortSignal);
|
|
8251
8873
|
return pools.map((pool) => new Pool(pool, this.config, this.api));
|
|
8252
8874
|
}
|
|
8253
8875
|
/**
|
|
@@ -8337,8 +8959,8 @@ var init_pools = __esm({
|
|
|
8337
8959
|
* console.log(poolIds);
|
|
8338
8960
|
* ```
|
|
8339
8961
|
*/
|
|
8340
|
-
async getPoolObjectIdsForLpCoinTypes(inputs) {
|
|
8341
|
-
return this.fetchApi("pool-object-ids", inputs);
|
|
8962
|
+
async getPoolObjectIdsForLpCoinTypes(inputs, abortSignal) {
|
|
8963
|
+
return this.fetchApi("pool-object-ids", inputs, abortSignal);
|
|
8342
8964
|
}
|
|
8343
8965
|
/**
|
|
8344
8966
|
* Retrieves the total value locked (TVL) across all or specific pool IDs.
|
|
@@ -8368,8 +8990,8 @@ var init_pools = __esm({
|
|
|
8368
8990
|
* console.log(stats[0].volume, stats[1].tvl);
|
|
8369
8991
|
* ```
|
|
8370
8992
|
*/
|
|
8371
|
-
async getPoolsStats(inputs) {
|
|
8372
|
-
return this.fetchApi("stats", inputs);
|
|
8993
|
+
async getPoolsStats(inputs, abortSignal) {
|
|
8994
|
+
return this.fetchApi("stats", inputs, abortSignal);
|
|
8373
8995
|
}
|
|
8374
8996
|
/**
|
|
8375
8997
|
* Returns all DAO fee pool owner capabilities owned by a particular user.
|
|
@@ -8987,7 +9609,7 @@ var init_types2 = __esm({
|
|
|
8987
9609
|
|
|
8988
9610
|
// src/packages/perpetuals/perpetualsAccount.ts
|
|
8989
9611
|
import {
|
|
8990
|
-
Transaction as
|
|
9612
|
+
Transaction as Transaction4
|
|
8991
9613
|
} from "@mysten/sui/transactions";
|
|
8992
9614
|
var PerpetualsAccount;
|
|
8993
9615
|
var init_perpetualsAccount = __esm({
|
|
@@ -9068,7 +9690,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9068
9690
|
accountId: this.accountCap.accountId,
|
|
9069
9691
|
accountCapId: this.accountCap.objectId,
|
|
9070
9692
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
9071
|
-
tx: tx ?? new
|
|
9693
|
+
tx: tx ?? new Transaction4()
|
|
9072
9694
|
})
|
|
9073
9695
|
},
|
|
9074
9696
|
void 0,
|
|
@@ -9116,7 +9738,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9116
9738
|
walletAddress: this.ownerAddress(),
|
|
9117
9739
|
accountId: this.accountCap.accountId,
|
|
9118
9740
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
9119
|
-
tx: txFromInputs ?? new
|
|
9741
|
+
tx: txFromInputs ?? new Transaction4()
|
|
9120
9742
|
})
|
|
9121
9743
|
},
|
|
9122
9744
|
void 0,
|
|
@@ -9152,7 +9774,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9152
9774
|
vaultId: void 0
|
|
9153
9775
|
},
|
|
9154
9776
|
walletAddress: this.ownerAddress(),
|
|
9155
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new
|
|
9777
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
|
|
9156
9778
|
},
|
|
9157
9779
|
void 0,
|
|
9158
9780
|
{
|
|
@@ -9187,7 +9809,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9187
9809
|
vaultId: void 0
|
|
9188
9810
|
},
|
|
9189
9811
|
walletAddress: this.ownerAddress(),
|
|
9190
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new
|
|
9812
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
|
|
9191
9813
|
},
|
|
9192
9814
|
void 0,
|
|
9193
9815
|
{
|
|
@@ -9220,7 +9842,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9220
9842
|
walletAddress: this.ownerAddress(),
|
|
9221
9843
|
fromAccountId: this.accountCap.accountId,
|
|
9222
9844
|
fromAccountCapId: this.accountCap.objectId,
|
|
9223
|
-
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new
|
|
9845
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
|
|
9224
9846
|
},
|
|
9225
9847
|
void 0,
|
|
9226
9848
|
{
|
|
@@ -9268,7 +9890,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9268
9890
|
*/
|
|
9269
9891
|
async getPlaceMarketOrderTx(inputs) {
|
|
9270
9892
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9271
|
-
const tx = txFromInputs ?? new
|
|
9893
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9272
9894
|
return this.fetchApiTxObject(
|
|
9273
9895
|
`${this.vaultId ? "vault" : "account"}/transactions/place-market-order`,
|
|
9274
9896
|
{
|
|
@@ -9310,7 +9932,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9310
9932
|
*/
|
|
9311
9933
|
async getPlaceLimitOrderTx(inputs) {
|
|
9312
9934
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9313
|
-
const tx = txFromInputs ?? new
|
|
9935
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9314
9936
|
return this.fetchApiTxObject(
|
|
9315
9937
|
`${this.vaultId ? "vault" : "account"}/transactions/place-limit-order`,
|
|
9316
9938
|
{
|
|
@@ -9347,7 +9969,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9347
9969
|
*/
|
|
9348
9970
|
async getPlaceScaleOrderTx(inputs) {
|
|
9349
9971
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9350
|
-
const tx = txFromInputs ?? new
|
|
9972
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9351
9973
|
return this.fetchApiTxObject(
|
|
9352
9974
|
`${this.vaultId ? "vault" : "account"}/transactions/place-scale-order`,
|
|
9353
9975
|
{
|
|
@@ -9382,7 +10004,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9382
10004
|
*/
|
|
9383
10005
|
async getCancelAndPlaceOrdersTx(inputs) {
|
|
9384
10006
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9385
|
-
const tx = txFromInputs ?? new
|
|
10007
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9386
10008
|
return this.fetchApiTxObject(
|
|
9387
10009
|
`${this.vaultId ? "vault" : "account"}/transactions/cancel-and-place-orders`,
|
|
9388
10010
|
{
|
|
@@ -9497,7 +10119,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9497
10119
|
*/
|
|
9498
10120
|
async getPlaceStopOrdersTx(inputs) {
|
|
9499
10121
|
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
9500
|
-
const tx = txFromInputs ?? new
|
|
10122
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9501
10123
|
return this.fetchApiTxObject(
|
|
9502
10124
|
`${this.vaultId ? "vault" : "account"}/transactions/place-stop-orders`,
|
|
9503
10125
|
{
|
|
@@ -9541,7 +10163,7 @@ var init_perpetualsAccount = __esm({
|
|
|
9541
10163
|
if (!position) {
|
|
9542
10164
|
throw new Error("you have no position for this market");
|
|
9543
10165
|
}
|
|
9544
|
-
const tx = txFromInputs ?? new
|
|
10166
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
9545
10167
|
return this.fetchApiTxObject(
|
|
9546
10168
|
`${this.vaultId ? "vault" : "account"}/transactions/place-sl-tp-orders`,
|
|
9547
10169
|
{
|
|
@@ -9577,16 +10199,110 @@ var init_perpetualsAccount = __esm({
|
|
|
9577
10199
|
* - This is typically used to adjust trigger prices, sizes, expiries, or the
|
|
9578
10200
|
* embedded limit-order parameters.
|
|
9579
10201
|
*
|
|
9580
|
-
* @param inputs.stopOrders - Full updated stop-order payloads to apply.
|
|
10202
|
+
* @param inputs.stopOrders - Full updated stop-order payloads to apply.
|
|
10203
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
10204
|
+
*
|
|
10205
|
+
* @returns Transaction response containing `tx`.
|
|
10206
|
+
*/
|
|
10207
|
+
async getEditStopOrdersTx(inputs) {
|
|
10208
|
+
const { tx: txFromInputs, ...otherInputs } = inputs;
|
|
10209
|
+
const tx = txFromInputs ?? new Transaction4();
|
|
10210
|
+
return this.fetchApiTxObject(
|
|
10211
|
+
`${this.vaultId ? "vault" : "account"}/transactions/edit-stop-orders`,
|
|
10212
|
+
{
|
|
10213
|
+
...otherInputs,
|
|
10214
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
10215
|
+
walletAddress: this.ownerAddress(),
|
|
10216
|
+
..."vaultId" in this.accountCap ? {
|
|
10217
|
+
vaultId: this.accountCap.vaultId,
|
|
10218
|
+
accountId: void 0
|
|
10219
|
+
} : {
|
|
10220
|
+
accountId: this.accountCap.accountId,
|
|
10221
|
+
accountCapId: this.accountCap.objectId,
|
|
10222
|
+
vaultId: void 0
|
|
10223
|
+
}
|
|
10224
|
+
},
|
|
10225
|
+
void 0,
|
|
10226
|
+
{
|
|
10227
|
+
txKind: true
|
|
10228
|
+
}
|
|
10229
|
+
);
|
|
10230
|
+
}
|
|
10231
|
+
/**
|
|
10232
|
+
* Build a `create-twap-orders` transaction for this account.
|
|
10233
|
+
*
|
|
10234
|
+
* @param inputs - See {@link SdkPerpetualsCreateTwapOrdersInputs}.
|
|
10235
|
+
*
|
|
10236
|
+
* @returns Transaction response containing `tx`.
|
|
10237
|
+
*/
|
|
10238
|
+
async getCreateTwapOrdersTx(inputs) {
|
|
10239
|
+
const { tx, ...otherInputs } = inputs;
|
|
10240
|
+
return this.fetchApiTxObject(
|
|
10241
|
+
`${this.vaultId ? "vault" : "account"}/transactions/create-twap-orders`,
|
|
10242
|
+
{
|
|
10243
|
+
...otherInputs,
|
|
10244
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
10245
|
+
walletAddress: this.ownerAddress(),
|
|
10246
|
+
..."vaultId" in this.accountCap ? {
|
|
10247
|
+
vaultId: this.accountCap.vaultId,
|
|
10248
|
+
accountId: void 0
|
|
10249
|
+
} : {
|
|
10250
|
+
accountId: this.accountCap.accountId,
|
|
10251
|
+
accountCapId: this.accountCap.objectId,
|
|
10252
|
+
vaultId: void 0
|
|
10253
|
+
}
|
|
10254
|
+
},
|
|
10255
|
+
void 0,
|
|
10256
|
+
{
|
|
10257
|
+
txKind: true
|
|
10258
|
+
}
|
|
10259
|
+
);
|
|
10260
|
+
}
|
|
10261
|
+
/**
|
|
10262
|
+
* Build an `edit-twap-orders` transaction for this account.
|
|
10263
|
+
* `newTwapOrders` maps each TWAP order object id to the edit to apply.
|
|
10264
|
+
*
|
|
10265
|
+
* @param inputs.newTwapOrders - Map of TWAP order id to the edit to apply.
|
|
10266
|
+
* @param inputs.tx - Optional transaction to extend.
|
|
10267
|
+
*
|
|
10268
|
+
* @returns Transaction response containing `tx`.
|
|
10269
|
+
*/
|
|
10270
|
+
async getEditTwapOrdersTx(inputs) {
|
|
10271
|
+
const { tx, ...otherInputs } = inputs;
|
|
10272
|
+
return this.fetchApiTxObject(
|
|
10273
|
+
`${this.vaultId ? "vault" : "account"}/transactions/edit-twap-orders`,
|
|
10274
|
+
{
|
|
10275
|
+
...otherInputs,
|
|
10276
|
+
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
10277
|
+
walletAddress: this.ownerAddress(),
|
|
10278
|
+
..."vaultId" in this.accountCap ? {
|
|
10279
|
+
vaultId: this.accountCap.vaultId,
|
|
10280
|
+
accountId: void 0
|
|
10281
|
+
} : {
|
|
10282
|
+
accountId: this.accountCap.accountId,
|
|
10283
|
+
accountCapId: this.accountCap.objectId,
|
|
10284
|
+
vaultId: void 0
|
|
10285
|
+
}
|
|
10286
|
+
},
|
|
10287
|
+
void 0,
|
|
10288
|
+
{
|
|
10289
|
+
txKind: true
|
|
10290
|
+
}
|
|
10291
|
+
);
|
|
10292
|
+
}
|
|
10293
|
+
/**
|
|
10294
|
+
* Build a `cancel-twap-orders` transaction for this account.
|
|
10295
|
+
* This cancels TWAP order objects by their object IDs.
|
|
10296
|
+
*
|
|
9581
10297
|
* @param inputs.tx - Optional transaction to extend.
|
|
10298
|
+
* @param inputs.twapOrderIds - Array of TWAP order object IDs to cancel.
|
|
9582
10299
|
*
|
|
9583
10300
|
* @returns Transaction response containing `tx`.
|
|
9584
10301
|
*/
|
|
9585
|
-
async
|
|
9586
|
-
const { tx
|
|
9587
|
-
const tx = txFromInputs ?? new Transaction3();
|
|
10302
|
+
async getCancelTwapOrdersTx(inputs) {
|
|
10303
|
+
const { tx, ...otherInputs } = inputs;
|
|
9588
10304
|
return this.fetchApiTxObject(
|
|
9589
|
-
`${this.vaultId ? "vault" : "account"}/transactions/
|
|
10305
|
+
`${this.vaultId ? "vault" : "account"}/transactions/cancel-twap-orders`,
|
|
9590
10306
|
{
|
|
9591
10307
|
...otherInputs,
|
|
9592
10308
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
|
|
@@ -9606,6 +10322,29 @@ var init_perpetualsAccount = __esm({
|
|
|
9606
10322
|
}
|
|
9607
10323
|
);
|
|
9608
10324
|
}
|
|
10325
|
+
/**
|
|
10326
|
+
* Fetch TWAP-order data for this account, using an off-chain signed payload.
|
|
10327
|
+
*
|
|
10328
|
+
* @param inputs.bytes - Serialized message that was signed.
|
|
10329
|
+
* @param inputs.signature - Signature over `bytes`.
|
|
10330
|
+
* @param inputs.marketIds - Optional subset of markets to filter results by.
|
|
10331
|
+
*
|
|
10332
|
+
* @returns {@link ApiPerpetualsTwapOrderDatasResponse} containing `twapOrderDatas`.
|
|
10333
|
+
*/
|
|
10334
|
+
async getTwapOrderDatas(inputs) {
|
|
10335
|
+
const { bytes, signature, marketIds } = inputs;
|
|
10336
|
+
return await this.fetchApi(`${this.vaultId ? "vault" : "account"}/twap-order-datas`, {
|
|
10337
|
+
bytes,
|
|
10338
|
+
signature,
|
|
10339
|
+
walletAddress: this.ownerAddress(),
|
|
10340
|
+
marketIds: marketIds ?? [],
|
|
10341
|
+
..."vaultId" in this.accountCap ? {
|
|
10342
|
+
vaultId: this.accountCap.vaultId
|
|
10343
|
+
} : {
|
|
10344
|
+
accountId: this.accountCap.accountId
|
|
10345
|
+
}
|
|
10346
|
+
});
|
|
10347
|
+
}
|
|
9609
10348
|
// public async getReduceOrderTx(inputs: {
|
|
9610
10349
|
// tx?: Transaction;
|
|
9611
10350
|
// collateralChange: number;
|
|
@@ -10174,7 +10913,7 @@ var init_perpetualsAccount = __esm({
|
|
|
10174
10913
|
recipientAddress,
|
|
10175
10914
|
accountId: this.accountCap.accountId,
|
|
10176
10915
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
10177
|
-
tx: tx ?? new
|
|
10916
|
+
tx: tx ?? new Transaction4()
|
|
10178
10917
|
})
|
|
10179
10918
|
},
|
|
10180
10919
|
void 0,
|
|
@@ -10206,7 +10945,7 @@ var init_perpetualsAccount = __esm({
|
|
|
10206
10945
|
accountCapId,
|
|
10207
10946
|
accountId: this.accountCap.accountId,
|
|
10208
10947
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
10209
|
-
tx: tx ?? new
|
|
10948
|
+
tx: tx ?? new Transaction4()
|
|
10210
10949
|
})
|
|
10211
10950
|
},
|
|
10212
10951
|
void 0,
|
|
@@ -10337,7 +11076,7 @@ var init_perpetualsAccount = __esm({
|
|
|
10337
11076
|
* - Market ID matches the input market.
|
|
10338
11077
|
* - `slTp` field is present.
|
|
10339
11078
|
* - Order side is opposite of the position side.
|
|
10340
|
-
* - At least a `
|
|
11079
|
+
* - At least a `stopLossPrice` or `takeProfitPrice` is set.
|
|
10341
11080
|
*
|
|
10342
11081
|
* Notes on matching:
|
|
10343
11082
|
* - The side comparison uses the current position side derived from the account snapshot.
|
|
@@ -10361,10 +11100,10 @@ var init_perpetualsAccount = __esm({
|
|
|
10361
11100
|
}
|
|
10362
11101
|
const side = position ? Perpetuals.positionSide(position) : void 0;
|
|
10363
11102
|
const fullSlTpOrder = stopOrderDatas.find(
|
|
10364
|
-
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.
|
|
11103
|
+
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size >= Casting.i64MaxBigInt && !order.limitOrder
|
|
10365
11104
|
);
|
|
10366
11105
|
const partialSlTpOrders = stopOrderDatas.filter(
|
|
10367
|
-
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.
|
|
11106
|
+
(order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size < Casting.i64MaxBigInt && !order.limitOrder
|
|
10368
11107
|
);
|
|
10369
11108
|
return {
|
|
10370
11109
|
fullSlTpOrder,
|
|
@@ -10374,10 +11113,10 @@ var init_perpetualsAccount = __esm({
|
|
|
10374
11113
|
slTpStopOrderDatasForLimitOrder(inputs) {
|
|
10375
11114
|
const { stopOrderDatas, limitOrderId } = inputs;
|
|
10376
11115
|
const fullSlTpOrder = stopOrderDatas.find(
|
|
10377
|
-
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.
|
|
11116
|
+
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size >= Casting.i64MaxBigInt
|
|
10378
11117
|
);
|
|
10379
11118
|
const partialSlTpOrders = stopOrderDatas.filter(
|
|
10380
|
-
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.
|
|
11119
|
+
(order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size < Casting.i64MaxBigInt
|
|
10381
11120
|
);
|
|
10382
11121
|
return {
|
|
10383
11122
|
fullSlTpOrder,
|
|
@@ -10562,12 +11301,13 @@ var init_perpetualsMarket = __esm({
|
|
|
10562
11301
|
* @param marketData - Snapshot of market configuration and state.
|
|
10563
11302
|
* @param config - Optional {@link CallerConfig} (network, base URL, etc.).
|
|
10564
11303
|
* @param api - Optional shared {@link AftermathApi} provider instance.
|
|
11304
|
+
* @param metadata - Optional display metadata for the market.
|
|
10565
11305
|
*
|
|
10566
11306
|
* @remarks
|
|
10567
11307
|
* This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning
|
|
10568
11308
|
* all HTTP requests resolve under `/perpetuals/...`.
|
|
10569
11309
|
*/
|
|
10570
|
-
constructor(marketData, config, api) {
|
|
11310
|
+
constructor(marketData, config, api, metadata) {
|
|
10571
11311
|
super(config, "perpetuals");
|
|
10572
11312
|
this.marketData = marketData;
|
|
10573
11313
|
this.api = api;
|
|
@@ -10765,10 +11505,6 @@ var init_perpetualsMarket = __esm({
|
|
|
10765
11505
|
asksQuantity: 0,
|
|
10766
11506
|
bidsQuantity: 0,
|
|
10767
11507
|
pendingOrders: [],
|
|
10768
|
-
makerFee: 1,
|
|
10769
|
-
// 100% (placeholder default)
|
|
10770
|
-
takerFee: 1,
|
|
10771
|
-
// 100% (placeholder default)
|
|
10772
11508
|
leverage: 1,
|
|
10773
11509
|
entryPrice: 0,
|
|
10774
11510
|
freeCollateral: 0,
|
|
@@ -10785,6 +11521,7 @@ var init_perpetualsMarket = __esm({
|
|
|
10785
11521
|
this.collateralCoinType = marketData.collateralCoinType;
|
|
10786
11522
|
this.marketParams = marketData.marketParams;
|
|
10787
11523
|
this.marketState = marketData.marketState;
|
|
11524
|
+
this.metadata = metadata ?? null;
|
|
10788
11525
|
}
|
|
10789
11526
|
// =========================================================================
|
|
10790
11527
|
// Inspections
|
|
@@ -10998,7 +11735,7 @@ var init_perpetualsMarket = __esm({
|
|
|
10998
11735
|
|
|
10999
11736
|
// src/packages/perpetuals/perpetualsVault.ts
|
|
11000
11737
|
import {
|
|
11001
|
-
Transaction as
|
|
11738
|
+
Transaction as Transaction5
|
|
11002
11739
|
} from "@mysten/sui/transactions";
|
|
11003
11740
|
var PerpetualsVault;
|
|
11004
11741
|
var init_perpetualsVault = __esm({
|
|
@@ -11051,7 +11788,7 @@ var init_perpetualsVault = __esm({
|
|
|
11051
11788
|
...otherInputs,
|
|
11052
11789
|
vaultId: this.vaultObject.objectId,
|
|
11053
11790
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11054
|
-
tx: tx ?? new
|
|
11791
|
+
tx: tx ?? new Transaction5()
|
|
11055
11792
|
})
|
|
11056
11793
|
},
|
|
11057
11794
|
void 0,
|
|
@@ -11067,7 +11804,7 @@ var init_perpetualsVault = __esm({
|
|
|
11067
11804
|
...otherInputs,
|
|
11068
11805
|
vaultId: this.vaultObject.objectId,
|
|
11069
11806
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11070
|
-
tx: tx ?? new
|
|
11807
|
+
tx: tx ?? new Transaction5()
|
|
11071
11808
|
})
|
|
11072
11809
|
},
|
|
11073
11810
|
void 0,
|
|
@@ -11093,7 +11830,7 @@ var init_perpetualsVault = __esm({
|
|
|
11093
11830
|
...otherInputs,
|
|
11094
11831
|
vaultId: this.vaultObject.objectId,
|
|
11095
11832
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11096
|
-
tx: tx ?? new
|
|
11833
|
+
tx: tx ?? new Transaction5()
|
|
11097
11834
|
})
|
|
11098
11835
|
},
|
|
11099
11836
|
void 0,
|
|
@@ -11119,7 +11856,7 @@ var init_perpetualsVault = __esm({
|
|
|
11119
11856
|
...otherInputs,
|
|
11120
11857
|
vaultId: this.vaultObject.objectId,
|
|
11121
11858
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11122
|
-
tx: tx ?? new
|
|
11859
|
+
tx: tx ?? new Transaction5()
|
|
11123
11860
|
})
|
|
11124
11861
|
},
|
|
11125
11862
|
void 0,
|
|
@@ -11142,7 +11879,7 @@ var init_perpetualsVault = __esm({
|
|
|
11142
11879
|
...otherInputs,
|
|
11143
11880
|
vaultId: this.vaultObject.objectId,
|
|
11144
11881
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11145
|
-
tx: tx ?? new
|
|
11882
|
+
tx: tx ?? new Transaction5()
|
|
11146
11883
|
})
|
|
11147
11884
|
},
|
|
11148
11885
|
void 0,
|
|
@@ -11166,7 +11903,7 @@ var init_perpetualsVault = __esm({
|
|
|
11166
11903
|
...otherInputs,
|
|
11167
11904
|
vaultId: this.vaultObject.objectId,
|
|
11168
11905
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11169
|
-
tx: tx ?? new
|
|
11906
|
+
tx: tx ?? new Transaction5()
|
|
11170
11907
|
})
|
|
11171
11908
|
},
|
|
11172
11909
|
void 0,
|
|
@@ -11195,7 +11932,7 @@ var init_perpetualsVault = __esm({
|
|
|
11195
11932
|
...otherInputs,
|
|
11196
11933
|
vaultId: this.vaultObject.objectId,
|
|
11197
11934
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11198
|
-
tx: tx ?? new
|
|
11935
|
+
tx: tx ?? new Transaction5()
|
|
11199
11936
|
})
|
|
11200
11937
|
},
|
|
11201
11938
|
void 0,
|
|
@@ -11220,7 +11957,7 @@ var init_perpetualsVault = __esm({
|
|
|
11220
11957
|
...otherInputs,
|
|
11221
11958
|
vaultId: this.vaultObject.objectId,
|
|
11222
11959
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11223
|
-
tx: txFromInputs ?? new
|
|
11960
|
+
tx: txFromInputs ?? new Transaction5()
|
|
11224
11961
|
})
|
|
11225
11962
|
},
|
|
11226
11963
|
void 0,
|
|
@@ -11246,7 +11983,7 @@ var init_perpetualsVault = __esm({
|
|
|
11246
11983
|
...otherInputs,
|
|
11247
11984
|
vaultId: this.vaultObject.objectId,
|
|
11248
11985
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11249
|
-
tx: tx ?? new
|
|
11986
|
+
tx: tx ?? new Transaction5()
|
|
11250
11987
|
})
|
|
11251
11988
|
},
|
|
11252
11989
|
void 0,
|
|
@@ -11277,7 +12014,7 @@ var init_perpetualsVault = __esm({
|
|
|
11277
12014
|
...otherInputs,
|
|
11278
12015
|
vaultId: this.vaultObject.objectId,
|
|
11279
12016
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11280
|
-
tx: tx ?? new
|
|
12017
|
+
tx: tx ?? new Transaction5()
|
|
11281
12018
|
})
|
|
11282
12019
|
},
|
|
11283
12020
|
void 0,
|
|
@@ -11308,7 +12045,7 @@ var init_perpetualsVault = __esm({
|
|
|
11308
12045
|
...otherInputs,
|
|
11309
12046
|
vaultId: this.vaultObject.objectId,
|
|
11310
12047
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11311
|
-
tx: tx ?? new
|
|
12048
|
+
tx: tx ?? new Transaction5()
|
|
11312
12049
|
})
|
|
11313
12050
|
},
|
|
11314
12051
|
void 0,
|
|
@@ -11331,7 +12068,7 @@ var init_perpetualsVault = __esm({
|
|
|
11331
12068
|
...otherInputs,
|
|
11332
12069
|
vaultId: this.vaultObject.objectId,
|
|
11333
12070
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11334
|
-
tx: tx ?? new
|
|
12071
|
+
tx: tx ?? new Transaction5()
|
|
11335
12072
|
})
|
|
11336
12073
|
},
|
|
11337
12074
|
void 0,
|
|
@@ -11377,7 +12114,7 @@ var init_perpetualsVault = __esm({
|
|
|
11377
12114
|
...depositInputs,
|
|
11378
12115
|
vaultId: this.vaultObject.objectId,
|
|
11379
12116
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
11380
|
-
tx: tx ?? new
|
|
12117
|
+
tx: tx ?? new Transaction5()
|
|
11381
12118
|
})
|
|
11382
12119
|
},
|
|
11383
12120
|
void 0,
|
|
@@ -11692,7 +12429,7 @@ var init_perpetualsOrderUtils = __esm({
|
|
|
11692
12429
|
// Return price of given `order_id`, (works for ask or bid)
|
|
11693
12430
|
_PerpetualsOrderUtils.price = (orderId) => {
|
|
11694
12431
|
const side = Perpetuals.orderIdToSide(orderId);
|
|
11695
|
-
if (side ===
|
|
12432
|
+
if (side === PerpetualsOrderSide.Ask) {
|
|
11696
12433
|
return _PerpetualsOrderUtils.priceAsk(orderId);
|
|
11697
12434
|
}
|
|
11698
12435
|
return _PerpetualsOrderUtils.priceBid(orderId);
|
|
@@ -11725,7 +12462,7 @@ var init_utils2 = __esm({
|
|
|
11725
12462
|
|
|
11726
12463
|
// src/packages/perpetuals/perpetuals.ts
|
|
11727
12464
|
import {
|
|
11728
|
-
Transaction as
|
|
12465
|
+
Transaction as Transaction6
|
|
11729
12466
|
} from "@mysten/sui/transactions";
|
|
11730
12467
|
var _Perpetuals, Perpetuals;
|
|
11731
12468
|
var init_perpetuals = __esm({
|
|
@@ -11833,7 +12570,12 @@ var init_perpetuals = __esm({
|
|
|
11833
12570
|
const res = await this.fetchApi("markets", inputs);
|
|
11834
12571
|
return {
|
|
11835
12572
|
markets: res.marketDatas.map(
|
|
11836
|
-
(marketData) => new PerpetualsMarket(
|
|
12573
|
+
(marketData) => new PerpetualsMarket(
|
|
12574
|
+
marketData.market,
|
|
12575
|
+
this.config,
|
|
12576
|
+
this.api,
|
|
12577
|
+
marketData.metadata
|
|
12578
|
+
)
|
|
11837
12579
|
)
|
|
11838
12580
|
};
|
|
11839
12581
|
}
|
|
@@ -12095,12 +12837,12 @@ var init_perpetuals = __esm({
|
|
|
12095
12837
|
*/
|
|
12096
12838
|
// TODO: move to market class ?
|
|
12097
12839
|
getMarketCandleHistory(inputs) {
|
|
12098
|
-
const { marketId, fromTimestamp, toTimestamp,
|
|
12840
|
+
const { marketId, fromTimestamp, toTimestamp, resolution } = inputs;
|
|
12099
12841
|
return this.fetchApi("market/candle-history", {
|
|
12100
12842
|
marketId,
|
|
12101
12843
|
fromTimestamp,
|
|
12102
12844
|
toTimestamp,
|
|
12103
|
-
|
|
12845
|
+
resolution
|
|
12104
12846
|
});
|
|
12105
12847
|
}
|
|
12106
12848
|
/**
|
|
@@ -12194,7 +12936,7 @@ var init_perpetuals = __esm({
|
|
|
12194
12936
|
{
|
|
12195
12937
|
...otherInputs,
|
|
12196
12938
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
12197
|
-
tx: tx ?? new
|
|
12939
|
+
tx: tx ?? new Transaction6()
|
|
12198
12940
|
})
|
|
12199
12941
|
},
|
|
12200
12942
|
void 0,
|
|
@@ -12253,7 +12995,7 @@ var init_perpetuals = __esm({
|
|
|
12253
12995
|
{
|
|
12254
12996
|
...otherInputs,
|
|
12255
12997
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
12256
|
-
tx: tx ?? new
|
|
12998
|
+
tx: tx ?? new Transaction6()
|
|
12257
12999
|
})
|
|
12258
13000
|
},
|
|
12259
13001
|
void 0,
|
|
@@ -12288,7 +13030,7 @@ var init_perpetuals = __esm({
|
|
|
12288
13030
|
{
|
|
12289
13031
|
...otherInputs,
|
|
12290
13032
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
12291
|
-
tx: tx ?? new
|
|
13033
|
+
tx: tx ?? new Transaction6()
|
|
12292
13034
|
})
|
|
12293
13035
|
},
|
|
12294
13036
|
void 0,
|
|
@@ -12418,8 +13160,8 @@ var init_perpetuals = __esm({
|
|
|
12418
13160
|
*
|
|
12419
13161
|
* This endpoint creates a transaction that allows a user to grant permission to an
|
|
12420
13162
|
* integrator to receive fees on orders placed on their behalf. The user specifies
|
|
12421
|
-
* a maximum
|
|
12422
|
-
* include their
|
|
13163
|
+
* a maximum integrator fee that the integrator can charge. The integrator can then
|
|
13164
|
+
* include their id and fee (up to the maximum) when placing orders for the user.
|
|
12423
13165
|
*
|
|
12424
13166
|
* The resulting transaction must be signed by the account owner and executed on-chain.
|
|
12425
13167
|
*
|
|
@@ -12430,8 +13172,8 @@ var init_perpetuals = __esm({
|
|
|
12430
13172
|
* ```ts
|
|
12431
13173
|
* const tx = await perps.getCreateBuilderCodeIntegratorConfigTx({
|
|
12432
13174
|
* accountId: 123n,
|
|
12433
|
-
*
|
|
12434
|
-
*
|
|
13175
|
+
* integratorId: 7,
|
|
13176
|
+
* maxIntegratorFee: 0.001, // 0.1% max fee
|
|
12435
13177
|
* });
|
|
12436
13178
|
* ```
|
|
12437
13179
|
*/
|
|
@@ -12467,7 +13209,7 @@ var init_perpetuals = __esm({
|
|
|
12467
13209
|
* ```ts
|
|
12468
13210
|
* const tx = await perps.getRemoveBuilderCodeIntegratorConfigTx({
|
|
12469
13211
|
* accountId: 123n,
|
|
12470
|
-
*
|
|
13212
|
+
* integratorId: 7,
|
|
12471
13213
|
* });
|
|
12472
13214
|
* ```
|
|
12473
13215
|
*/
|
|
@@ -12486,13 +13228,12 @@ var init_perpetuals = __esm({
|
|
|
12486
13228
|
);
|
|
12487
13229
|
}
|
|
12488
13230
|
/**
|
|
12489
|
-
* Build a transaction to initialize an integrator fee vault
|
|
13231
|
+
* Build a transaction to initialize an integrator's global fee vault.
|
|
12490
13232
|
*
|
|
12491
|
-
* This endpoint creates a transaction that initializes
|
|
12492
|
-
* fees
|
|
12493
|
-
*
|
|
12494
|
-
*
|
|
12495
|
-
* integrator submits orders on behalf of users in that market.
|
|
13233
|
+
* This endpoint creates a transaction that initializes the global vault where an
|
|
13234
|
+
* integrator's fees accumulate across all markets. This is a one-time setup that
|
|
13235
|
+
* must be performed before the integrator can claim fees. The integrator's identity
|
|
13236
|
+
* is taken from the transaction sender on-chain.
|
|
12496
13237
|
*
|
|
12497
13238
|
* The resulting transaction must be signed by the integrator and executed on-chain.
|
|
12498
13239
|
*
|
|
@@ -12501,10 +13242,7 @@ var init_perpetuals = __esm({
|
|
|
12501
13242
|
*
|
|
12502
13243
|
* @example
|
|
12503
13244
|
* ```ts
|
|
12504
|
-
* const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({
|
|
12505
|
-
* marketId: "0x...",
|
|
12506
|
-
* integratorAddress: "0x...",
|
|
12507
|
-
* });
|
|
13245
|
+
* const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({});
|
|
12508
13246
|
* ```
|
|
12509
13247
|
*/
|
|
12510
13248
|
async getCreateBuilderCodeIntegratorVaultTx(inputs) {
|
|
@@ -12525,36 +13263,34 @@ var init_perpetuals = __esm({
|
|
|
12525
13263
|
* Build a transaction to claim accumulated integrator fees from a vault.
|
|
12526
13264
|
*
|
|
12527
13265
|
* 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
|
-
*
|
|
13266
|
+
* they have earned from orders placed on behalf of users. Fees accumulate in the
|
|
13267
|
+
* integrator's global vault (across all markets) and can be claimed at any moment.
|
|
13268
|
+
* The fees are proportional to the taker volume generated by the users' orders that
|
|
13269
|
+
* the integrator submitted.
|
|
12532
13270
|
*
|
|
12533
13271
|
* If a `recipientAddress` is provided, the claimed fees will be automatically
|
|
12534
|
-
* transferred to that address. Otherwise, the coin
|
|
12535
|
-
*
|
|
13272
|
+
* transferred to that address. Otherwise, the coin outputs are exposed as transaction
|
|
13273
|
+
* arguments for further use in the transaction (one per non-zero collateral balance).
|
|
12536
13274
|
*
|
|
12537
13275
|
* The resulting transaction must be signed by the integrator and executed on-chain.
|
|
12538
13276
|
*
|
|
12539
13277
|
* @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
|
|
12540
13278
|
* @returns {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse} containing
|
|
12541
|
-
* `txKind` and optionally `
|
|
13279
|
+
* `txKind` and optionally `coinOutArgs`.
|
|
12542
13280
|
*
|
|
12543
13281
|
* @example
|
|
12544
13282
|
* ```ts
|
|
12545
13283
|
* // Claim with automatic transfer to recipient
|
|
12546
13284
|
* const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
|
|
12547
|
-
*
|
|
12548
|
-
* integratorAddress: "0x...",
|
|
13285
|
+
* integratorId: 7,
|
|
12549
13286
|
* recipientAddress: "0x...",
|
|
12550
13287
|
* });
|
|
12551
13288
|
*
|
|
12552
|
-
* // Claim with coin
|
|
13289
|
+
* // Claim with coin outputs for further use
|
|
12553
13290
|
* const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
|
|
12554
|
-
*
|
|
12555
|
-
* integratorAddress: "0x...",
|
|
13291
|
+
* integratorId: 7,
|
|
12556
13292
|
* });
|
|
12557
|
-
* // response.
|
|
13293
|
+
* // response.coinOutArgs can be used in subsequent transaction commands
|
|
12558
13294
|
* ```
|
|
12559
13295
|
*/
|
|
12560
13296
|
async getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
|
|
@@ -12579,24 +13315,24 @@ var init_perpetuals = __esm({
|
|
|
12579
13315
|
*
|
|
12580
13316
|
* This endpoint queries whether an integrator has been approved by an account to collect
|
|
12581
13317
|
* fees on orders placed on behalf of the account. If approved, it returns the maximum
|
|
12582
|
-
*
|
|
13318
|
+
* integrator fee the integrator is authorized to charge. This information is useful for:
|
|
12583
13319
|
* - Verifying integrator permissions before placing orders
|
|
12584
13320
|
* - Displaying authorized integrators and their fee limits in UIs
|
|
12585
13321
|
* - Validating that an integrator's requested fee doesn't exceed the approved maximum
|
|
12586
13322
|
*
|
|
12587
13323
|
* @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorConfigBody}.
|
|
12588
13324
|
* @returns {@link ApiPerpetualsBuilderCodesIntegratorConfigResponse} containing
|
|
12589
|
-
* `
|
|
13325
|
+
* `maxIntegratorFee` and `exists` flag.
|
|
12590
13326
|
*
|
|
12591
13327
|
* @example
|
|
12592
13328
|
* ```ts
|
|
12593
13329
|
* const config = await perps.getBuilderCodeIntegratorConfig({
|
|
12594
13330
|
* accountId: 123n,
|
|
12595
|
-
*
|
|
13331
|
+
* integratorId: 7,
|
|
12596
13332
|
* });
|
|
12597
13333
|
*
|
|
12598
13334
|
* if (config.exists) {
|
|
12599
|
-
* console.log(`Integrator is approved with max fee: ${config.
|
|
13335
|
+
* console.log(`Integrator is approved with max fee: ${config.maxIntegratorFee}`);
|
|
12600
13336
|
* } else {
|
|
12601
13337
|
* console.log("Integrator is not approved for this account");
|
|
12602
13338
|
* }
|
|
@@ -12606,36 +13342,35 @@ var init_perpetuals = __esm({
|
|
|
12606
13342
|
return this.fetchApi("builder-codes/integrator-config", inputs);
|
|
12607
13343
|
}
|
|
12608
13344
|
/**
|
|
12609
|
-
* Fetch accumulated integrator vault fees
|
|
13345
|
+
* Fetch accumulated integrator vault fees.
|
|
12610
13346
|
*
|
|
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
|
|
13347
|
+
* This endpoint queries the total fees an integrator has earned and accumulated in
|
|
13348
|
+
* their global vault, grouped by collateral coin type. Integrators earn fees
|
|
13349
|
+
* proportional to the taker volume generated by orders they submit on behalf of
|
|
13350
|
+
* users. These fees can be claimed at any time using
|
|
13351
|
+
* {@link getClaimBuilderCodeIntegratorVaultFeesTx}.
|
|
12616
13352
|
*
|
|
12617
13353
|
* This information is useful for:
|
|
12618
13354
|
* - Displaying total claimable fees to integrators in dashboards
|
|
12619
|
-
* - Monitoring fee accrual across
|
|
12620
|
-
* - Determining
|
|
13355
|
+
* - Monitoring fee accrual across collateral types
|
|
13356
|
+
* - Determining whether fees are ready to be claimed
|
|
12621
13357
|
*
|
|
12622
13358
|
* @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
|
|
12623
13359
|
* @returns {@link ApiPerpetualsBuilderCodesIntegratorVaultsResponse} containing
|
|
12624
|
-
* a vector of
|
|
13360
|
+
* a vector of per-collateral vault data with accumulated fees.
|
|
12625
13361
|
*
|
|
12626
13362
|
* @example
|
|
12627
13363
|
* ```ts
|
|
12628
13364
|
* const vaultFees = await perps.getBuilderCodeIntegratorVaults({
|
|
12629
|
-
*
|
|
12630
|
-
* integratorAddress: "0x...",
|
|
13365
|
+
* integratorId: 7,
|
|
12631
13366
|
* });
|
|
12632
13367
|
*
|
|
12633
13368
|
* for (const vault of vaultFees.integratorVaults) {
|
|
12634
|
-
* console.log(
|
|
13369
|
+
* console.log(`${vault.collateralCoinType}: ${vault.fees} collateral units claimable`);
|
|
12635
13370
|
* }
|
|
12636
13371
|
*
|
|
12637
|
-
* const
|
|
12638
|
-
* console.log(`Total claimable: ${
|
|
13372
|
+
* const totalFeesUsd = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.feesUsd, 0);
|
|
13373
|
+
* console.log(`Total claimable (USD): ${totalFeesUsd}`);
|
|
12639
13374
|
* ```
|
|
12640
13375
|
*/
|
|
12641
13376
|
async getBuilderCodeIntegratorVaults(inputs) {
|
|
@@ -12653,7 +13388,7 @@ var init_perpetuals = __esm({
|
|
|
12653
13388
|
static positionSide(inputs) {
|
|
12654
13389
|
const baseAmount = inputs.baseAssetAmount;
|
|
12655
13390
|
const isLong = Math.sign(baseAmount);
|
|
12656
|
-
const side = isLong >= 0 ?
|
|
13391
|
+
const side = isLong >= 0 ? PerpetualsOrderSide.Bid : PerpetualsOrderSide.Ask;
|
|
12657
13392
|
return side;
|
|
12658
13393
|
}
|
|
12659
13394
|
/**
|
|
@@ -12849,6 +13584,20 @@ var init_perpetuals = __esm({
|
|
|
12849
13584
|
}
|
|
12850
13585
|
}
|
|
12851
13586
|
});
|
|
13587
|
+
const subscribeMarketCandles = ({
|
|
13588
|
+
marketId,
|
|
13589
|
+
interval
|
|
13590
|
+
}) => ctl.send({
|
|
13591
|
+
action: "subscribe",
|
|
13592
|
+
subscriptionType: { marketCandles: { marketId, interval } }
|
|
13593
|
+
});
|
|
13594
|
+
const unsubscribeMarketCandles = ({
|
|
13595
|
+
marketId,
|
|
13596
|
+
interval
|
|
13597
|
+
}) => ctl.send({
|
|
13598
|
+
action: "unsubscribe",
|
|
13599
|
+
subscriptionType: { marketCandles: { marketId, interval } }
|
|
13600
|
+
});
|
|
12852
13601
|
return {
|
|
12853
13602
|
ws: ctl.ws,
|
|
12854
13603
|
subscribeMarket,
|
|
@@ -12867,6 +13616,8 @@ var init_perpetuals = __esm({
|
|
|
12867
13616
|
unsubscribeUserCollateralChanges,
|
|
12868
13617
|
subscribeTopOfOrderbook,
|
|
12869
13618
|
unsubscribeTopOfOrderbook,
|
|
13619
|
+
subscribeMarketCandles,
|
|
13620
|
+
unsubscribeMarketCandles,
|
|
12870
13621
|
close: ctl.close
|
|
12871
13622
|
};
|
|
12872
13623
|
}
|
|
@@ -12896,19 +13647,27 @@ var init_perpetuals = __esm({
|
|
|
12896
13647
|
* ```
|
|
12897
13648
|
*/
|
|
12898
13649
|
openMarketCandlesWebsocketStream(args) {
|
|
12899
|
-
const { marketId,
|
|
12900
|
-
const
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
13650
|
+
const { marketId, interval, onMessage, onOpen, onError, onClose } = args;
|
|
13651
|
+
const ctl = this.openWsStream({
|
|
13652
|
+
path: "ws/updates",
|
|
13653
|
+
onMessage: (env) => {
|
|
13654
|
+
if ("marketCandles" in env) {
|
|
13655
|
+
onMessage({
|
|
13656
|
+
marketId: env.marketCandles.marketId,
|
|
13657
|
+
lastCandle: env.marketCandles.lastCandle
|
|
13658
|
+
});
|
|
13659
|
+
}
|
|
13660
|
+
},
|
|
13661
|
+
onOpen: (ev) => {
|
|
13662
|
+
ctl.send({
|
|
13663
|
+
action: "subscribe",
|
|
13664
|
+
subscriptionType: { marketCandles: { marketId, interval } }
|
|
13665
|
+
});
|
|
13666
|
+
onOpen?.(ev);
|
|
13667
|
+
},
|
|
13668
|
+
onError,
|
|
13669
|
+
onClose
|
|
13670
|
+
});
|
|
12912
13671
|
return {
|
|
12913
13672
|
ws: ctl.ws,
|
|
12914
13673
|
close: ctl.close
|
|
@@ -12953,7 +13712,7 @@ var init_perpetuals = __esm({
|
|
|
12953
13712
|
* @returns {@link PerpetualsOrderSide}.
|
|
12954
13713
|
*/
|
|
12955
13714
|
_Perpetuals.orderIdToSide = (orderId) => {
|
|
12956
|
-
return _Perpetuals.OrderUtils.isAsk(orderId) ?
|
|
13715
|
+
return _Perpetuals.OrderUtils.isAsk(orderId) ? PerpetualsOrderSide.Ask : PerpetualsOrderSide.Bid;
|
|
12957
13716
|
};
|
|
12958
13717
|
/**
|
|
12959
13718
|
* Construct a collateral-specialized Move event type string.
|
|
@@ -13048,7 +13807,7 @@ var init_referralVault2 = __esm({
|
|
|
13048
13807
|
});
|
|
13049
13808
|
|
|
13050
13809
|
// src/packages/router/router.ts
|
|
13051
|
-
import { Transaction as
|
|
13810
|
+
import { Transaction as Transaction7 } from "@mysten/sui/transactions";
|
|
13052
13811
|
var Router;
|
|
13053
13812
|
var init_router = __esm({
|
|
13054
13813
|
"src/packages/router/router.ts"() {
|
|
@@ -13249,7 +14008,7 @@ var init_router = __esm({
|
|
|
13249
14008
|
serializedTx: tx.serialize()
|
|
13250
14009
|
});
|
|
13251
14010
|
return {
|
|
13252
|
-
tx:
|
|
14011
|
+
tx: Transaction7.from(newTx),
|
|
13253
14012
|
coinOutId
|
|
13254
14013
|
};
|
|
13255
14014
|
}
|
|
@@ -14808,7 +15567,7 @@ var init_referrals = __esm({
|
|
|
14808
15567
|
});
|
|
14809
15568
|
|
|
14810
15569
|
// src/packages/rewards/rewards.ts
|
|
14811
|
-
import { Transaction as
|
|
15570
|
+
import { Transaction as Transaction8 } from "@mysten/sui/transactions";
|
|
14812
15571
|
var Rewards;
|
|
14813
15572
|
var init_rewards = __esm({
|
|
14814
15573
|
"src/packages/rewards/rewards.ts"() {
|
|
@@ -14837,6 +15596,15 @@ var init_rewards = __esm({
|
|
|
14837
15596
|
async getClaimable(inputs) {
|
|
14838
15597
|
return this.fetchApi("claimable", inputs);
|
|
14839
15598
|
}
|
|
15599
|
+
/**
|
|
15600
|
+
* Preview a single account's expected rewards for an epoch, broken down by
|
|
15601
|
+
* domain (trading, referral, AFLP, integrator) plus totals. Backed by the
|
|
15602
|
+
* newer `rewards/expectedRewards` endpoint. Provide exactly one of `address`
|
|
15603
|
+
* or `accountId`; omit `epoch` for the current epoch.
|
|
15604
|
+
*/
|
|
15605
|
+
async getExpectedRewards(inputs) {
|
|
15606
|
+
return this.fetchApi("expectedRewards", inputs);
|
|
15607
|
+
}
|
|
14840
15608
|
// =========================================================================
|
|
14841
15609
|
// Transactions
|
|
14842
15610
|
// =========================================================================
|
|
@@ -14847,7 +15615,7 @@ var init_rewards = __esm({
|
|
|
14847
15615
|
{
|
|
14848
15616
|
...otherInputs,
|
|
14849
15617
|
txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
|
|
14850
|
-
tx: tx ?? new
|
|
15618
|
+
tx: tx ?? new Transaction8()
|
|
14851
15619
|
})
|
|
14852
15620
|
},
|
|
14853
15621
|
void 0,
|
|
@@ -14899,7 +15667,7 @@ var init_userData = __esm({
|
|
|
14899
15667
|
*/
|
|
14900
15668
|
async getUserPublicKey(inputs) {
|
|
14901
15669
|
return this.fetchApi(
|
|
14902
|
-
|
|
15670
|
+
"public-key",
|
|
14903
15671
|
inputs
|
|
14904
15672
|
);
|
|
14905
15673
|
}
|
|
@@ -14922,7 +15690,7 @@ var init_userData = __esm({
|
|
|
14922
15690
|
*/
|
|
14923
15691
|
async createUserPublicKey(inputs) {
|
|
14924
15692
|
return this.fetchApi(
|
|
14925
|
-
|
|
15693
|
+
"save-public-key",
|
|
14926
15694
|
inputs
|
|
14927
15695
|
);
|
|
14928
15696
|
}
|
|
@@ -14942,7 +15710,7 @@ var init_userData = __esm({
|
|
|
14942
15710
|
*/
|
|
14943
15711
|
createUserAccountMessageToSign() {
|
|
14944
15712
|
return {
|
|
14945
|
-
action:
|
|
15713
|
+
action: "CREATE_USER_ACCOUNT"
|
|
14946
15714
|
};
|
|
14947
15715
|
}
|
|
14948
15716
|
/**
|
|
@@ -14961,7 +15729,7 @@ var init_userData = __esm({
|
|
|
14961
15729
|
*/
|
|
14962
15730
|
createSignTermsAndConditionsMessageToSign() {
|
|
14963
15731
|
return {
|
|
14964
|
-
action:
|
|
15732
|
+
action: "SIGN_TERMS_AND_CONDITIONS"
|
|
14965
15733
|
};
|
|
14966
15734
|
}
|
|
14967
15735
|
};
|
|
@@ -15136,6 +15904,7 @@ var init_coinApi = __esm({
|
|
|
15136
15904
|
"src/packages/coin/api/coinApi.ts"() {
|
|
15137
15905
|
"use strict";
|
|
15138
15906
|
init_transactionsApiHelpers();
|
|
15907
|
+
init_grpcCasting();
|
|
15139
15908
|
init_helpers();
|
|
15140
15909
|
init_coin();
|
|
15141
15910
|
_CoinApi = class _CoinApi {
|
|
@@ -15188,14 +15957,16 @@ var init_coinApi = __esm({
|
|
|
15188
15957
|
let allCoinData = [];
|
|
15189
15958
|
let cursor;
|
|
15190
15959
|
do {
|
|
15191
|
-
const paginatedCoins = await this.api.client.
|
|
15192
|
-
|
|
15960
|
+
const paginatedCoins = await this.api.client.listCoins({
|
|
15961
|
+
coinType: inputs.coinType,
|
|
15193
15962
|
owner: inputs.walletAddress,
|
|
15194
15963
|
cursor
|
|
15195
15964
|
});
|
|
15196
|
-
const coinData = paginatedCoins.
|
|
15965
|
+
const coinData = paginatedCoins.objects.map(
|
|
15966
|
+
GrpcCasting.coinStructFromGrpcCoin
|
|
15967
|
+
);
|
|
15197
15968
|
allCoinData = [...allCoinData, ...coinData];
|
|
15198
|
-
if (paginatedCoins.
|
|
15969
|
+
if (paginatedCoins.objects.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.cursor) {
|
|
15199
15970
|
allCoinData.sort(
|
|
15200
15971
|
(b, a) => Number(BigInt(a.balance) - BigInt(b.balance))
|
|
15201
15972
|
);
|
|
@@ -15210,7 +15981,7 @@ var init_coinApi = __esm({
|
|
|
15210
15981
|
}
|
|
15211
15982
|
throw new Error("wallet does not have coins of sufficient balance");
|
|
15212
15983
|
}
|
|
15213
|
-
cursor = paginatedCoins.
|
|
15984
|
+
cursor = paginatedCoins.cursor;
|
|
15214
15985
|
} while (true);
|
|
15215
15986
|
};
|
|
15216
15987
|
// fetchCoinsUntilAmountReachedOrEnd
|
|
@@ -15218,19 +15989,21 @@ var init_coinApi = __esm({
|
|
|
15218
15989
|
let allCoinData = [];
|
|
15219
15990
|
let cursor;
|
|
15220
15991
|
do {
|
|
15221
|
-
const paginatedCoins = await this.api.client.
|
|
15222
|
-
|
|
15992
|
+
const paginatedCoins = await this.api.client.listCoins({
|
|
15993
|
+
coinType: inputs.coinType,
|
|
15223
15994
|
owner: inputs.walletAddress,
|
|
15224
15995
|
cursor
|
|
15225
15996
|
});
|
|
15226
|
-
const coinData = paginatedCoins.
|
|
15997
|
+
const coinData = paginatedCoins.objects.map(
|
|
15998
|
+
GrpcCasting.coinStructFromGrpcCoin
|
|
15999
|
+
);
|
|
15227
16000
|
allCoinData = [...allCoinData, ...coinData];
|
|
15228
|
-
if (paginatedCoins.
|
|
16001
|
+
if (paginatedCoins.objects.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.cursor) {
|
|
15229
16002
|
return allCoinData.sort(
|
|
15230
16003
|
(b, a) => Number(BigInt(b.coinObjectId) - BigInt(a.coinObjectId))
|
|
15231
16004
|
);
|
|
15232
16005
|
}
|
|
15233
|
-
cursor = paginatedCoins.
|
|
16006
|
+
cursor = paginatedCoins.cursor;
|
|
15234
16007
|
} while (true);
|
|
15235
16008
|
};
|
|
15236
16009
|
}
|
|
@@ -15377,7 +16150,7 @@ var init_dcaApi = __esm({
|
|
|
15377
16150
|
|
|
15378
16151
|
// src/packages/farms/api/farmsApi.ts
|
|
15379
16152
|
import {
|
|
15380
|
-
Transaction as
|
|
16153
|
+
Transaction as Transaction9
|
|
15381
16154
|
} from "@mysten/sui/transactions";
|
|
15382
16155
|
var _FarmsApi, FarmsApi;
|
|
15383
16156
|
var init_farmsApi = __esm({
|
|
@@ -16439,6 +17212,49 @@ var init_farmsApi = __esm({
|
|
|
16439
17212
|
]
|
|
16440
17213
|
});
|
|
16441
17214
|
};
|
|
17215
|
+
/**
|
|
17216
|
+
* Creates a transaction command to set the minimum lock duration (ms) for a
|
|
17217
|
+
* staking pool. Owner-cap only; V2 vault module. Mirrors
|
|
17218
|
+
* `setStakingPoolMinStakeAmountTxV2`.
|
|
17219
|
+
*/
|
|
17220
|
+
this.setStakingPoolMinLockDurationMsTxV2 = (inputs) => {
|
|
17221
|
+
const { tx } = inputs;
|
|
17222
|
+
return tx.moveCall({
|
|
17223
|
+
target: Helpers.transactions.createTxTarget(
|
|
17224
|
+
this.addresses.packages.vaultsV2,
|
|
17225
|
+
_FarmsApi.constants.moduleNames.vaultV2,
|
|
17226
|
+
"set_min_lock_duration_ms"
|
|
17227
|
+
),
|
|
17228
|
+
typeArguments: [inputs.stakeCoinType],
|
|
17229
|
+
arguments: [
|
|
17230
|
+
tx.object(inputs.ownerCapId),
|
|
17231
|
+
tx.object(inputs.stakingPoolId),
|
|
17232
|
+
tx.object(this.addresses.objects.version),
|
|
17233
|
+
tx.pure.u64(inputs.lockDurationMs)
|
|
17234
|
+
]
|
|
17235
|
+
});
|
|
17236
|
+
};
|
|
17237
|
+
/**
|
|
17238
|
+
* Creates a transaction command to set the maximum lock duration (ms) for a
|
|
17239
|
+
* staking pool. Owner-cap only; V2 vault module.
|
|
17240
|
+
*/
|
|
17241
|
+
this.setStakingPoolMaxLockDurationMsTxV2 = (inputs) => {
|
|
17242
|
+
const { tx } = inputs;
|
|
17243
|
+
return tx.moveCall({
|
|
17244
|
+
target: Helpers.transactions.createTxTarget(
|
|
17245
|
+
this.addresses.packages.vaultsV2,
|
|
17246
|
+
_FarmsApi.constants.moduleNames.vaultV2,
|
|
17247
|
+
"set_max_lock_duration_ms"
|
|
17248
|
+
),
|
|
17249
|
+
typeArguments: [inputs.stakeCoinType],
|
|
17250
|
+
arguments: [
|
|
17251
|
+
tx.object(inputs.ownerCapId),
|
|
17252
|
+
tx.object(inputs.stakingPoolId),
|
|
17253
|
+
tx.object(this.addresses.objects.version),
|
|
17254
|
+
tx.pure.u64(inputs.lockDurationMs)
|
|
17255
|
+
]
|
|
17256
|
+
});
|
|
17257
|
+
};
|
|
16442
17258
|
/**
|
|
16443
17259
|
* Creates a Move call (V1) to **remove undistributed reward coins** from a staking pool.
|
|
16444
17260
|
* Only callable by the pool **owner** (validated via `ownerCapId`). This does not claw back
|
|
@@ -16563,7 +17379,7 @@ var init_farmsApi = __esm({
|
|
|
16563
17379
|
*/
|
|
16564
17380
|
this.fetchBuildStakeTxV1 = async (inputs) => {
|
|
16565
17381
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16566
|
-
const tx = new
|
|
17382
|
+
const tx = new Transaction9();
|
|
16567
17383
|
tx.setSender(walletAddress);
|
|
16568
17384
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16569
17385
|
tx,
|
|
@@ -16587,7 +17403,7 @@ var init_farmsApi = __esm({
|
|
|
16587
17403
|
*/
|
|
16588
17404
|
this.fetchBuildStakeTxV2 = async (inputs) => {
|
|
16589
17405
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16590
|
-
const tx = new
|
|
17406
|
+
const tx = new Transaction9();
|
|
16591
17407
|
tx.setSender(walletAddress);
|
|
16592
17408
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16593
17409
|
tx,
|
|
@@ -16613,7 +17429,7 @@ var init_farmsApi = __esm({
|
|
|
16613
17429
|
*/
|
|
16614
17430
|
this.fetchBuildDepositPrincipalTxV1 = async (inputs) => {
|
|
16615
17431
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16616
|
-
const tx = new
|
|
17432
|
+
const tx = new Transaction9();
|
|
16617
17433
|
tx.setSender(walletAddress);
|
|
16618
17434
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16619
17435
|
tx,
|
|
@@ -16636,7 +17452,7 @@ var init_farmsApi = __esm({
|
|
|
16636
17452
|
*/
|
|
16637
17453
|
this.fetchBuildDepositPrincipalTxV2 = async (inputs) => {
|
|
16638
17454
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16639
|
-
const tx = new
|
|
17455
|
+
const tx = new Transaction9();
|
|
16640
17456
|
tx.setSender(walletAddress);
|
|
16641
17457
|
const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16642
17458
|
tx,
|
|
@@ -16660,7 +17476,7 @@ var init_farmsApi = __esm({
|
|
|
16660
17476
|
*/
|
|
16661
17477
|
this.buildWithdrawPrincipalTxV1 = (inputs) => {
|
|
16662
17478
|
const { walletAddress } = inputs;
|
|
16663
|
-
const tx = new
|
|
17479
|
+
const tx = new Transaction9();
|
|
16664
17480
|
tx.setSender(walletAddress);
|
|
16665
17481
|
const withdrawnCoin = this.withdrawPrincipalTxV1({
|
|
16666
17482
|
...inputs,
|
|
@@ -16676,7 +17492,7 @@ var init_farmsApi = __esm({
|
|
|
16676
17492
|
*/
|
|
16677
17493
|
this.buildWithdrawPrincipalTxV2 = (inputs) => {
|
|
16678
17494
|
const { walletAddress } = inputs;
|
|
16679
|
-
const tx = new
|
|
17495
|
+
const tx = new Transaction9();
|
|
16680
17496
|
tx.setSender(walletAddress);
|
|
16681
17497
|
const withdrawnCoin = this.withdrawPrincipalTxV2({
|
|
16682
17498
|
...inputs,
|
|
@@ -16700,7 +17516,7 @@ var init_farmsApi = __esm({
|
|
|
16700
17516
|
stakedPositionIds: [inputs.stakedPositionId]
|
|
16701
17517
|
});
|
|
16702
17518
|
} else {
|
|
16703
|
-
tx = new
|
|
17519
|
+
tx = new Transaction9();
|
|
16704
17520
|
tx.setSender(walletAddress);
|
|
16705
17521
|
}
|
|
16706
17522
|
const withdrawnCoin = this.withdrawPrincipalTxV1({
|
|
@@ -16730,7 +17546,7 @@ var init_farmsApi = __esm({
|
|
|
16730
17546
|
stakedPositionIds: [inputs.stakedPositionId]
|
|
16731
17547
|
});
|
|
16732
17548
|
} else {
|
|
16733
|
-
tx = new
|
|
17549
|
+
tx = new Transaction9();
|
|
16734
17550
|
tx.setSender(walletAddress);
|
|
16735
17551
|
}
|
|
16736
17552
|
const withdrawnCoin = this.withdrawPrincipalTxV2({
|
|
@@ -16823,7 +17639,7 @@ var init_farmsApi = __esm({
|
|
|
16823
17639
|
*/
|
|
16824
17640
|
this.buildHarvestRewardsTxV1 = (inputs) => {
|
|
16825
17641
|
const { walletAddress, stakedPositionIds } = inputs;
|
|
16826
|
-
const tx = inputs.tx ?? new
|
|
17642
|
+
const tx = inputs.tx ?? new Transaction9();
|
|
16827
17643
|
tx.setSender(walletAddress);
|
|
16828
17644
|
const harvestRewardsCap = this.beginHarvestTxV1({
|
|
16829
17645
|
...inputs,
|
|
@@ -16875,7 +17691,7 @@ var init_farmsApi = __esm({
|
|
|
16875
17691
|
*/
|
|
16876
17692
|
this.buildHarvestRewardsTxV2 = (inputs) => {
|
|
16877
17693
|
const { walletAddress, stakedPositionIds } = inputs;
|
|
16878
|
-
const tx = inputs.tx ?? new
|
|
17694
|
+
const tx = inputs.tx ?? new Transaction9();
|
|
16879
17695
|
tx.setSender(walletAddress);
|
|
16880
17696
|
const firstPositionId = stakedPositionIds[0];
|
|
16881
17697
|
const harvestRewardsCap = this.beginHarvestTxV2({
|
|
@@ -16933,7 +17749,7 @@ var init_farmsApi = __esm({
|
|
|
16933
17749
|
*/
|
|
16934
17750
|
this.buildCreateStakingPoolTxV1 = (inputs) => {
|
|
16935
17751
|
const { walletAddress } = inputs;
|
|
16936
|
-
const tx = new
|
|
17752
|
+
const tx = new Transaction9();
|
|
16937
17753
|
tx.setSender(walletAddress);
|
|
16938
17754
|
const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV1({
|
|
16939
17755
|
...inputs,
|
|
@@ -16959,7 +17775,7 @@ var init_farmsApi = __esm({
|
|
|
16959
17775
|
*/
|
|
16960
17776
|
this.buildCreateStakingPoolTxV2 = (inputs) => {
|
|
16961
17777
|
const { walletAddress } = inputs;
|
|
16962
|
-
const tx = new
|
|
17778
|
+
const tx = new Transaction9();
|
|
16963
17779
|
tx.setSender(walletAddress);
|
|
16964
17780
|
const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV2({
|
|
16965
17781
|
...inputs,
|
|
@@ -16985,7 +17801,7 @@ var init_farmsApi = __esm({
|
|
|
16985
17801
|
*/
|
|
16986
17802
|
this.fetchBuildInitializeStakingPoolRewardTxV1 = async (inputs) => {
|
|
16987
17803
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
16988
|
-
const tx = new
|
|
17804
|
+
const tx = new Transaction9();
|
|
16989
17805
|
tx.setSender(walletAddress);
|
|
16990
17806
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
16991
17807
|
tx,
|
|
@@ -17004,7 +17820,7 @@ var init_farmsApi = __esm({
|
|
|
17004
17820
|
*/
|
|
17005
17821
|
this.fetchBuildInitializeStakingPoolRewardTxV2 = async (inputs) => {
|
|
17006
17822
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
17007
|
-
const tx = new
|
|
17823
|
+
const tx = new Transaction9();
|
|
17008
17824
|
tx.setSender(walletAddress);
|
|
17009
17825
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
17010
17826
|
tx,
|
|
@@ -17024,7 +17840,7 @@ var init_farmsApi = __esm({
|
|
|
17024
17840
|
*/
|
|
17025
17841
|
this.fetchBuildTopUpStakingPoolRewardsTxV1 = async (inputs) => {
|
|
17026
17842
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
17027
|
-
const tx = new
|
|
17843
|
+
const tx = new Transaction9();
|
|
17028
17844
|
tx.setSender(walletAddress);
|
|
17029
17845
|
for (const reward of inputs.rewards) {
|
|
17030
17846
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
@@ -17050,7 +17866,7 @@ var init_farmsApi = __esm({
|
|
|
17050
17866
|
*/
|
|
17051
17867
|
this.fetchBuildTopUpStakingPoolRewardsTxV2 = async (inputs) => {
|
|
17052
17868
|
const { walletAddress, isSponsoredTx } = inputs;
|
|
17053
|
-
const tx = new
|
|
17869
|
+
const tx = new Transaction9();
|
|
17054
17870
|
tx.setSender(walletAddress);
|
|
17055
17871
|
for (const reward of inputs.rewards) {
|
|
17056
17872
|
const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
@@ -17077,7 +17893,7 @@ var init_farmsApi = __esm({
|
|
|
17077
17893
|
*/
|
|
17078
17894
|
this.buildIncreaseStakingPoolRewardsEmissionsTxV1 = (inputs) => {
|
|
17079
17895
|
const { walletAddress } = inputs;
|
|
17080
|
-
const tx = new
|
|
17896
|
+
const tx = new Transaction9();
|
|
17081
17897
|
tx.setSender(walletAddress);
|
|
17082
17898
|
for (const reward of inputs.rewards) {
|
|
17083
17899
|
this.increaseStakingPoolRewardEmissionsTxV1({
|
|
@@ -17095,7 +17911,7 @@ var init_farmsApi = __esm({
|
|
|
17095
17911
|
*/
|
|
17096
17912
|
this.buildIncreaseStakingPoolRewardsEmissionsTxV2 = (inputs) => {
|
|
17097
17913
|
const { walletAddress } = inputs;
|
|
17098
|
-
const tx = new
|
|
17914
|
+
const tx = new Transaction9();
|
|
17099
17915
|
tx.setSender(walletAddress);
|
|
17100
17916
|
for (const reward of inputs.rewards) {
|
|
17101
17917
|
this.increaseStakingPoolRewardEmissionsTxV2({
|
|
@@ -17123,6 +17939,12 @@ var init_farmsApi = __esm({
|
|
|
17123
17939
|
this.buildSetStakingPoolMinStakeAmountTxV2 = Helpers.transactions.createBuildTxFunc(
|
|
17124
17940
|
this.setStakingPoolMinStakeAmountTxV2
|
|
17125
17941
|
);
|
|
17942
|
+
this.buildSetStakingPoolMinLockDurationMsTxV2 = Helpers.transactions.createBuildTxFunc(
|
|
17943
|
+
this.setStakingPoolMinLockDurationMsTxV2
|
|
17944
|
+
);
|
|
17945
|
+
this.buildSetStakingPoolMaxLockDurationMsTxV2 = Helpers.transactions.createBuildTxFunc(
|
|
17946
|
+
this.setStakingPoolMaxLockDurationMsTxV2
|
|
17947
|
+
);
|
|
17126
17948
|
/**
|
|
17127
17949
|
* Builds a transaction for **removing undistributed reward coins** from a staking pool (V1).
|
|
17128
17950
|
* Requires the pool **OwnerCap**. The removal is specific to a `rewardCoinType`.
|
|
@@ -17132,7 +17954,7 @@ var init_farmsApi = __esm({
|
|
|
17132
17954
|
*/
|
|
17133
17955
|
this.buildRemoveStakingPoolRewardTxV1 = (inputs) => {
|
|
17134
17956
|
const { walletAddress } = inputs;
|
|
17135
|
-
const tx = new
|
|
17957
|
+
const tx = new Transaction9();
|
|
17136
17958
|
tx.setSender(walletAddress);
|
|
17137
17959
|
for (const reward of inputs.rewards) {
|
|
17138
17960
|
this.removeStakingPoolRewardTxV1({
|
|
@@ -17152,7 +17974,7 @@ var init_farmsApi = __esm({
|
|
|
17152
17974
|
*/
|
|
17153
17975
|
this.buildRemoveStakingPoolRewardTxV2 = (inputs) => {
|
|
17154
17976
|
const { walletAddress } = inputs;
|
|
17155
|
-
const tx = new
|
|
17977
|
+
const tx = new Transaction9();
|
|
17156
17978
|
tx.setSender(walletAddress);
|
|
17157
17979
|
for (const reward of inputs.rewards) {
|
|
17158
17980
|
this.removeStakingPoolRewardTxV2({
|
|
@@ -17561,7 +18383,7 @@ var init_farmsApi = __esm({
|
|
|
17561
18383
|
|
|
17562
18384
|
// src/packages/faucet/api/faucetApi.ts
|
|
17563
18385
|
import {
|
|
17564
|
-
Transaction as
|
|
18386
|
+
Transaction as Transaction10
|
|
17565
18387
|
} from "@mysten/sui/transactions";
|
|
17566
18388
|
var _FaucetApi, FaucetApi;
|
|
17567
18389
|
var init_faucetApi = __esm({
|
|
@@ -17569,7 +18391,6 @@ var init_faucetApi = __esm({
|
|
|
17569
18391
|
"use strict";
|
|
17570
18392
|
init_eventsApiHelpers();
|
|
17571
18393
|
init_transactionsApiHelpers();
|
|
17572
|
-
init_utils();
|
|
17573
18394
|
init_coin2();
|
|
17574
18395
|
init_sui2();
|
|
17575
18396
|
init_faucetApiCasting();
|
|
@@ -17590,35 +18411,24 @@ var init_faucetApi = __esm({
|
|
|
17590
18411
|
// =========================================================================
|
|
17591
18412
|
// Transaction Commands
|
|
17592
18413
|
// =========================================================================
|
|
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
|
-
// };
|
|
18414
|
+
/**
|
|
18415
|
+
* Mints `coinType`'s configured default amount and returns the resulting
|
|
18416
|
+
* `Coin<T>`. Use {@link buildRequestCoinTx} to mint and transfer it to a
|
|
18417
|
+
* wallet in one transaction.
|
|
18418
|
+
*/
|
|
17612
18419
|
this.requestCoinTx = (inputs) => {
|
|
17613
18420
|
const { tx, coinType } = inputs;
|
|
17614
18421
|
return tx.moveCall({
|
|
17615
18422
|
target: TransactionsApiHelpers.createTxTarget(
|
|
17616
18423
|
this.addresses.packages.faucet,
|
|
17617
18424
|
_FaucetApi.constants.moduleNames.faucet,
|
|
17618
|
-
"
|
|
18425
|
+
"mint"
|
|
17619
18426
|
),
|
|
17620
18427
|
typeArguments: [coinType],
|
|
17621
|
-
arguments: [
|
|
18428
|
+
arguments: [
|
|
18429
|
+
tx.object(this.addresses.objects.faucet),
|
|
18430
|
+
tx.object(this.addresses.objects.config)
|
|
18431
|
+
]
|
|
17622
18432
|
});
|
|
17623
18433
|
};
|
|
17624
18434
|
this.mintSuiFrenTx = (inputs) => {
|
|
@@ -17643,12 +18453,17 @@ var init_faucetApi = __esm({
|
|
|
17643
18453
|
// =========================================================================
|
|
17644
18454
|
// Transaction Builders
|
|
17645
18455
|
// =========================================================================
|
|
17646
|
-
this.buildRequestCoinTx =
|
|
17647
|
-
|
|
17648
|
-
|
|
18456
|
+
this.buildRequestCoinTx = (inputs) => {
|
|
18457
|
+
const { walletAddress, coinType } = inputs;
|
|
18458
|
+
const tx = new Transaction10();
|
|
18459
|
+
tx.setSender(walletAddress);
|
|
18460
|
+
const coin = this.requestCoinTx({ tx, coinType });
|
|
18461
|
+
tx.transferObjects([coin], walletAddress);
|
|
18462
|
+
return tx;
|
|
18463
|
+
};
|
|
17649
18464
|
this.fetchBuildMintSuiFrenTx = async (inputs) => {
|
|
17650
18465
|
const { walletAddress, mintFee, suiFrenType } = inputs;
|
|
17651
|
-
const tx = new
|
|
18466
|
+
const tx = new Transaction10();
|
|
17652
18467
|
tx.setSender(walletAddress);
|
|
17653
18468
|
const suiPaymentCoinId = await this.api.Coin().fetchCoinWithAmountTx({
|
|
17654
18469
|
tx,
|
|
@@ -17662,7 +18477,6 @@ var init_faucetApi = __esm({
|
|
|
17662
18477
|
// =========================================================================
|
|
17663
18478
|
// Events
|
|
17664
18479
|
// =========================================================================
|
|
17665
|
-
// TODO: add to indexer
|
|
17666
18480
|
this.fetchMintCoinEvents = async (inputs) => await this.api.Events().fetchCastEventsWithCursor({
|
|
17667
18481
|
...inputs,
|
|
17668
18482
|
query: {
|
|
@@ -17670,7 +18484,6 @@ var init_faucetApi = __esm({
|
|
|
17670
18484
|
},
|
|
17671
18485
|
eventFromEventOnChain: FaucetApiCasting.faucetMintCoinEventFromOnChain
|
|
17672
18486
|
});
|
|
17673
|
-
// TODO: add to indexer
|
|
17674
18487
|
this.fetchAddCoinEvents = async (inputs) => await this.api.Events().fetchCastEventsWithCursor(
|
|
17675
18488
|
{
|
|
17676
18489
|
...inputs,
|
|
@@ -17721,7 +18534,7 @@ var init_faucetApi = __esm({
|
|
|
17721
18534
|
},
|
|
17722
18535
|
eventNames: {
|
|
17723
18536
|
mintCoin: "MintedCoin",
|
|
17724
|
-
addCoin: "
|
|
18537
|
+
addCoin: "AddedCoin"
|
|
17725
18538
|
}
|
|
17726
18539
|
};
|
|
17727
18540
|
FaucetApi = _FaucetApi;
|
|
@@ -17812,7 +18625,7 @@ var init_multisigApi = __esm({
|
|
|
17812
18625
|
|
|
17813
18626
|
// src/packages/nftAmm/api/nftAmmApi.ts
|
|
17814
18627
|
import {
|
|
17815
|
-
Transaction as
|
|
18628
|
+
Transaction as Transaction11
|
|
17816
18629
|
} from "@mysten/sui/transactions";
|
|
17817
18630
|
var _NftAmmApi, NftAmmApi;
|
|
17818
18631
|
var init_nftAmmApi = __esm({
|
|
@@ -17857,7 +18670,7 @@ var init_nftAmmApi = __esm({
|
|
|
17857
18670
|
// Transaction Builders
|
|
17858
18671
|
// =========================================================================
|
|
17859
18672
|
this.fetchBuildBuyTx = async (inputs) => {
|
|
17860
|
-
const tx = new
|
|
18673
|
+
const tx = new Transaction11();
|
|
17861
18674
|
tx.setSender(inputs.walletAddress);
|
|
17862
18675
|
const { market } = inputs;
|
|
17863
18676
|
const marketObject = market.market;
|
|
@@ -17883,7 +18696,7 @@ var init_nftAmmApi = __esm({
|
|
|
17883
18696
|
return tx;
|
|
17884
18697
|
};
|
|
17885
18698
|
this.fetchBuildSellTx = async (inputs) => {
|
|
17886
|
-
const tx = new
|
|
18699
|
+
const tx = new Transaction11();
|
|
17887
18700
|
tx.setSender(inputs.walletAddress);
|
|
17888
18701
|
const { market } = inputs;
|
|
17889
18702
|
const marketObject = market.market;
|
|
@@ -17903,7 +18716,7 @@ var init_nftAmmApi = __esm({
|
|
|
17903
18716
|
return tx;
|
|
17904
18717
|
};
|
|
17905
18718
|
this.fetchBuildDepositTx = async (inputs) => {
|
|
17906
|
-
const tx = new
|
|
18719
|
+
const tx = new Transaction11();
|
|
17907
18720
|
tx.setSender(inputs.walletAddress);
|
|
17908
18721
|
const { market } = inputs;
|
|
17909
18722
|
const marketObject = market.market;
|
|
@@ -17930,7 +18743,7 @@ var init_nftAmmApi = __esm({
|
|
|
17930
18743
|
return tx;
|
|
17931
18744
|
};
|
|
17932
18745
|
this.fetchBuildWithdrawTx = async (inputs) => {
|
|
17933
|
-
const tx = new
|
|
18746
|
+
const tx = new Transaction11();
|
|
17934
18747
|
tx.setSender(inputs.walletAddress);
|
|
17935
18748
|
const { market } = inputs;
|
|
17936
18749
|
const marketObject = market.market;
|
|
@@ -19547,9 +20360,9 @@ var init_perpetualsApi = __esm({
|
|
|
19547
20360
|
// src/packages/pools/api/poolsApi.ts
|
|
19548
20361
|
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
19549
20362
|
import {
|
|
19550
|
-
Transaction as
|
|
20363
|
+
Transaction as Transaction12
|
|
19551
20364
|
} from "@mysten/sui/transactions";
|
|
19552
|
-
import { fromBase64, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
20365
|
+
import { fromBase64 as fromBase642, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
19553
20366
|
var _PoolsApi, PoolsApi;
|
|
19554
20367
|
var init_poolsApi = __esm({
|
|
19555
20368
|
"src/packages/pools/api/poolsApi.ts"() {
|
|
@@ -19754,7 +20567,7 @@ var init_poolsApi = __esm({
|
|
|
19754
20567
|
const compiledModulesAndDeps = JSON.parse(compilations[lpCoinDecimals]);
|
|
19755
20568
|
return tx.publish({
|
|
19756
20569
|
modules: compiledModulesAndDeps.modules.map(
|
|
19757
|
-
(m) => Array.from(
|
|
20570
|
+
(m) => Array.from(fromBase642(m))
|
|
19758
20571
|
),
|
|
19759
20572
|
dependencies: compiledModulesAndDeps.dependencies.map(
|
|
19760
20573
|
(addr) => normalizeSuiObjectId(addr)
|
|
@@ -20072,7 +20885,7 @@ var init_poolsApi = __esm({
|
|
|
20072
20885
|
referrer,
|
|
20073
20886
|
isSponsoredTx
|
|
20074
20887
|
} = inputs;
|
|
20075
|
-
const tx = new
|
|
20888
|
+
const tx = new Transaction12();
|
|
20076
20889
|
tx.setSender(walletAddress);
|
|
20077
20890
|
if (referrer) {
|
|
20078
20891
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20168,7 +20981,7 @@ var init_poolsApi = __esm({
|
|
|
20168
20981
|
referrer,
|
|
20169
20982
|
isSponsoredTx
|
|
20170
20983
|
} = inputs;
|
|
20171
|
-
const tx = new
|
|
20984
|
+
const tx = new Transaction12();
|
|
20172
20985
|
tx.setSender(walletAddress);
|
|
20173
20986
|
if (referrer) {
|
|
20174
20987
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20234,7 +21047,7 @@ var init_poolsApi = __esm({
|
|
|
20234
21047
|
slippage,
|
|
20235
21048
|
referrer
|
|
20236
21049
|
} = inputs;
|
|
20237
|
-
const tx = new
|
|
21050
|
+
const tx = new Transaction12();
|
|
20238
21051
|
tx.setSender(walletAddress);
|
|
20239
21052
|
if (referrer) {
|
|
20240
21053
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20279,7 +21092,7 @@ var init_poolsApi = __esm({
|
|
|
20279
21092
|
*/
|
|
20280
21093
|
this.fetchBuildAllCoinWithdrawTx = async (inputs) => {
|
|
20281
21094
|
const { walletAddress, pool, lpCoinAmount, referrer } = inputs;
|
|
20282
|
-
const tx = new
|
|
21095
|
+
const tx = new Transaction12();
|
|
20283
21096
|
tx.setSender(walletAddress);
|
|
20284
21097
|
if (referrer) {
|
|
20285
21098
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -20325,7 +21138,7 @@ var init_poolsApi = __esm({
|
|
|
20325
21138
|
*/
|
|
20326
21139
|
this.buildPublishLpCoinTx = (inputs) => {
|
|
20327
21140
|
const { lpCoinDecimals } = inputs;
|
|
20328
|
-
const tx = new
|
|
21141
|
+
const tx = new Transaction12();
|
|
20329
21142
|
tx.setSender(inputs.walletAddress);
|
|
20330
21143
|
const upgradeCap = this.publishLpCoinTx({ tx, lpCoinDecimals });
|
|
20331
21144
|
tx.transferObjects([upgradeCap], inputs.walletAddress);
|
|
@@ -20567,7 +21380,7 @@ var init_poolsApi = __esm({
|
|
|
20567
21380
|
|
|
20568
21381
|
// src/packages/referralVault/api/referralVaultApi.ts
|
|
20569
21382
|
import { bcs as bcs3 } from "@mysten/sui/bcs";
|
|
20570
|
-
import { Transaction as
|
|
21383
|
+
import { Transaction as Transaction13 } from "@mysten/sui/transactions";
|
|
20571
21384
|
var _ReferralVaultApi, ReferralVaultApi;
|
|
20572
21385
|
var init_referralVaultApi = __esm({
|
|
20573
21386
|
"src/packages/referralVault/api/referralVaultApi.ts"() {
|
|
@@ -20668,7 +21481,7 @@ var init_referralVaultApi = __esm({
|
|
|
20668
21481
|
// Inspections
|
|
20669
21482
|
// =========================================================================
|
|
20670
21483
|
this.fetchBalanceOfRebate = async (inputs) => {
|
|
20671
|
-
const tx = new
|
|
21484
|
+
const tx = new Transaction13();
|
|
20672
21485
|
this.balanceOfRebateTx({ ...inputs, tx });
|
|
20673
21486
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
|
|
20674
21487
|
tx
|
|
@@ -20676,7 +21489,7 @@ var init_referralVaultApi = __esm({
|
|
|
20676
21489
|
return Casting.bigIntFromBytes(bytes);
|
|
20677
21490
|
};
|
|
20678
21491
|
this.fetchReferrer = async (inputs) => {
|
|
20679
|
-
const tx = new
|
|
21492
|
+
const tx = new Transaction13();
|
|
20680
21493
|
this.referrerForTx({ ...inputs, tx });
|
|
20681
21494
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
|
|
20682
21495
|
tx
|
|
@@ -20799,7 +21612,7 @@ var init_routerApi = __esm({
|
|
|
20799
21612
|
|
|
20800
21613
|
// src/packages/staking/api/stakingApi.ts
|
|
20801
21614
|
import {
|
|
20802
|
-
Transaction as
|
|
21615
|
+
Transaction as Transaction14
|
|
20803
21616
|
} from "@mysten/sui/transactions";
|
|
20804
21617
|
var _StakingApi, StakingApi;
|
|
20805
21618
|
var init_stakingApi = __esm({
|
|
@@ -21083,7 +21896,7 @@ var init_stakingApi = __esm({
|
|
|
21083
21896
|
if (externalFee) {
|
|
21084
21897
|
_StakingApi.assertValidExternalFee(externalFee);
|
|
21085
21898
|
}
|
|
21086
|
-
const tx = new
|
|
21899
|
+
const tx = new Transaction14();
|
|
21087
21900
|
tx.setSender(inputs.walletAddress);
|
|
21088
21901
|
if (referrer) {
|
|
21089
21902
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -21124,7 +21937,7 @@ var init_stakingApi = __esm({
|
|
|
21124
21937
|
if (externalFee) {
|
|
21125
21938
|
_StakingApi.assertValidExternalFee(externalFee);
|
|
21126
21939
|
}
|
|
21127
|
-
const tx = new
|
|
21940
|
+
const tx = new Transaction14();
|
|
21128
21941
|
tx.setSender(inputs.walletAddress);
|
|
21129
21942
|
if (referrer) {
|
|
21130
21943
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -21172,7 +21985,7 @@ var init_stakingApi = __esm({
|
|
|
21172
21985
|
*/
|
|
21173
21986
|
this.fetchBuildStakeStakedSuiTx = async (inputs) => {
|
|
21174
21987
|
const { referrer } = inputs;
|
|
21175
|
-
const tx = new
|
|
21988
|
+
const tx = new Transaction14();
|
|
21176
21989
|
tx.setSender(inputs.walletAddress);
|
|
21177
21990
|
if (referrer) {
|
|
21178
21991
|
this.api.ReferralVault().updateReferrerTx({
|
|
@@ -21189,7 +22002,7 @@ var init_stakingApi = __esm({
|
|
|
21189
22002
|
return tx;
|
|
21190
22003
|
};
|
|
21191
22004
|
this.buildUpdateValidatorFeeTx = async (inputs) => {
|
|
21192
|
-
const tx = new
|
|
22005
|
+
const tx = new Transaction14();
|
|
21193
22006
|
tx.setSender(inputs.walletAddress);
|
|
21194
22007
|
this.updateValidatorFeeTx({
|
|
21195
22008
|
...inputs,
|
|
@@ -21434,6 +22247,28 @@ var init_suiApi = __esm({
|
|
|
21434
22247
|
/**
|
|
21435
22248
|
* @deprecated Use `getSystemState()` method instead.
|
|
21436
22249
|
* This method will be removed in a future release.
|
|
22250
|
+
*
|
|
22251
|
+
* @remarks **Remaining JSON-RPC surface** — see
|
|
22252
|
+
* {@link AftermathApi.jsonRpcClient}. gRPC has no `SuiSystemStateSummary`
|
|
22253
|
+
* equivalent. `client.core.getCurrentSystemState()` carries no validators at
|
|
22254
|
+
* all, and while `client.ledgerService.getEpoch({ readMask: { paths:
|
|
22255
|
+
* ["system_state"] } })` does return them (verified: 125 active validators on
|
|
22256
|
+
* mainnet, under the runtime key `validators`, not the generated
|
|
22257
|
+
* `validatorSet`), its validator shape is not a superset of
|
|
22258
|
+
* `SuiValidatorSummary`: keys are renamed (`address`/`p2PAddress`/
|
|
22259
|
+
* `networkAddress`/`protocolPublicKey` vs `suiAddress`/`p2pAddress`/
|
|
22260
|
+
* `netAddress`/`protocolPubkeyBytes`), the staking-pool fields are nested
|
|
22261
|
+
* rather than flattened, numbers are `bigint` rather than decimal strings,
|
|
22262
|
+
* public keys are `Uint8Array` rather than base64, and
|
|
22263
|
+
* `stakingPoolDeactivationEpoch` / `validatorVeryLowStakeThreshold` are
|
|
22264
|
+
* absent entirely. Remapping it would change what this method returns.
|
|
22265
|
+
*
|
|
22266
|
+
* Note `Sui().getSystemState()` — the public method — does not touch the
|
|
22267
|
+
* fullnode; it reads the Aftermath API. Only this deprecated helper does.
|
|
22268
|
+
*
|
|
22269
|
+
* @throws If no `jsonRpcClient` was passed to {@link AftermathApi}, since it
|
|
22270
|
+
* is optional there.
|
|
22271
|
+
*
|
|
21437
22272
|
* @example
|
|
21438
22273
|
* ```typescript
|
|
21439
22274
|
* const afSdk = await Aftermath.create({ network: "MAINNET" });
|
|
@@ -21444,7 +22279,10 @@ var init_suiApi = __esm({
|
|
|
21444
22279
|
* console.log(systemState.epoch, systemState.validators);
|
|
21445
22280
|
*/
|
|
21446
22281
|
this.fetchSystemState = async () => {
|
|
21447
|
-
const
|
|
22282
|
+
const jsonRpcClient = this.api.requireJsonRpcClient(
|
|
22283
|
+
"Sui().fetchSystemState"
|
|
22284
|
+
);
|
|
22285
|
+
const systemState = await jsonRpcClient.getLatestSuiSystemState();
|
|
21448
22286
|
const activeValidators = systemState.activeValidators.map((validator) => ({
|
|
21449
22287
|
...validator,
|
|
21450
22288
|
suiAddress: Helpers.addLeadingZeroesToType(validator.suiAddress)
|
|
@@ -21461,7 +22299,7 @@ var init_suiApi = __esm({
|
|
|
21461
22299
|
|
|
21462
22300
|
// src/packages/suiFrens/api/suiFrensApi.ts
|
|
21463
22301
|
import {
|
|
21464
|
-
Transaction as
|
|
22302
|
+
Transaction as Transaction15
|
|
21465
22303
|
} from "@mysten/sui/transactions";
|
|
21466
22304
|
import { bcs as bcs4 } from "@mysten/sui/bcs";
|
|
21467
22305
|
var _SuiFrensApi, SuiFrensApi;
|
|
@@ -21487,7 +22325,7 @@ var init_suiFrensApi = __esm({
|
|
|
21487
22325
|
// Inspections
|
|
21488
22326
|
// =========================================================================
|
|
21489
22327
|
this.fetchMixingLimitsAndLastEpochMixeds = async (inputs) => {
|
|
21490
|
-
const tx = new
|
|
22328
|
+
const tx = new Transaction15();
|
|
21491
22329
|
this.devInspectMixLimitAndLastEpochMixedMulTx({ ...inputs, tx });
|
|
21492
22330
|
const [mixLimitBytes, lastEpochMixedBytes] = await this.api.Inspections().fetchAllBytesFromTxOutput({
|
|
21493
22331
|
tx
|
|
@@ -21501,7 +22339,7 @@ var init_suiFrensApi = __esm({
|
|
|
21501
22339
|
};
|
|
21502
22340
|
this.fetchMixingLimit = async (inputs) => {
|
|
21503
22341
|
if (inputs.suiFrenType === this.objectTypes.bullshark) return void 0;
|
|
21504
|
-
const tx = new
|
|
22342
|
+
const tx = new Transaction15();
|
|
21505
22343
|
this.mixingLimitTx({ tx, ...inputs });
|
|
21506
22344
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput(
|
|
21507
22345
|
{
|
|
@@ -21513,7 +22351,7 @@ var init_suiFrensApi = __esm({
|
|
|
21513
22351
|
};
|
|
21514
22352
|
this.fetchLastEpochMixed = async (inputs) => {
|
|
21515
22353
|
if (inputs.suiFrenType === this.objectTypes.bullshark) return void 0;
|
|
21516
|
-
const tx = new
|
|
22354
|
+
const tx = new Transaction15();
|
|
21517
22355
|
this.lastEpochMixedTx({ tx, ...inputs });
|
|
21518
22356
|
const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput(
|
|
21519
22357
|
{
|
|
@@ -21525,7 +22363,7 @@ var init_suiFrensApi = __esm({
|
|
|
21525
22363
|
};
|
|
21526
22364
|
this.fetchStakedSuiFrenMetadataIds = async (inputs) => {
|
|
21527
22365
|
const { suiFrenIds } = inputs;
|
|
21528
|
-
const tx = new
|
|
22366
|
+
const tx = new Transaction15();
|
|
21529
22367
|
this.devInspectMetadataObjectIdMulTx({ tx, suiFrenIds });
|
|
21530
22368
|
const idBytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
|
|
21531
22369
|
tx
|
|
@@ -21590,11 +22428,7 @@ var init_suiFrensApi = __esm({
|
|
|
21590
22428
|
const partialSuiFrens = await this.api.Objects().fetchCastObjectBatch({
|
|
21591
22429
|
objectIds: suiFrenIds,
|
|
21592
22430
|
objectFromSuiObjectResponse: Casting.suiFrens.partialSuiFrenObjectFromSuiObjectResponse,
|
|
21593
|
-
|
|
21594
|
-
showDisplay: true,
|
|
21595
|
-
showType: true,
|
|
21596
|
-
showContent: true
|
|
21597
|
-
}
|
|
22431
|
+
withDisplay: true
|
|
21598
22432
|
});
|
|
21599
22433
|
return this.fetchCompletePartialSuiFrenObjects({
|
|
21600
22434
|
partialSuiFrens,
|
|
@@ -21626,11 +22460,7 @@ var init_suiFrensApi = __esm({
|
|
|
21626
22460
|
const stakedSuiFrenData = await this.api.Objects().fetchCastObjectBatch({
|
|
21627
22461
|
objectIds: stakedSuiFrenIds,
|
|
21628
22462
|
objectFromSuiObjectResponse: Casting.suiFrens.partialSuiFrenAndStakedSuiFrenMetadataV1ObjectFromSuiObjectResponse,
|
|
21629
|
-
|
|
21630
|
-
showDisplay: true,
|
|
21631
|
-
showType: true,
|
|
21632
|
-
showContent: true
|
|
21633
|
-
}
|
|
22463
|
+
withDisplay: true
|
|
21634
22464
|
});
|
|
21635
22465
|
const suiFrens = await this.fetchCompletePartialSuiFrenObjects({
|
|
21636
22466
|
partialSuiFrens: stakedSuiFrenData.map((data) => data.partialSuiFren),
|
|
@@ -21675,11 +22505,7 @@ var init_suiFrensApi = __esm({
|
|
|
21675
22505
|
return this.api.Objects().fetchCastObjectBatch({
|
|
21676
22506
|
objectIds,
|
|
21677
22507
|
objectFromSuiObjectResponse: Casting.suiFrens.accessoryObjectFromSuiObjectResponse,
|
|
21678
|
-
|
|
21679
|
-
showDisplay: true,
|
|
21680
|
-
showType: true,
|
|
21681
|
-
showContent: true
|
|
21682
|
-
}
|
|
22508
|
+
withDisplay: true
|
|
21683
22509
|
});
|
|
21684
22510
|
};
|
|
21685
22511
|
// =========================================================================
|
|
@@ -22085,7 +22911,7 @@ var init_suiFrensApi = __esm({
|
|
|
22085
22911
|
baseFee,
|
|
22086
22912
|
isSponsoredTx
|
|
22087
22913
|
} = inputs;
|
|
22088
|
-
const tx = new
|
|
22914
|
+
const tx = new Transaction15();
|
|
22089
22915
|
tx.setSender(walletAddress);
|
|
22090
22916
|
const totalFee = baseFee + SuiFrens.calcTotalInternalMixFee({
|
|
22091
22917
|
mixFee1: suiFrenParentOne.mixFee,
|
|
@@ -22135,7 +22961,7 @@ var init_suiFrensApi = __esm({
|
|
|
22135
22961
|
// =========================================================================
|
|
22136
22962
|
this.fetchBuildHarvestFeesTx = async (inputs) => {
|
|
22137
22963
|
const { stakedPositionIds } = inputs;
|
|
22138
|
-
const tx = new
|
|
22964
|
+
const tx = new Transaction15();
|
|
22139
22965
|
tx.setSender(inputs.walletAddress);
|
|
22140
22966
|
const harvestFeesEventMetadataId = this.beginHarvestTx({ tx });
|
|
22141
22967
|
let harvestedCoins = [];
|
|
@@ -22398,26 +23224,17 @@ var init_nftsApi = __esm({
|
|
|
22398
23224
|
this.fetchOwnedNfts = async (inputs) => {
|
|
22399
23225
|
const objects = await this.api.Objects().fetchOwnedObjects({
|
|
22400
23226
|
...inputs,
|
|
22401
|
-
|
|
22402
|
-
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
showType: true,
|
|
22406
|
-
showDisplay: true
|
|
22407
|
-
}
|
|
23227
|
+
// @dev: `showDisplay` -> `withDisplay`, which becomes
|
|
23228
|
+
// `include: { display: true }`. `nftFromSuiObject` reads display, so
|
|
23229
|
+
// dropping this would leave every NFT with an empty one.
|
|
23230
|
+
withDisplay: true
|
|
22408
23231
|
});
|
|
22409
23232
|
return Casting.nfts.nftsFromSuiObjects(objects);
|
|
22410
23233
|
};
|
|
22411
23234
|
this.fetchNfts = async (inputs) => {
|
|
22412
23235
|
const objects = await this.api.Objects().fetchObjectBatch({
|
|
22413
23236
|
...inputs,
|
|
22414
|
-
|
|
22415
|
-
// NOTE: do we need all of this ?
|
|
22416
|
-
showContent: true,
|
|
22417
|
-
showOwner: true,
|
|
22418
|
-
showType: true,
|
|
22419
|
-
showDisplay: true
|
|
22420
|
-
}
|
|
23237
|
+
withDisplay: true
|
|
22421
23238
|
});
|
|
22422
23239
|
return Casting.nfts.nftsFromSuiObjects(objects);
|
|
22423
23240
|
};
|
|
@@ -22451,7 +23268,7 @@ var init_nftsApi = __esm({
|
|
|
22451
23268
|
const { kioskOwnerCapIds } = inputs;
|
|
22452
23269
|
return this.api.Objects().fetchCastObjectBatch({
|
|
22453
23270
|
objectIds: kioskOwnerCapIds,
|
|
22454
|
-
objectFromSuiObjectResponse: (
|
|
23271
|
+
objectFromSuiObjectResponse: (object) => object.type && Helpers.addLeadingZeroesToType(object.type) === this.objectTypes.personalKioskCap ? Casting.nfts.kioskOwnerCapFromPersonalKioskCapSuiObject(object) : Casting.nfts.kioskOwnerCapFromSuiObject(object)
|
|
22455
23272
|
});
|
|
22456
23273
|
};
|
|
22457
23274
|
this.fetchKiosks = async (inputs) => {
|
|
@@ -22524,25 +23341,35 @@ var init_walletApi = __esm({
|
|
|
22524
23341
|
// =========================================================================
|
|
22525
23342
|
this.fetchCoinBalance = async (inputs) => {
|
|
22526
23343
|
const { walletAddress, coin } = inputs;
|
|
22527
|
-
const
|
|
23344
|
+
const { balance } = await this.api.client.getBalance({
|
|
22528
23345
|
owner: walletAddress,
|
|
22529
23346
|
coinType: Helpers.stripLeadingZeroesFromType(coin)
|
|
22530
23347
|
});
|
|
22531
|
-
return BigInt(
|
|
23348
|
+
return BigInt(balance.balance);
|
|
22532
23349
|
};
|
|
22533
23350
|
// TODO: make toBigIntSafe function ?
|
|
22534
23351
|
// TODO: return prices here as well and sort ?
|
|
22535
23352
|
this.fetchAllCoinBalances = async (inputs) => {
|
|
22536
23353
|
const { walletAddress } = inputs;
|
|
22537
|
-
const allBalances =
|
|
22538
|
-
|
|
22539
|
-
|
|
23354
|
+
const allBalances = [];
|
|
23355
|
+
let cursor;
|
|
23356
|
+
do {
|
|
23357
|
+
const page = await this.api.client.listBalances({
|
|
23358
|
+
owner: walletAddress,
|
|
23359
|
+
cursor
|
|
23360
|
+
});
|
|
23361
|
+
allBalances.push(...page.balances);
|
|
23362
|
+
if (page.balances.length === 0 || !page.hasNextPage || !page.cursor) {
|
|
23363
|
+
break;
|
|
23364
|
+
}
|
|
23365
|
+
cursor = page.cursor;
|
|
23366
|
+
} while (true);
|
|
22540
23367
|
const coinsToBalance = allBalances.reduce(
|
|
22541
23368
|
(acc, balance) => {
|
|
22542
23369
|
return {
|
|
22543
23370
|
...acc,
|
|
22544
23371
|
[Helpers.addLeadingZeroesToType(balance.coinType)]: BigInt(
|
|
22545
|
-
balance.
|
|
23372
|
+
balance.balance
|
|
22546
23373
|
)
|
|
22547
23374
|
};
|
|
22548
23375
|
},
|
|
@@ -22608,12 +23435,44 @@ var init_aftermathApi = __esm({
|
|
|
22608
23435
|
* Constructs a new instance of the `AftermathApi`, binding the given Sui client
|
|
22609
23436
|
* to the known `addresses`.
|
|
22610
23437
|
*
|
|
22611
|
-
* @param client - A `
|
|
23438
|
+
* @param client - A `SuiGrpcClient` for on-chain queries and transactions.
|
|
22612
23439
|
* @param addresses - The config addresses (object IDs, package IDs, etc.) for the Aftermath protocol.
|
|
22613
|
-
|
|
22614
|
-
|
|
23440
|
+
* @param jsonRpcClient - **Optional.** A `SuiJsonRpcClient` pointed at the same
|
|
23441
|
+
* fullnode. Only used by the three legacy helpers listed on
|
|
23442
|
+
* {@link AftermathApi.jsonRpcClient}; every other call goes over gRPC via
|
|
23443
|
+
* `client`. Omit it unless you call one of those three — they then throw a
|
|
23444
|
+
* descriptive error instead of failing against a deprecated protocol. See
|
|
23445
|
+
* {@link AftermathApi.requireJsonRpcClient}.
|
|
23446
|
+
*/
|
|
23447
|
+
constructor(client, addresses, jsonRpcClient) {
|
|
22615
23448
|
this.client = client;
|
|
22616
23449
|
this.addresses = addresses;
|
|
23450
|
+
this.jsonRpcClient = jsonRpcClient;
|
|
23451
|
+
// =========================================================================
|
|
23452
|
+
// Legacy JSON-RPC Access
|
|
23453
|
+
// =========================================================================
|
|
23454
|
+
/**
|
|
23455
|
+
* Returns the optional {@link AftermathApi.jsonRpcClient}, throwing a
|
|
23456
|
+
* descriptive error when it was not supplied.
|
|
23457
|
+
*
|
|
23458
|
+
* Used by the three helpers that have no `SuiGrpcClient` equivalent. The
|
|
23459
|
+
* throw is deliberate: these helpers cannot degrade to an empty result
|
|
23460
|
+
* without silently lying to their callers, and JSON-RPC is scheduled for
|
|
23461
|
+
* removal from Sui fullnodes in mid-October 2026, so a missing client is a
|
|
23462
|
+
* configuration error worth naming rather than hiding.
|
|
23463
|
+
*
|
|
23464
|
+
* @param methodName - The public helper the caller invoked, e.g.
|
|
23465
|
+
* `"Events().fetchCastEventsWithCursor"`. Named in the error message.
|
|
23466
|
+
* @throws If no `jsonRpcClient` was passed to the constructor.
|
|
23467
|
+
*/
|
|
23468
|
+
this.requireJsonRpcClient = (methodName) => {
|
|
23469
|
+
if (!this.jsonRpcClient) {
|
|
23470
|
+
throw new Error(
|
|
23471
|
+
`${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.`
|
|
23472
|
+
);
|
|
23473
|
+
}
|
|
23474
|
+
return this.jsonRpcClient;
|
|
23475
|
+
};
|
|
22617
23476
|
// =========================================================================
|
|
22618
23477
|
// Class Object Creation
|
|
22619
23478
|
// =========================================================================
|
|
@@ -22789,6 +23648,7 @@ var init_aftermathApi = __esm({
|
|
|
22789
23648
|
});
|
|
22790
23649
|
|
|
22791
23650
|
// src/general/providers/aftermath.ts
|
|
23651
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
22792
23652
|
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
22793
23653
|
var _Aftermath, Aftermath;
|
|
22794
23654
|
var init_aftermath = __esm({
|
|
@@ -22895,28 +23755,32 @@ var init_aftermath = __esm({
|
|
|
22895
23755
|
* returns a ready-to-use instance. Pass `addresses` or `api` to skip
|
|
22896
23756
|
* the corresponding bootstrap steps.
|
|
22897
23757
|
*/
|
|
22898
|
-
static async create(options = {}) {
|
|
23758
|
+
static async create(options = {}, abortSignal) {
|
|
22899
23759
|
const af = new _Aftermath(options);
|
|
22900
|
-
await af.bootstrap();
|
|
23760
|
+
await af.bootstrap(abortSignal);
|
|
22901
23761
|
return af;
|
|
22902
23762
|
}
|
|
22903
23763
|
/**
|
|
22904
23764
|
* Resolves addresses and wires up the internal `AftermathApi`. Called
|
|
22905
23765
|
* exactly once by the {@link Aftermath.create} factory.
|
|
22906
23766
|
*/
|
|
22907
|
-
async bootstrap() {
|
|
23767
|
+
async bootstrap(abortSignal) {
|
|
22908
23768
|
if (this.options.api) {
|
|
22909
23769
|
this.api = this.options.api;
|
|
22910
23770
|
return;
|
|
22911
23771
|
}
|
|
22912
23772
|
const network = this.network;
|
|
22913
|
-
const addresses = this.options.addresses ?? await this.getAddresses();
|
|
23773
|
+
const addresses = this.options.addresses ?? await this.getAddresses(abortSignal);
|
|
22914
23774
|
const fullnodeUrl = this.options.fullnodeUrl ?? Caller.defaultFullnodeUrl(network);
|
|
22915
|
-
const client = new
|
|
23775
|
+
const client = new SuiGrpcClient({
|
|
23776
|
+
network: network.toLowerCase(),
|
|
23777
|
+
baseUrl: fullnodeUrl
|
|
23778
|
+
});
|
|
23779
|
+
const jsonRpcClient = new SuiJsonRpcClient({
|
|
22916
23780
|
url: fullnodeUrl,
|
|
22917
23781
|
network: network.toLowerCase()
|
|
22918
23782
|
});
|
|
22919
|
-
this.api = new AftermathApi(client, addresses);
|
|
23783
|
+
this.api = new AftermathApi(client, addresses, jsonRpcClient);
|
|
22920
23784
|
}
|
|
22921
23785
|
// =========================================================================
|
|
22922
23786
|
// Public Accessors
|
|
@@ -22938,8 +23802,8 @@ var init_aftermath = __esm({
|
|
|
22938
23802
|
* directly from the API. Typically you don't need to call this — the
|
|
22939
23803
|
* `create` factory handles it. Useful for cache warmers or tooling.
|
|
22940
23804
|
*/
|
|
22941
|
-
getAddresses() {
|
|
22942
|
-
return this.fetchApi("addresses");
|
|
23805
|
+
getAddresses(abortSignal) {
|
|
23806
|
+
return this.fetchApi("addresses", void 0, abortSignal);
|
|
22943
23807
|
}
|
|
22944
23808
|
/**
|
|
22945
23809
|
* Attempts to decode a raw Move abort/error string into a structured
|
|
@@ -22986,6 +23850,7 @@ init_index();
|
|
|
22986
23850
|
export {
|
|
22987
23851
|
Aftermath,
|
|
22988
23852
|
AftermathApi,
|
|
23853
|
+
AftermathTransportError,
|
|
22989
23854
|
Auth,
|
|
22990
23855
|
Casting,
|
|
22991
23856
|
Coin,
|
|
@@ -22994,6 +23859,7 @@ export {
|
|
|
22994
23859
|
FarmsStakingPool,
|
|
22995
23860
|
Faucet,
|
|
22996
23861
|
GasPools,
|
|
23862
|
+
GrpcCasting,
|
|
22997
23863
|
Helpers,
|
|
22998
23864
|
NftAmm,
|
|
22999
23865
|
Perpetuals,
|
|
@@ -23001,6 +23867,7 @@ export {
|
|
|
23001
23867
|
PerpetualsMarket,
|
|
23002
23868
|
PerpetualsOrderSide,
|
|
23003
23869
|
PerpetualsOrderType,
|
|
23870
|
+
PerpetualsStopOrderTriggerPriceType,
|
|
23004
23871
|
PerpetualsStopOrderType,
|
|
23005
23872
|
PerpetualsVault,
|
|
23006
23873
|
Pool,
|
|
@@ -23013,6 +23880,7 @@ export {
|
|
|
23013
23880
|
SuiFren,
|
|
23014
23881
|
SuiFrens,
|
|
23015
23882
|
SuiFrensSortOption,
|
|
23883
|
+
isAftermathTransportError,
|
|
23016
23884
|
isAllocatedCollateralEvent,
|
|
23017
23885
|
isCanceledOrderEvent,
|
|
23018
23886
|
isDeallocatedCollateralEvent,
|