@mysten/sui 2.22.0 → 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 (147) hide show
  1. package/CHANGELOG.md +47 -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 +4225 -1319
  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/address-balance-transaction-expiration.mjs +22 -0
  13. package/dist/client/address-balance-transaction-expiration.mjs.map +1 -0
  14. package/dist/client/core-resolver.mjs +2 -1
  15. package/dist/client/core-resolver.mjs.map +1 -1
  16. package/dist/client/core.d.mts +2 -0
  17. package/dist/client/core.d.mts.map +1 -1
  18. package/dist/client/core.mjs.map +1 -1
  19. package/dist/client/query-filters.mjs +119 -0
  20. package/dist/client/query-filters.mjs.map +1 -0
  21. package/dist/client/types.d.mts +166 -1
  22. package/dist/client/types.d.mts.map +1 -1
  23. package/dist/client/utils.d.mts.map +1 -1
  24. package/dist/client/utils.mjs +13 -1
  25. package/dist/client/utils.mjs.map +1 -1
  26. package/dist/cryptography/signature.d.mts +6 -6
  27. package/dist/graphql/client.d.mts +15 -2
  28. package/dist/graphql/client.d.mts.map +1 -1
  29. package/dist/graphql/client.mjs +6 -0
  30. package/dist/graphql/client.mjs.map +1 -1
  31. package/dist/graphql/core.d.mts +5 -1
  32. package/dist/graphql/core.d.mts.map +1 -1
  33. package/dist/graphql/core.mjs +96 -4
  34. package/dist/graphql/core.mjs.map +1 -1
  35. package/dist/graphql/generated/queries.d.mts.map +1 -1
  36. package/dist/graphql/generated/queries.mjs +140 -1
  37. package/dist/graphql/generated/queries.mjs.map +1 -1
  38. package/dist/graphql/generated/tada-env.d.mts +108 -0
  39. package/dist/graphql/index.d.mts +2 -2
  40. package/dist/grpc/client.d.mts +11 -0
  41. package/dist/grpc/client.d.mts.map +1 -1
  42. package/dist/grpc/client.mjs +6 -0
  43. package/dist/grpc/client.mjs.map +1 -1
  44. package/dist/grpc/core.d.mts +5 -1
  45. package/dist/grpc/core.d.mts.map +1 -1
  46. package/dist/grpc/core.mjs +113 -4
  47. package/dist/grpc/core.mjs.map +1 -1
  48. package/dist/grpc/filters.mjs +45 -0
  49. package/dist/grpc/filters.mjs.map +1 -0
  50. package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
  51. package/dist/grpc/proto/sui/rpc/v2/event.d.mts +31 -0
  52. package/dist/grpc/proto/sui/rpc/v2/event.d.mts.map +1 -1
  53. package/dist/grpc/proto/sui/rpc/v2/event.mjs +30 -0
  54. package/dist/grpc/proto/sui/rpc/v2/event.mjs.map +1 -1
  55. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +7 -0
  56. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts.map +1 -1
  57. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs +8 -0
  58. package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs.map +1 -1
  59. package/dist/grpc/proto/sui/rpc/v2/filter.d.mts +423 -0
  60. package/dist/grpc/proto/sui/rpc/v2/filter.d.mts.map +1 -0
  61. package/dist/grpc/proto/sui/rpc/v2/filter.mjs +297 -0
  62. package/dist/grpc/proto/sui/rpc/v2/filter.mjs.map +1 -0
  63. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +62 -6
  64. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts.map +1 -1
  65. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs +37 -0
  66. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs.map +1 -1
  67. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +293 -1
  68. package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
  69. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +241 -1
  70. package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
  71. package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
  72. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  73. package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts +15 -2
  74. package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts.map +1 -1
  75. package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs +11 -0
  76. package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs.map +1 -1
  77. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +211 -0
  78. package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -0
  79. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +163 -0
  80. package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -0
  81. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  82. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +105 -23
  83. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
  84. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +56 -9
  85. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
  86. package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts +148 -8
  87. package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts.map +1 -1
  88. package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs +109 -8
  89. package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs.map +1 -1
  90. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  91. package/dist/grpc/proto/types.d.mts +5 -3
  92. package/dist/grpc/proto/types.mjs +33 -2
  93. package/dist/grpc/proto/types.mjs.map +1 -1
  94. package/dist/jsonRpc/core.d.mts +10 -0
  95. package/dist/jsonRpc/core.d.mts.map +1 -1
  96. package/dist/jsonRpc/core.mjs +85 -2
  97. package/dist/jsonRpc/core.mjs.map +1 -1
  98. package/dist/transactions/Transaction.d.mts +6 -6
  99. package/dist/transactions/Transaction.d.mts.map +1 -1
  100. package/dist/transactions/intents/CoinWithBalance.mjs +14 -18
  101. package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
  102. package/dist/version.mjs +1 -1
  103. package/dist/version.mjs.map +1 -1
  104. package/dist/zklogin/address.mjs +2 -2
  105. package/dist/zklogin/address.mjs.map +1 -1
  106. package/dist/zklogin/bcs.d.mts +14 -14
  107. package/dist/zklogin/poseidon.mjs +5 -2
  108. package/dist/zklogin/poseidon.mjs.map +1 -1
  109. package/docs/clients/core.md +115 -1
  110. package/docs/clients/grpc.md +68 -0
  111. package/docs/migrations/sui-2.0/json-rpc-migration.md +104 -101
  112. package/package.json +2 -2
  113. package/src/bcs/bcs.ts +0 -27
  114. package/src/bcs/index.ts +7 -5
  115. package/src/bcs/transactions.ts +226 -0
  116. package/src/client/address-balance-transaction-expiration.ts +53 -0
  117. package/src/client/core-resolver.ts +5 -1
  118. package/src/client/core.ts +8 -0
  119. package/src/client/query-filters.ts +195 -0
  120. package/src/client/types.ts +186 -1
  121. package/src/client/utils.ts +13 -0
  122. package/src/graphql/client.ts +25 -1
  123. package/src/graphql/core.ts +156 -6
  124. package/src/graphql/generated/queries.ts +230 -1
  125. package/src/graphql/generated/schema.graphql +75 -0
  126. package/src/graphql/generated/tada-env.ts +133 -0
  127. package/src/graphql/index.ts +1 -0
  128. package/src/graphql/queries/listEvents.graphql +40 -0
  129. package/src/graphql/queries/transactions.graphql +29 -0
  130. package/src/grpc/client.ts +19 -0
  131. package/src/grpc/core.ts +201 -6
  132. package/src/grpc/filters.ts +68 -0
  133. package/src/grpc/proto/sui/rpc/v2/event.ts +49 -0
  134. package/src/grpc/proto/sui/rpc/v2/executed_transaction.ts +15 -0
  135. package/src/grpc/proto/sui/rpc/v2/filter.ts +589 -0
  136. package/src/grpc/proto/sui/rpc/v2/ledger_service.client.ts +111 -0
  137. package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +406 -0
  138. package/src/grpc/proto/sui/rpc/v2/protocol_config.ts +22 -2
  139. package/src/grpc/proto/sui/rpc/v2/query_options.ts +255 -0
  140. package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +136 -18
  141. package/src/grpc/proto/sui/rpc/v2/subscription_service.ts +187 -7
  142. package/src/grpc/proto/types.ts +2 -0
  143. package/src/jsonRpc/core.ts +136 -2
  144. package/src/transactions/intents/CoinWithBalance.ts +41 -41
  145. package/src/version.ts +1 -1
  146. package/src/zklogin/address.ts +2 -2
  147. package/src/zklogin/poseidon.ts +6 -4
@@ -71,6 +71,32 @@ query getTransactionBlock(
71
71
  }
72
72
  }
73
73
 
74
+ query listTransactions(
75
+ $filter: TransactionFilter
76
+ $first: Int
77
+ $after: String
78
+ $last: Int
79
+ $before: String
80
+ $includeTransaction: Boolean = false
81
+ $includeEffects: Boolean = false
82
+ $includeEvents: Boolean = false
83
+ $includeBalanceChanges: Boolean = false
84
+ $includeObjectTypes: Boolean = false
85
+ $includeBcs: Boolean = false
86
+ ) {
87
+ transactions(filter: $filter, first: $first, after: $after, last: $last, before: $before) {
88
+ pageInfo {
89
+ hasNextPage
90
+ hasPreviousPage
91
+ startCursor
92
+ endCursor
93
+ }
94
+ nodes {
95
+ ...TRANSACTION_FIELDS
96
+ }
97
+ }
98
+ }
99
+
74
100
  fragment TRANSACTION_FIELDS on Transaction {
75
101
  digest
76
102
  transactionJson @include(if: $includeTransaction)
@@ -157,6 +183,9 @@ query resolveTransaction(
157
183
  transaction {
158
184
  transactionBcs
159
185
  effects {
186
+ epoch {
187
+ epochId
188
+ }
160
189
  status
161
190
  executionError {
162
191
  message
@@ -127,6 +127,15 @@ export interface GrpcSimulateTransactionOptions<
127
127
  Include extends GrpcSimulateTransactionInclude = {},
128
128
  > extends SuiClientTypes.SimulateTransactionOptions<Include> {
129
129
  include?: Include & GrpcSimulateTransactionInclude;
130
+ /**
131
+ * Overrides whether the server selects gas payment during simulation.
132
+ *
133
+ * When not set, gas selection is enabled only when the transaction's gas payment is explicitly
134
+ * set to an empty list (`[]`), which indicates gas is paid from the sender's address balance.
135
+ * Transactions with gas coins set are simulated as-is, and transactions without a gas payment
136
+ * are simulated with a mocked gas coin.
137
+ */
138
+ doGasSelection?: boolean;
130
139
  }
131
140
 
132
141
  export class SuiGrpcClient extends BaseClient implements SuiClientTypes.TransportMethods {
@@ -296,6 +305,16 @@ export class SuiGrpcClient extends BaseClient implements SuiClientTypes.Transpor
296
305
  return this.core.getDynamicField(input);
297
306
  }
298
307
 
308
+ listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
309
+ input: SuiClientTypes.ListTransactionsOptions<Include>,
310
+ ): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
311
+ return this.core.listTransactions(input);
312
+ }
313
+
314
+ listEvents(input: SuiClientTypes.ListEventsOptions): Promise<SuiClientTypes.ListEventsResponse> {
315
+ return this.core.listEvents(input);
316
+ }
317
+
299
318
  getMoveFunction(
300
319
  input: SuiClientTypes.GetMoveFunctionOptions,
301
320
  ): Promise<SuiClientTypes.GetMoveFunctionResponse> {
package/src/grpc/core.ts CHANGED
@@ -43,12 +43,24 @@ import {
43
43
  transactionToGrpcTransaction,
44
44
  grpcTransactionToTransactionData,
45
45
  } from '../client/transaction-resolver.js';
46
+ import { setAddressBalanceTransactionExpirationFromSimulatedEpoch } from '../client/address-balance-transaction-expiration.js';
47
+ import { transactionBytesHaveEmptyGasPayment } from '../client/utils.js';
46
48
  import { Value } from './proto/google/protobuf/struct.js';
47
49
  import { ExecutedTransaction } from './proto/sui/rpc/v2/executed_transaction.js';
48
50
  import {
49
51
  SimulateTransactionRequest_TransactionChecks,
50
52
  SimulateTransactionResponse,
51
53
  } from './proto/sui/rpc/v2/transaction_execution_service.js';
54
+ import type { QueryEnd, QueryOptions } from './proto/sui/rpc/v2/query_options.js';
55
+ import { Ordering, QueryEndReason } from './proto/sui/rpc/v2/query_options.js';
56
+ import type { ResolvedPagination } from '../client/query-filters.js';
57
+ import {
58
+ resolveEventFilter,
59
+ resolvePagination,
60
+ resolveTransactionFilter,
61
+ validateTransactionQuery,
62
+ } from '../client/query-filters.js';
63
+ import { toGrpcEventFilter, toGrpcTransactionFilter } from './filters.js';
52
64
 
53
65
  export interface GrpcCoreClientOptions extends CoreClientOptions {
54
66
  client: SuiGrpcClient;
@@ -386,8 +398,9 @@ export class GrpcCoreClient extends CoreClient {
386
398
  );
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>> {
403
+ // The simulated transaction is nested one level deeper in the response
391
404
  const paths = transactionReadMaskPaths(options.include, 'transaction.');
392
405
  if (options.include?.commandResults) {
393
406
  paths.push('command_outputs');
@@ -397,6 +410,15 @@ export class GrpcCoreClient extends CoreClient {
397
410
  await options.transaction.prepareForSerialization({ client: this });
398
411
  }
399
412
 
413
+ // A gas payment explicitly set to an empty list means gas is paid from the sender's
414
+ // address balance, so the server needs to perform gas selection rather than simulating
415
+ // with a mocked gas coin.
416
+ const doGasSelection =
417
+ options.doGasSelection ??
418
+ (options.transaction instanceof Uint8Array
419
+ ? transactionBytesHaveEmptyGasPayment(options.transaction)
420
+ : options.transaction.getData().gasData.payment?.length === 0);
421
+
400
422
  const { response } = await this.#client.transactionExecutionService.simulateTransaction(
401
423
  {
402
424
  transaction:
@@ -410,7 +432,7 @@ export class GrpcCoreClient extends CoreClient {
410
432
  readMask: {
411
433
  paths,
412
434
  },
413
- doGasSelection: false,
435
+ doGasSelection,
414
436
  checks:
415
437
  options.checksEnabled === false
416
438
  ? SimulateTransactionRequest_TransactionChecks.DISABLED
@@ -566,6 +588,158 @@ export class GrpcCoreClient extends CoreClient {
566
588
  return this.#client.listDynamicFields(options);
567
589
  }
568
590
 
591
+ async listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
592
+ options: SuiClientTypes.ListTransactionsOptions<Include>,
593
+ ): Promise<SuiClientTypes.ListTransactionsResponse<Include>> {
594
+ const paths = transactionReadMaskPaths(options.include);
595
+
596
+ const filter = options.filter
597
+ ? await resolveTransactionFilter(this.mvr, options.filter, options.signal)
598
+ : undefined;
599
+ const pagination = resolvePagination(options);
600
+ validateTransactionQuery(filter, pagination);
601
+
602
+ const call = this.#client.ledgerService.listTransactions(
603
+ {
604
+ readMask: { paths },
605
+ filter: filter && toGrpcTransactionFilter(filter),
606
+ // Request one extra item as lookahead: the server reports its item limit as reached
607
+ // without scanning past it, so an exact-limit final page is otherwise
608
+ // indistinguishable from one with more results
609
+ options: toGrpcQueryOptions(pagination, pagination.limit + 1),
610
+ },
611
+ { abort: options.signal },
612
+ );
613
+
614
+ const transactions: SuiClientTypes.TransactionResult<Include>[] = [];
615
+ let startCursor: string | null = null;
616
+ let endCursor: string | null = null;
617
+ let frontier: string | null = null;
618
+ let end: QueryEnd | undefined;
619
+ let sawLookaheadItem = false;
620
+
621
+ for await (const frame of call.responses) {
622
+ if (frame.watermark?.cursor) {
623
+ frontier = toBase64(frame.watermark.cursor);
624
+ }
625
+ if (frame.transaction) {
626
+ if (transactions.length >= pagination.limit) {
627
+ sawLookaheadItem = true;
628
+ } else {
629
+ startCursor ??= frontier;
630
+ endCursor = frontier;
631
+ transactions.push(
632
+ parseGrpcTransactionResponse(frame.transaction, { include: options.include }),
633
+ );
634
+ }
635
+ }
636
+ if (frame.end) {
637
+ end = frame.end;
638
+ }
639
+ }
640
+
641
+ // ITEM_LIMIT without the lookahead item means the server clamped the requested limit to
642
+ // its own maximum, so the filled page is still evidence of a possible next page
643
+ const hasNextPage =
644
+ sawLookaheadItem ||
645
+ end?.reason === QueryEndReason.SCAN_LIMIT ||
646
+ end?.reason === QueryEndReason.ITEM_LIMIT;
647
+
648
+ return {
649
+ transactions,
650
+ hasNextPage,
651
+ startCursor,
652
+ // Scans that stopped early without filling the page continue from the scan frontier
653
+ // (so already-scanned positions are not revisited), full pages continue after the last
654
+ // returned item, and terminal pages have no positions to continue from
655
+ endCursor: sawLookaheadItem ? endCursor : hasNextPage ? (frontier ?? endCursor) : endCursor,
656
+ };
657
+ }
658
+
659
+ async listEvents(
660
+ options: SuiClientTypes.ListEventsOptions,
661
+ ): Promise<SuiClientTypes.ListEventsResponse> {
662
+ const pagination = resolvePagination(options);
663
+ const call = this.#client.ledgerService.listEvents(
664
+ {
665
+ readMask: {
666
+ paths: [
667
+ 'package_id',
668
+ 'module',
669
+ 'sender',
670
+ 'event_type',
671
+ 'contents',
672
+ 'json',
673
+ 'checkpoint',
674
+ 'transaction_digest',
675
+ 'event_index',
676
+ ],
677
+ },
678
+ filter: options.filter
679
+ ? toGrpcEventFilter(await resolveEventFilter(this.mvr, options.filter, options.signal))
680
+ : undefined,
681
+ // Request one extra item as lookahead: the server reports its item limit as reached
682
+ // without scanning past it, so an exact-limit final page is otherwise
683
+ // indistinguishable from one with more results
684
+ options: toGrpcQueryOptions(pagination, pagination.limit + 1),
685
+ },
686
+ { abort: options.signal },
687
+ );
688
+
689
+ const events: SuiClientTypes.EventEntry[] = [];
690
+ let startCursor: string | null = null;
691
+ let endCursor: string | null = null;
692
+ let frontier: string | null = null;
693
+ let end: QueryEnd | undefined;
694
+ let sawLookaheadItem = false;
695
+
696
+ for await (const frame of call.responses) {
697
+ if (frame.watermark?.cursor) {
698
+ frontier = toBase64(frame.watermark.cursor);
699
+ }
700
+ if (frame.event) {
701
+ if (events.length >= pagination.limit) {
702
+ sawLookaheadItem = true;
703
+ } else {
704
+ startCursor ??= frontier;
705
+ endCursor = frontier;
706
+ const event = frame.event;
707
+ events.push({
708
+ packageId: normalizeSuiAddress(event.packageId!),
709
+ module: event.module!,
710
+ sender: normalizeSuiAddress(event.sender!),
711
+ eventType: normalizeStructTag(event.eventType!),
712
+ bcs: event.contents?.value ?? new Uint8Array(),
713
+ json: event.json ? (Value.toJson(event.json) as Record<string, unknown>) : null,
714
+ checkpoint: event.checkpoint?.toString() ?? null,
715
+ transactionDigest: event.transactionDigest!,
716
+ eventIndex: event.eventIndex!,
717
+ });
718
+ }
719
+ }
720
+ if (frame.end) {
721
+ end = frame.end;
722
+ }
723
+ }
724
+
725
+ // ITEM_LIMIT without the lookahead item means the server clamped the requested limit to
726
+ // its own maximum, so the filled page is still evidence of a possible next page
727
+ const hasNextPage =
728
+ sawLookaheadItem ||
729
+ end?.reason === QueryEndReason.SCAN_LIMIT ||
730
+ end?.reason === QueryEndReason.ITEM_LIMIT;
731
+
732
+ return {
733
+ events,
734
+ hasNextPage,
735
+ startCursor,
736
+ // Scans that stopped early without filling the page continue from the scan frontier
737
+ // (so already-scanned positions are not revisited), full pages continue after the last
738
+ // returned item, and terminal pages have no positions to continue from
739
+ endCursor: sawLookaheadItem ? endCursor : hasNextPage ? (frontier ?? endCursor) : endCursor,
740
+ };
741
+ }
742
+
569
743
  async verifyZkLoginSignature(
570
744
  options: SuiClientTypes.VerifyZkLoginSignatureOptions,
571
745
  ): Promise<SuiClientTypes.ZkLoginVerifyResponse> {
@@ -720,14 +894,15 @@ export class GrpcCoreClient extends CoreClient {
720
894
  snapshot.sender = '0x0000000000000000000000000000000000000000000000000000000000000000';
721
895
  }
722
896
  const grpcTransaction = transactionDataToGrpcTransaction(snapshot);
897
+ const doGasSelection =
898
+ !options.onlyTransactionKind &&
899
+ (snapshot.gasData.budget == null || snapshot.gasData.payment == null);
723
900
 
724
901
  let response;
725
902
  try {
726
903
  const result = await client.transactionExecutionService.simulateTransaction({
727
904
  transaction: grpcTransaction,
728
- doGasSelection:
729
- !options.onlyTransactionKind &&
730
- (snapshot.gasData.budget == null || snapshot.gasData.payment == null),
905
+ doGasSelection,
731
906
  // Kind-only txns are never executed directly and do not have sender, so skip validation checks.
732
907
  checks: options.onlyTransactionKind
733
908
  ? SimulateTransactionRequest_TransactionChecks.DISABLED
@@ -739,6 +914,7 @@ export class GrpcCoreClient extends CoreClient {
739
914
  'transaction.transaction.expiration',
740
915
  'transaction.transaction.kind',
741
916
  'transaction.effects.status',
917
+ 'transaction.effects.epoch',
742
918
  ],
743
919
  },
744
920
  });
@@ -770,17 +946,35 @@ export class GrpcCoreClient extends CoreClient {
770
946
  }
771
947
 
772
948
  applyGrpcResolvedTransaction(transactionData, response.transaction.transaction, options);
949
+ await setAddressBalanceTransactionExpirationFromSimulatedEpoch({
950
+ transactionData,
951
+ client,
952
+ epoch: response.transaction.effects?.epoch,
953
+ originalTransactionData: snapshot,
954
+ isTransactionKindOnly: !!options.onlyTransactionKind,
955
+ doGasSelection,
956
+ });
773
957
 
774
958
  return await next();
775
959
  };
776
960
  }
777
961
  }
778
962
 
963
+ function toGrpcQueryOptions(pagination: ResolvedPagination, limit: number): QueryOptions {
964
+ return {
965
+ limit,
966
+ ordering: pagination.descending ? Ordering.DESCENDING : Ordering.ASCENDING,
967
+ after: pagination.after ? fromBase64(pagination.after) : undefined,
968
+ before: pagination.before ? fromBase64(pagination.before) : undefined,
969
+ };
970
+ }
971
+
779
972
  function transactionReadMaskPaths(
780
973
  include: SuiClientTypes.TransactionInclude | undefined,
781
974
  prefix = '',
782
- ) {
975
+ ): string[] {
783
976
  const paths = ['digest', 'transaction.digest', 'signatures', 'effects.status'];
977
+
784
978
  if (include?.transaction) {
785
979
  paths.push(
786
980
  'transaction.sender',
@@ -802,6 +996,7 @@ function transactionReadMaskPaths(
802
996
  paths.push('events');
803
997
  }
804
998
  if (include?.objectTypes) {
999
+ // Use effects.changed_objects to match JSON-RPC behavior (which uses objectChanges)
805
1000
  paths.push('effects.changed_objects.object_type');
806
1001
  paths.push('effects.changed_objects.object_id');
807
1002
  }
@@ -0,0 +1,68 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { ResolvedEventFilter, ResolvedTransactionFilter } from '../client/query-filters.js';
5
+ import type { EventFilter, TransactionFilter } from './proto/sui/rpc/v2/filter.js';
6
+
7
+ export function toGrpcTransactionFilter(filter: ResolvedTransactionFilter): TransactionFilter {
8
+ return {
9
+ terms: [
10
+ {
11
+ literals: [
12
+ filter.$kind === 'sender'
13
+ ? {
14
+ negated: false,
15
+ predicate: { oneofKind: 'sender', sender: { address: filter.sender } },
16
+ }
17
+ : {
18
+ negated: false,
19
+ predicate: {
20
+ oneofKind: 'moveCall',
21
+ moveCall: {
22
+ function: [filter.package, filter.module, filter.function]
23
+ .filter(Boolean)
24
+ .join('::'),
25
+ },
26
+ },
27
+ },
28
+ ],
29
+ },
30
+ ],
31
+ };
32
+ }
33
+
34
+ export function toGrpcEventFilter(filter: ResolvedEventFilter): EventFilter {
35
+ return {
36
+ terms: [
37
+ {
38
+ literals: [
39
+ filter.$kind === 'sender'
40
+ ? {
41
+ negated: false,
42
+ predicate: { oneofKind: 'sender', sender: { address: filter.sender } },
43
+ }
44
+ : filter.$kind === 'emitModule'
45
+ ? {
46
+ negated: false,
47
+ predicate: {
48
+ oneofKind: 'emitModule',
49
+ emitModule: { module: `${filter.package}::${filter.module}` },
50
+ },
51
+ }
52
+ : {
53
+ negated: false,
54
+ predicate: {
55
+ oneofKind: 'eventType',
56
+ eventType: {
57
+ eventType:
58
+ filter.$kind === 'eventTypeModule'
59
+ ? `${filter.package}::${filter.module}`
60
+ : filter.eventType,
61
+ },
62
+ },
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ };
68
+ }
@@ -81,6 +81,37 @@ export interface Event {
81
81
  * @generated from protobuf field: optional google.protobuf.Value json = 6;
82
82
  */
83
83
  json?: Value;
84
+ /**
85
+ * The sequence number of the checkpoint that includes the transaction
86
+ * that emitted this event. Populated when the event is delivered on its
87
+ * own (for example via `LedgerService.ListEvents`); left unset when the
88
+ * event is carried inside its transaction's `events` list, where the
89
+ * enclosing `ExecutedTransaction` already provides this context.
90
+ *
91
+ * @generated from protobuf field: optional uint64 checkpoint = 7;
92
+ */
93
+ checkpoint?: bigint;
94
+ /**
95
+ * The digest of the transaction that emitted this event.
96
+ *
97
+ * @generated from protobuf field: optional string transaction_digest = 8;
98
+ */
99
+ transactionDigest?: string;
100
+ /**
101
+ * Zero-based position of the emitting transaction within its containing
102
+ * checkpoint. For clients verifying authenticated event streams this
103
+ * index is part of the BCS-encoded `EventCommitment` leaf used to
104
+ * construct the per-checkpoint merkle root.
105
+ *
106
+ * @generated from protobuf field: optional uint64 transaction_index = 9;
107
+ */
108
+ transactionIndex?: bigint;
109
+ /**
110
+ * Zero-based index of this event within its transaction's event list.
111
+ *
112
+ * @generated from protobuf field: optional uint32 event_index = 10;
113
+ */
114
+ eventIndex?: number;
84
115
  }
85
116
  // @generated message type with reflection information, may provide speed optimized methods
86
117
  class TransactionEvents$Type extends MessageType<TransactionEvents> {
@@ -106,6 +137,24 @@ class Event$Type extends MessageType<Event> {
106
137
  { no: 4, name: 'event_type', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },
107
138
  { no: 5, name: 'contents', kind: 'message', T: () => Bcs },
108
139
  { no: 6, name: 'json', kind: 'message', T: () => Value },
140
+ {
141
+ no: 7,
142
+ name: 'checkpoint',
143
+ kind: 'scalar',
144
+ opt: true,
145
+ T: 4 /*ScalarType.UINT64*/,
146
+ L: 0 /*LongType.BIGINT*/,
147
+ },
148
+ { no: 8, name: 'transaction_digest', kind: 'scalar', opt: true, T: 9 /*ScalarType.STRING*/ },
149
+ {
150
+ no: 9,
151
+ name: 'transaction_index',
152
+ kind: 'scalar',
153
+ opt: true,
154
+ T: 4 /*ScalarType.UINT64*/,
155
+ L: 0 /*LongType.BIGINT*/,
156
+ },
157
+ { no: 10, name: 'event_index', kind: 'scalar', opt: true, T: 13 /*ScalarType.UINT32*/ },
109
158
  ]);
110
159
  }
111
160
  }
@@ -80,6 +80,13 @@ export interface ExecutedTransaction {
80
80
  * @generated from protobuf field: optional sui.rpc.v2.ObjectSet objects = 9;
81
81
  */
82
82
  objects?: ObjectSet;
83
+ /**
84
+ * Zero-based position of this transaction within the checkpoint that
85
+ * includes it.
86
+ *
87
+ * @generated from protobuf field: optional uint64 transaction_index = 10;
88
+ */
89
+ transactionIndex?: bigint;
83
90
  }
84
91
  // @generated message type with reflection information, may provide speed optimized methods
85
92
  class ExecutedTransaction$Type extends MessageType<ExecutedTransaction> {
@@ -113,6 +120,14 @@ class ExecutedTransaction$Type extends MessageType<ExecutedTransaction> {
113
120
  T: () => BalanceChange,
114
121
  },
115
122
  { no: 9, name: 'objects', kind: 'message', T: () => ObjectSet },
123
+ {
124
+ no: 10,
125
+ name: 'transaction_index',
126
+ kind: 'scalar',
127
+ opt: true,
128
+ T: 4 /*ScalarType.UINT64*/,
129
+ L: 0 /*LongType.BIGINT*/,
130
+ },
116
131
  ]);
117
132
  }
118
133
  }