@mysten/sui 2.22.1 → 2.23.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.
Files changed (139) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/bcs/bcs.d.mts.map +1 -1
  4. package/dist/bcs/bcs.mjs +1 -19
  5. package/dist/bcs/bcs.mjs.map +1 -1
  6. package/dist/bcs/index.d.mts +3812 -906
  7. package/dist/bcs/index.d.mts.map +1 -1
  8. package/dist/bcs/index.mjs +2 -1
  9. package/dist/bcs/index.mjs.map +1 -1
  10. package/dist/bcs/transactions.mjs +147 -0
  11. package/dist/bcs/transactions.mjs.map +1 -0
  12. package/dist/client/core-resolver.mjs +2 -1
  13. package/dist/client/core-resolver.mjs.map +1 -1
  14. package/dist/client/core.d.mts +2 -0
  15. package/dist/client/core.d.mts.map +1 -1
  16. package/dist/client/core.mjs.map +1 -1
  17. package/dist/client/query-filters.mjs +119 -0
  18. package/dist/client/query-filters.mjs.map +1 -0
  19. package/dist/client/types.d.mts +166 -1
  20. package/dist/client/types.d.mts.map +1 -1
  21. package/dist/client/utils.d.mts.map +1 -1
  22. package/dist/client/utils.mjs +13 -1
  23. package/dist/client/utils.mjs.map +1 -1
  24. package/dist/cryptography/signature.d.mts +6 -6
  25. package/dist/graphql/client.d.mts +15 -2
  26. package/dist/graphql/client.d.mts.map +1 -1
  27. package/dist/graphql/client.mjs +6 -0
  28. package/dist/graphql/client.mjs.map +1 -1
  29. package/dist/graphql/core.d.mts +5 -1
  30. package/dist/graphql/core.d.mts.map +1 -1
  31. package/dist/graphql/core.mjs +85 -3
  32. package/dist/graphql/core.mjs.map +1 -1
  33. package/dist/graphql/generated/queries.d.mts.map +1 -1
  34. package/dist/graphql/generated/queries.mjs +137 -1
  35. package/dist/graphql/generated/queries.mjs.map +1 -1
  36. package/dist/graphql/generated/tada-env.d.mts +108 -0
  37. package/dist/graphql/index.d.mts +2 -2
  38. package/dist/grpc/client.d.mts +11 -0
  39. package/dist/grpc/client.d.mts.map +1 -1
  40. package/dist/grpc/client.mjs +6 -0
  41. package/dist/grpc/client.mjs.map +1 -1
  42. package/dist/grpc/core.d.mts +5 -1
  43. package/dist/grpc/core.d.mts.map +1 -1
  44. package/dist/grpc/core.mjs +100 -2
  45. package/dist/grpc/core.mjs.map +1 -1
  46. package/dist/grpc/filters.mjs +45 -0
  47. package/dist/grpc/filters.mjs.map +1 -0
  48. package/dist/grpc/proto/sui/rpc/v2/event.d.mts +31 -0
  49. package/dist/grpc/proto/sui/rpc/v2/event.d.mts.map +1 -1
  50. package/dist/grpc/proto/sui/rpc/v2/event.mjs +30 -0
  51. package/dist/grpc/proto/sui/rpc/v2/event.mjs.map +1 -1
  52. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +7 -0
  53. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts.map +1 -1
  54. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs +8 -0
  55. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs.map +1 -1
  56. package/dist/grpc/proto/sui/rpc/v2/filter.d.mts +423 -0
  57. package/dist/grpc/proto/sui/rpc/v2/filter.d.mts.map +1 -0
  58. package/dist/grpc/proto/sui/rpc/v2/filter.mjs +297 -0
  59. package/dist/grpc/proto/sui/rpc/v2/filter.mjs.map +1 -0
  60. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +62 -6
  61. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts.map +1 -1
  62. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs +37 -0
  63. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs.map +1 -1
  64. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +293 -1
  65. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
  66. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +241 -1
  67. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  68. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  69. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  70. package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts +15 -2
  71. package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts.map +1 -1
  72. package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs +11 -0
  73. package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs.map +1 -1
  74. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +211 -0
  75. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -0
  76. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +163 -0
  77. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -0
  78. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  79. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  80. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +105 -23
  81. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
  82. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +56 -9
  83. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
  84. package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts +148 -8
  85. package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts.map +1 -1
  86. package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs +109 -8
  87. package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs.map +1 -1
  88. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  89. package/dist/grpc/proto/types.d.mts +5 -3
  90. package/dist/grpc/proto/types.mjs +33 -2
  91. package/dist/grpc/proto/types.mjs.map +1 -1
  92. package/dist/jsonRpc/core.d.mts +10 -0
  93. package/dist/jsonRpc/core.d.mts.map +1 -1
  94. package/dist/jsonRpc/core.mjs +85 -2
  95. package/dist/jsonRpc/core.mjs.map +1 -1
  96. package/dist/transactions/Transaction.d.mts +9 -9
  97. package/dist/transactions/Transaction.d.mts.map +1 -1
  98. package/dist/transactions/intents/CoinWithBalance.mjs +14 -18
  99. package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
  100. package/dist/version.mjs +1 -1
  101. package/dist/version.mjs.map +1 -1
  102. package/dist/zklogin/bcs.d.mts +14 -14
  103. package/dist/zklogin/bcs.d.mts.map +1 -1
  104. package/docs/clients/core.md +115 -1
  105. package/docs/clients/grpc.md +68 -0
  106. package/docs/migrations/sui-2.0/json-rpc-migration.md +104 -101
  107. package/package.json +2 -2
  108. package/src/bcs/bcs.ts +0 -27
  109. package/src/bcs/index.ts +7 -5
  110. package/src/bcs/transactions.ts +226 -0
  111. package/src/client/core-resolver.ts +5 -1
  112. package/src/client/core.ts +8 -0
  113. package/src/client/query-filters.ts +195 -0
  114. package/src/client/types.ts +186 -1
  115. package/src/client/utils.ts +13 -0
  116. package/src/graphql/client.ts +25 -1
  117. package/src/graphql/core.ts +143 -3
  118. package/src/graphql/generated/queries.ts +226 -0
  119. package/src/graphql/generated/schema.graphql +75 -0
  120. package/src/graphql/generated/tada-env.ts +133 -0
  121. package/src/graphql/index.ts +1 -0
  122. package/src/graphql/queries/listEvents.graphql +40 -0
  123. package/src/graphql/queries/transactions.graphql +26 -0
  124. package/src/grpc/client.ts +19 -0
  125. package/src/grpc/core.ts +187 -3
  126. package/src/grpc/filters.ts +68 -0
  127. package/src/grpc/proto/sui/rpc/v2/event.ts +49 -0
  128. package/src/grpc/proto/sui/rpc/v2/executed_transaction.ts +15 -0
  129. package/src/grpc/proto/sui/rpc/v2/filter.ts +589 -0
  130. package/src/grpc/proto/sui/rpc/v2/ledger_service.client.ts +111 -0
  131. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +406 -0
  132. package/src/grpc/proto/sui/rpc/v2/protocol_config.ts +22 -2
  133. package/src/grpc/proto/sui/rpc/v2/query_options.ts +255 -0
  134. package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +136 -18
  135. package/src/grpc/proto/sui/rpc/v2/subscription_service.ts +187 -7
  136. package/src/grpc/proto/types.ts +2 -0
  137. package/src/jsonRpc/core.ts +136 -2
  138. package/src/transactions/intents/CoinWithBalance.ts +41 -41
  139. package/src/version.ts +1 -1
@@ -366,7 +366,12 @@ export namespace SuiClientTypes {
366
366
  balanceChanges?: boolean;
367
367
  /** Include parsed transaction effects (gas used, changed objects, status, etc.). */
368
368
  effects?: boolean;
369
- /** Include events emitted by the transaction. */
369
+ /**
370
+ * Include events emitted by the transaction.
371
+ *
372
+ * On the GraphQL transport, at most the first 50 events of a transaction are returned;
373
+ * gRPC and JSON-RPC return the full event list.
374
+ */
370
375
  events?: boolean;
371
376
  /** Include a map of object IDs to their types for all changed objects. */
372
377
  objectTypes?: boolean;
@@ -461,6 +466,186 @@ export namespace SuiClientTypes {
461
466
  checksEnabled?: boolean;
462
467
  }
463
468
 
469
+ /** Query methods */
470
+ export interface TransportMethods {
471
+ listTransactions: <Include extends TransactionInclude = {}>(
472
+ options: ListTransactionsOptions<Include>,
473
+ ) => Promise<ListTransactionsResponse<Include>>;
474
+ listEvents: (options: ListEventsOptions) => Promise<ListEventsResponse>;
475
+ }
476
+
477
+ /**
478
+ * A filter matching transactions. Exactly one predicate must be specified.
479
+ *
480
+ * All predicates are supported identically by every transport.
481
+ */
482
+ export type TransactionFilter =
483
+ | {
484
+ /** Match transactions sent by this address. */
485
+ sender: string;
486
+ function?: never;
487
+ }
488
+ | {
489
+ /**
490
+ * Match transactions that called a Move function, specified as a
491
+ * `::`-delimited Move path: `package`, `package::module`, or
492
+ * `package::module::function`.
493
+ */
494
+ function: string;
495
+ sender?: never;
496
+ };
497
+
498
+ /**
499
+ * A filter matching events. Exactly one predicate must be specified.
500
+ *
501
+ * All predicates are supported by every transport, with one caveat: on the deprecated
502
+ * JSON-RPC transport, an `eventType` naming a generic type must include type arguments —
503
+ * a bare generic name (e.g. `0xpkg::mod::Event` for events of type `0xpkg::mod::Event<T>`)
504
+ * matches any instantiation on gRPC and GraphQL, but matches nothing on JSON-RPC, which
505
+ * compares the full type for exact equality.
506
+ */
507
+ export type EventFilter =
508
+ | {
509
+ /** Match events emitted by transactions sent by this address. */
510
+ sender: string;
511
+ emitModule?: never;
512
+ eventType?: never;
513
+ }
514
+ | {
515
+ /** Match events emitted by a module, specified as `package::module`. */
516
+ emitModule: string;
517
+ sender?: never;
518
+ eventType?: never;
519
+ }
520
+ | {
521
+ /**
522
+ * Match events by type: either every event whose type is defined in a
523
+ * module (`package::module`), or events with a fully qualified type
524
+ * name (`package::module::Name` or `package::module::Name<T1, T2>`).
525
+ *
526
+ * A bare generic name (`package::module::Name` without type arguments) matches
527
+ * any instantiation on gRPC and GraphQL, but matches nothing on the deprecated
528
+ * JSON-RPC transport, which compares the full type for exact equality.
529
+ */
530
+ eventType: string;
531
+ sender?: never;
532
+ emitModule?: never;
533
+ };
534
+
535
+ export interface ListTransactionsOptions<
536
+ Include extends TransactionInclude = {},
537
+ > extends CoreClientMethodOptions {
538
+ filter?: TransactionFilter;
539
+ /**
540
+ * Maximum number of items to return. Defaults to 50.
541
+ *
542
+ * Servers cap page sizes (50 by default): values above the server's cap cause the
543
+ * GraphQL and JSON-RPC transports to throw, while gRPC servers silently truncate
544
+ * the page to their configured maximum.
545
+ */
546
+ limit?: number;
547
+ /**
548
+ * Return items strictly after this cursor in ledger order (usually the `endCursor` of
549
+ * an ascending page, or the `startCursor` of a descending page to poll for new items).
550
+ * Implies `order: 'ascending'`, and cannot be combined with `before`.
551
+ */
552
+ after?: string | null;
553
+ /**
554
+ * Return items strictly before this cursor in ledger order (usually the `endCursor` of
555
+ * a descending page). Implies `order: 'descending'`, and cannot be combined with
556
+ * `after`.
557
+ */
558
+ before?: string | null;
559
+ /** Order of returned results. Defaults to `ascending` (oldest first). */
560
+ order?: 'ascending' | 'descending';
561
+ include?: Include & TransactionInclude;
562
+ }
563
+
564
+ export interface ListTransactionsResponse<out Include extends TransactionInclude = {}> {
565
+ transactions: TransactionResult<Include>[];
566
+ /**
567
+ * Whether more items may be available after this page.
568
+ *
569
+ * gRPC servers bound how much of the ledger a single request scans, so a scan-limited
570
+ * query can return fewer items than `limit` (even none) with `hasNextPage: true`;
571
+ * continuing from `endCursor` always makes progress through the scanned range.
572
+ */
573
+ hasNextPage: boolean;
574
+ /**
575
+ * Cursor at the first returned item. After a descending read of the most recent
576
+ * items, pass as `after` to poll for items added since.
577
+ */
578
+ startCursor: string | null;
579
+ /**
580
+ * Cursor at the last returned item. Continue the query by passing it as `after`
581
+ * (ascending) or `before` (descending).
582
+ */
583
+ endCursor: string | null;
584
+ }
585
+
586
+ export interface ListEventsOptions extends CoreClientMethodOptions {
587
+ filter?: EventFilter;
588
+ /**
589
+ * Maximum number of items to return. Defaults to 50.
590
+ *
591
+ * Servers cap page sizes (50 by default): values above the server's cap cause the
592
+ * GraphQL and JSON-RPC transports to throw, while gRPC servers silently truncate
593
+ * the page to their configured maximum.
594
+ */
595
+ limit?: number;
596
+ /**
597
+ * Return items strictly after this cursor in ledger order (usually the `endCursor` of
598
+ * an ascending page, or the `startCursor` of a descending page to poll for new items).
599
+ * Implies `order: 'ascending'`, and cannot be combined with `before`.
600
+ */
601
+ after?: string | null;
602
+ /**
603
+ * Return items strictly before this cursor in ledger order (usually the `endCursor` of
604
+ * a descending page). Implies `order: 'descending'`, and cannot be combined with
605
+ * `after`.
606
+ */
607
+ before?: string | null;
608
+ /** Order of returned results. Defaults to `ascending` (oldest first). */
609
+ order?: 'ascending' | 'descending';
610
+ }
611
+
612
+ /** An event returned from a query, along with its position in the ledger. */
613
+ export interface EventEntry extends Event {
614
+ /**
615
+ * The sequence number of the checkpoint containing the emitting transaction.
616
+ *
617
+ * `null` on the JSON-RPC transport, which does not expose checkpoint
618
+ * information for queried events.
619
+ */
620
+ checkpoint: string | null;
621
+ /** The digest of the transaction that emitted this event. */
622
+ transactionDigest: string;
623
+ /** The index of this event within its transaction's event list. */
624
+ eventIndex: number;
625
+ }
626
+
627
+ export interface ListEventsResponse {
628
+ events: EventEntry[];
629
+ /**
630
+ * Whether more items may be available after this page.
631
+ *
632
+ * gRPC servers bound how much of the ledger a single request scans, so a scan-limited
633
+ * query can return fewer items than `limit` (even none) with `hasNextPage: true`;
634
+ * continuing from `endCursor` always makes progress through the scanned range.
635
+ */
636
+ hasNextPage: boolean;
637
+ /**
638
+ * Cursor at the first returned item. After a descending read of the most recent
639
+ * items, pass as `after` to poll for items added since.
640
+ */
641
+ startCursor: string | null;
642
+ /**
643
+ * Cursor at the last returned item. Continue the query by passing it as `after`
644
+ * (ascending) or `before` (descending).
645
+ */
646
+ endCursor: string | null;
647
+ }
648
+
464
649
  export interface GetReferenceGasPriceOptions extends CoreClientMethodOptions {}
465
650
 
466
651
  export interface TransportMethods {
@@ -401,6 +401,19 @@ export function parseTransactionBcs(
401
401
  ).snapshot();
402
402
  }
403
403
 
404
+ /**
405
+ * Checks whether serialized transaction bytes have a gas payment explicitly set to an empty
406
+ * list, which indicates gas is paid from the sender's address balance. Returns false for
407
+ * bytes that can't be parsed as `TransactionData`, leaving validation to the server.
408
+ */
409
+ export function transactionBytesHaveEmptyGasPayment(bytes: Uint8Array): boolean {
410
+ try {
411
+ return bcs.TransactionData.parse(bytes).V1?.gasData.payment?.length === 0;
412
+ } catch {
413
+ return false;
414
+ }
415
+ }
416
+
404
417
  /**
405
418
  * Extracts just the status from transaction effects BCS without fully parsing.
406
419
  * This is optimized for cases where we only need the status (success/failure)
@@ -70,6 +70,20 @@ export function isSuiGraphQLClient(client: unknown): client is SuiGraphQLClient
70
70
  );
71
71
  }
72
72
 
73
+ export interface GraphQLSimulateTransactionOptions<
74
+ Include extends SuiClientTypes.SimulateTransactionInclude = {},
75
+ > extends SuiClientTypes.SimulateTransactionOptions<Include> {
76
+ /**
77
+ * Overrides whether the server selects gas payment during simulation.
78
+ *
79
+ * When not set, gas selection is enabled only when the transaction's gas payment is explicitly
80
+ * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.
81
+ * Transactions with gas coins set are simulated as-is, and transactions without a gas payment
82
+ * are simulated with a mocked gas coin.
83
+ */
84
+ doGasSelection?: boolean;
85
+ }
86
+
73
87
  export interface DynamicFieldInclude {
74
88
  value?: boolean;
75
89
  }
@@ -230,7 +244,7 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
230
244
  }
231
245
 
232
246
  simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
233
- input: SuiClientTypes.SimulateTransactionOptions<Include>,
247
+ input: GraphQLSimulateTransactionOptions<Include>,
234
248
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
235
249
  return this.core.simulateTransaction(input);
236
250
  }
@@ -324,6 +338,16 @@ export class SuiGraphQLClient<Queries extends Record<string, GraphQLDocument> =
324
338
  return this.core.getDynamicField(input);
325
339
  }
326
340
 
341
+ listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
342
+ input: SuiClientTypes.ListTransactionsOptions<Include>,
343
+ ): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
344
+ return this.core.listTransactions(input);
345
+ }
346
+
347
+ listEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse> {
348
+ return this.core.listEvents(input);
349
+ }
350
+
327
351
  getMoveFunction(
328
352
  input: SuiClientTypes.GetMoveFunctionOptions,
329
353
  ): Promise<SuiClientTypes.GetMoveFunctionResponse> {
@@ -28,6 +28,8 @@ import {
28
28
  GetOwnedObjectsDocument,
29
29
  GetReferenceGasPriceDocument,
30
30
  GetTransactionBlockDocument,
31
+ ListEventsDocument,
32
+ ListTransactionsDocument,
31
33
  MultiGetObjectsDocument,
32
34
  ResolveTransactionDocument,
33
35
  SimulateTransactionDocument,
@@ -36,8 +38,12 @@ import {
36
38
  } from './generated/queries.js';
37
39
  import { ObjectError, SimulationError } from '../client/errors.js';
38
40
  import { chunk, fromBase64, toBase64 } from '@mysten/utils';
39
- import { normalizeSuiAddress } from '../utils/sui-types.js';
40
- import { formatMoveAbortMessage, parseTransactionEffectsBcs } from '../client/utils.js';
41
+ import { normalizeStructTag, normalizeSuiAddress } from '../utils/sui-types.js';
42
+ import {
43
+ formatMoveAbortMessage,
44
+ parseTransactionEffectsBcs,
45
+ transactionBytesHaveEmptyGasPayment,
46
+ } from '../client/utils.js';
41
47
  import type { OpenMoveTypeSignatureBody, OpenMoveTypeSignature } from './types.js';
42
48
  import {
43
49
  transactionDataToGrpcTransaction,
@@ -50,6 +56,12 @@ import { TransactionEffects as TransactionEffectsType } from '../grpc/proto/sui/
50
56
  import { Transaction as GrpcTransactionType } from '../grpc/proto/sui/rpc/v2/transaction.js';
51
57
  import { TransactionDataBuilder } from '../transactions/TransactionData.js';
52
58
  import type { BuildTransactionOptions } from '../transactions/index.js';
59
+ import {
60
+ resolveEventFilter,
61
+ resolvePagination,
62
+ resolveTransactionFilter,
63
+ validateTransactionQuery,
64
+ } from '../client/query-filters.js';
53
65
 
54
66
  export class GraphQLCoreClient extends CoreClient {
55
67
  #graphqlClient: SuiGraphQLClient;
@@ -386,12 +398,21 @@ export class GraphQLCoreClient extends CoreClient {
386
398
  return parseTransaction(result.effects?.transaction!, options.include);
387
399
  }
388
400
  async simulateTransaction<Include extends SuiClientTypes.SimulateTransactionInclude = {}>(
389
- options: SuiClientTypes.SimulateTransactionOptions<Include>,
401
+ options: SuiClientTypes.SimulateTransactionOptions<Include> & { doGasSelection?: boolean },
390
402
  ): Promise<SuiClientTypes.SimulateTransactionResult<Include>> {
391
403
  if (!(options.transaction instanceof Uint8Array)) {
392
404
  await options.transaction.prepareForSerialization({ client: this });
393
405
  }
394
406
 
407
+ // A gas payment explicitly set to an empty list means gas is paid from the sender's
408
+ // address balance, so the server needs to perform gas selection rather than simulating
409
+ // with a mocked gas coin.
410
+ const doGasSelection =
411
+ options.doGasSelection ??
412
+ (options.transaction instanceof Uint8Array
413
+ ? transactionBytesHaveEmptyGasPayment(options.transaction)
414
+ : options.transaction.getData().gasData.payment?.length === 0);
415
+
395
416
  const result = await this.#graphqlQuery(
396
417
  {
397
418
  query: SimulateTransactionDocument,
@@ -411,6 +432,7 @@ export class GraphQLCoreClient extends CoreClient {
411
432
  includeObjectTypes: options.include?.objectTypes ?? false,
412
433
  includeCommandResults: options.include?.commandResults ?? false,
413
434
  includeBcs: options.include?.bcs ?? false,
435
+ doGasSelection,
414
436
  checksEnabled: options.checksEnabled ?? true,
415
437
  },
416
438
  },
@@ -593,6 +615,124 @@ export class GraphQLCoreClient extends CoreClient {
593
615
  return this.#graphqlClient.listDynamicFields(options);
594
616
  }
595
617
 
618
+ async listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
619
+ options: SuiClientTypes.ListTransactionsOptions<Include>,
620
+ ): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
621
+ const pagination = resolvePagination(options);
622
+ const { descending, after, before, limit } = pagination;
623
+ const filter = options.filter
624
+ ? await resolveTransactionFilter(this.mvr, options.filter, options.signal)
625
+ : undefined;
626
+ validateTransactionQuery(filter, pagination);
627
+
628
+ const transactions = await this.#graphqlQuery(
629
+ {
630
+ query: ListTransactionsDocument,
631
+ signal: options.signal,
632
+ variables: {
633
+ filter: filter && {
634
+ sentAddress: filter.$kind === 'sender' ? filter.sender : undefined,
635
+ function:
636
+ filter.$kind === 'function'
637
+ ? [filter.package, filter.module, filter.function].filter(Boolean).join('::')
638
+ : undefined,
639
+ },
640
+ first: descending ? undefined : limit,
641
+ after,
642
+ last: descending ? limit : undefined,
643
+ before,
644
+ includeTransaction: options.include?.transaction ?? false,
645
+ includeEffects: options.include?.effects ?? false,
646
+ includeEvents: options.include?.events ?? false,
647
+ includeBalanceChanges: options.include?.balanceChanges ?? false,
648
+ includeObjectTypes: options.include?.objectTypes ?? false,
649
+ includeBcs: options.include?.bcs ?? false,
650
+ },
651
+ },
652
+ (result) => result.transactions,
653
+ );
654
+
655
+ // Backwards pagination returns nodes in ascending order, so reverse them for descending reads
656
+ const nodes = descending ? [...transactions.nodes].reverse() : transactions.nodes;
657
+
658
+ return {
659
+ transactions: nodes.map((transaction) => parseTransaction(transaction, options.include)),
660
+ hasNextPage: descending
661
+ ? transactions.pageInfo.hasPreviousPage
662
+ : transactions.pageInfo.hasNextPage,
663
+ startCursor:
664
+ (descending ? transactions.pageInfo.endCursor : transactions.pageInfo.startCursor) ?? null,
665
+ endCursor:
666
+ (descending ? transactions.pageInfo.startCursor : transactions.pageInfo.endCursor) ?? null,
667
+ };
668
+ }
669
+
670
+ async listEvents(
671
+ options: SuiClientTypes.ListEventsOptions,
672
+ ): Promise<SuiClientTypes.ListEventsResponse> {
673
+ const { descending, after, before, limit } = resolvePagination(options);
674
+ const filter = options.filter
675
+ ? await resolveEventFilter(this.mvr, options.filter, options.signal)
676
+ : undefined;
677
+
678
+ const events = await this.#graphqlQuery(
679
+ {
680
+ query: ListEventsDocument,
681
+ signal: options.signal,
682
+ variables: {
683
+ filter: filter && {
684
+ sender: filter.$kind === 'sender' ? filter.sender : undefined,
685
+ module:
686
+ filter.$kind === 'emitModule' ? `${filter.package}::${filter.module}` : undefined,
687
+ type:
688
+ filter.$kind === 'eventTypeModule'
689
+ ? `${filter.package}::${filter.module}`
690
+ : filter.$kind === 'eventType'
691
+ ? filter.eventType
692
+ : undefined,
693
+ },
694
+ first: descending ? undefined : limit,
695
+ after,
696
+ last: descending ? limit : undefined,
697
+ before,
698
+ },
699
+ },
700
+ (result) => result.events,
701
+ );
702
+
703
+ // Backwards pagination returns nodes in ascending order, so reverse them for descending reads
704
+ const nodes = descending ? [...events.nodes].reverse() : events.nodes;
705
+
706
+ return {
707
+ events: nodes.map((event): SuiClientTypes.EventEntry => {
708
+ const packageId = event.transactionModule?.package?.address;
709
+ const module = event.transactionModule?.name;
710
+ const sender = event.sender?.address;
711
+ const eventType = event.contents?.type?.repr;
712
+ const transactionDigest = event.transaction?.digest;
713
+
714
+ if (!packageId || !module || !sender || !eventType || !transactionDigest) {
715
+ throw new Error('listEvents response is missing expected event fields');
716
+ }
717
+
718
+ return {
719
+ packageId: normalizeSuiAddress(packageId),
720
+ module,
721
+ sender: normalizeSuiAddress(sender),
722
+ eventType: normalizeStructTag(eventType),
723
+ bcs: event.contents?.bcs ? fromBase64(event.contents.bcs) : new Uint8Array(),
724
+ json: (event.contents?.json as Record<string, unknown>) ?? null,
725
+ checkpoint: event.transaction?.effects?.checkpoint?.sequenceNumber?.toString() ?? null,
726
+ transactionDigest,
727
+ eventIndex: event.sequenceNumber,
728
+ };
729
+ }),
730
+ hasNextPage: descending ? events.pageInfo.hasPreviousPage : events.pageInfo.hasNextPage,
731
+ startCursor: (descending ? events.pageInfo.endCursor : events.pageInfo.startCursor) ?? null,
732
+ endCursor: (descending ? events.pageInfo.startCursor : events.pageInfo.endCursor) ?? null,
733
+ };
734
+ }
735
+
596
736
  async verifyZkLoginSignature(
597
737
  options: SuiClientTypes.VerifyZkLoginSignatureOptions,
598
738
  ): Promise<SuiClientTypes.ZkLoginVerifyResponse> {