@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
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
This guide covers migrating from `SuiJsonRpcClient` to the new client APIs. The JSON-RPC API is
|
|
6
6
|
being deprecated in favor of `SuiGrpcClient` and `SuiGraphQLClient`.
|
|
7
7
|
|
|
8
|
-
> **Note:**
|
|
9
|
-
>
|
|
8
|
+
> **Note:** Use `SuiGrpcClient` for most operations, including filtering transactions and events with the core
|
|
9
|
+
> query API. `SuiGraphQLClient` remains useful for complex queries that aren't covered by the core
|
|
10
|
+
> API.
|
|
10
11
|
|
|
11
12
|
## Choosing a client
|
|
12
13
|
|
|
13
|
-
| Client | Best For
|
|
14
|
-
| ------------------ |
|
|
15
|
-
| `SuiGrpcClient` | Most operations, SDK integrations, real-time data
|
|
16
|
-
| `SuiGraphQLClient` | Complex queries
|
|
14
|
+
| Client | Best For |
|
|
15
|
+
| ------------------ | -------------------------------------------------------------------- |
|
|
16
|
+
| `SuiGrpcClient` | Most operations, SDK integrations, queries, real-time data |
|
|
17
|
+
| `SuiGraphQLClient` | Complex queries not covered by the core API, like historical objects |
|
|
17
18
|
|
|
18
19
|
## Quick migration to gRPC
|
|
19
20
|
|
|
@@ -58,6 +59,58 @@ These JSON-RPC methods have direct replacements in the core API:
|
|
|
58
59
|
| `dryRunTransactionBlock` | `simulateTransaction` |
|
|
59
60
|
| `getNormalizedMoveFunction` | `getMoveFunction` |
|
|
60
61
|
| `getMoveFunctionArgTypes` | `getMoveFunction` |
|
|
62
|
+
| `queryTransactionBlocks` | `listTransactions` |
|
|
63
|
+
| `queryEvents` | `listEvents` |
|
|
64
|
+
|
|
65
|
+
> **Note:** The query methods (`listTransactions` and `listEvents`) behave identically on every client,
|
|
66
|
+
> including `SuiJsonRpcClient`. See [Core API query methods](/sui/clients/core#query-methods) for
|
|
67
|
+
> details.
|
|
68
|
+
|
|
69
|
+
### Example: Migrating queryTransactionBlocks
|
|
70
|
+
|
|
71
|
+
```diff
|
|
72
|
+
- const result = await jsonRpcClient.queryTransactionBlocks({
|
|
73
|
+
- filter: { FromAddress: '0xabc...' },
|
|
74
|
+
- options: { showEffects: true },
|
|
75
|
+
- limit: 10,
|
|
76
|
+
- });
|
|
77
|
+
- const digests = result.data.map((tx) => tx.digest);
|
|
78
|
+
+ const result = await client.core.listTransactions({
|
|
79
|
+
+ filter: { sender: '0xabc...' },
|
|
80
|
+
+ include: { effects: true },
|
|
81
|
+
+ limit: 10,
|
|
82
|
+
+ });
|
|
83
|
+
+ const digests = result.transactions.map(
|
|
84
|
+
+ (tx) => (tx.Transaction ?? tx.FailedTransaction).digest,
|
|
85
|
+
+ );
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The core API filters map to the JSON-RPC `TransactionFilter` variants:
|
|
89
|
+
|
|
90
|
+
| JSON-RPC filter | Core API filter predicate |
|
|
91
|
+
| -------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `FromAddress` | `sender` |
|
|
93
|
+
| `MoveFunction` | `function` |
|
|
94
|
+
| `ToAddress` / `FromOrToAddress` / `ChangedObject` / `AffectedObject` | No core equivalent. Use raw [gRPC](/sui/clients/grpc#ledger-service) or [GraphQL](/sui/clients/graphql) queries |
|
|
95
|
+
|
|
96
|
+
### Example: Migrating queryEvents
|
|
97
|
+
|
|
98
|
+
```diff
|
|
99
|
+
- const result = await jsonRpcClient.queryEvents({
|
|
100
|
+
- query: { MoveEventType: '0x2::coin::CoinCreated' },
|
|
101
|
+
- limit: 10,
|
|
102
|
+
- order: 'descending',
|
|
103
|
+
- });
|
|
104
|
+
+ const result = await client.core.listEvents({
|
|
105
|
+
+ filter: { eventType: '0x2::coin::CoinCreated' },
|
|
106
|
+
+ limit: 10,
|
|
107
|
+
+ order: 'descending',
|
|
108
|
+
+ });
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The JSON-RPC `EventFilter` variants map to `sender`, `emitModule` (replaces `MoveModule` /
|
|
112
|
+
`MoveEventModule`), and `eventType` (replaces `MoveEventType`). Each returned event includes its
|
|
113
|
+
ledger position (`checkpoint`, `transactionDigest`, and `eventIndex`).
|
|
61
114
|
|
|
62
115
|
### Example: Migrating devInspectTransactionBlock
|
|
63
116
|
|
|
@@ -95,6 +148,7 @@ These JSON-RPC methods can be replaced by calling gRPC service clients directly:
|
|
|
95
148
|
| JSON-RPC Method | gRPC Service Replacement |
|
|
96
149
|
| ----------------------------------- | ---------------------------------------------------------------- |
|
|
97
150
|
| `getCheckpoint` | `ledgerService.getCheckpoint` |
|
|
151
|
+
| `getCheckpoints` | `ledgerService.listCheckpoints` |
|
|
98
152
|
| `getLatestCheckpointSequenceNumber` | `ledgerService.getServiceInfo` (read `checkpointHeight`) |
|
|
99
153
|
| `getCurrentEpoch` | `ledgerService.getEpoch` (omit `epoch` for the current) |
|
|
100
154
|
| `getLatestSuiSystemState` | `ledgerService.getEpoch` with `system_state` in the read mask |
|
|
@@ -108,10 +162,10 @@ These JSON-RPC methods can be replaced by calling gRPC service clients directly:
|
|
|
108
162
|
| `resolveNameServiceAddress` | `nameService.lookupName` |
|
|
109
163
|
| `resolveNameServiceNames` | `nameService.reverseLookupName` |
|
|
110
164
|
|
|
111
|
-
> **Warning:** `
|
|
112
|
-
> `
|
|
113
|
-
>
|
|
114
|
-
>
|
|
165
|
+
> **Warning:** `getEpochs` (paginated listing) has no gRPC equivalent. Use the `epochs` GraphQL query instead.
|
|
166
|
+
> `getValidatorsApy` also has no replacement: there is no canonical definition of validator APY, so
|
|
167
|
+
> it must be computed client-side from validator exchange rates (see [Validator APY](#validator-apy)
|
|
168
|
+
> below).
|
|
115
169
|
|
|
116
170
|
### Example: using gRPC service clients
|
|
117
171
|
|
|
@@ -167,16 +221,53 @@ const { response: address } = await client.nameService.lookupName({
|
|
|
167
221
|
});
|
|
168
222
|
```
|
|
169
223
|
|
|
224
|
+
## Methods replaced by gRPC subscriptions
|
|
225
|
+
|
|
226
|
+
Replace the deprecated JSON-RPC websocket subscriptions with the gRPC `subscriptionService`, which
|
|
227
|
+
provides filtered, real-time streams:
|
|
228
|
+
|
|
229
|
+
| JSON-RPC Method | gRPC Service Replacement |
|
|
230
|
+
| ---------------------- | ------------------------------------------- |
|
|
231
|
+
| `subscribeTransaction` | `subscriptionService.subscribeTransactions` |
|
|
232
|
+
| `subscribeEvent` | `subscriptionService.subscribeEvents` |
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
const stream = client.subscriptionService.subscribeEvents({
|
|
236
|
+
filter: {
|
|
237
|
+
terms: [
|
|
238
|
+
{
|
|
239
|
+
literals: [
|
|
240
|
+
{
|
|
241
|
+
negated: false,
|
|
242
|
+
predicate: {
|
|
243
|
+
oneofKind: 'eventType',
|
|
244
|
+
eventType: { eventType: '0x2::coin::CoinCreated' },
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
readMask: { paths: ['event_type', 'contents', 'json', 'checkpoint', 'transaction_digest'] },
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
for await (const frame of stream.responses) {
|
|
255
|
+
if (frame.event) {
|
|
256
|
+
console.log(frame.event.eventType, frame.event.json);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Subscriptions always begin at the current tip of the chain. To recover events you missed between
|
|
262
|
+
subscriptions, replay the gap with `client.core.listEvents` using the same filter.
|
|
263
|
+
|
|
170
264
|
## Methods requiring GraphQL
|
|
171
265
|
|
|
172
266
|
Some JSON-RPC methods don't have gRPC equivalents and require using `SuiGraphQLClient` instead:
|
|
173
267
|
|
|
174
268
|
| JSON-RPC Method | GraphQL Alternative |
|
|
175
269
|
| --------------------------- | --------------------------------------------------------- |
|
|
176
|
-
| `queryTransactionBlocks` | `transactions` query |
|
|
177
270
|
| `multiGetTransactionBlocks` | `multiGetTransactionEffects` query |
|
|
178
|
-
| `queryEvents` | `events` query |
|
|
179
|
-
| `getCheckpoints` | `checkpoints` query |
|
|
180
271
|
| `getEpochs` | `epochs` query |
|
|
181
272
|
| `getCoinMetadata` | `coinMetadata` query (or gRPC `stateService.getCoinInfo`) |
|
|
182
273
|
| `getTotalSupply` | `coinMetadata` query (or gRPC `stateService.getCoinInfo`) |
|
|
@@ -197,94 +288,6 @@ const graphqlClient = new SuiGraphQLClient({
|
|
|
197
288
|
});
|
|
198
289
|
```
|
|
199
290
|
|
|
200
|
-
### Querying transactions
|
|
201
|
-
|
|
202
|
-
Replace `queryTransactionBlocks` with a GraphQL query:
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
const result = await graphqlClient.query({
|
|
206
|
-
query: `
|
|
207
|
-
query QueryTransactions($sender: SuiAddress, $first: Int, $after: String) {
|
|
208
|
-
transactions(
|
|
209
|
-
first: $first
|
|
210
|
-
after: $after
|
|
211
|
-
filter: { sentAddress: $sender }
|
|
212
|
-
) {
|
|
213
|
-
pageInfo {
|
|
214
|
-
hasNextPage
|
|
215
|
-
endCursor
|
|
216
|
-
}
|
|
217
|
-
nodes {
|
|
218
|
-
digest
|
|
219
|
-
effects {
|
|
220
|
-
status
|
|
221
|
-
epoch { epochId }
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
`,
|
|
227
|
-
variables: {
|
|
228
|
-
sender: '0xabc...',
|
|
229
|
-
first: 10,
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
**Available transaction filters:**
|
|
235
|
-
|
|
236
|
-
- `sentAddress`: Filter by sender address
|
|
237
|
-
- `affectedAddress`: Filter by any address involved in the transaction
|
|
238
|
-
- `affectedObject`: Filter by object ID that was affected
|
|
239
|
-
- `function`: Filter by Move function called (for example, `0x2::coin::transfer`)
|
|
240
|
-
- `kind`: Filter by transaction kind (`SYSTEM` or `PROGRAMMABLE`)
|
|
241
|
-
- `atCheckpoint` / `beforeCheckpoint` / `afterCheckpoint` - Filter by checkpoint
|
|
242
|
-
|
|
243
|
-
### Querying events
|
|
244
|
-
|
|
245
|
-
Replace `queryEvents` with a GraphQL query:
|
|
246
|
-
|
|
247
|
-
```typescript
|
|
248
|
-
const result = await graphqlClient.query({
|
|
249
|
-
query: `
|
|
250
|
-
query QueryEvents($type: String, $first: Int, $after: String) {
|
|
251
|
-
events(
|
|
252
|
-
first: $first
|
|
253
|
-
after: $after
|
|
254
|
-
filter: { type: $type }
|
|
255
|
-
) {
|
|
256
|
-
pageInfo {
|
|
257
|
-
hasNextPage
|
|
258
|
-
endCursor
|
|
259
|
-
}
|
|
260
|
-
nodes {
|
|
261
|
-
transactionModule {
|
|
262
|
-
package { address }
|
|
263
|
-
name
|
|
264
|
-
}
|
|
265
|
-
sender { address }
|
|
266
|
-
contents {
|
|
267
|
-
type { repr }
|
|
268
|
-
bcs
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
`,
|
|
274
|
-
variables: {
|
|
275
|
-
type: '0x2::coin::CoinCreated',
|
|
276
|
-
first: 10,
|
|
277
|
-
},
|
|
278
|
-
});
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
**Available event filters:**
|
|
282
|
-
|
|
283
|
-
- `type`: Filter by event type (package, package::module, or full type)
|
|
284
|
-
- `module`: Filter by emitting module
|
|
285
|
-
- `sender`: Filter by transaction sender
|
|
286
|
-
- `atCheckpoint` / `beforeCheckpoint` / `afterCheckpoint`: Filter by checkpoint
|
|
287
|
-
|
|
288
291
|
### Fetching multiple transactions
|
|
289
292
|
|
|
290
293
|
Replace `multiGetTransactionBlocks` with a GraphQL query:
|
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
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { TransactionDataBuilder } from '../transactions/TransactionData.js';
|
|
5
|
+
import type { TransactionData } from '../transactions/data/internal.js';
|
|
6
|
+
import type { ClientWithCoreApi } from './core.js';
|
|
7
|
+
|
|
8
|
+
export async function setAddressBalanceTransactionExpirationFromSimulatedEpoch({
|
|
9
|
+
transactionData,
|
|
10
|
+
client,
|
|
11
|
+
epoch,
|
|
12
|
+
originalTransactionData,
|
|
13
|
+
isTransactionKindOnly,
|
|
14
|
+
doGasSelection,
|
|
15
|
+
}: {
|
|
16
|
+
transactionData: TransactionDataBuilder;
|
|
17
|
+
client: ClientWithCoreApi;
|
|
18
|
+
epoch: string | number | bigint | null | undefined;
|
|
19
|
+
originalTransactionData: TransactionData;
|
|
20
|
+
isTransactionKindOnly: boolean;
|
|
21
|
+
doGasSelection: boolean;
|
|
22
|
+
}) {
|
|
23
|
+
if (
|
|
24
|
+
isTransactionKindOnly ||
|
|
25
|
+
doGasSelection ||
|
|
26
|
+
originalTransactionData.expiration ||
|
|
27
|
+
originalTransactionData.gasData.payment?.length !== 0
|
|
28
|
+
) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (transactionData.expiration && transactionData.expiration.$kind !== 'None') {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [{ chainIdentifier }, systemStateResult] = await Promise.all([
|
|
37
|
+
client.core.getChainIdentifier(),
|
|
38
|
+
epoch == null ? client.core.getCurrentSystemState() : null,
|
|
39
|
+
]);
|
|
40
|
+
const currentEpoch = BigInt(epoch ?? systemStateResult!.systemState.epoch);
|
|
41
|
+
|
|
42
|
+
transactionData.expiration = {
|
|
43
|
+
$kind: 'ValidDuring',
|
|
44
|
+
ValidDuring: {
|
|
45
|
+
minEpoch: String(currentEpoch),
|
|
46
|
+
maxEpoch: String(currentEpoch + 1n),
|
|
47
|
+
minTimestamp: null,
|
|
48
|
+
maxTimestamp: null,
|
|
49
|
+
chain: chainIdentifier,
|
|
50
|
+
nonce: (Math.random() * 0x100000000) >>> 0,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -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(
|