@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.
- package/CHANGELOG.md +38 -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 +3812 -906
- 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/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 +85 -3
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +137 -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 +100 -2
- 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/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/state_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 +9 -9
- 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/bcs.d.mts +14 -14
- package/dist/zklogin/bcs.d.mts.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/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 +143 -3
- package/src/graphql/generated/queries.ts +226 -0
- 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 +26 -0
- package/src/grpc/client.ts +19 -0
- package/src/grpc/core.ts +187 -3
- 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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui TypeScript API",
|
|
5
5
|
"homepage": "https://sdk.mystenlabs.com",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.23.1",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"files": [
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"gql.tada": "^1.10.1",
|
|
168
168
|
"graphql": "^16.14.2",
|
|
169
169
|
"poseidon-lite": "0.2.1",
|
|
170
|
-
"valibot": "^1.4.
|
|
170
|
+
"valibot": "^1.4.2",
|
|
171
171
|
"@mysten/bcs": "^2.1.0",
|
|
172
172
|
"@mysten/utils": "^0.4.0"
|
|
173
173
|
},
|
package/src/bcs/bcs.ts
CHANGED
|
@@ -228,13 +228,6 @@ export const ProgrammableTransaction = bcs.struct('ProgrammableTransaction', {
|
|
|
228
228
|
commands: bcs.vector(Command),
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
-
export const TransactionKind = bcs.enum('TransactionKind', {
|
|
232
|
-
ProgrammableTransaction: ProgrammableTransaction,
|
|
233
|
-
ChangeEpoch: null,
|
|
234
|
-
Genesis: null,
|
|
235
|
-
ConsensusCommitPrologue: null,
|
|
236
|
-
});
|
|
237
|
-
|
|
238
231
|
// Rust: crates/sui-types/src/transaction.rs
|
|
239
232
|
export const ValidDuring = bcs.struct('ValidDuring', {
|
|
240
233
|
minEpoch: bcs.option(bcs.u64()),
|
|
@@ -265,17 +258,6 @@ export const GasData = bcs.struct('GasData', {
|
|
|
265
258
|
budget: bcs.u64(),
|
|
266
259
|
});
|
|
267
260
|
|
|
268
|
-
export const TransactionDataV1 = bcs.struct('TransactionDataV1', {
|
|
269
|
-
kind: TransactionKind,
|
|
270
|
-
sender: Address,
|
|
271
|
-
gasData: GasData,
|
|
272
|
-
expiration: TransactionExpiration,
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
export const TransactionData = bcs.enum('TransactionData', {
|
|
276
|
-
V1: TransactionDataV1,
|
|
277
|
-
});
|
|
278
|
-
|
|
279
261
|
export const IntentScope = bcs.enum('IntentScope', {
|
|
280
262
|
TransactionData: null,
|
|
281
263
|
TransactionEffects: null,
|
|
@@ -341,15 +323,6 @@ export const base64String = bcs.byteVector().transform({
|
|
|
341
323
|
output: (val) => toBase64(new Uint8Array(val)),
|
|
342
324
|
});
|
|
343
325
|
|
|
344
|
-
export const SenderSignedTransaction = bcs.struct('SenderSignedTransaction', {
|
|
345
|
-
intentMessage: IntentMessage(TransactionData),
|
|
346
|
-
txSignatures: bcs.vector(base64String),
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
export const SenderSignedData = bcs.vector(SenderSignedTransaction, {
|
|
350
|
-
name: 'SenderSignedData',
|
|
351
|
-
});
|
|
352
|
-
|
|
353
326
|
export const PasskeyAuthenticator = bcs.struct('PasskeyAuthenticator', {
|
|
354
327
|
authenticatorData: bcs.byteVector(),
|
|
355
328
|
clientDataJson: bcs.string(),
|
package/src/bcs/index.ts
CHANGED
|
@@ -30,19 +30,21 @@ import {
|
|
|
30
30
|
ProgrammableMoveCall,
|
|
31
31
|
ProgrammableTransaction,
|
|
32
32
|
PublicKey,
|
|
33
|
-
SenderSignedData,
|
|
34
|
-
SenderSignedTransaction,
|
|
35
33
|
SharedObjectRef,
|
|
36
34
|
StructTag,
|
|
37
35
|
SuiObjectRef,
|
|
38
|
-
TransactionData,
|
|
39
|
-
TransactionDataV1,
|
|
40
36
|
TransactionExpiration,
|
|
41
|
-
TransactionKind,
|
|
42
37
|
TypeOrigin,
|
|
43
38
|
TypeTag,
|
|
44
39
|
UpgradeInfo,
|
|
45
40
|
} from './bcs.js';
|
|
41
|
+
import {
|
|
42
|
+
SenderSignedData,
|
|
43
|
+
SenderSignedTransaction,
|
|
44
|
+
TransactionData,
|
|
45
|
+
TransactionDataV1,
|
|
46
|
+
TransactionKind,
|
|
47
|
+
} from './transactions.js';
|
|
46
48
|
import { TransactionEffects } from './effects.js';
|
|
47
49
|
|
|
48
50
|
export type { TypeTag } from './types.js';
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { bcs } from '@mysten/bcs';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Address,
|
|
8
|
+
base64String,
|
|
9
|
+
Data,
|
|
10
|
+
GasData,
|
|
11
|
+
IntentMessage,
|
|
12
|
+
ObjectDigest,
|
|
13
|
+
Owner,
|
|
14
|
+
ProgrammableTransaction,
|
|
15
|
+
TransactionExpiration,
|
|
16
|
+
TypeTag,
|
|
17
|
+
} from './bcs.js';
|
|
18
|
+
|
|
19
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
20
|
+
export const ChangeEpoch = bcs.struct('ChangeEpoch', {
|
|
21
|
+
epoch: bcs.u64(),
|
|
22
|
+
protocolVersion: bcs.u64(),
|
|
23
|
+
storageCharge: bcs.u64(),
|
|
24
|
+
computationCharge: bcs.u64(),
|
|
25
|
+
storageRebate: bcs.u64(),
|
|
26
|
+
nonRefundableStorageFee: bcs.u64(),
|
|
27
|
+
epochStartTimestampMs: bcs.u64(),
|
|
28
|
+
systemPackages: bcs.vector(
|
|
29
|
+
bcs.tuple([bcs.u64(), bcs.vector(bcs.byteVector()), bcs.vector(Address)]),
|
|
30
|
+
),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
34
|
+
export const GenesisObject = bcs.enum('GenesisObject', {
|
|
35
|
+
RawObject: bcs.struct('RawObject', {
|
|
36
|
+
data: Data,
|
|
37
|
+
owner: Owner,
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
42
|
+
export const GenesisTransaction = bcs.struct('GenesisTransaction', {
|
|
43
|
+
objects: bcs.vector(GenesisObject),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Rust: crates/sui-types/src/messages_consensus.rs
|
|
47
|
+
export const ConsensusCommitPrologue = bcs.struct('ConsensusCommitPrologue', {
|
|
48
|
+
epoch: bcs.u64(),
|
|
49
|
+
round: bcs.u64(),
|
|
50
|
+
commitTimestampMs: bcs.u64(),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Rust: crates/sui-types/src/messages_consensus.rs
|
|
54
|
+
export const ConsensusCommitPrologueV2 = bcs.struct('ConsensusCommitPrologueV2', {
|
|
55
|
+
epoch: bcs.u64(),
|
|
56
|
+
round: bcs.u64(),
|
|
57
|
+
commitTimestampMs: bcs.u64(),
|
|
58
|
+
consensusCommitDigest: ObjectDigest,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Rust: crates/sui-types/src/messages_consensus.rs
|
|
62
|
+
export const ConsensusDeterminedVersionAssignments = bcs.enum(
|
|
63
|
+
'ConsensusDeterminedVersionAssignments',
|
|
64
|
+
{
|
|
65
|
+
CancelledTransactions: bcs.vector(
|
|
66
|
+
bcs.tuple([ObjectDigest, bcs.vector(bcs.tuple([Address, bcs.u64()]))]),
|
|
67
|
+
),
|
|
68
|
+
CancelledTransactionsV2: bcs.vector(
|
|
69
|
+
bcs.tuple([
|
|
70
|
+
ObjectDigest,
|
|
71
|
+
bcs.vector(bcs.tuple([bcs.tuple([Address, bcs.u64()]), bcs.u64()])),
|
|
72
|
+
]),
|
|
73
|
+
),
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Rust: crates/sui-types/src/messages_consensus.rs
|
|
78
|
+
export const ConsensusCommitPrologueV3 = bcs.struct('ConsensusCommitPrologueV3', {
|
|
79
|
+
epoch: bcs.u64(),
|
|
80
|
+
round: bcs.u64(),
|
|
81
|
+
subDagIndex: bcs.option(bcs.u64()),
|
|
82
|
+
commitTimestampMs: bcs.u64(),
|
|
83
|
+
consensusCommitDigest: ObjectDigest,
|
|
84
|
+
consensusDeterminedVersionAssignments: ConsensusDeterminedVersionAssignments,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Rust: crates/sui-types/src/messages_consensus.rs
|
|
88
|
+
export const ConsensusCommitPrologueV4 = bcs.struct('ConsensusCommitPrologueV4', {
|
|
89
|
+
epoch: bcs.u64(),
|
|
90
|
+
round: bcs.u64(),
|
|
91
|
+
subDagIndex: bcs.option(bcs.u64()),
|
|
92
|
+
commitTimestampMs: bcs.u64(),
|
|
93
|
+
consensusCommitDigest: ObjectDigest,
|
|
94
|
+
consensusDeterminedVersionAssignments: ConsensusDeterminedVersionAssignments,
|
|
95
|
+
additionalStateDigest: ObjectDigest,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Rust: crates/sui-types/src/authenticator_state.rs
|
|
99
|
+
export const ActiveJwk = bcs.struct('ActiveJwk', {
|
|
100
|
+
jwkId: bcs.struct('JwkId', {
|
|
101
|
+
iss: bcs.string(),
|
|
102
|
+
kid: bcs.string(),
|
|
103
|
+
}),
|
|
104
|
+
jwk: bcs.struct('JWK', {
|
|
105
|
+
kty: bcs.string(),
|
|
106
|
+
e: bcs.string(),
|
|
107
|
+
n: bcs.string(),
|
|
108
|
+
alg: bcs.string(),
|
|
109
|
+
}),
|
|
110
|
+
epoch: bcs.u64(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
114
|
+
export const AuthenticatorStateUpdate = bcs.struct('AuthenticatorStateUpdate', {
|
|
115
|
+
epoch: bcs.u64(),
|
|
116
|
+
round: bcs.u64(),
|
|
117
|
+
newActiveJwks: bcs.vector(ActiveJwk),
|
|
118
|
+
authenticatorObjInitialSharedVersion: bcs.u64(),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
122
|
+
export const RandomnessStateUpdate = bcs.struct('RandomnessStateUpdate', {
|
|
123
|
+
epoch: bcs.u64(),
|
|
124
|
+
randomnessRound: bcs.u64(),
|
|
125
|
+
randomBytes: bcs.byteVector(),
|
|
126
|
+
randomnessObjInitialSharedVersion: bcs.u64(),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
130
|
+
export const AuthenticatorStateExpire = bcs.struct('AuthenticatorStateExpire', {
|
|
131
|
+
minEpoch: bcs.u64(),
|
|
132
|
+
authenticatorObjInitialSharedVersion: bcs.u64(),
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Rust: crates/sui-types/src/execution.rs
|
|
136
|
+
export const ExecutionTimeObservationKey = bcs.enum('ExecutionTimeObservationKey', {
|
|
137
|
+
MoveEntryPoint: bcs.struct('MoveEntryPoint', {
|
|
138
|
+
package: Address,
|
|
139
|
+
module: bcs.string(),
|
|
140
|
+
function: bcs.string(),
|
|
141
|
+
typeArguments: bcs.vector(TypeTag),
|
|
142
|
+
}),
|
|
143
|
+
TransferObjects: null,
|
|
144
|
+
SplitCoins: null,
|
|
145
|
+
MergeCoins: null,
|
|
146
|
+
Publish: null,
|
|
147
|
+
MakeMoveVec: null,
|
|
148
|
+
Upgrade: null,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
152
|
+
export const StoredExecutionTimeObservations = bcs.enum('StoredExecutionTimeObservations', {
|
|
153
|
+
V1: bcs.vector(
|
|
154
|
+
bcs.tuple([
|
|
155
|
+
ExecutionTimeObservationKey,
|
|
156
|
+
bcs.vector(
|
|
157
|
+
bcs.tuple([
|
|
158
|
+
// AuthorityName (BLS public key bytes)
|
|
159
|
+
bcs.byteVector(),
|
|
160
|
+
bcs.struct('Duration', {
|
|
161
|
+
secs: bcs.u64(),
|
|
162
|
+
nanos: bcs.u32(),
|
|
163
|
+
}),
|
|
164
|
+
]),
|
|
165
|
+
),
|
|
166
|
+
]),
|
|
167
|
+
),
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
171
|
+
export const WriteAccumulatorStorageCost = bcs.struct('WriteAccumulatorStorageCost', {
|
|
172
|
+
storageCost: bcs.u64(),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
176
|
+
export const EndOfEpochTransactionKind = bcs.enum('EndOfEpochTransactionKind', {
|
|
177
|
+
ChangeEpoch: ChangeEpoch,
|
|
178
|
+
AuthenticatorStateCreate: null,
|
|
179
|
+
AuthenticatorStateExpire: AuthenticatorStateExpire,
|
|
180
|
+
RandomnessStateCreate: null,
|
|
181
|
+
DenyListStateCreate: null,
|
|
182
|
+
// ChainIdentifier (the genesis checkpoint digest)
|
|
183
|
+
BridgeStateCreate: ObjectDigest,
|
|
184
|
+
BridgeCommitteeInit: bcs.u64(),
|
|
185
|
+
StoreExecutionTimeObservations: StoredExecutionTimeObservations,
|
|
186
|
+
AccumulatorRootCreate: null,
|
|
187
|
+
CoinRegistryCreate: null,
|
|
188
|
+
DisplayRegistryCreate: null,
|
|
189
|
+
AddressAliasStateCreate: null,
|
|
190
|
+
WriteAccumulatorStorageCost: WriteAccumulatorStorageCost,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Rust: crates/sui-types/src/transaction.rs
|
|
194
|
+
export const TransactionKind = bcs.enum('TransactionKind', {
|
|
195
|
+
ProgrammableTransaction: ProgrammableTransaction,
|
|
196
|
+
ChangeEpoch: ChangeEpoch,
|
|
197
|
+
Genesis: GenesisTransaction,
|
|
198
|
+
ConsensusCommitPrologue: ConsensusCommitPrologue,
|
|
199
|
+
AuthenticatorStateUpdate: AuthenticatorStateUpdate,
|
|
200
|
+
EndOfEpochTransaction: bcs.vector(EndOfEpochTransactionKind),
|
|
201
|
+
RandomnessStateUpdate: RandomnessStateUpdate,
|
|
202
|
+
ConsensusCommitPrologueV2: ConsensusCommitPrologueV2,
|
|
203
|
+
ConsensusCommitPrologueV3: ConsensusCommitPrologueV3,
|
|
204
|
+
ConsensusCommitPrologueV4: ConsensusCommitPrologueV4,
|
|
205
|
+
ProgrammableSystemTransaction: ProgrammableTransaction,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export const TransactionDataV1 = bcs.struct('TransactionDataV1', {
|
|
209
|
+
kind: TransactionKind,
|
|
210
|
+
sender: Address,
|
|
211
|
+
gasData: GasData,
|
|
212
|
+
expiration: TransactionExpiration,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
export const TransactionData = bcs.enum('TransactionData', {
|
|
216
|
+
V1: TransactionDataV1,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
export const SenderSignedTransaction = bcs.struct('SenderSignedTransaction', {
|
|
220
|
+
intentMessage: IntentMessage(TransactionData),
|
|
221
|
+
txSignatures: bcs.vector(base64String),
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
export const SenderSignedData = bcs.vector(SenderSignedTransaction, {
|
|
225
|
+
name: 'SenderSignedData',
|
|
226
|
+
});
|
|
@@ -169,7 +169,11 @@ async function setGasBudget(
|
|
|
169
169
|
},
|
|
170
170
|
}),
|
|
171
171
|
include: { effects: true },
|
|
172
|
-
|
|
172
|
+
// The empty payment above is a placeholder for budget estimation, not a real address
|
|
173
|
+
// balance payment, so the server must simulate with a mocked gas coin rather than
|
|
174
|
+
// selecting gas. gRPC and GraphQL support this option, and JSON-RPC always mocks gas.
|
|
175
|
+
doGasSelection: false,
|
|
176
|
+
} as SuiClientTypes.SimulateTransactionOptions<{ effects: true }> & { doGasSelection: boolean });
|
|
173
177
|
|
|
174
178
|
if (simulateResult.$kind === 'FailedTransaction') {
|
|
175
179
|
const executionError = simulateResult.FailedTransaction.status.error ?? undefined;
|
package/src/client/core.ts
CHANGED
|
@@ -112,6 +112,14 @@ export abstract class CoreClient extends BaseClient implements SuiClientTypes.Tr
|
|
|
112
112
|
options: SuiClientTypes.ListDynamicFieldsOptions,
|
|
113
113
|
): Promise<SuiClientTypes.ListDynamicFieldsResponse>;
|
|
114
114
|
|
|
115
|
+
abstract listTransactions<Include extends SuiClientTypes.TransactionInclude = {}>(
|
|
116
|
+
options: SuiClientTypes.ListTransactionsOptions<Include>,
|
|
117
|
+
): Promise<SuiClientTypes.ListTransactionsResponse<Include>>;
|
|
118
|
+
|
|
119
|
+
abstract listEvents(
|
|
120
|
+
options: SuiClientTypes.ListEventsOptions,
|
|
121
|
+
): Promise<SuiClientTypes.ListEventsResponse>;
|
|
122
|
+
|
|
115
123
|
abstract resolveTransactionPlugin(): TransactionPlugin;
|
|
116
124
|
|
|
117
125
|
abstract verifyZkLoginSignature(
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { normalizeSuiAddress } from '../utils/sui-types.js';
|
|
5
|
+
import type { SuiClientTypes } from './types.js';
|
|
6
|
+
|
|
7
|
+
export interface ResolvedPagination {
|
|
8
|
+
descending: boolean;
|
|
9
|
+
after: string | undefined;
|
|
10
|
+
before: string | undefined;
|
|
11
|
+
limit: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Default page size applied when `limit` is omitted, so every transport
|
|
16
|
+
* requests the same page size instead of falling back to differing server
|
|
17
|
+
* defaults.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validates pagination bounds and resolves the traversal direction.
|
|
23
|
+
*
|
|
24
|
+
* `after` and `before` are exclusive ledger-position bounds. Until every
|
|
25
|
+
* transport can combine bounds freely, a query accepts at most one bound, and
|
|
26
|
+
* the bound must match the traversal direction (`after` implies ascending,
|
|
27
|
+
* `before` implies descending).
|
|
28
|
+
*/
|
|
29
|
+
export function resolvePagination(options: {
|
|
30
|
+
after?: string | null;
|
|
31
|
+
before?: string | null;
|
|
32
|
+
order?: 'ascending' | 'descending';
|
|
33
|
+
limit?: number;
|
|
34
|
+
}): ResolvedPagination {
|
|
35
|
+
if (options.after != null && options.before != null) {
|
|
36
|
+
throw new Error('Only one of `after` or `before` may be provided');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const descending = options.order ? options.order === 'descending' : options.before != null;
|
|
40
|
+
|
|
41
|
+
if (options.after != null && descending) {
|
|
42
|
+
throw new Error('`after` can not be combined with descending queries');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (options.before != null && !descending) {
|
|
46
|
+
throw new Error('`before` can not be combined with ascending queries');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
descending,
|
|
51
|
+
after: options.after ?? undefined,
|
|
52
|
+
before: options.before ?? undefined,
|
|
53
|
+
limit: options.limit ?? DEFAULT_PAGE_SIZE,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type ResolvedTransactionFilter =
|
|
58
|
+
| { $kind: 'sender'; sender: string }
|
|
59
|
+
| { $kind: 'function'; package: string; module?: string; function?: string };
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Validates that a transaction query's filter supports pagination bounds.
|
|
63
|
+
*
|
|
64
|
+
* Function filters can only be paginated when fully qualified, since JSON-RPC
|
|
65
|
+
* rejects cursors on package- or module-level `MoveFunction` filters.
|
|
66
|
+
*/
|
|
67
|
+
export function validateTransactionQuery(
|
|
68
|
+
filter: ResolvedTransactionFilter | undefined,
|
|
69
|
+
pagination: ResolvedPagination,
|
|
70
|
+
): void {
|
|
71
|
+
if (
|
|
72
|
+
filter?.$kind === 'function' &&
|
|
73
|
+
(pagination.after != null || pagination.before != null) &&
|
|
74
|
+
(!filter.module || !filter.function)
|
|
75
|
+
) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
'Paginating transactions filtered by function requires a fully qualified `package::module::function`',
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type ResolvedEventFilter =
|
|
83
|
+
| { $kind: 'sender'; sender: string }
|
|
84
|
+
| { $kind: 'emitModule'; package: string; module: string }
|
|
85
|
+
| { $kind: 'eventTypeModule'; package: string; module: string }
|
|
86
|
+
| { $kind: 'eventType'; eventType: string };
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Validates a transaction filter and resolves any MVR names it contains.
|
|
90
|
+
*
|
|
91
|
+
* Every transport resolves filters through this function so that validation
|
|
92
|
+
* errors and MVR handling are identical across clients.
|
|
93
|
+
*/
|
|
94
|
+
export async function resolveTransactionFilter(
|
|
95
|
+
mvr: SuiClientTypes.MvrMethods,
|
|
96
|
+
filter: SuiClientTypes.TransactionFilter,
|
|
97
|
+
signal?: AbortSignal,
|
|
98
|
+
): Promise<ResolvedTransactionFilter> {
|
|
99
|
+
assertSinglePredicate(filter, ['sender', 'function'], 'transaction');
|
|
100
|
+
|
|
101
|
+
if (filter.sender != null) {
|
|
102
|
+
return { $kind: 'sender', sender: normalizeSuiAddress(filter.sender) };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const [pkg, module, fn, ...rest] = filter.function!.split('::');
|
|
106
|
+
|
|
107
|
+
if (!pkg || rest.length > 0 || module === '' || fn === '') {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Invalid function filter "${filter.function}": expected "package", "package::module", or "package::module::function"`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
$kind: 'function',
|
|
115
|
+
package: normalizeSuiAddress((await mvr.resolvePackage({ package: pkg, signal })).package),
|
|
116
|
+
module,
|
|
117
|
+
function: fn,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Validates an event filter and resolves any MVR names it contains.
|
|
123
|
+
*
|
|
124
|
+
* `emitModule` must name a module (`package::module`), and `eventType` must be
|
|
125
|
+
* at least module-qualified (`package::module` or a full type). Every transport
|
|
126
|
+
* resolves filters through this function so that validation errors and MVR
|
|
127
|
+
* handling are identical across clients.
|
|
128
|
+
*/
|
|
129
|
+
export async function resolveEventFilter(
|
|
130
|
+
mvr: SuiClientTypes.MvrMethods,
|
|
131
|
+
filter: SuiClientTypes.EventFilter,
|
|
132
|
+
signal?: AbortSignal,
|
|
133
|
+
): Promise<ResolvedEventFilter> {
|
|
134
|
+
assertSinglePredicate(filter, ['sender', 'emitModule', 'eventType'], 'event');
|
|
135
|
+
|
|
136
|
+
if (filter.sender != null) {
|
|
137
|
+
return { $kind: 'sender', sender: normalizeSuiAddress(filter.sender) };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (filter.emitModule != null) {
|
|
141
|
+
const [pkg, module, ...rest] = filter.emitModule.split('::');
|
|
142
|
+
|
|
143
|
+
if (!pkg || !module || rest.length > 0) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Invalid emitModule filter "${filter.emitModule}": expected "package::module"`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
$kind: 'emitModule',
|
|
151
|
+
package: normalizeSuiAddress((await mvr.resolvePackage({ package: pkg, signal })).package),
|
|
152
|
+
module,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const eventType = filter.eventType!;
|
|
157
|
+
const segments = eventType.split('::');
|
|
158
|
+
|
|
159
|
+
if (segments.length === 2 && segments.every((segment) => segment !== '')) {
|
|
160
|
+
return {
|
|
161
|
+
$kind: 'eventTypeModule',
|
|
162
|
+
package: normalizeSuiAddress(
|
|
163
|
+
(await mvr.resolvePackage({ package: segments[0], signal })).package,
|
|
164
|
+
),
|
|
165
|
+
module: segments[1],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (segments.length < 3 || segments.some((segment) => segment === '')) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Invalid eventType filter "${eventType}": expected "package::module" or a fully qualified type name`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
$kind: 'eventType',
|
|
177
|
+
eventType: (await mvr.resolveType({ type: eventType, signal })).type,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function assertSinglePredicate(
|
|
182
|
+
filter: Record<string, unknown>,
|
|
183
|
+
predicates: string[],
|
|
184
|
+
kind: string,
|
|
185
|
+
): void {
|
|
186
|
+
const present = predicates.filter((predicate) => filter[predicate] != null);
|
|
187
|
+
|
|
188
|
+
if (present.length !== 1) {
|
|
189
|
+
throw new Error(
|
|
190
|
+
`A ${kind} filter must specify exactly one of ${predicates.join(', ')}${
|
|
191
|
+
present.length ? ` (got ${present.join(', ')})` : ''
|
|
192
|
+
}`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|