aftermath-ts-sdk 2.1.0 → 2.2.0-abort.1

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/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.getDynamicFields({
94
- ...inputs,
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 dynamicFields = dynamicFieldType === void 0 ? dynamicFieldsResponse.data : dynamicFieldsResponse.data.filter(
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.nextCursor;
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
- this.fetchDynamicFieldObject = (inputs) => {
111
- return this.api.client.getDynamicFieldObject(inputs);
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 `subscribeEvent` was removed from `SuiJsonRpcClient` in
146
- * `@mysten/sui` v2. Poll `queryEvents` instead or use a WebSocket transport.
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 supported in @mysten/sui v2. subscribeEvent was removed from SuiJsonRpcClient. Poll queryEvents instead or use a WebSocket transport."
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 fetchedEvents = await this.api.client.queryEvents({
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 response = await this.api.client.devInspectTransactionBlock({
299
- sender,
300
- transactionBlock: inputs.tx
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
- if (response.effects.status.status === "failure") {
303
- throw new Error(
304
- response.effects.status.error ?? response.error ?? "dev inspect failed"
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 (!response.results) {
590
+ if (!simulation.commandResults) {
308
591
  throw new Error("dev inspect move call returned no results");
309
592
  }
310
- const resultBytes = response.results.map(
311
- (result) => result.returnValues?.map((val) => val[0]) ?? []
593
+ const resultBytes = simulation.commandResults.map(
594
+ (result) => result.returnValues.map((val) => Array.from(val.bcs))
312
595
  );
313
596
  return {
314
- events: response.events,
315
- effects: response.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
- const object = await this.api.client.getObject({ id: objectId });
348
- return object.error === void 0;
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.data?.owner;
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, filter } = inputs;
661
+ const { walletAddress, withDisplay, objectType } = inputs;
375
662
  let allObjectData = [];
376
663
  let cursor;
377
664
  do {
378
- const paginatedObjects = await this.api.client.getOwnedObjects({
665
+ const paginatedObjects = await this.api.client.listOwnedObjects({
379
666
  owner: walletAddress,
380
- options: inputs.options ?? {
381
- showContent: true,
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
- const objectData = paginatedObjects.data;
391
- allObjectData = [...allObjectData, ...objectData];
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.nextCursor;
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
- options: {
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, options } = inputs;
412
- const object = await this.api.client.getObject({
413
- id: objectId,
414
- options
415
- });
416
- if (object.error !== void 0) {
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: ${object.error?.code}`
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, options } = inputs;
704
+ const { objectId, objectFromSuiObjectResponse, include } = inputs;
428
705
  return objectFromSuiObjectResponse(
429
- await this.fetchObjectGeneral({ objectId, options })
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, options } = inputs;
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
- (objectIds2) => this.api.client.multiGetObjects({
448
- ids: objectIds2,
449
- options: options === void 0 ? {
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
- const objectBatch = objectBatches.reduce(
458
- (acc, objects) => [...acc, ...objects],
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
- (SuiObjectResponse) => {
466
- return inputs.objectFromSuiObjectResponse(SuiObjectResponse);
467
- }
750
+ (object) => inputs.objectFromSuiObjectResponse(object)
468
751
  );
469
752
  };
470
753
  this.fetchCastObjectsOwnedByAddressOfType = async (inputs) => {
471
- const objects = (await this.fetchObjectsOfTypeOwnedByAddress(inputs)).map(
472
- (SuiObjectResponse) => {
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
- const objectResponse = await this.api.client.getObject({
483
- id: objectId,
484
- options: { showBcs: true }
485
- });
486
- if (objectResponse.error !== void 0) {
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: ${objectResponse.error?.code}`
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 transactionsWithCursor = await this.api.client.queryTransactionBlocks(
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 [txResponse, referenceGasPrice] = await Promise.all([
585
- this.api.client.dryRunTransactionBlock({
586
- transactionBlock: await tx.build({
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 gasData = txResponse.effects.gasUsed;
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 Transaction();
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 `SuiObjectResponse`,
919
- * normalizing it with leading zeroes if necessary.
920
- *
921
- * @param data - The object response from Sui.
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.data?.type;
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.data?.objectId}`);
1254
+ throw new Error(`no object type found on ${data?.objectId}`);
931
1255
  }
932
1256
  /**
933
- * Extracts the object ID from a `SuiObjectResponse`, normalizing it with leading zeroes.
1257
+ * Extracts the object ID from a gRPC object view, normalizing it with
1258
+ * leading zeroes.
934
1259
  *
935
- * @param data - The object response from Sui.
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.data?.objectId;
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.data?.type}`);
1269
+ throw new Error(`no object id found on ${data?.type}`);
945
1270
  }
946
1271
  /**
947
- * Retrieves the fields of a Move object from a `SuiObjectResponse`.
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
- * @param data - The Sui object response containing a Move object.
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
- try {
956
- const content = data.data?.content;
957
- return content.fields;
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 Sui object response, if present.
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 response.
1312
+ * @param data - The Sui object view.
966
1313
  * @returns The display fields for that object.
967
- * @throws If display fields are not found.
1314
+ * @throws If display was not requested at the fetch site.
968
1315
  */
969
1316
  static getObjectDisplay(data) {
970
- const display = data.data?.display;
971
- if (display) {
972
- return display;
1317
+ const display = data?.display;
1318
+ if (display === void 0) {
1319
+ throw new Error(`no object display found on ${data?.objectId}`);
973
1320
  }
974
- throw new Error(`no object display found on ${data.data?.objectId}`);
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 Transaction2 } from "@mysten/sui/transactions";
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
- return `${safeUrl}/${this.apiEndpoint}/${this.apiUrlPrefix + (url === "" ? "" : "/")}${url}`;
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 Error(`HTTP ${status} ${response.statusText}: ${body}`);
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
- const output = disableBigIntJsonParsing ? JSON.parse(text, (_key, value) => value === null ? void 0 : value) : Helpers.parseJsonWithBigint(text);
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
- const apiCallUrl = this.urlForApiCall(url);
1593
- const headers = {
1594
- "Content-Type": "application/json",
1595
- ...this.config.accessToken ? { Authorization: `Bearer ${this.config.accessToken}` } : {}
1596
- };
1597
- const uncastResponse = await (body === void 0 ? fetch(apiCallUrl, { headers, signal }) : fetch(apiCallUrl, {
1598
- method: "POST",
1599
- body: JSON.stringify(body, bigIntReplacer),
1600
- headers,
1601
- signal
1602
- }));
1603
- return _Caller.fetchResponseToType(
1604
- uncastResponse,
1605
- !!options?.disableBigIntJsonParsing
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 ? Transaction2.fromKind(txKind) : Transaction2.from(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 ? Transaction2.from(response.txKind) : Transaction2.fromKind(response.txKind);
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 prefix = `${this.apiEndpoint}/${this.apiUrlPrefix}`;
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
- coins: [inputs.coin]
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(inputs);
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({ coins: [coinType] });
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
- coin: coinType
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: fields.cap.fields.for
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(poolFieldsOnChain.lp_supply.type)
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
- ...poolFieldsOnChain.coin_decimals ? {
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(poolFieldsOnChain.lp_supply.fields.value),
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 pool = PoolsApiCasting.poolObjectFromSuiObject(fields.pool);
2908
- const fractionalizedCoinType = Coin.getInnerCoinType(fields.supply.type);
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: fields.nfts.fields.id.id,
2919
- size: BigInt(fields.nfts.fields.size)
3480
+ objectId: GrpcCasting.unwrapUid(nfts.id),
3481
+ size: BigInt(nfts.size)
2920
3482
  },
2921
- fractionalizedSupply: BigInt(fields.supply.fields.value),
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 = /* @__PURE__ */ ((PerpetualsOrderSide2) => {
2938
- PerpetualsOrderSide2[PerpetualsOrderSide2["Ask"] = 1] = "Ask";
2939
- PerpetualsOrderSide2[PerpetualsOrderSide2["Bid"] = 0] = "Bid";
2940
- return PerpetualsOrderSide2;
2941
- })(PerpetualsOrderSide || {});
2942
- PerpetualsOrderType = /* @__PURE__ */ ((PerpetualsOrderType2) => {
2943
- PerpetualsOrderType2[PerpetualsOrderType2["Standard"] = 0] = "Standard";
2944
- PerpetualsOrderType2[PerpetualsOrderType2["FillOrKill"] = 1] = "FillOrKill";
2945
- PerpetualsOrderType2[PerpetualsOrderType2["PostOnly"] = 2] = "PostOnly";
2946
- PerpetualsOrderType2[PerpetualsOrderType2["ImmediateOrCancel"] = 3] = "ImmediateOrCancel";
2947
- return PerpetualsOrderType2;
2948
- })(PerpetualsOrderType || {});
2949
- PerpetualsStopOrderType = /* @__PURE__ */ ((PerpetualsStopOrderType2) => {
2950
- PerpetualsStopOrderType2[PerpetualsStopOrderType2["SlTp"] = 0] = "SlTp";
2951
- PerpetualsStopOrderType2[PerpetualsStopOrderType2["Standalone"] = 1] = "Standalone";
2952
- return PerpetualsStopOrderType2;
2953
- })(PerpetualsStopOrderType || {});
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 ? 0 /* Bid */ : 1 /* Ask */,
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
- fields.protocol_config.fields.atomic_unstake_sui_reserves_target_value
4210
+ protocolConfig.atomic_unstake_sui_reserves_target_value
3642
4211
  ),
3643
4212
  atomicUnstakeSuiReserves: BigInt(fields.atomic_unstake_sui_reserves),
3644
- minAtomicUnstakeFee: BigInt(
3645
- fields.protocol_config.fields.atomic_unstake_protocol_fee.fields.min_fee
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(fields.suifrens_metadata.fields.size)
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.data?.display);
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(fields.cap.fields.for)
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
- farmIds: [this.stakingPool.objectId]
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
- farmIds: [this.stakingPool.objectId]
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
- farmIds: inputs.objectIds
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,19 @@ 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);
6365
+ }
6366
+ /**
6367
+ * Fetches TVL and reward TVL for multiple farms in a single batch response.
6368
+ * When `farmIds` is omitted, the API returns summaries for all farms.
6369
+ *
6370
+ * @param inputs - Optionally provide the farm IDs to include.
6371
+ * @param abortSignal - An optional signal for cancelling the request.
6372
+ * @returns TVL and reward TVL metrics for each requested farm.
6373
+ */
6374
+ async getFarmSummaries(inputs, abortSignal) {
6375
+ return this.fetchApi("summary", inputs ?? {}, abortSignal);
5745
6376
  }
5746
6377
  // =========================================================================
5747
6378
  // Transactions
@@ -5861,29 +6492,19 @@ var init_faucet = __esm({
5861
6492
  // =========================================================================
5862
6493
  // Inspections
5863
6494
  // =========================================================================
5864
- async getSupportedCoins() {
6495
+ getSupportedCoins() {
5865
6496
  return this.fetchApi("supported-coins");
5866
6497
  }
5867
6498
  // =========================================================================
5868
- // Events
5869
- // =========================================================================
5870
- // TODO: add mint coin event getter ?
5871
- // =========================================================================
5872
6499
  // Transactions
5873
6500
  // =========================================================================
5874
- async getRequestCoinTransaction(inputs) {
6501
+ getRequestCoinTransaction(inputs) {
5875
6502
  return this.faucetApi().buildRequestCoinTx(inputs);
5876
6503
  }
5877
- async getMintSuiFrenTransaction(inputs) {
6504
+ getMintSuiFrenTransaction(inputs) {
5878
6505
  return this.faucetApi().fetchBuildMintSuiFrenTx(inputs);
5879
6506
  }
5880
6507
  };
5881
- // =========================================================================
5882
- // Constants
5883
- // =========================================================================
5884
- Faucet.constants = {
5885
- defaultRequestAmountUsd: 10
5886
- };
5887
6508
  }
5888
6509
  });
5889
6510
 
@@ -6004,24 +6625,25 @@ var init_gasPools = __esm({
6004
6625
  );
6005
6626
  }
6006
6627
  /**
6007
- * Builds a transaction to sponsor (rebate) the transaction sender
6008
- * using SUI from the gas pool.
6628
+ * Requests a gas-pool-sponsored transaction. Returns a complete transaction
6629
+ * with the gas payment and epoch bound attached, the sponsor's signature, and
6630
+ * the digest both signatures commit to — the caller signs `transaction` as the
6631
+ * sender and submits it together with `sponsorSignature`.
6009
6632
  *
6010
- * @param inputs.walletAddress - Wallet address submitting the sponsor transaction.
6011
- * @param inputs.amount - Amount of SUI to rebate in MIST.
6012
- * @param inputs.tx - Optional transaction to extend.
6013
- * @returns {@link SdkTransactionResponse} with `tx`.
6633
+ * @param inputs.walletAddress - Wallet address requesting the sponsorship.
6634
+ * @param inputs.bytes - Base64 of the signed `SPONSOR_GAS` auth message.
6635
+ * @param inputs.signature - Signature over `bytes`.
6636
+ * @param inputs.tx - Optional transaction to sponsor (appended as a tx kind).
6637
+ * @returns {@link ApiGasPoolSponsorResponse}.
6014
6638
  */
6015
- async getSponsorTx(inputs) {
6639
+ async getSponsoredTransaction(inputs) {
6016
6640
  const { tx, ...otherInputs } = inputs;
6017
- return this.fetchApiTxObject(
6641
+ return this.fetchApi(
6018
6642
  "transactions/sponsor",
6019
6643
  {
6020
6644
  ...otherInputs,
6021
- txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx })
6022
- },
6023
- void 0,
6024
- { txKind: true }
6645
+ txKind: tx ? await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }) : void 0
6646
+ }
6025
6647
  );
6026
6648
  }
6027
6649
  /**
@@ -8150,10 +8772,13 @@ var init_pools = __esm({
8150
8772
  * console.log(poolId);
8151
8773
  * ```
8152
8774
  */
8153
- this.getPoolObjectIdForLpCoinType = (inputs) => {
8154
- return this.getPoolObjectIdsForLpCoinTypes({
8155
- lpCoinTypes: [inputs.lpCoinType]
8156
- });
8775
+ this.getPoolObjectIdForLpCoinType = (inputs, abortSignal) => {
8776
+ return this.getPoolObjectIdsForLpCoinTypes(
8777
+ {
8778
+ lpCoinTypes: [inputs.lpCoinType]
8779
+ },
8780
+ abortSignal
8781
+ );
8157
8782
  };
8158
8783
  /**
8159
8784
  * Checks if a given coin type is recognized as an LP coin.
@@ -8162,8 +8787,8 @@ var init_pools = __esm({
8162
8787
  * @param inputs - Contains the `lpCoinType` to check.
8163
8788
  * @returns `true` if the coin is an LP token, `false` otherwise.
8164
8789
  */
8165
- this.isLpCoinType = async (inputs) => {
8166
- const result = await this.getPoolObjectIdForLpCoinType(inputs);
8790
+ this.isLpCoinType = async (inputs, abortSignal) => {
8791
+ const result = await this.getPoolObjectIdForLpCoinType(inputs, abortSignal);
8167
8792
  return result.some((id) => id !== void 0);
8168
8793
  };
8169
8794
  /**
@@ -8213,8 +8838,12 @@ var init_pools = __esm({
8213
8838
  * console.log(pool.pool.lpCoinType, pool.pool.name);
8214
8839
  * ```
8215
8840
  */
8216
- async getPool(inputs) {
8217
- const pool = await this.fetchApi(inputs.objectId);
8841
+ async getPool(inputs, abortSignal) {
8842
+ const pool = await this.fetchApi(
8843
+ inputs.objectId,
8844
+ void 0,
8845
+ abortSignal
8846
+ );
8218
8847
  return new Pool(pool, this.config, this.api);
8219
8848
  }
8220
8849
  /**
@@ -8229,10 +8858,14 @@ var init_pools = __esm({
8229
8858
  * console.log(poolArray.length);
8230
8859
  * ```
8231
8860
  */
8232
- async getPools(inputs) {
8233
- const pools = await this.fetchApi("", {
8234
- poolIds: inputs.objectIds
8235
- });
8861
+ async getPools(inputs, abortSignal) {
8862
+ const pools = await this.fetchApi(
8863
+ "",
8864
+ {
8865
+ poolIds: inputs.objectIds
8866
+ },
8867
+ abortSignal
8868
+ );
8236
8869
  return pools.map((pool) => new Pool(pool, this.config, this.api));
8237
8870
  }
8238
8871
  /**
@@ -8246,8 +8879,8 @@ var init_pools = __esm({
8246
8879
  * console.log(allPools.map(p => p.pool.name));
8247
8880
  * ```
8248
8881
  */
8249
- async getAllPools() {
8250
- const pools = await this.fetchApi("", {});
8882
+ async getAllPools(abortSignal) {
8883
+ const pools = await this.fetchApi("", {}, abortSignal);
8251
8884
  return pools.map((pool) => new Pool(pool, this.config, this.api));
8252
8885
  }
8253
8886
  /**
@@ -8337,8 +8970,8 @@ var init_pools = __esm({
8337
8970
  * console.log(poolIds);
8338
8971
  * ```
8339
8972
  */
8340
- async getPoolObjectIdsForLpCoinTypes(inputs) {
8341
- return this.fetchApi("pool-object-ids", inputs);
8973
+ async getPoolObjectIdsForLpCoinTypes(inputs, abortSignal) {
8974
+ return this.fetchApi("pool-object-ids", inputs, abortSignal);
8342
8975
  }
8343
8976
  /**
8344
8977
  * Retrieves the total value locked (TVL) across all or specific pool IDs.
@@ -8368,8 +9001,19 @@ var init_pools = __esm({
8368
9001
  * console.log(stats[0].volume, stats[1].tvl);
8369
9002
  * ```
8370
9003
  */
8371
- async getPoolsStats(inputs) {
8372
- return this.fetchApi("stats", inputs);
9004
+ async getPoolsStats(inputs, abortSignal) {
9005
+ return this.fetchApi("stats", inputs, abortSignal);
9006
+ }
9007
+ /**
9008
+ * Fetches pool objects and their statistics in a single batch response.
9009
+ * When `poolIds` is omitted, the API returns summaries for all pools.
9010
+ *
9011
+ * @param inputs - Optionally provide the pool IDs to include.
9012
+ * @param abortSignal - An optional signal for cancelling the request.
9013
+ * @returns Pool objects paired with their current statistics.
9014
+ */
9015
+ async getPoolSummaries(inputs, abortSignal) {
9016
+ return this.fetchApi("summary", inputs ?? {}, abortSignal);
8373
9017
  }
8374
9018
  /**
8375
9019
  * Returns all DAO fee pool owner capabilities owned by a particular user.
@@ -8987,7 +9631,7 @@ var init_types2 = __esm({
8987
9631
 
8988
9632
  // src/packages/perpetuals/perpetualsAccount.ts
8989
9633
  import {
8990
- Transaction as Transaction3
9634
+ Transaction as Transaction4
8991
9635
  } from "@mysten/sui/transactions";
8992
9636
  var PerpetualsAccount;
8993
9637
  var init_perpetualsAccount = __esm({
@@ -9068,7 +9712,7 @@ var init_perpetualsAccount = __esm({
9068
9712
  accountId: this.accountCap.accountId,
9069
9713
  accountCapId: this.accountCap.objectId,
9070
9714
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
9071
- tx: tx ?? new Transaction3()
9715
+ tx: tx ?? new Transaction4()
9072
9716
  })
9073
9717
  },
9074
9718
  void 0,
@@ -9116,7 +9760,7 @@ var init_perpetualsAccount = __esm({
9116
9760
  walletAddress: this.ownerAddress(),
9117
9761
  accountId: this.accountCap.accountId,
9118
9762
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
9119
- tx: txFromInputs ?? new Transaction3()
9763
+ tx: txFromInputs ?? new Transaction4()
9120
9764
  })
9121
9765
  },
9122
9766
  void 0,
@@ -9152,7 +9796,7 @@ var init_perpetualsAccount = __esm({
9152
9796
  vaultId: void 0
9153
9797
  },
9154
9798
  walletAddress: this.ownerAddress(),
9155
- txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction3() })
9799
+ txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
9156
9800
  },
9157
9801
  void 0,
9158
9802
  {
@@ -9187,7 +9831,7 @@ var init_perpetualsAccount = __esm({
9187
9831
  vaultId: void 0
9188
9832
  },
9189
9833
  walletAddress: this.ownerAddress(),
9190
- txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction3() })
9834
+ txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
9191
9835
  },
9192
9836
  void 0,
9193
9837
  {
@@ -9220,7 +9864,7 @@ var init_perpetualsAccount = __esm({
9220
9864
  walletAddress: this.ownerAddress(),
9221
9865
  fromAccountId: this.accountCap.accountId,
9222
9866
  fromAccountCapId: this.accountCap.objectId,
9223
- txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction3() })
9867
+ txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx: tx ?? new Transaction4() })
9224
9868
  },
9225
9869
  void 0,
9226
9870
  {
@@ -9268,7 +9912,7 @@ var init_perpetualsAccount = __esm({
9268
9912
  */
9269
9913
  async getPlaceMarketOrderTx(inputs) {
9270
9914
  const { tx: txFromInputs, ...otherInputs } = inputs;
9271
- const tx = txFromInputs ?? new Transaction3();
9915
+ const tx = txFromInputs ?? new Transaction4();
9272
9916
  return this.fetchApiTxObject(
9273
9917
  `${this.vaultId ? "vault" : "account"}/transactions/place-market-order`,
9274
9918
  {
@@ -9310,7 +9954,7 @@ var init_perpetualsAccount = __esm({
9310
9954
  */
9311
9955
  async getPlaceLimitOrderTx(inputs) {
9312
9956
  const { tx: txFromInputs, ...otherInputs } = inputs;
9313
- const tx = txFromInputs ?? new Transaction3();
9957
+ const tx = txFromInputs ?? new Transaction4();
9314
9958
  return this.fetchApiTxObject(
9315
9959
  `${this.vaultId ? "vault" : "account"}/transactions/place-limit-order`,
9316
9960
  {
@@ -9347,7 +9991,7 @@ var init_perpetualsAccount = __esm({
9347
9991
  */
9348
9992
  async getPlaceScaleOrderTx(inputs) {
9349
9993
  const { tx: txFromInputs, ...otherInputs } = inputs;
9350
- const tx = txFromInputs ?? new Transaction3();
9994
+ const tx = txFromInputs ?? new Transaction4();
9351
9995
  return this.fetchApiTxObject(
9352
9996
  `${this.vaultId ? "vault" : "account"}/transactions/place-scale-order`,
9353
9997
  {
@@ -9382,7 +10026,7 @@ var init_perpetualsAccount = __esm({
9382
10026
  */
9383
10027
  async getCancelAndPlaceOrdersTx(inputs) {
9384
10028
  const { tx: txFromInputs, ...otherInputs } = inputs;
9385
- const tx = txFromInputs ?? new Transaction3();
10029
+ const tx = txFromInputs ?? new Transaction4();
9386
10030
  return this.fetchApiTxObject(
9387
10031
  `${this.vaultId ? "vault" : "account"}/transactions/cancel-and-place-orders`,
9388
10032
  {
@@ -9497,7 +10141,7 @@ var init_perpetualsAccount = __esm({
9497
10141
  */
9498
10142
  async getPlaceStopOrdersTx(inputs) {
9499
10143
  const { tx: txFromInputs, ...otherInputs } = inputs;
9500
- const tx = txFromInputs ?? new Transaction3();
10144
+ const tx = txFromInputs ?? new Transaction4();
9501
10145
  return this.fetchApiTxObject(
9502
10146
  `${this.vaultId ? "vault" : "account"}/transactions/place-stop-orders`,
9503
10147
  {
@@ -9541,7 +10185,7 @@ var init_perpetualsAccount = __esm({
9541
10185
  if (!position) {
9542
10186
  throw new Error("you have no position for this market");
9543
10187
  }
9544
- const tx = txFromInputs ?? new Transaction3();
10188
+ const tx = txFromInputs ?? new Transaction4();
9545
10189
  return this.fetchApiTxObject(
9546
10190
  `${this.vaultId ? "vault" : "account"}/transactions/place-sl-tp-orders`,
9547
10191
  {
@@ -9577,16 +10221,110 @@ var init_perpetualsAccount = __esm({
9577
10221
  * - This is typically used to adjust trigger prices, sizes, expiries, or the
9578
10222
  * embedded limit-order parameters.
9579
10223
  *
9580
- * @param inputs.stopOrders - Full updated stop-order payloads to apply.
10224
+ * @param inputs.stopOrders - Full updated stop-order payloads to apply.
10225
+ * @param inputs.tx - Optional transaction to extend.
10226
+ *
10227
+ * @returns Transaction response containing `tx`.
10228
+ */
10229
+ async getEditStopOrdersTx(inputs) {
10230
+ const { tx: txFromInputs, ...otherInputs } = inputs;
10231
+ const tx = txFromInputs ?? new Transaction4();
10232
+ return this.fetchApiTxObject(
10233
+ `${this.vaultId ? "vault" : "account"}/transactions/edit-stop-orders`,
10234
+ {
10235
+ ...otherInputs,
10236
+ txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
10237
+ walletAddress: this.ownerAddress(),
10238
+ ..."vaultId" in this.accountCap ? {
10239
+ vaultId: this.accountCap.vaultId,
10240
+ accountId: void 0
10241
+ } : {
10242
+ accountId: this.accountCap.accountId,
10243
+ accountCapId: this.accountCap.objectId,
10244
+ vaultId: void 0
10245
+ }
10246
+ },
10247
+ void 0,
10248
+ {
10249
+ txKind: true
10250
+ }
10251
+ );
10252
+ }
10253
+ /**
10254
+ * Build a `create-twap-orders` transaction for this account.
10255
+ *
10256
+ * @param inputs - See {@link SdkPerpetualsCreateTwapOrdersInputs}.
10257
+ *
10258
+ * @returns Transaction response containing `tx`.
10259
+ */
10260
+ async getCreateTwapOrdersTx(inputs) {
10261
+ const { tx, ...otherInputs } = inputs;
10262
+ return this.fetchApiTxObject(
10263
+ `${this.vaultId ? "vault" : "account"}/transactions/create-twap-orders`,
10264
+ {
10265
+ ...otherInputs,
10266
+ txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
10267
+ walletAddress: this.ownerAddress(),
10268
+ ..."vaultId" in this.accountCap ? {
10269
+ vaultId: this.accountCap.vaultId,
10270
+ accountId: void 0
10271
+ } : {
10272
+ accountId: this.accountCap.accountId,
10273
+ accountCapId: this.accountCap.objectId,
10274
+ vaultId: void 0
10275
+ }
10276
+ },
10277
+ void 0,
10278
+ {
10279
+ txKind: true
10280
+ }
10281
+ );
10282
+ }
10283
+ /**
10284
+ * Build an `edit-twap-orders` transaction for this account.
10285
+ * `newTwapOrders` maps each TWAP order object id to the edit to apply.
10286
+ *
10287
+ * @param inputs.newTwapOrders - Map of TWAP order id to the edit to apply.
10288
+ * @param inputs.tx - Optional transaction to extend.
10289
+ *
10290
+ * @returns Transaction response containing `tx`.
10291
+ */
10292
+ async getEditTwapOrdersTx(inputs) {
10293
+ const { tx, ...otherInputs } = inputs;
10294
+ return this.fetchApiTxObject(
10295
+ `${this.vaultId ? "vault" : "account"}/transactions/edit-twap-orders`,
10296
+ {
10297
+ ...otherInputs,
10298
+ txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
10299
+ walletAddress: this.ownerAddress(),
10300
+ ..."vaultId" in this.accountCap ? {
10301
+ vaultId: this.accountCap.vaultId,
10302
+ accountId: void 0
10303
+ } : {
10304
+ accountId: this.accountCap.accountId,
10305
+ accountCapId: this.accountCap.objectId,
10306
+ vaultId: void 0
10307
+ }
10308
+ },
10309
+ void 0,
10310
+ {
10311
+ txKind: true
10312
+ }
10313
+ );
10314
+ }
10315
+ /**
10316
+ * Build a `cancel-twap-orders` transaction for this account.
10317
+ * This cancels TWAP order objects by their object IDs.
10318
+ *
9581
10319
  * @param inputs.tx - Optional transaction to extend.
10320
+ * @param inputs.twapOrderIds - Array of TWAP order object IDs to cancel.
9582
10321
  *
9583
10322
  * @returns Transaction response containing `tx`.
9584
10323
  */
9585
- async getEditStopOrdersTx(inputs) {
9586
- const { tx: txFromInputs, ...otherInputs } = inputs;
9587
- const tx = txFromInputs ?? new Transaction3();
10324
+ async getCancelTwapOrdersTx(inputs) {
10325
+ const { tx, ...otherInputs } = inputs;
9588
10326
  return this.fetchApiTxObject(
9589
- `${this.vaultId ? "vault" : "account"}/transactions/edit-stop-orders`,
10327
+ `${this.vaultId ? "vault" : "account"}/transactions/cancel-twap-orders`,
9590
10328
  {
9591
10329
  ...otherInputs,
9592
10330
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({ tx }),
@@ -9606,6 +10344,29 @@ var init_perpetualsAccount = __esm({
9606
10344
  }
9607
10345
  );
9608
10346
  }
10347
+ /**
10348
+ * Fetch TWAP-order data for this account, using an off-chain signed payload.
10349
+ *
10350
+ * @param inputs.bytes - Serialized message that was signed.
10351
+ * @param inputs.signature - Signature over `bytes`.
10352
+ * @param inputs.marketIds - Optional subset of markets to filter results by.
10353
+ *
10354
+ * @returns {@link ApiPerpetualsTwapOrderDatasResponse} containing `twapOrderDatas`.
10355
+ */
10356
+ async getTwapOrderDatas(inputs) {
10357
+ const { bytes, signature, marketIds } = inputs;
10358
+ return await this.fetchApi(`${this.vaultId ? "vault" : "account"}/twap-order-datas`, {
10359
+ bytes,
10360
+ signature,
10361
+ walletAddress: this.ownerAddress(),
10362
+ marketIds: marketIds ?? [],
10363
+ ..."vaultId" in this.accountCap ? {
10364
+ vaultId: this.accountCap.vaultId
10365
+ } : {
10366
+ accountId: this.accountCap.accountId
10367
+ }
10368
+ });
10369
+ }
9609
10370
  // public async getReduceOrderTx(inputs: {
9610
10371
  // tx?: Transaction;
9611
10372
  // collateralChange: number;
@@ -10174,7 +10935,7 @@ var init_perpetualsAccount = __esm({
10174
10935
  recipientAddress,
10175
10936
  accountId: this.accountCap.accountId,
10176
10937
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
10177
- tx: tx ?? new Transaction3()
10938
+ tx: tx ?? new Transaction4()
10178
10939
  })
10179
10940
  },
10180
10941
  void 0,
@@ -10206,7 +10967,7 @@ var init_perpetualsAccount = __esm({
10206
10967
  accountCapId,
10207
10968
  accountId: this.accountCap.accountId,
10208
10969
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
10209
- tx: tx ?? new Transaction3()
10970
+ tx: tx ?? new Transaction4()
10210
10971
  })
10211
10972
  },
10212
10973
  void 0,
@@ -10337,7 +11098,7 @@ var init_perpetualsAccount = __esm({
10337
11098
  * - Market ID matches the input market.
10338
11099
  * - `slTp` field is present.
10339
11100
  * - Order side is opposite of the position side.
10340
- * - At least a `stopLossIndexPrice` or `takeProfitIndexPrice` is set.
11101
+ * - At least a `stopLossPrice` or `takeProfitPrice` is set.
10341
11102
  *
10342
11103
  * Notes on matching:
10343
11104
  * - The side comparison uses the current position side derived from the account snapshot.
@@ -10361,10 +11122,10 @@ var init_perpetualsAccount = __esm({
10361
11122
  }
10362
11123
  const side = position ? Perpetuals.positionSide(position) : void 0;
10363
11124
  const fullSlTpOrder = stopOrderDatas.find(
10364
- (order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossIndexPrice || order.slTp.takeProfitIndexPrice) && order.size >= Casting.i64MaxBigInt && !order.limitOrder
11125
+ (order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size >= Casting.i64MaxBigInt && !order.limitOrder
10365
11126
  );
10366
11127
  const partialSlTpOrders = stopOrderDatas.filter(
10367
- (order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossIndexPrice || order.slTp.takeProfitIndexPrice) && order.size < Casting.i64MaxBigInt && !order.limitOrder
11128
+ (order) => order.marketId === marketId && order.slTp && order.side !== side && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size < Casting.i64MaxBigInt && !order.limitOrder
10368
11129
  );
10369
11130
  return {
10370
11131
  fullSlTpOrder,
@@ -10374,10 +11135,10 @@ var init_perpetualsAccount = __esm({
10374
11135
  slTpStopOrderDatasForLimitOrder(inputs) {
10375
11136
  const { stopOrderDatas, limitOrderId } = inputs;
10376
11137
  const fullSlTpOrder = stopOrderDatas.find(
10377
- (order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossIndexPrice || order.slTp.takeProfitIndexPrice) && order.size >= Casting.i64MaxBigInt
11138
+ (order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size >= Casting.i64MaxBigInt
10378
11139
  );
10379
11140
  const partialSlTpOrders = stopOrderDatas.filter(
10380
- (order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossIndexPrice || order.slTp.takeProfitIndexPrice) && order.size < Casting.i64MaxBigInt
11141
+ (order) => order.slTp && order.slTp.limitOrderId === limitOrderId && (order.slTp.stopLossPrice || order.slTp.takeProfitPrice) && order.size < Casting.i64MaxBigInt
10381
11142
  );
10382
11143
  return {
10383
11144
  fullSlTpOrder,
@@ -10562,12 +11323,13 @@ var init_perpetualsMarket = __esm({
10562
11323
  * @param marketData - Snapshot of market configuration and state.
10563
11324
  * @param config - Optional {@link CallerConfig} (network, base URL, etc.).
10564
11325
  * @param api - Optional shared {@link AftermathApi} provider instance.
11326
+ * @param metadata - Optional display metadata for the market.
10565
11327
  *
10566
11328
  * @remarks
10567
11329
  * This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning
10568
11330
  * all HTTP requests resolve under `/perpetuals/...`.
10569
11331
  */
10570
- constructor(marketData, config, api) {
11332
+ constructor(marketData, config, api, metadata) {
10571
11333
  super(config, "perpetuals");
10572
11334
  this.marketData = marketData;
10573
11335
  this.api = api;
@@ -10765,10 +11527,6 @@ var init_perpetualsMarket = __esm({
10765
11527
  asksQuantity: 0,
10766
11528
  bidsQuantity: 0,
10767
11529
  pendingOrders: [],
10768
- makerFee: 1,
10769
- // 100% (placeholder default)
10770
- takerFee: 1,
10771
- // 100% (placeholder default)
10772
11530
  leverage: 1,
10773
11531
  entryPrice: 0,
10774
11532
  freeCollateral: 0,
@@ -10785,6 +11543,7 @@ var init_perpetualsMarket = __esm({
10785
11543
  this.collateralCoinType = marketData.collateralCoinType;
10786
11544
  this.marketParams = marketData.marketParams;
10787
11545
  this.marketState = marketData.marketState;
11546
+ this.metadata = metadata ?? null;
10788
11547
  }
10789
11548
  // =========================================================================
10790
11549
  // Inspections
@@ -10998,7 +11757,7 @@ var init_perpetualsMarket = __esm({
10998
11757
 
10999
11758
  // src/packages/perpetuals/perpetualsVault.ts
11000
11759
  import {
11001
- Transaction as Transaction4
11760
+ Transaction as Transaction5
11002
11761
  } from "@mysten/sui/transactions";
11003
11762
  var PerpetualsVault;
11004
11763
  var init_perpetualsVault = __esm({
@@ -11051,7 +11810,7 @@ var init_perpetualsVault = __esm({
11051
11810
  ...otherInputs,
11052
11811
  vaultId: this.vaultObject.objectId,
11053
11812
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11054
- tx: tx ?? new Transaction4()
11813
+ tx: tx ?? new Transaction5()
11055
11814
  })
11056
11815
  },
11057
11816
  void 0,
@@ -11067,7 +11826,7 @@ var init_perpetualsVault = __esm({
11067
11826
  ...otherInputs,
11068
11827
  vaultId: this.vaultObject.objectId,
11069
11828
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11070
- tx: tx ?? new Transaction4()
11829
+ tx: tx ?? new Transaction5()
11071
11830
  })
11072
11831
  },
11073
11832
  void 0,
@@ -11093,7 +11852,7 @@ var init_perpetualsVault = __esm({
11093
11852
  ...otherInputs,
11094
11853
  vaultId: this.vaultObject.objectId,
11095
11854
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11096
- tx: tx ?? new Transaction4()
11855
+ tx: tx ?? new Transaction5()
11097
11856
  })
11098
11857
  },
11099
11858
  void 0,
@@ -11119,7 +11878,7 @@ var init_perpetualsVault = __esm({
11119
11878
  ...otherInputs,
11120
11879
  vaultId: this.vaultObject.objectId,
11121
11880
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11122
- tx: tx ?? new Transaction4()
11881
+ tx: tx ?? new Transaction5()
11123
11882
  })
11124
11883
  },
11125
11884
  void 0,
@@ -11142,7 +11901,7 @@ var init_perpetualsVault = __esm({
11142
11901
  ...otherInputs,
11143
11902
  vaultId: this.vaultObject.objectId,
11144
11903
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11145
- tx: tx ?? new Transaction4()
11904
+ tx: tx ?? new Transaction5()
11146
11905
  })
11147
11906
  },
11148
11907
  void 0,
@@ -11166,7 +11925,7 @@ var init_perpetualsVault = __esm({
11166
11925
  ...otherInputs,
11167
11926
  vaultId: this.vaultObject.objectId,
11168
11927
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11169
- tx: tx ?? new Transaction4()
11928
+ tx: tx ?? new Transaction5()
11170
11929
  })
11171
11930
  },
11172
11931
  void 0,
@@ -11195,7 +11954,7 @@ var init_perpetualsVault = __esm({
11195
11954
  ...otherInputs,
11196
11955
  vaultId: this.vaultObject.objectId,
11197
11956
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11198
- tx: tx ?? new Transaction4()
11957
+ tx: tx ?? new Transaction5()
11199
11958
  })
11200
11959
  },
11201
11960
  void 0,
@@ -11220,7 +11979,7 @@ var init_perpetualsVault = __esm({
11220
11979
  ...otherInputs,
11221
11980
  vaultId: this.vaultObject.objectId,
11222
11981
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11223
- tx: txFromInputs ?? new Transaction4()
11982
+ tx: txFromInputs ?? new Transaction5()
11224
11983
  })
11225
11984
  },
11226
11985
  void 0,
@@ -11246,7 +12005,7 @@ var init_perpetualsVault = __esm({
11246
12005
  ...otherInputs,
11247
12006
  vaultId: this.vaultObject.objectId,
11248
12007
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11249
- tx: tx ?? new Transaction4()
12008
+ tx: tx ?? new Transaction5()
11250
12009
  })
11251
12010
  },
11252
12011
  void 0,
@@ -11277,7 +12036,7 @@ var init_perpetualsVault = __esm({
11277
12036
  ...otherInputs,
11278
12037
  vaultId: this.vaultObject.objectId,
11279
12038
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11280
- tx: tx ?? new Transaction4()
12039
+ tx: tx ?? new Transaction5()
11281
12040
  })
11282
12041
  },
11283
12042
  void 0,
@@ -11308,7 +12067,7 @@ var init_perpetualsVault = __esm({
11308
12067
  ...otherInputs,
11309
12068
  vaultId: this.vaultObject.objectId,
11310
12069
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11311
- tx: tx ?? new Transaction4()
12070
+ tx: tx ?? new Transaction5()
11312
12071
  })
11313
12072
  },
11314
12073
  void 0,
@@ -11331,7 +12090,7 @@ var init_perpetualsVault = __esm({
11331
12090
  ...otherInputs,
11332
12091
  vaultId: this.vaultObject.objectId,
11333
12092
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11334
- tx: tx ?? new Transaction4()
12093
+ tx: tx ?? new Transaction5()
11335
12094
  })
11336
12095
  },
11337
12096
  void 0,
@@ -11377,7 +12136,7 @@ var init_perpetualsVault = __esm({
11377
12136
  ...depositInputs,
11378
12137
  vaultId: this.vaultObject.objectId,
11379
12138
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
11380
- tx: tx ?? new Transaction4()
12139
+ tx: tx ?? new Transaction5()
11381
12140
  })
11382
12141
  },
11383
12142
  void 0,
@@ -11692,7 +12451,7 @@ var init_perpetualsOrderUtils = __esm({
11692
12451
  // Return price of given `order_id`, (works for ask or bid)
11693
12452
  _PerpetualsOrderUtils.price = (orderId) => {
11694
12453
  const side = Perpetuals.orderIdToSide(orderId);
11695
- if (side === 1 /* Ask */) {
12454
+ if (side === PerpetualsOrderSide.Ask) {
11696
12455
  return _PerpetualsOrderUtils.priceAsk(orderId);
11697
12456
  }
11698
12457
  return _PerpetualsOrderUtils.priceBid(orderId);
@@ -11725,7 +12484,7 @@ var init_utils2 = __esm({
11725
12484
 
11726
12485
  // src/packages/perpetuals/perpetuals.ts
11727
12486
  import {
11728
- Transaction as Transaction5
12487
+ Transaction as Transaction6
11729
12488
  } from "@mysten/sui/transactions";
11730
12489
  var _Perpetuals, Perpetuals;
11731
12490
  var init_perpetuals = __esm({
@@ -11833,7 +12592,12 @@ var init_perpetuals = __esm({
11833
12592
  const res = await this.fetchApi("markets", inputs);
11834
12593
  return {
11835
12594
  markets: res.marketDatas.map(
11836
- (marketData) => new PerpetualsMarket(marketData.market, this.config, this.api)
12595
+ (marketData) => new PerpetualsMarket(
12596
+ marketData.market,
12597
+ this.config,
12598
+ this.api,
12599
+ marketData.metadata
12600
+ )
11837
12601
  )
11838
12602
  };
11839
12603
  }
@@ -12095,12 +12859,12 @@ var init_perpetuals = __esm({
12095
12859
  */
12096
12860
  // TODO: move to market class ?
12097
12861
  getMarketCandleHistory(inputs) {
12098
- const { marketId, fromTimestamp, toTimestamp, intervalMs } = inputs;
12862
+ const { marketId, fromTimestamp, toTimestamp, resolution } = inputs;
12099
12863
  return this.fetchApi("market/candle-history", {
12100
12864
  marketId,
12101
12865
  fromTimestamp,
12102
12866
  toTimestamp,
12103
- intervalMs
12867
+ resolution
12104
12868
  });
12105
12869
  }
12106
12870
  /**
@@ -12194,7 +12958,7 @@ var init_perpetuals = __esm({
12194
12958
  {
12195
12959
  ...otherInputs,
12196
12960
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
12197
- tx: tx ?? new Transaction5()
12961
+ tx: tx ?? new Transaction6()
12198
12962
  })
12199
12963
  },
12200
12964
  void 0,
@@ -12253,7 +13017,7 @@ var init_perpetuals = __esm({
12253
13017
  {
12254
13018
  ...otherInputs,
12255
13019
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
12256
- tx: tx ?? new Transaction5()
13020
+ tx: tx ?? new Transaction6()
12257
13021
  })
12258
13022
  },
12259
13023
  void 0,
@@ -12288,7 +13052,7 @@ var init_perpetuals = __esm({
12288
13052
  {
12289
13053
  ...otherInputs,
12290
13054
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
12291
- tx: tx ?? new Transaction5()
13055
+ tx: tx ?? new Transaction6()
12292
13056
  })
12293
13057
  },
12294
13058
  void 0,
@@ -12418,8 +13182,8 @@ var init_perpetuals = __esm({
12418
13182
  *
12419
13183
  * This endpoint creates a transaction that allows a user to grant permission to an
12420
13184
  * integrator to receive fees on orders placed on their behalf. The user specifies
12421
- * a maximum taker fee that the integrator can charge. The integrator can then
12422
- * include their address and fee (up to the maximum) when placing orders for the user.
13185
+ * a maximum integrator fee that the integrator can charge. The integrator can then
13186
+ * include their id and fee (up to the maximum) when placing orders for the user.
12423
13187
  *
12424
13188
  * The resulting transaction must be signed by the account owner and executed on-chain.
12425
13189
  *
@@ -12430,8 +13194,8 @@ var init_perpetuals = __esm({
12430
13194
  * ```ts
12431
13195
  * const tx = await perps.getCreateBuilderCodeIntegratorConfigTx({
12432
13196
  * accountId: 123n,
12433
- * integratorAddress: "0x...",
12434
- * maxTakerFee: 0.001, // 0.1% max fee
13197
+ * integratorId: 7,
13198
+ * maxIntegratorFee: 0.001, // 0.1% max fee
12435
13199
  * });
12436
13200
  * ```
12437
13201
  */
@@ -12467,7 +13231,7 @@ var init_perpetuals = __esm({
12467
13231
  * ```ts
12468
13232
  * const tx = await perps.getRemoveBuilderCodeIntegratorConfigTx({
12469
13233
  * accountId: 123n,
12470
- * integratorAddress: "0x...",
13234
+ * integratorId: 7,
12471
13235
  * });
12472
13236
  * ```
12473
13237
  */
@@ -12486,13 +13250,12 @@ var init_perpetuals = __esm({
12486
13250
  );
12487
13251
  }
12488
13252
  /**
12489
- * Build a transaction to initialize an integrator fee vault for a specific market.
13253
+ * Build a transaction to initialize an integrator's global fee vault.
12490
13254
  *
12491
- * This endpoint creates a transaction that initializes a vault where an integrator's
12492
- * fees will accumulate for a specific market (clearing house). This is a one-time
12493
- * setup operation that must be performed before the integrator can claim fees from
12494
- * that market. Once created, the vault will automatically collect fees as the
12495
- * integrator submits orders on behalf of users in that market.
13255
+ * This endpoint creates a transaction that initializes the global vault where an
13256
+ * integrator's fees accumulate across all markets. This is a one-time setup that
13257
+ * must be performed before the integrator can claim fees. The integrator's identity
13258
+ * is taken from the transaction sender on-chain.
12496
13259
  *
12497
13260
  * The resulting transaction must be signed by the integrator and executed on-chain.
12498
13261
  *
@@ -12501,10 +13264,7 @@ var init_perpetuals = __esm({
12501
13264
  *
12502
13265
  * @example
12503
13266
  * ```ts
12504
- * const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({
12505
- * marketId: "0x...",
12506
- * integratorAddress: "0x...",
12507
- * });
13267
+ * const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({});
12508
13268
  * ```
12509
13269
  */
12510
13270
  async getCreateBuilderCodeIntegratorVaultTx(inputs) {
@@ -12525,36 +13285,34 @@ var init_perpetuals = __esm({
12525
13285
  * Build a transaction to claim accumulated integrator fees from a vault.
12526
13286
  *
12527
13287
  * 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 a vault
12529
- * specific to each market (clearing house) and can be claimed at any moment by the
12530
- * integrator. The fees are proportional to the taker volume generated by the users'
12531
- * orders that the integrator submitted.
13288
+ * they have earned from orders placed on behalf of users. Fees accumulate in the
13289
+ * integrator's global vault (across all markets) and can be claimed at any moment.
13290
+ * The fees are proportional to the taker volume generated by the users' orders that
13291
+ * the integrator submitted.
12532
13292
  *
12533
13293
  * If a `recipientAddress` is provided, the claimed fees will be automatically
12534
- * transferred to that address. Otherwise, the coin output is exposed as a transaction
12535
- * argument for further use in the transaction.
13294
+ * transferred to that address. Otherwise, the coin outputs are exposed as transaction
13295
+ * arguments for further use in the transaction (one per non-zero collateral balance).
12536
13296
  *
12537
13297
  * The resulting transaction must be signed by the integrator and executed on-chain.
12538
13298
  *
12539
13299
  * @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
12540
13300
  * @returns {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse} containing
12541
- * `txKind` and optionally `coinOutArg`.
13301
+ * `txKind` and optionally `coinOutArgs`.
12542
13302
  *
12543
13303
  * @example
12544
13304
  * ```ts
12545
13305
  * // Claim with automatic transfer to recipient
12546
13306
  * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
12547
- * marketId: "0x...",
12548
- * integratorAddress: "0x...",
13307
+ * integratorId: 7,
12549
13308
  * recipientAddress: "0x...",
12550
13309
  * });
12551
13310
  *
12552
- * // Claim with coin output for further use
13311
+ * // Claim with coin outputs for further use
12553
13312
  * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
12554
- * marketId: "0x...",
12555
- * integratorAddress: "0x...",
13313
+ * integratorId: 7,
12556
13314
  * });
12557
- * // response.coinOutArg can be used in subsequent transaction commands
13315
+ * // response.coinOutArgs can be used in subsequent transaction commands
12558
13316
  * ```
12559
13317
  */
12560
13318
  async getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
@@ -12579,24 +13337,24 @@ var init_perpetuals = __esm({
12579
13337
  *
12580
13338
  * This endpoint queries whether an integrator has been approved by an account to collect
12581
13339
  * fees on orders placed on behalf of the account. If approved, it returns the maximum
12582
- * taker fee the integrator is authorized to charge. This information is useful for:
13340
+ * integrator fee the integrator is authorized to charge. This information is useful for:
12583
13341
  * - Verifying integrator permissions before placing orders
12584
13342
  * - Displaying authorized integrators and their fee limits in UIs
12585
13343
  * - Validating that an integrator's requested fee doesn't exceed the approved maximum
12586
13344
  *
12587
13345
  * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorConfigBody}.
12588
13346
  * @returns {@link ApiPerpetualsBuilderCodesIntegratorConfigResponse} containing
12589
- * `maxTakerFee` and `exists` flag.
13347
+ * `maxIntegratorFee` and `exists` flag.
12590
13348
  *
12591
13349
  * @example
12592
13350
  * ```ts
12593
13351
  * const config = await perps.getBuilderCodeIntegratorConfig({
12594
13352
  * accountId: 123n,
12595
- * integratorAddress: "0x...",
13353
+ * integratorId: 7,
12596
13354
  * });
12597
13355
  *
12598
13356
  * if (config.exists) {
12599
- * console.log(`Integrator is approved with max fee: ${config.maxTakerFee}`);
13357
+ * console.log(`Integrator is approved with max fee: ${config.maxIntegratorFee}`);
12600
13358
  * } else {
12601
13359
  * console.log("Integrator is not approved for this account");
12602
13360
  * }
@@ -12606,36 +13364,35 @@ var init_perpetuals = __esm({
12606
13364
  return this.fetchApi("builder-codes/integrator-config", inputs);
12607
13365
  }
12608
13366
  /**
12609
- * Fetch accumulated integrator vault fees across multiple markets.
13367
+ * Fetch accumulated integrator vault fees.
12610
13368
  *
12611
- * This endpoint queries the total fees an integrator has earned and accumulated in their
12612
- * vaults across one or more markets (clearing houses). Integrators earn fees proportional
12613
- * to the taker volume generated by orders they submit on behalf of users. These fees
12614
- * accumulate in per-market vaults and can be claimed at any time using
12615
- * {@link getClaimIntegratorVaultFeesTx}.
13369
+ * This endpoint queries the total fees an integrator has earned and accumulated in
13370
+ * their global vault, grouped by collateral coin type. Integrators earn fees
13371
+ * proportional to the taker volume generated by orders they submit on behalf of
13372
+ * users. These fees can be claimed at any time using
13373
+ * {@link getClaimBuilderCodeIntegratorVaultFeesTx}.
12616
13374
  *
12617
13375
  * This information is useful for:
12618
13376
  * - Displaying total claimable fees to integrators in dashboards
12619
- * - Monitoring fee accrual across different markets
12620
- * - Determining which markets have fees ready to be claimed
13377
+ * - Monitoring fee accrual across collateral types
13378
+ * - Determining whether fees are ready to be claimed
12621
13379
  *
12622
13380
  * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
12623
13381
  * @returns {@link ApiPerpetualsBuilderCodesIntegratorVaultsResponse} containing
12624
- * a vector of market vault data with accumulated fees.
13382
+ * a vector of per-collateral vault data with accumulated fees.
12625
13383
  *
12626
13384
  * @example
12627
13385
  * ```ts
12628
13386
  * const vaultFees = await perps.getBuilderCodeIntegratorVaults({
12629
- * marketIds: ["0x...BTCUSD", "0x...SUIUSD"],
12630
- * integratorAddress: "0x...",
13387
+ * integratorId: 7,
12631
13388
  * });
12632
13389
  *
12633
13390
  * for (const vault of vaultFees.integratorVaults) {
12634
- * console.log(`Market ${vault.marketId}: ${vault.fees} collateral units claimable`);
13391
+ * console.log(`${vault.collateralCoinType}: ${vault.fees} collateral units claimable`);
12635
13392
  * }
12636
13393
  *
12637
- * const totalFees = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.fees, 0);
12638
- * console.log(`Total claimable: ${totalFees}`);
13394
+ * const totalFeesUsd = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.feesUsd, 0);
13395
+ * console.log(`Total claimable (USD): ${totalFeesUsd}`);
12639
13396
  * ```
12640
13397
  */
12641
13398
  async getBuilderCodeIntegratorVaults(inputs) {
@@ -12653,7 +13410,7 @@ var init_perpetuals = __esm({
12653
13410
  static positionSide(inputs) {
12654
13411
  const baseAmount = inputs.baseAssetAmount;
12655
13412
  const isLong = Math.sign(baseAmount);
12656
- const side = isLong >= 0 ? 0 /* Bid */ : 1 /* Ask */;
13413
+ const side = isLong >= 0 ? PerpetualsOrderSide.Bid : PerpetualsOrderSide.Ask;
12657
13414
  return side;
12658
13415
  }
12659
13416
  /**
@@ -12849,6 +13606,20 @@ var init_perpetuals = __esm({
12849
13606
  }
12850
13607
  }
12851
13608
  });
13609
+ const subscribeMarketCandles = ({
13610
+ marketId,
13611
+ interval
13612
+ }) => ctl.send({
13613
+ action: "subscribe",
13614
+ subscriptionType: { marketCandles: { marketId, interval } }
13615
+ });
13616
+ const unsubscribeMarketCandles = ({
13617
+ marketId,
13618
+ interval
13619
+ }) => ctl.send({
13620
+ action: "unsubscribe",
13621
+ subscriptionType: { marketCandles: { marketId, interval } }
13622
+ });
12852
13623
  return {
12853
13624
  ws: ctl.ws,
12854
13625
  subscribeMarket,
@@ -12867,6 +13638,8 @@ var init_perpetuals = __esm({
12867
13638
  unsubscribeUserCollateralChanges,
12868
13639
  subscribeTopOfOrderbook,
12869
13640
  unsubscribeTopOfOrderbook,
13641
+ subscribeMarketCandles,
13642
+ unsubscribeMarketCandles,
12870
13643
  close: ctl.close
12871
13644
  };
12872
13645
  }
@@ -12896,19 +13669,27 @@ var init_perpetuals = __esm({
12896
13669
  * ```
12897
13670
  */
12898
13671
  openMarketCandlesWebsocketStream(args) {
12899
- const { marketId, intervalMs, onMessage, onOpen, onError, onClose } = args;
12900
- const path = `ws/market-candles/${encodeURIComponent(
12901
- marketId
12902
- )}/${intervalMs}`;
12903
- const ctl = this.openWsStream(
12904
- {
12905
- path,
12906
- onMessage,
12907
- onOpen,
12908
- onError,
12909
- onClose
12910
- }
12911
- );
13672
+ const { marketId, interval, onMessage, onOpen, onError, onClose } = args;
13673
+ const ctl = this.openWsStream({
13674
+ path: "ws/updates",
13675
+ onMessage: (env) => {
13676
+ if ("marketCandles" in env) {
13677
+ onMessage({
13678
+ marketId: env.marketCandles.marketId,
13679
+ lastCandle: env.marketCandles.lastCandle
13680
+ });
13681
+ }
13682
+ },
13683
+ onOpen: (ev) => {
13684
+ ctl.send({
13685
+ action: "subscribe",
13686
+ subscriptionType: { marketCandles: { marketId, interval } }
13687
+ });
13688
+ onOpen?.(ev);
13689
+ },
13690
+ onError,
13691
+ onClose
13692
+ });
12912
13693
  return {
12913
13694
  ws: ctl.ws,
12914
13695
  close: ctl.close
@@ -12953,7 +13734,7 @@ var init_perpetuals = __esm({
12953
13734
  * @returns {@link PerpetualsOrderSide}.
12954
13735
  */
12955
13736
  _Perpetuals.orderIdToSide = (orderId) => {
12956
- return _Perpetuals.OrderUtils.isAsk(orderId) ? 1 /* Ask */ : 0 /* Bid */;
13737
+ return _Perpetuals.OrderUtils.isAsk(orderId) ? PerpetualsOrderSide.Ask : PerpetualsOrderSide.Bid;
12957
13738
  };
12958
13739
  /**
12959
13740
  * Construct a collateral-specialized Move event type string.
@@ -13048,7 +13829,7 @@ var init_referralVault2 = __esm({
13048
13829
  });
13049
13830
 
13050
13831
  // src/packages/router/router.ts
13051
- import { Transaction as Transaction6 } from "@mysten/sui/transactions";
13832
+ import { Transaction as Transaction7 } from "@mysten/sui/transactions";
13052
13833
  var Router;
13053
13834
  var init_router = __esm({
13054
13835
  "src/packages/router/router.ts"() {
@@ -13249,7 +14030,7 @@ var init_router = __esm({
13249
14030
  serializedTx: tx.serialize()
13250
14031
  });
13251
14032
  return {
13252
- tx: Transaction6.from(newTx),
14033
+ tx: Transaction7.from(newTx),
13253
14034
  coinOutId
13254
14035
  };
13255
14036
  }
@@ -14808,7 +15589,7 @@ var init_referrals = __esm({
14808
15589
  });
14809
15590
 
14810
15591
  // src/packages/rewards/rewards.ts
14811
- import { Transaction as Transaction7 } from "@mysten/sui/transactions";
15592
+ import { Transaction as Transaction8 } from "@mysten/sui/transactions";
14812
15593
  var Rewards;
14813
15594
  var init_rewards = __esm({
14814
15595
  "src/packages/rewards/rewards.ts"() {
@@ -14837,6 +15618,15 @@ var init_rewards = __esm({
14837
15618
  async getClaimable(inputs) {
14838
15619
  return this.fetchApi("claimable", inputs);
14839
15620
  }
15621
+ /**
15622
+ * Preview a single account's expected rewards for an epoch, broken down by
15623
+ * domain (trading, referral, AFLP, integrator) plus totals. Backed by the
15624
+ * newer `rewards/expectedRewards` endpoint. Provide exactly one of `address`
15625
+ * or `accountId`; omit `epoch` for the current epoch.
15626
+ */
15627
+ async getExpectedRewards(inputs) {
15628
+ return this.fetchApi("expectedRewards", inputs);
15629
+ }
14840
15630
  // =========================================================================
14841
15631
  // Transactions
14842
15632
  // =========================================================================
@@ -14847,7 +15637,7 @@ var init_rewards = __esm({
14847
15637
  {
14848
15638
  ...otherInputs,
14849
15639
  txKind: await this.api?.Transactions().fetchBase64TxKindFromTx({
14850
- tx: tx ?? new Transaction7()
15640
+ tx: tx ?? new Transaction8()
14851
15641
  })
14852
15642
  },
14853
15643
  void 0,
@@ -14899,7 +15689,7 @@ var init_userData = __esm({
14899
15689
  */
14900
15690
  async getUserPublicKey(inputs) {
14901
15691
  return this.fetchApi(
14902
- `public-key`,
15692
+ "public-key",
14903
15693
  inputs
14904
15694
  );
14905
15695
  }
@@ -14922,7 +15712,7 @@ var init_userData = __esm({
14922
15712
  */
14923
15713
  async createUserPublicKey(inputs) {
14924
15714
  return this.fetchApi(
14925
- `save-public-key`,
15715
+ "save-public-key",
14926
15716
  inputs
14927
15717
  );
14928
15718
  }
@@ -14942,7 +15732,7 @@ var init_userData = __esm({
14942
15732
  */
14943
15733
  createUserAccountMessageToSign() {
14944
15734
  return {
14945
- action: `CREATE_USER_ACCOUNT`
15735
+ action: "CREATE_USER_ACCOUNT"
14946
15736
  };
14947
15737
  }
14948
15738
  /**
@@ -14961,7 +15751,7 @@ var init_userData = __esm({
14961
15751
  */
14962
15752
  createSignTermsAndConditionsMessageToSign() {
14963
15753
  return {
14964
- action: `SIGN_TERMS_AND_CONDITIONS`
15754
+ action: "SIGN_TERMS_AND_CONDITIONS"
14965
15755
  };
14966
15756
  }
14967
15757
  };
@@ -15136,6 +15926,7 @@ var init_coinApi = __esm({
15136
15926
  "src/packages/coin/api/coinApi.ts"() {
15137
15927
  "use strict";
15138
15928
  init_transactionsApiHelpers();
15929
+ init_grpcCasting();
15139
15930
  init_helpers();
15140
15931
  init_coin();
15141
15932
  _CoinApi = class _CoinApi {
@@ -15188,14 +15979,16 @@ var init_coinApi = __esm({
15188
15979
  let allCoinData = [];
15189
15980
  let cursor;
15190
15981
  do {
15191
- const paginatedCoins = await this.api.client.getCoins({
15192
- ...inputs,
15982
+ const paginatedCoins = await this.api.client.listCoins({
15983
+ coinType: inputs.coinType,
15193
15984
  owner: inputs.walletAddress,
15194
15985
  cursor
15195
15986
  });
15196
- const coinData = paginatedCoins.data;
15987
+ const coinData = paginatedCoins.objects.map(
15988
+ GrpcCasting.coinStructFromGrpcCoin
15989
+ );
15197
15990
  allCoinData = [...allCoinData, ...coinData];
15198
- if (paginatedCoins.data.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.nextCursor) {
15991
+ if (paginatedCoins.objects.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.cursor) {
15199
15992
  allCoinData.sort(
15200
15993
  (b, a) => Number(BigInt(a.balance) - BigInt(b.balance))
15201
15994
  );
@@ -15210,7 +16003,7 @@ var init_coinApi = __esm({
15210
16003
  }
15211
16004
  throw new Error("wallet does not have coins of sufficient balance");
15212
16005
  }
15213
- cursor = paginatedCoins.nextCursor;
16006
+ cursor = paginatedCoins.cursor;
15214
16007
  } while (true);
15215
16008
  };
15216
16009
  // fetchCoinsUntilAmountReachedOrEnd
@@ -15218,19 +16011,21 @@ var init_coinApi = __esm({
15218
16011
  let allCoinData = [];
15219
16012
  let cursor;
15220
16013
  do {
15221
- const paginatedCoins = await this.api.client.getCoins({
15222
- ...inputs,
16014
+ const paginatedCoins = await this.api.client.listCoins({
16015
+ coinType: inputs.coinType,
15223
16016
  owner: inputs.walletAddress,
15224
16017
  cursor
15225
16018
  });
15226
- const coinData = paginatedCoins.data;
16019
+ const coinData = paginatedCoins.objects.map(
16020
+ GrpcCasting.coinStructFromGrpcCoin
16021
+ );
15227
16022
  allCoinData = [...allCoinData, ...coinData];
15228
- if (paginatedCoins.data.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.nextCursor) {
16023
+ if (paginatedCoins.objects.length === 0 || !paginatedCoins.hasNextPage || !paginatedCoins.cursor) {
15229
16024
  return allCoinData.sort(
15230
16025
  (b, a) => Number(BigInt(b.coinObjectId) - BigInt(a.coinObjectId))
15231
16026
  );
15232
16027
  }
15233
- cursor = paginatedCoins.nextCursor;
16028
+ cursor = paginatedCoins.cursor;
15234
16029
  } while (true);
15235
16030
  };
15236
16031
  }
@@ -15377,7 +16172,7 @@ var init_dcaApi = __esm({
15377
16172
 
15378
16173
  // src/packages/farms/api/farmsApi.ts
15379
16174
  import {
15380
- Transaction as Transaction8
16175
+ Transaction as Transaction9
15381
16176
  } from "@mysten/sui/transactions";
15382
16177
  var _FarmsApi, FarmsApi;
15383
16178
  var init_farmsApi = __esm({
@@ -16439,6 +17234,49 @@ var init_farmsApi = __esm({
16439
17234
  ]
16440
17235
  });
16441
17236
  };
17237
+ /**
17238
+ * Creates a transaction command to set the minimum lock duration (ms) for a
17239
+ * staking pool. Owner-cap only; V2 vault module. Mirrors
17240
+ * `setStakingPoolMinStakeAmountTxV2`.
17241
+ */
17242
+ this.setStakingPoolMinLockDurationMsTxV2 = (inputs) => {
17243
+ const { tx } = inputs;
17244
+ return tx.moveCall({
17245
+ target: Helpers.transactions.createTxTarget(
17246
+ this.addresses.packages.vaultsV2,
17247
+ _FarmsApi.constants.moduleNames.vaultV2,
17248
+ "set_min_lock_duration_ms"
17249
+ ),
17250
+ typeArguments: [inputs.stakeCoinType],
17251
+ arguments: [
17252
+ tx.object(inputs.ownerCapId),
17253
+ tx.object(inputs.stakingPoolId),
17254
+ tx.object(this.addresses.objects.version),
17255
+ tx.pure.u64(inputs.lockDurationMs)
17256
+ ]
17257
+ });
17258
+ };
17259
+ /**
17260
+ * Creates a transaction command to set the maximum lock duration (ms) for a
17261
+ * staking pool. Owner-cap only; V2 vault module.
17262
+ */
17263
+ this.setStakingPoolMaxLockDurationMsTxV2 = (inputs) => {
17264
+ const { tx } = inputs;
17265
+ return tx.moveCall({
17266
+ target: Helpers.transactions.createTxTarget(
17267
+ this.addresses.packages.vaultsV2,
17268
+ _FarmsApi.constants.moduleNames.vaultV2,
17269
+ "set_max_lock_duration_ms"
17270
+ ),
17271
+ typeArguments: [inputs.stakeCoinType],
17272
+ arguments: [
17273
+ tx.object(inputs.ownerCapId),
17274
+ tx.object(inputs.stakingPoolId),
17275
+ tx.object(this.addresses.objects.version),
17276
+ tx.pure.u64(inputs.lockDurationMs)
17277
+ ]
17278
+ });
17279
+ };
16442
17280
  /**
16443
17281
  * Creates a Move call (V1) to **remove undistributed reward coins** from a staking pool.
16444
17282
  * Only callable by the pool **owner** (validated via `ownerCapId`). This does not claw back
@@ -16563,7 +17401,7 @@ var init_farmsApi = __esm({
16563
17401
  */
16564
17402
  this.fetchBuildStakeTxV1 = async (inputs) => {
16565
17403
  const { walletAddress, isSponsoredTx } = inputs;
16566
- const tx = new Transaction8();
17404
+ const tx = new Transaction9();
16567
17405
  tx.setSender(walletAddress);
16568
17406
  const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
16569
17407
  tx,
@@ -16587,7 +17425,7 @@ var init_farmsApi = __esm({
16587
17425
  */
16588
17426
  this.fetchBuildStakeTxV2 = async (inputs) => {
16589
17427
  const { walletAddress, isSponsoredTx } = inputs;
16590
- const tx = new Transaction8();
17428
+ const tx = new Transaction9();
16591
17429
  tx.setSender(walletAddress);
16592
17430
  const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
16593
17431
  tx,
@@ -16613,7 +17451,7 @@ var init_farmsApi = __esm({
16613
17451
  */
16614
17452
  this.fetchBuildDepositPrincipalTxV1 = async (inputs) => {
16615
17453
  const { walletAddress, isSponsoredTx } = inputs;
16616
- const tx = new Transaction8();
17454
+ const tx = new Transaction9();
16617
17455
  tx.setSender(walletAddress);
16618
17456
  const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
16619
17457
  tx,
@@ -16636,7 +17474,7 @@ var init_farmsApi = __esm({
16636
17474
  */
16637
17475
  this.fetchBuildDepositPrincipalTxV2 = async (inputs) => {
16638
17476
  const { walletAddress, isSponsoredTx } = inputs;
16639
- const tx = new Transaction8();
17477
+ const tx = new Transaction9();
16640
17478
  tx.setSender(walletAddress);
16641
17479
  const stakeCoinId = await this.api.Coin().fetchCoinWithAmountTx({
16642
17480
  tx,
@@ -16660,7 +17498,7 @@ var init_farmsApi = __esm({
16660
17498
  */
16661
17499
  this.buildWithdrawPrincipalTxV1 = (inputs) => {
16662
17500
  const { walletAddress } = inputs;
16663
- const tx = new Transaction8();
17501
+ const tx = new Transaction9();
16664
17502
  tx.setSender(walletAddress);
16665
17503
  const withdrawnCoin = this.withdrawPrincipalTxV1({
16666
17504
  ...inputs,
@@ -16676,7 +17514,7 @@ var init_farmsApi = __esm({
16676
17514
  */
16677
17515
  this.buildWithdrawPrincipalTxV2 = (inputs) => {
16678
17516
  const { walletAddress } = inputs;
16679
- const tx = new Transaction8();
17517
+ const tx = new Transaction9();
16680
17518
  tx.setSender(walletAddress);
16681
17519
  const withdrawnCoin = this.withdrawPrincipalTxV2({
16682
17520
  ...inputs,
@@ -16700,7 +17538,7 @@ var init_farmsApi = __esm({
16700
17538
  stakedPositionIds: [inputs.stakedPositionId]
16701
17539
  });
16702
17540
  } else {
16703
- tx = new Transaction8();
17541
+ tx = new Transaction9();
16704
17542
  tx.setSender(walletAddress);
16705
17543
  }
16706
17544
  const withdrawnCoin = this.withdrawPrincipalTxV1({
@@ -16730,7 +17568,7 @@ var init_farmsApi = __esm({
16730
17568
  stakedPositionIds: [inputs.stakedPositionId]
16731
17569
  });
16732
17570
  } else {
16733
- tx = new Transaction8();
17571
+ tx = new Transaction9();
16734
17572
  tx.setSender(walletAddress);
16735
17573
  }
16736
17574
  const withdrawnCoin = this.withdrawPrincipalTxV2({
@@ -16823,7 +17661,7 @@ var init_farmsApi = __esm({
16823
17661
  */
16824
17662
  this.buildHarvestRewardsTxV1 = (inputs) => {
16825
17663
  const { walletAddress, stakedPositionIds } = inputs;
16826
- const tx = inputs.tx ?? new Transaction8();
17664
+ const tx = inputs.tx ?? new Transaction9();
16827
17665
  tx.setSender(walletAddress);
16828
17666
  const harvestRewardsCap = this.beginHarvestTxV1({
16829
17667
  ...inputs,
@@ -16875,7 +17713,7 @@ var init_farmsApi = __esm({
16875
17713
  */
16876
17714
  this.buildHarvestRewardsTxV2 = (inputs) => {
16877
17715
  const { walletAddress, stakedPositionIds } = inputs;
16878
- const tx = inputs.tx ?? new Transaction8();
17716
+ const tx = inputs.tx ?? new Transaction9();
16879
17717
  tx.setSender(walletAddress);
16880
17718
  const firstPositionId = stakedPositionIds[0];
16881
17719
  const harvestRewardsCap = this.beginHarvestTxV2({
@@ -16933,7 +17771,7 @@ var init_farmsApi = __esm({
16933
17771
  */
16934
17772
  this.buildCreateStakingPoolTxV1 = (inputs) => {
16935
17773
  const { walletAddress } = inputs;
16936
- const tx = new Transaction8();
17774
+ const tx = new Transaction9();
16937
17775
  tx.setSender(walletAddress);
16938
17776
  const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV1({
16939
17777
  ...inputs,
@@ -16959,7 +17797,7 @@ var init_farmsApi = __esm({
16959
17797
  */
16960
17798
  this.buildCreateStakingPoolTxV2 = (inputs) => {
16961
17799
  const { walletAddress } = inputs;
16962
- const tx = new Transaction8();
17800
+ const tx = new Transaction9();
16963
17801
  tx.setSender(walletAddress);
16964
17802
  const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV2({
16965
17803
  ...inputs,
@@ -16985,7 +17823,7 @@ var init_farmsApi = __esm({
16985
17823
  */
16986
17824
  this.fetchBuildInitializeStakingPoolRewardTxV1 = async (inputs) => {
16987
17825
  const { walletAddress, isSponsoredTx } = inputs;
16988
- const tx = new Transaction8();
17826
+ const tx = new Transaction9();
16989
17827
  tx.setSender(walletAddress);
16990
17828
  const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
16991
17829
  tx,
@@ -17004,7 +17842,7 @@ var init_farmsApi = __esm({
17004
17842
  */
17005
17843
  this.fetchBuildInitializeStakingPoolRewardTxV2 = async (inputs) => {
17006
17844
  const { walletAddress, isSponsoredTx } = inputs;
17007
- const tx = new Transaction8();
17845
+ const tx = new Transaction9();
17008
17846
  tx.setSender(walletAddress);
17009
17847
  const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
17010
17848
  tx,
@@ -17024,7 +17862,7 @@ var init_farmsApi = __esm({
17024
17862
  */
17025
17863
  this.fetchBuildTopUpStakingPoolRewardsTxV1 = async (inputs) => {
17026
17864
  const { walletAddress, isSponsoredTx } = inputs;
17027
- const tx = new Transaction8();
17865
+ const tx = new Transaction9();
17028
17866
  tx.setSender(walletAddress);
17029
17867
  for (const reward of inputs.rewards) {
17030
17868
  const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
@@ -17050,7 +17888,7 @@ var init_farmsApi = __esm({
17050
17888
  */
17051
17889
  this.fetchBuildTopUpStakingPoolRewardsTxV2 = async (inputs) => {
17052
17890
  const { walletAddress, isSponsoredTx } = inputs;
17053
- const tx = new Transaction8();
17891
+ const tx = new Transaction9();
17054
17892
  tx.setSender(walletAddress);
17055
17893
  for (const reward of inputs.rewards) {
17056
17894
  const rewardCoinId = await this.api.Coin().fetchCoinWithAmountTx({
@@ -17077,7 +17915,7 @@ var init_farmsApi = __esm({
17077
17915
  */
17078
17916
  this.buildIncreaseStakingPoolRewardsEmissionsTxV1 = (inputs) => {
17079
17917
  const { walletAddress } = inputs;
17080
- const tx = new Transaction8();
17918
+ const tx = new Transaction9();
17081
17919
  tx.setSender(walletAddress);
17082
17920
  for (const reward of inputs.rewards) {
17083
17921
  this.increaseStakingPoolRewardEmissionsTxV1({
@@ -17095,7 +17933,7 @@ var init_farmsApi = __esm({
17095
17933
  */
17096
17934
  this.buildIncreaseStakingPoolRewardsEmissionsTxV2 = (inputs) => {
17097
17935
  const { walletAddress } = inputs;
17098
- const tx = new Transaction8();
17936
+ const tx = new Transaction9();
17099
17937
  tx.setSender(walletAddress);
17100
17938
  for (const reward of inputs.rewards) {
17101
17939
  this.increaseStakingPoolRewardEmissionsTxV2({
@@ -17123,6 +17961,12 @@ var init_farmsApi = __esm({
17123
17961
  this.buildSetStakingPoolMinStakeAmountTxV2 = Helpers.transactions.createBuildTxFunc(
17124
17962
  this.setStakingPoolMinStakeAmountTxV2
17125
17963
  );
17964
+ this.buildSetStakingPoolMinLockDurationMsTxV2 = Helpers.transactions.createBuildTxFunc(
17965
+ this.setStakingPoolMinLockDurationMsTxV2
17966
+ );
17967
+ this.buildSetStakingPoolMaxLockDurationMsTxV2 = Helpers.transactions.createBuildTxFunc(
17968
+ this.setStakingPoolMaxLockDurationMsTxV2
17969
+ );
17126
17970
  /**
17127
17971
  * Builds a transaction for **removing undistributed reward coins** from a staking pool (V1).
17128
17972
  * Requires the pool **OwnerCap**. The removal is specific to a `rewardCoinType`.
@@ -17132,7 +17976,7 @@ var init_farmsApi = __esm({
17132
17976
  */
17133
17977
  this.buildRemoveStakingPoolRewardTxV1 = (inputs) => {
17134
17978
  const { walletAddress } = inputs;
17135
- const tx = new Transaction8();
17979
+ const tx = new Transaction9();
17136
17980
  tx.setSender(walletAddress);
17137
17981
  for (const reward of inputs.rewards) {
17138
17982
  this.removeStakingPoolRewardTxV1({
@@ -17152,7 +17996,7 @@ var init_farmsApi = __esm({
17152
17996
  */
17153
17997
  this.buildRemoveStakingPoolRewardTxV2 = (inputs) => {
17154
17998
  const { walletAddress } = inputs;
17155
- const tx = new Transaction8();
17999
+ const tx = new Transaction9();
17156
18000
  tx.setSender(walletAddress);
17157
18001
  for (const reward of inputs.rewards) {
17158
18002
  this.removeStakingPoolRewardTxV2({
@@ -17561,7 +18405,7 @@ var init_farmsApi = __esm({
17561
18405
 
17562
18406
  // src/packages/faucet/api/faucetApi.ts
17563
18407
  import {
17564
- Transaction as Transaction9
18408
+ Transaction as Transaction10
17565
18409
  } from "@mysten/sui/transactions";
17566
18410
  var _FaucetApi, FaucetApi;
17567
18411
  var init_faucetApi = __esm({
@@ -17569,7 +18413,6 @@ var init_faucetApi = __esm({
17569
18413
  "use strict";
17570
18414
  init_eventsApiHelpers();
17571
18415
  init_transactionsApiHelpers();
17572
- init_utils();
17573
18416
  init_coin2();
17574
18417
  init_sui2();
17575
18418
  init_faucetApiCasting();
@@ -17590,35 +18433,24 @@ var init_faucetApi = __esm({
17590
18433
  // =========================================================================
17591
18434
  // Transaction Commands
17592
18435
  // =========================================================================
17593
- // public addCoinTx = (inputs: {
17594
- // tx: Transaction;
17595
- // treasuryCapId: ObjectId;
17596
- // treasuryCapType: AnyObjectType;
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
- // };
18436
+ /**
18437
+ * Mints `coinType`'s configured default amount and returns the resulting
18438
+ * `Coin<T>`. Use {@link buildRequestCoinTx} to mint and transfer it to a
18439
+ * wallet in one transaction.
18440
+ */
17612
18441
  this.requestCoinTx = (inputs) => {
17613
18442
  const { tx, coinType } = inputs;
17614
18443
  return tx.moveCall({
17615
18444
  target: TransactionsApiHelpers.createTxTarget(
17616
18445
  this.addresses.packages.faucet,
17617
18446
  _FaucetApi.constants.moduleNames.faucet,
17618
- "request_default_amount"
18447
+ "mint"
17619
18448
  ),
17620
18449
  typeArguments: [coinType],
17621
- arguments: [tx.object(this.addresses.objects.faucet)]
18450
+ arguments: [
18451
+ tx.object(this.addresses.objects.faucet),
18452
+ tx.object(this.addresses.objects.config)
18453
+ ]
17622
18454
  });
17623
18455
  };
17624
18456
  this.mintSuiFrenTx = (inputs) => {
@@ -17643,12 +18475,17 @@ var init_faucetApi = __esm({
17643
18475
  // =========================================================================
17644
18476
  // Transaction Builders
17645
18477
  // =========================================================================
17646
- this.buildRequestCoinTx = Helpers.transactions.createBuildTxFunc(
17647
- this.requestCoinTx
17648
- );
18478
+ this.buildRequestCoinTx = (inputs) => {
18479
+ const { walletAddress, coinType } = inputs;
18480
+ const tx = new Transaction10();
18481
+ tx.setSender(walletAddress);
18482
+ const coin = this.requestCoinTx({ tx, coinType });
18483
+ tx.transferObjects([coin], walletAddress);
18484
+ return tx;
18485
+ };
17649
18486
  this.fetchBuildMintSuiFrenTx = async (inputs) => {
17650
18487
  const { walletAddress, mintFee, suiFrenType } = inputs;
17651
- const tx = new Transaction9();
18488
+ const tx = new Transaction10();
17652
18489
  tx.setSender(walletAddress);
17653
18490
  const suiPaymentCoinId = await this.api.Coin().fetchCoinWithAmountTx({
17654
18491
  tx,
@@ -17662,7 +18499,6 @@ var init_faucetApi = __esm({
17662
18499
  // =========================================================================
17663
18500
  // Events
17664
18501
  // =========================================================================
17665
- // TODO: add to indexer
17666
18502
  this.fetchMintCoinEvents = async (inputs) => await this.api.Events().fetchCastEventsWithCursor({
17667
18503
  ...inputs,
17668
18504
  query: {
@@ -17670,7 +18506,6 @@ var init_faucetApi = __esm({
17670
18506
  },
17671
18507
  eventFromEventOnChain: FaucetApiCasting.faucetMintCoinEventFromOnChain
17672
18508
  });
17673
- // TODO: add to indexer
17674
18509
  this.fetchAddCoinEvents = async (inputs) => await this.api.Events().fetchCastEventsWithCursor(
17675
18510
  {
17676
18511
  ...inputs,
@@ -17721,7 +18556,7 @@ var init_faucetApi = __esm({
17721
18556
  },
17722
18557
  eventNames: {
17723
18558
  mintCoin: "MintedCoin",
17724
- addCoin: "AddedCoinEvent"
18559
+ addCoin: "AddedCoin"
17725
18560
  }
17726
18561
  };
17727
18562
  FaucetApi = _FaucetApi;
@@ -17812,7 +18647,7 @@ var init_multisigApi = __esm({
17812
18647
 
17813
18648
  // src/packages/nftAmm/api/nftAmmApi.ts
17814
18649
  import {
17815
- Transaction as Transaction10
18650
+ Transaction as Transaction11
17816
18651
  } from "@mysten/sui/transactions";
17817
18652
  var _NftAmmApi, NftAmmApi;
17818
18653
  var init_nftAmmApi = __esm({
@@ -17857,7 +18692,7 @@ var init_nftAmmApi = __esm({
17857
18692
  // Transaction Builders
17858
18693
  // =========================================================================
17859
18694
  this.fetchBuildBuyTx = async (inputs) => {
17860
- const tx = new Transaction10();
18695
+ const tx = new Transaction11();
17861
18696
  tx.setSender(inputs.walletAddress);
17862
18697
  const { market } = inputs;
17863
18698
  const marketObject = market.market;
@@ -17883,7 +18718,7 @@ var init_nftAmmApi = __esm({
17883
18718
  return tx;
17884
18719
  };
17885
18720
  this.fetchBuildSellTx = async (inputs) => {
17886
- const tx = new Transaction10();
18721
+ const tx = new Transaction11();
17887
18722
  tx.setSender(inputs.walletAddress);
17888
18723
  const { market } = inputs;
17889
18724
  const marketObject = market.market;
@@ -17903,7 +18738,7 @@ var init_nftAmmApi = __esm({
17903
18738
  return tx;
17904
18739
  };
17905
18740
  this.fetchBuildDepositTx = async (inputs) => {
17906
- const tx = new Transaction10();
18741
+ const tx = new Transaction11();
17907
18742
  tx.setSender(inputs.walletAddress);
17908
18743
  const { market } = inputs;
17909
18744
  const marketObject = market.market;
@@ -17930,7 +18765,7 @@ var init_nftAmmApi = __esm({
17930
18765
  return tx;
17931
18766
  };
17932
18767
  this.fetchBuildWithdrawTx = async (inputs) => {
17933
- const tx = new Transaction10();
18768
+ const tx = new Transaction11();
17934
18769
  tx.setSender(inputs.walletAddress);
17935
18770
  const { market } = inputs;
17936
18771
  const marketObject = market.market;
@@ -19547,9 +20382,9 @@ var init_perpetualsApi = __esm({
19547
20382
  // src/packages/pools/api/poolsApi.ts
19548
20383
  import { bcs as bcs2 } from "@mysten/sui/bcs";
19549
20384
  import {
19550
- Transaction as Transaction11
20385
+ Transaction as Transaction12
19551
20386
  } from "@mysten/sui/transactions";
19552
- import { fromBase64, normalizeSuiObjectId } from "@mysten/sui/utils";
20387
+ import { fromBase64 as fromBase642, normalizeSuiObjectId } from "@mysten/sui/utils";
19553
20388
  var _PoolsApi, PoolsApi;
19554
20389
  var init_poolsApi = __esm({
19555
20390
  "src/packages/pools/api/poolsApi.ts"() {
@@ -19754,7 +20589,7 @@ var init_poolsApi = __esm({
19754
20589
  const compiledModulesAndDeps = JSON.parse(compilations[lpCoinDecimals]);
19755
20590
  return tx.publish({
19756
20591
  modules: compiledModulesAndDeps.modules.map(
19757
- (m) => Array.from(fromBase64(m))
20592
+ (m) => Array.from(fromBase642(m))
19758
20593
  ),
19759
20594
  dependencies: compiledModulesAndDeps.dependencies.map(
19760
20595
  (addr) => normalizeSuiObjectId(addr)
@@ -20072,7 +20907,7 @@ var init_poolsApi = __esm({
20072
20907
  referrer,
20073
20908
  isSponsoredTx
20074
20909
  } = inputs;
20075
- const tx = new Transaction11();
20910
+ const tx = new Transaction12();
20076
20911
  tx.setSender(walletAddress);
20077
20912
  if (referrer) {
20078
20913
  this.api.ReferralVault().updateReferrerTx({
@@ -20168,7 +21003,7 @@ var init_poolsApi = __esm({
20168
21003
  referrer,
20169
21004
  isSponsoredTx
20170
21005
  } = inputs;
20171
- const tx = new Transaction11();
21006
+ const tx = new Transaction12();
20172
21007
  tx.setSender(walletAddress);
20173
21008
  if (referrer) {
20174
21009
  this.api.ReferralVault().updateReferrerTx({
@@ -20234,7 +21069,7 @@ var init_poolsApi = __esm({
20234
21069
  slippage,
20235
21070
  referrer
20236
21071
  } = inputs;
20237
- const tx = new Transaction11();
21072
+ const tx = new Transaction12();
20238
21073
  tx.setSender(walletAddress);
20239
21074
  if (referrer) {
20240
21075
  this.api.ReferralVault().updateReferrerTx({
@@ -20279,7 +21114,7 @@ var init_poolsApi = __esm({
20279
21114
  */
20280
21115
  this.fetchBuildAllCoinWithdrawTx = async (inputs) => {
20281
21116
  const { walletAddress, pool, lpCoinAmount, referrer } = inputs;
20282
- const tx = new Transaction11();
21117
+ const tx = new Transaction12();
20283
21118
  tx.setSender(walletAddress);
20284
21119
  if (referrer) {
20285
21120
  this.api.ReferralVault().updateReferrerTx({
@@ -20325,7 +21160,7 @@ var init_poolsApi = __esm({
20325
21160
  */
20326
21161
  this.buildPublishLpCoinTx = (inputs) => {
20327
21162
  const { lpCoinDecimals } = inputs;
20328
- const tx = new Transaction11();
21163
+ const tx = new Transaction12();
20329
21164
  tx.setSender(inputs.walletAddress);
20330
21165
  const upgradeCap = this.publishLpCoinTx({ tx, lpCoinDecimals });
20331
21166
  tx.transferObjects([upgradeCap], inputs.walletAddress);
@@ -20567,7 +21402,7 @@ var init_poolsApi = __esm({
20567
21402
 
20568
21403
  // src/packages/referralVault/api/referralVaultApi.ts
20569
21404
  import { bcs as bcs3 } from "@mysten/sui/bcs";
20570
- import { Transaction as Transaction12 } from "@mysten/sui/transactions";
21405
+ import { Transaction as Transaction13 } from "@mysten/sui/transactions";
20571
21406
  var _ReferralVaultApi, ReferralVaultApi;
20572
21407
  var init_referralVaultApi = __esm({
20573
21408
  "src/packages/referralVault/api/referralVaultApi.ts"() {
@@ -20668,7 +21503,7 @@ var init_referralVaultApi = __esm({
20668
21503
  // Inspections
20669
21504
  // =========================================================================
20670
21505
  this.fetchBalanceOfRebate = async (inputs) => {
20671
- const tx = new Transaction12();
21506
+ const tx = new Transaction13();
20672
21507
  this.balanceOfRebateTx({ ...inputs, tx });
20673
21508
  const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
20674
21509
  tx
@@ -20676,7 +21511,7 @@ var init_referralVaultApi = __esm({
20676
21511
  return Casting.bigIntFromBytes(bytes);
20677
21512
  };
20678
21513
  this.fetchReferrer = async (inputs) => {
20679
- const tx = new Transaction12();
21514
+ const tx = new Transaction13();
20680
21515
  this.referrerForTx({ ...inputs, tx });
20681
21516
  const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
20682
21517
  tx
@@ -20799,7 +21634,7 @@ var init_routerApi = __esm({
20799
21634
 
20800
21635
  // src/packages/staking/api/stakingApi.ts
20801
21636
  import {
20802
- Transaction as Transaction13
21637
+ Transaction as Transaction14
20803
21638
  } from "@mysten/sui/transactions";
20804
21639
  var _StakingApi, StakingApi;
20805
21640
  var init_stakingApi = __esm({
@@ -21083,7 +21918,7 @@ var init_stakingApi = __esm({
21083
21918
  if (externalFee) {
21084
21919
  _StakingApi.assertValidExternalFee(externalFee);
21085
21920
  }
21086
- const tx = new Transaction13();
21921
+ const tx = new Transaction14();
21087
21922
  tx.setSender(inputs.walletAddress);
21088
21923
  if (referrer) {
21089
21924
  this.api.ReferralVault().updateReferrerTx({
@@ -21124,7 +21959,7 @@ var init_stakingApi = __esm({
21124
21959
  if (externalFee) {
21125
21960
  _StakingApi.assertValidExternalFee(externalFee);
21126
21961
  }
21127
- const tx = new Transaction13();
21962
+ const tx = new Transaction14();
21128
21963
  tx.setSender(inputs.walletAddress);
21129
21964
  if (referrer) {
21130
21965
  this.api.ReferralVault().updateReferrerTx({
@@ -21172,7 +22007,7 @@ var init_stakingApi = __esm({
21172
22007
  */
21173
22008
  this.fetchBuildStakeStakedSuiTx = async (inputs) => {
21174
22009
  const { referrer } = inputs;
21175
- const tx = new Transaction13();
22010
+ const tx = new Transaction14();
21176
22011
  tx.setSender(inputs.walletAddress);
21177
22012
  if (referrer) {
21178
22013
  this.api.ReferralVault().updateReferrerTx({
@@ -21189,7 +22024,7 @@ var init_stakingApi = __esm({
21189
22024
  return tx;
21190
22025
  };
21191
22026
  this.buildUpdateValidatorFeeTx = async (inputs) => {
21192
- const tx = new Transaction13();
22027
+ const tx = new Transaction14();
21193
22028
  tx.setSender(inputs.walletAddress);
21194
22029
  this.updateValidatorFeeTx({
21195
22030
  ...inputs,
@@ -21434,6 +22269,28 @@ var init_suiApi = __esm({
21434
22269
  /**
21435
22270
  * @deprecated Use `getSystemState()` method instead.
21436
22271
  * This method will be removed in a future release.
22272
+ *
22273
+ * @remarks **Remaining JSON-RPC surface** — see
22274
+ * {@link AftermathApi.jsonRpcClient}. gRPC has no `SuiSystemStateSummary`
22275
+ * equivalent. `client.core.getCurrentSystemState()` carries no validators at
22276
+ * all, and while `client.ledgerService.getEpoch({ readMask: { paths:
22277
+ * ["system_state"] } })` does return them (verified: 125 active validators on
22278
+ * mainnet, under the runtime key `validators`, not the generated
22279
+ * `validatorSet`), its validator shape is not a superset of
22280
+ * `SuiValidatorSummary`: keys are renamed (`address`/`p2PAddress`/
22281
+ * `networkAddress`/`protocolPublicKey` vs `suiAddress`/`p2pAddress`/
22282
+ * `netAddress`/`protocolPubkeyBytes`), the staking-pool fields are nested
22283
+ * rather than flattened, numbers are `bigint` rather than decimal strings,
22284
+ * public keys are `Uint8Array` rather than base64, and
22285
+ * `stakingPoolDeactivationEpoch` / `validatorVeryLowStakeThreshold` are
22286
+ * absent entirely. Remapping it would change what this method returns.
22287
+ *
22288
+ * Note `Sui().getSystemState()` — the public method — does not touch the
22289
+ * fullnode; it reads the Aftermath API. Only this deprecated helper does.
22290
+ *
22291
+ * @throws If no `jsonRpcClient` was passed to {@link AftermathApi}, since it
22292
+ * is optional there.
22293
+ *
21437
22294
  * @example
21438
22295
  * ```typescript
21439
22296
  * const afSdk = await Aftermath.create({ network: "MAINNET" });
@@ -21444,7 +22301,10 @@ var init_suiApi = __esm({
21444
22301
  * console.log(systemState.epoch, systemState.validators);
21445
22302
  */
21446
22303
  this.fetchSystemState = async () => {
21447
- const systemState = await this.api.client.getLatestSuiSystemState();
22304
+ const jsonRpcClient = this.api.requireJsonRpcClient(
22305
+ "Sui().fetchSystemState"
22306
+ );
22307
+ const systemState = await jsonRpcClient.getLatestSuiSystemState();
21448
22308
  const activeValidators = systemState.activeValidators.map((validator) => ({
21449
22309
  ...validator,
21450
22310
  suiAddress: Helpers.addLeadingZeroesToType(validator.suiAddress)
@@ -21461,7 +22321,7 @@ var init_suiApi = __esm({
21461
22321
 
21462
22322
  // src/packages/suiFrens/api/suiFrensApi.ts
21463
22323
  import {
21464
- Transaction as Transaction14
22324
+ Transaction as Transaction15
21465
22325
  } from "@mysten/sui/transactions";
21466
22326
  import { bcs as bcs4 } from "@mysten/sui/bcs";
21467
22327
  var _SuiFrensApi, SuiFrensApi;
@@ -21487,7 +22347,7 @@ var init_suiFrensApi = __esm({
21487
22347
  // Inspections
21488
22348
  // =========================================================================
21489
22349
  this.fetchMixingLimitsAndLastEpochMixeds = async (inputs) => {
21490
- const tx = new Transaction14();
22350
+ const tx = new Transaction15();
21491
22351
  this.devInspectMixLimitAndLastEpochMixedMulTx({ ...inputs, tx });
21492
22352
  const [mixLimitBytes, lastEpochMixedBytes] = await this.api.Inspections().fetchAllBytesFromTxOutput({
21493
22353
  tx
@@ -21501,7 +22361,7 @@ var init_suiFrensApi = __esm({
21501
22361
  };
21502
22362
  this.fetchMixingLimit = async (inputs) => {
21503
22363
  if (inputs.suiFrenType === this.objectTypes.bullshark) return void 0;
21504
- const tx = new Transaction14();
22364
+ const tx = new Transaction15();
21505
22365
  this.mixingLimitTx({ tx, ...inputs });
21506
22366
  const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput(
21507
22367
  {
@@ -21513,7 +22373,7 @@ var init_suiFrensApi = __esm({
21513
22373
  };
21514
22374
  this.fetchLastEpochMixed = async (inputs) => {
21515
22375
  if (inputs.suiFrenType === this.objectTypes.bullshark) return void 0;
21516
- const tx = new Transaction14();
22376
+ const tx = new Transaction15();
21517
22377
  this.lastEpochMixedTx({ tx, ...inputs });
21518
22378
  const bytes = await this.api.Inspections().fetchFirstBytesFromTxOutput(
21519
22379
  {
@@ -21525,7 +22385,7 @@ var init_suiFrensApi = __esm({
21525
22385
  };
21526
22386
  this.fetchStakedSuiFrenMetadataIds = async (inputs) => {
21527
22387
  const { suiFrenIds } = inputs;
21528
- const tx = new Transaction14();
22388
+ const tx = new Transaction15();
21529
22389
  this.devInspectMetadataObjectIdMulTx({ tx, suiFrenIds });
21530
22390
  const idBytes = await this.api.Inspections().fetchFirstBytesFromTxOutput({
21531
22391
  tx
@@ -21590,11 +22450,7 @@ var init_suiFrensApi = __esm({
21590
22450
  const partialSuiFrens = await this.api.Objects().fetchCastObjectBatch({
21591
22451
  objectIds: suiFrenIds,
21592
22452
  objectFromSuiObjectResponse: Casting.suiFrens.partialSuiFrenObjectFromSuiObjectResponse,
21593
- options: {
21594
- showDisplay: true,
21595
- showType: true,
21596
- showContent: true
21597
- }
22453
+ withDisplay: true
21598
22454
  });
21599
22455
  return this.fetchCompletePartialSuiFrenObjects({
21600
22456
  partialSuiFrens,
@@ -21626,11 +22482,7 @@ var init_suiFrensApi = __esm({
21626
22482
  const stakedSuiFrenData = await this.api.Objects().fetchCastObjectBatch({
21627
22483
  objectIds: stakedSuiFrenIds,
21628
22484
  objectFromSuiObjectResponse: Casting.suiFrens.partialSuiFrenAndStakedSuiFrenMetadataV1ObjectFromSuiObjectResponse,
21629
- options: {
21630
- showDisplay: true,
21631
- showType: true,
21632
- showContent: true
21633
- }
22485
+ withDisplay: true
21634
22486
  });
21635
22487
  const suiFrens = await this.fetchCompletePartialSuiFrenObjects({
21636
22488
  partialSuiFrens: stakedSuiFrenData.map((data) => data.partialSuiFren),
@@ -21675,11 +22527,7 @@ var init_suiFrensApi = __esm({
21675
22527
  return this.api.Objects().fetchCastObjectBatch({
21676
22528
  objectIds,
21677
22529
  objectFromSuiObjectResponse: Casting.suiFrens.accessoryObjectFromSuiObjectResponse,
21678
- options: {
21679
- showDisplay: true,
21680
- showType: true,
21681
- showContent: true
21682
- }
22530
+ withDisplay: true
21683
22531
  });
21684
22532
  };
21685
22533
  // =========================================================================
@@ -22085,7 +22933,7 @@ var init_suiFrensApi = __esm({
22085
22933
  baseFee,
22086
22934
  isSponsoredTx
22087
22935
  } = inputs;
22088
- const tx = new Transaction14();
22936
+ const tx = new Transaction15();
22089
22937
  tx.setSender(walletAddress);
22090
22938
  const totalFee = baseFee + SuiFrens.calcTotalInternalMixFee({
22091
22939
  mixFee1: suiFrenParentOne.mixFee,
@@ -22135,7 +22983,7 @@ var init_suiFrensApi = __esm({
22135
22983
  // =========================================================================
22136
22984
  this.fetchBuildHarvestFeesTx = async (inputs) => {
22137
22985
  const { stakedPositionIds } = inputs;
22138
- const tx = new Transaction14();
22986
+ const tx = new Transaction15();
22139
22987
  tx.setSender(inputs.walletAddress);
22140
22988
  const harvestFeesEventMetadataId = this.beginHarvestTx({ tx });
22141
22989
  let harvestedCoins = [];
@@ -22398,26 +23246,17 @@ var init_nftsApi = __esm({
22398
23246
  this.fetchOwnedNfts = async (inputs) => {
22399
23247
  const objects = await this.api.Objects().fetchOwnedObjects({
22400
23248
  ...inputs,
22401
- options: {
22402
- // NOTE: do we need all of this ?
22403
- showContent: true,
22404
- showOwner: true,
22405
- showType: true,
22406
- showDisplay: true
22407
- }
23249
+ // @dev: `showDisplay` -> `withDisplay`, which becomes
23250
+ // `include: { display: true }`. `nftFromSuiObject` reads display, so
23251
+ // dropping this would leave every NFT with an empty one.
23252
+ withDisplay: true
22408
23253
  });
22409
23254
  return Casting.nfts.nftsFromSuiObjects(objects);
22410
23255
  };
22411
23256
  this.fetchNfts = async (inputs) => {
22412
23257
  const objects = await this.api.Objects().fetchObjectBatch({
22413
23258
  ...inputs,
22414
- options: {
22415
- // NOTE: do we need all of this ?
22416
- showContent: true,
22417
- showOwner: true,
22418
- showType: true,
22419
- showDisplay: true
22420
- }
23259
+ withDisplay: true
22421
23260
  });
22422
23261
  return Casting.nfts.nftsFromSuiObjects(objects);
22423
23262
  };
@@ -22451,7 +23290,7 @@ var init_nftsApi = __esm({
22451
23290
  const { kioskOwnerCapIds } = inputs;
22452
23291
  return this.api.Objects().fetchCastObjectBatch({
22453
23292
  objectIds: kioskOwnerCapIds,
22454
- objectFromSuiObjectResponse: (response) => response.data?.type && Helpers.addLeadingZeroesToType(response.data?.type) === this.objectTypes.personalKioskCap ? Casting.nfts.kioskOwnerCapFromPersonalKioskCapSuiObject(response) : Casting.nfts.kioskOwnerCapFromSuiObject(response)
23293
+ objectFromSuiObjectResponse: (object) => object.type && Helpers.addLeadingZeroesToType(object.type) === this.objectTypes.personalKioskCap ? Casting.nfts.kioskOwnerCapFromPersonalKioskCapSuiObject(object) : Casting.nfts.kioskOwnerCapFromSuiObject(object)
22455
23294
  });
22456
23295
  };
22457
23296
  this.fetchKiosks = async (inputs) => {
@@ -22524,25 +23363,35 @@ var init_walletApi = __esm({
22524
23363
  // =========================================================================
22525
23364
  this.fetchCoinBalance = async (inputs) => {
22526
23365
  const { walletAddress, coin } = inputs;
22527
- const coinBalance = await this.api.client.getBalance({
23366
+ const { balance } = await this.api.client.getBalance({
22528
23367
  owner: walletAddress,
22529
23368
  coinType: Helpers.stripLeadingZeroesFromType(coin)
22530
23369
  });
22531
- return BigInt(coinBalance.totalBalance);
23370
+ return BigInt(balance.balance);
22532
23371
  };
22533
23372
  // TODO: make toBigIntSafe function ?
22534
23373
  // TODO: return prices here as well and sort ?
22535
23374
  this.fetchAllCoinBalances = async (inputs) => {
22536
23375
  const { walletAddress } = inputs;
22537
- const allBalances = await this.api.client.getAllBalances({
22538
- owner: walletAddress
22539
- });
23376
+ const allBalances = [];
23377
+ let cursor;
23378
+ do {
23379
+ const page = await this.api.client.listBalances({
23380
+ owner: walletAddress,
23381
+ cursor
23382
+ });
23383
+ allBalances.push(...page.balances);
23384
+ if (page.balances.length === 0 || !page.hasNextPage || !page.cursor) {
23385
+ break;
23386
+ }
23387
+ cursor = page.cursor;
23388
+ } while (true);
22540
23389
  const coinsToBalance = allBalances.reduce(
22541
23390
  (acc, balance) => {
22542
23391
  return {
22543
23392
  ...acc,
22544
23393
  [Helpers.addLeadingZeroesToType(balance.coinType)]: BigInt(
22545
- balance.totalBalance
23394
+ balance.balance
22546
23395
  )
22547
23396
  };
22548
23397
  },
@@ -22608,12 +23457,44 @@ var init_aftermathApi = __esm({
22608
23457
  * Constructs a new instance of the `AftermathApi`, binding the given Sui client
22609
23458
  * to the known `addresses`.
22610
23459
  *
22611
- * @param client - A `SuiJsonRpcClient` for on-chain queries and transactions.
23460
+ * @param client - A `SuiGrpcClient` for on-chain queries and transactions.
22612
23461
  * @param addresses - The config addresses (object IDs, package IDs, etc.) for the Aftermath protocol.
22613
- */
22614
- constructor(client, addresses) {
23462
+ * @param jsonRpcClient - **Optional.** A `SuiJsonRpcClient` pointed at the same
23463
+ * fullnode. Only used by the three legacy helpers listed on
23464
+ * {@link AftermathApi.jsonRpcClient}; every other call goes over gRPC via
23465
+ * `client`. Omit it unless you call one of those three — they then throw a
23466
+ * descriptive error instead of failing against a deprecated protocol. See
23467
+ * {@link AftermathApi.requireJsonRpcClient}.
23468
+ */
23469
+ constructor(client, addresses, jsonRpcClient) {
22615
23470
  this.client = client;
22616
23471
  this.addresses = addresses;
23472
+ this.jsonRpcClient = jsonRpcClient;
23473
+ // =========================================================================
23474
+ // Legacy JSON-RPC Access
23475
+ // =========================================================================
23476
+ /**
23477
+ * Returns the optional {@link AftermathApi.jsonRpcClient}, throwing a
23478
+ * descriptive error when it was not supplied.
23479
+ *
23480
+ * Used by the three helpers that have no `SuiGrpcClient` equivalent. The
23481
+ * throw is deliberate: these helpers cannot degrade to an empty result
23482
+ * without silently lying to their callers, and JSON-RPC is scheduled for
23483
+ * removal from Sui fullnodes in mid-October 2026, so a missing client is a
23484
+ * configuration error worth naming rather than hiding.
23485
+ *
23486
+ * @param methodName - The public helper the caller invoked, e.g.
23487
+ * `"Events().fetchCastEventsWithCursor"`. Named in the error message.
23488
+ * @throws If no `jsonRpcClient` was passed to the constructor.
23489
+ */
23490
+ this.requireJsonRpcClient = (methodName) => {
23491
+ if (!this.jsonRpcClient) {
23492
+ throw new Error(
23493
+ `${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.`
23494
+ );
23495
+ }
23496
+ return this.jsonRpcClient;
23497
+ };
22617
23498
  // =========================================================================
22618
23499
  // Class Object Creation
22619
23500
  // =========================================================================
@@ -22789,6 +23670,7 @@ var init_aftermathApi = __esm({
22789
23670
  });
22790
23671
 
22791
23672
  // src/general/providers/aftermath.ts
23673
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
22792
23674
  import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
22793
23675
  var _Aftermath, Aftermath;
22794
23676
  var init_aftermath = __esm({
@@ -22895,28 +23777,32 @@ var init_aftermath = __esm({
22895
23777
  * returns a ready-to-use instance. Pass `addresses` or `api` to skip
22896
23778
  * the corresponding bootstrap steps.
22897
23779
  */
22898
- static async create(options = {}) {
23780
+ static async create(options = {}, abortSignal) {
22899
23781
  const af = new _Aftermath(options);
22900
- await af.bootstrap();
23782
+ await af.bootstrap(abortSignal);
22901
23783
  return af;
22902
23784
  }
22903
23785
  /**
22904
23786
  * Resolves addresses and wires up the internal `AftermathApi`. Called
22905
23787
  * exactly once by the {@link Aftermath.create} factory.
22906
23788
  */
22907
- async bootstrap() {
23789
+ async bootstrap(abortSignal) {
22908
23790
  if (this.options.api) {
22909
23791
  this.api = this.options.api;
22910
23792
  return;
22911
23793
  }
22912
23794
  const network = this.network;
22913
- const addresses = this.options.addresses ?? await this.getAddresses();
23795
+ const addresses = this.options.addresses ?? await this.getAddresses(abortSignal);
22914
23796
  const fullnodeUrl = this.options.fullnodeUrl ?? Caller.defaultFullnodeUrl(network);
22915
- const client = new SuiJsonRpcClient({
23797
+ const client = new SuiGrpcClient({
23798
+ network: network.toLowerCase(),
23799
+ baseUrl: fullnodeUrl
23800
+ });
23801
+ const jsonRpcClient = new SuiJsonRpcClient({
22916
23802
  url: fullnodeUrl,
22917
23803
  network: network.toLowerCase()
22918
23804
  });
22919
- this.api = new AftermathApi(client, addresses);
23805
+ this.api = new AftermathApi(client, addresses, jsonRpcClient);
22920
23806
  }
22921
23807
  // =========================================================================
22922
23808
  // Public Accessors
@@ -22938,8 +23824,8 @@ var init_aftermath = __esm({
22938
23824
  * directly from the API. Typically you don't need to call this — the
22939
23825
  * `create` factory handles it. Useful for cache warmers or tooling.
22940
23826
  */
22941
- getAddresses() {
22942
- return this.fetchApi("addresses");
23827
+ getAddresses(abortSignal) {
23828
+ return this.fetchApi("addresses", void 0, abortSignal);
22943
23829
  }
22944
23830
  /**
22945
23831
  * Attempts to decode a raw Move abort/error string into a structured
@@ -22986,6 +23872,7 @@ init_index();
22986
23872
  export {
22987
23873
  Aftermath,
22988
23874
  AftermathApi,
23875
+ AftermathTransportError,
22989
23876
  Auth,
22990
23877
  Casting,
22991
23878
  Coin,
@@ -22994,6 +23881,7 @@ export {
22994
23881
  FarmsStakingPool,
22995
23882
  Faucet,
22996
23883
  GasPools,
23884
+ GrpcCasting,
22997
23885
  Helpers,
22998
23886
  NftAmm,
22999
23887
  Perpetuals,
@@ -23001,6 +23889,7 @@ export {
23001
23889
  PerpetualsMarket,
23002
23890
  PerpetualsOrderSide,
23003
23891
  PerpetualsOrderType,
23892
+ PerpetualsStopOrderTriggerPriceType,
23004
23893
  PerpetualsStopOrderType,
23005
23894
  PerpetualsVault,
23006
23895
  Pool,
@@ -23013,6 +23902,7 @@ export {
23013
23902
  SuiFren,
23014
23903
  SuiFrens,
23015
23904
  SuiFrensSortOption,
23905
+ isAftermathTransportError,
23016
23906
  isAllocatedCollateralEvent,
23017
23907
  isCanceledOrderEvent,
23018
23908
  isDeallocatedCollateralEvent,