@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.
- package/CHANGELOG.md +47 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +1 -19
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/bcs/index.d.mts +4225 -1319
- package/dist/bcs/index.d.mts.map +1 -1
- package/dist/bcs/index.mjs +2 -1
- package/dist/bcs/index.mjs.map +1 -1
- package/dist/bcs/transactions.mjs +147 -0
- package/dist/bcs/transactions.mjs.map +1 -0
- package/dist/client/address-balance-transaction-expiration.mjs +22 -0
- package/dist/client/address-balance-transaction-expiration.mjs.map +1 -0
- package/dist/client/core-resolver.mjs +2 -1
- package/dist/client/core-resolver.mjs.map +1 -1
- package/dist/client/core.d.mts +2 -0
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/query-filters.mjs +119 -0
- package/dist/client/query-filters.mjs.map +1 -0
- package/dist/client/types.d.mts +166 -1
- package/dist/client/types.d.mts.map +1 -1
- package/dist/client/utils.d.mts.map +1 -1
- package/dist/client/utils.mjs +13 -1
- package/dist/client/utils.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +15 -2
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +6 -0
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +5 -1
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +96 -4
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +140 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +108 -0
- package/dist/graphql/index.d.mts +2 -2
- package/dist/grpc/client.d.mts +11 -0
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +6 -0
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +5 -1
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +113 -4
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/filters.mjs +45 -0
- package/dist/grpc/filters.mjs.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/event.d.mts +31 -0
- package/dist/grpc/proto/sui/rpc/v2/event.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/event.mjs +30 -0
- package/dist/grpc/proto/sui/rpc/v2/event.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts +7 -0
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs +8 -0
- package/dist/grpc/proto/sui/rpc/v2/executed_transaction.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/filter.d.mts +423 -0
- package/dist/grpc/proto/sui/rpc/v2/filter.d.mts.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/filter.mjs +297 -0
- package/dist/grpc/proto/sui/rpc/v2/filter.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +62 -6
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs +37 -0
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts +293 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs +241 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts +15 -2
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs +11 -0
- package/dist/grpc/proto/sui/rpc/v2/protocol_config.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts +211 -0
- package/dist/grpc/proto/sui/rpc/v2/query_options.d.mts.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs +163 -0
- package/dist/grpc/proto/sui/rpc/v2/query_options.mjs.map +1 -0
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +105 -23
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs +56 -9
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts +148 -8
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.d.mts.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs +109 -8
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/grpc/proto/types.d.mts +5 -3
- package/dist/grpc/proto/types.mjs +33 -2
- package/dist/grpc/proto/types.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +10 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +85 -2
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/Transaction.d.mts.map +1 -1
- package/dist/transactions/intents/CoinWithBalance.mjs +14 -18
- package/dist/transactions/intents/CoinWithBalance.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/address.mjs +2 -2
- package/dist/zklogin/address.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/poseidon.mjs +5 -2
- package/dist/zklogin/poseidon.mjs.map +1 -1
- package/docs/clients/core.md +115 -1
- package/docs/clients/grpc.md +68 -0
- package/docs/migrations/sui-2.0/json-rpc-migration.md +104 -101
- package/package.json +2 -2
- package/src/bcs/bcs.ts +0 -27
- package/src/bcs/index.ts +7 -5
- package/src/bcs/transactions.ts +226 -0
- package/src/client/address-balance-transaction-expiration.ts +53 -0
- package/src/client/core-resolver.ts +5 -1
- package/src/client/core.ts +8 -0
- package/src/client/query-filters.ts +195 -0
- package/src/client/types.ts +186 -1
- package/src/client/utils.ts +13 -0
- package/src/graphql/client.ts +25 -1
- package/src/graphql/core.ts +156 -6
- package/src/graphql/generated/queries.ts +230 -1
- package/src/graphql/generated/schema.graphql +75 -0
- package/src/graphql/generated/tada-env.ts +133 -0
- package/src/graphql/index.ts +1 -0
- package/src/graphql/queries/listEvents.graphql +40 -0
- package/src/graphql/queries/transactions.graphql +29 -0
- package/src/grpc/client.ts +19 -0
- package/src/grpc/core.ts +201 -6
- package/src/grpc/filters.ts +68 -0
- package/src/grpc/proto/sui/rpc/v2/event.ts +49 -0
- package/src/grpc/proto/sui/rpc/v2/executed_transaction.ts +15 -0
- package/src/grpc/proto/sui/rpc/v2/filter.ts +589 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.client.ts +111 -0
- package/src/grpc/proto/sui/rpc/v2/ledger_service.ts +406 -0
- package/src/grpc/proto/sui/rpc/v2/protocol_config.ts +22 -2
- package/src/grpc/proto/sui/rpc/v2/query_options.ts +255 -0
- package/src/grpc/proto/sui/rpc/v2/subscription_service.client.ts +136 -18
- package/src/grpc/proto/sui/rpc/v2/subscription_service.ts +187 -7
- package/src/grpc/proto/types.ts +2 -0
- package/src/jsonRpc/core.ts +136 -2
- package/src/transactions/intents/CoinWithBalance.ts +41 -41
- package/src/version.ts +1 -1
- package/src/zklogin/address.ts +2 -2
- 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
|
package/src/grpc/client.ts
CHANGED
|
@@ -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
|
|
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
|
}
|