@mysten/docs 0.1.43 → 0.1.45
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/dist/dapp-kit/getting-started/react.md +2 -2
- package/dist/dapp-kit/getting-started/vue.md +2 -2
- package/dist/dapp-kit/llms-index.md +4 -4
- package/dist/dapp-kit/react/hooks/use-current-client.md +6 -5
- package/dist/dapp-kit/state.md +2 -2
- package/dist/kiosk/advanced-examples.md +3 -3
- package/dist/kiosk/from-v1.md +9 -9
- package/dist/kiosk/index.md +6 -3
- package/dist/kiosk/kiosk-client/introduction.md +10 -7
- package/dist/kiosk/llms-index.md +4 -4
- package/dist/llms-index.md +25 -25
- package/dist/seal/index.md +3 -0
- package/dist/sui/clients/core.md +31 -10
- package/dist/sui/clients/graphql.md +43 -8
- package/dist/sui/clients/grpc.md +91 -9
- package/dist/sui/clients/index.md +86 -39
- package/dist/sui/clients/json-rpc.md +30 -26
- package/dist/sui/executors.md +28 -13
- package/dist/sui/index.md +1 -1
- package/dist/sui/llms-index.md +17 -17
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +3 -3
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +2 -2
- package/dist/sui/migrations/sui-2.0/index.md +46 -25
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +460 -284
- package/dist/sui/migrations/sui-2.0/kiosk.md +10 -9
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +17 -11
- package/dist/sui/migrations/sui-2.0/sui.md +47 -29
- package/dist/sui/migrations/sui-2.0/suins.md +2 -2
- package/dist/sui/migrations/sui-2.0/walrus.md +3 -3
- package/dist/sui/migrations/sui-2.0/zksend.md +9 -8
- package/dist/sui/sdk-building.md +7 -5
- package/package.json +21 -21
package/dist/sui/clients/grpc.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# SuiGrpcClient
|
|
2
2
|
|
|
3
|
-
> Connect to Sui through gRPC with SuiGrpcClient
|
|
3
|
+
> Connect to Sui through gRPC with the recommended SuiGrpcClient
|
|
4
4
|
|
|
5
|
-
The `SuiGrpcClient` provides access to the Full Node gRPC API.
|
|
5
|
+
The `SuiGrpcClient` provides access to the Full Node gRPC API. It is the recommended default client
|
|
6
|
+
for application code and SDK integrations.
|
|
6
7
|
|
|
7
8
|
For more complete details on what is available through this API see the
|
|
8
9
|
[gRPC API docs](https://docs.sui.io/develop/accessing-data/grpc/what-is-grpc).
|
|
@@ -28,6 +29,74 @@ const grpcClient = new SuiGrpcClient({
|
|
|
28
29
|
});
|
|
29
30
|
```
|
|
30
31
|
|
|
32
|
+
## Using top-level methods
|
|
33
|
+
|
|
34
|
+
Use top-level methods for most application code. These methods match the shared
|
|
35
|
+
[Core API](/sui/clients/core) option and response shapes, so the same calls can also be written as
|
|
36
|
+
`grpcClient.core.<method>()` when SDK code needs the transport-agnostic `ClientWithCoreApi`
|
|
37
|
+
contract.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
|
|
41
|
+
const grpcClient = new SuiGrpcClient({
|
|
42
|
+
network: 'testnet',
|
|
43
|
+
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const { balance } = await grpcClient.getBalance({
|
|
47
|
+
owner: '<OWNER_ADDRESS>',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const { object } = await grpcClient.getObject({
|
|
51
|
+
objectId: '<OBJECT_ID>',
|
|
52
|
+
include: { content: true, display: true },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const coins = await grpcClient.listCoins({
|
|
56
|
+
owner: '<OWNER_ADDRESS>',
|
|
57
|
+
coinType: '0x2::sui::SUI',
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Common top-level methods:
|
|
62
|
+
|
|
63
|
+
| Category | Methods |
|
|
64
|
+
| -------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
65
|
+
| Objects | `getObject`, `getObjects`, `listOwnedObjects`, `listDynamicFields`, `getDynamicField` |
|
|
66
|
+
| Coins | `listCoins`, `getBalance`, `listBalances`, `getCoinMetadata` |
|
|
67
|
+
| Transactions | `getTransaction`, `executeTransaction`, `signAndExecuteTransaction`, `waitForTransaction` |
|
|
68
|
+
| Simulation | `simulateTransaction` |
|
|
69
|
+
| Queries | `listTransactions`, `listEvents` |
|
|
70
|
+
| Move and names | `getMoveFunction`, `resolveNameServiceAddress`, `defaultNameServiceName`, `mvr.resolvePackage`, `mvr.resolveType` |
|
|
71
|
+
| Verification | `verifyZkLoginSignature` |
|
|
72
|
+
|
|
73
|
+
### gRPC-specific top-level data
|
|
74
|
+
|
|
75
|
+
Top-level gRPC methods are a superset of the shared Core API where the transport can expose useful
|
|
76
|
+
gRPC data directly:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const result = await grpcClient.getTransaction({
|
|
80
|
+
digest: '<TRANSACTION_DIGEST>',
|
|
81
|
+
include: {
|
|
82
|
+
effects: true,
|
|
83
|
+
protoJson: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const tx = result.Transaction ?? result.FailedTransaction;
|
|
88
|
+
console.log(tx.digest, result.protoJson);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
gRPC-specific options include:
|
|
92
|
+
|
|
93
|
+
| Option | Methods |
|
|
94
|
+
| -------------------------- | ----------------------------------------------------------------------------------------- |
|
|
95
|
+
| `include.protoJson` | `getTransaction`, `executeTransaction`, `signAndExecuteTransaction`, `waitForTransaction` |
|
|
96
|
+
| `include.protoJson` | `simulateTransaction` |
|
|
97
|
+
| `doGasSelection` | `simulateTransaction` |
|
|
98
|
+
| `include: { value: true }` | `listDynamicFields` |
|
|
99
|
+
|
|
31
100
|
## Transport options
|
|
32
101
|
|
|
33
102
|
By default, `SuiGrpcClient` uses `GrpcWebFetchTransport` from
|
|
@@ -105,9 +174,9 @@ service clients are generated using [protobuf-ts](https://github.com/timostamm/p
|
|
|
105
174
|
provides type-safe gRPC clients for TypeScript. For more details on how to use gRPC with Sui, see
|
|
106
175
|
the [gRPC overview](https://docs.sui.io/develop/accessing-data/grpc/what-is-grpc).
|
|
107
176
|
|
|
108
|
-
###
|
|
177
|
+
### Prefer top-level methods first
|
|
109
178
|
|
|
110
|
-
|
|
179
|
+
For common operations, call the top-level method before reaching for raw service clients:
|
|
111
180
|
|
|
112
181
|
```typescript
|
|
113
182
|
|
|
@@ -115,13 +184,14 @@ const grpcClient = new SuiGrpcClient({
|
|
|
115
184
|
network: 'testnet',
|
|
116
185
|
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
117
186
|
});
|
|
118
|
-
|
|
119
|
-
await grpcClient.
|
|
187
|
+
|
|
188
|
+
await grpcClient.listCoins({
|
|
120
189
|
owner: '<OWNER_ADDRESS>',
|
|
121
190
|
});
|
|
122
191
|
```
|
|
123
192
|
|
|
124
|
-
|
|
193
|
+
Use the generated service clients directly when you need gRPC methods, read masks, streaming
|
|
194
|
+
behavior, or filters that are not exposed by the top-level API.
|
|
125
195
|
|
|
126
196
|
### Transaction execution service
|
|
127
197
|
|
|
@@ -254,8 +324,20 @@ const { response } = await grpcClient.movePackageService.getFunction({
|
|
|
254
324
|
### Name service
|
|
255
325
|
|
|
256
326
|
```typescript
|
|
257
|
-
|
|
258
|
-
|
|
327
|
+
const { address } = await grpcClient.resolveNameServiceAddress({
|
|
328
|
+
name: 'example.sui',
|
|
329
|
+
});
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Use the raw name service when you need the complete gRPC `NameRecord` instead of only its target
|
|
333
|
+
address:
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
const { response } = await grpcClient.nameService.lookupName({
|
|
337
|
+
name: 'example.sui',
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const { response: reverseResponse } = await grpcClient.nameService.reverseLookupName({
|
|
259
341
|
address: '0xabc...',
|
|
260
342
|
});
|
|
261
343
|
```
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
# Sui Clients
|
|
2
2
|
|
|
3
|
-
> Choose and configure
|
|
3
|
+
> Choose and configure SuiGrpcClient, SuiGraphQLClient, and legacy JSON-RPC clients
|
|
4
4
|
|
|
5
5
|
The Sui TypeScript SDK provides multiple client implementations for interacting with the Sui
|
|
6
|
-
network.
|
|
6
|
+
network. For application code, choose one client for your transport and use its top-level methods
|
|
7
|
+
for common reads, writes, and queries. `SuiGrpcClient` is the recommended default.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
- [Core API](/sui/clients/core): A consistent interface across all clients for common operations
|
|
9
|
+
The gRPC and GraphQL clients expose three useful surfaces:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- Top-level methods: the main application API, matching the Core API for common operations
|
|
12
|
+
- [Core API](/sui/clients/core): the shared `client.core` contract used by SDKs and libraries
|
|
13
|
+
- Native API: direct access to transport-specific features when the common methods are not enough
|
|
14
|
+
|
|
15
|
+
The deprecated `SuiJsonRpcClient` also exposes `client.core`, but its top-level methods retain their
|
|
16
|
+
legacy JSON-RPC names and response shapes.
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
| -------------------------------------------------------- | ------------------------------------------------------------------ |
|
|
15
|
-
| [`SuiGrpcClient`](/sui/clients/grpc) (recommended) | [Full Node gRPC](https://docs.sui.io/references/fullnode-protocol) |
|
|
16
|
-
| [`SuiGraphQLClient`](/sui/clients/graphql) | [GraphQL](https://docs.sui.io/references/sui-graphql) |
|
|
17
|
-
| [`SuiJsonRpcClient`](/sui/clients/json-rpc) (deprecated) | [JSON-RPC (deprecated)](https://docs.sui.io/sui-api-ref) |
|
|
18
|
+
## Available clients
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
| Client | Use For |
|
|
21
|
+
| -------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
22
|
+
| [`SuiGrpcClient`](/sui/clients/grpc) (recommended) | Most application and SDK operations, full node data, execution, streams |
|
|
23
|
+
| [`SuiGraphQLClient`](/sui/clients/graphql) | Indexed queries, historical data, or custom GraphQL selection sets |
|
|
24
|
+
| [`SuiJsonRpcClient`](/sui/clients/json-rpc) (deprecated) | Maintaining legacy JSON-RPC code while migrating to gRPC or GraphQL |
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
All active Mysten SDKs are designed to accept clients that implement the Core API. `SuiGrpcClient`
|
|
27
|
+
is the default choice for most apps because it uses the full node gRPC API and has the most complete
|
|
28
|
+
top-level SDK surface. Use `SuiGraphQLClient` when the code needs GraphQL-specific indexed queries
|
|
29
|
+
or a custom query shape. JSON-RPC APIs are deprecated in the Sui TypeScript SDK; migrate legacy
|
|
30
|
+
JSON-RPC code to gRPC or GraphQL.
|
|
26
31
|
|
|
27
32
|
## Quick start
|
|
28
33
|
|
|
@@ -33,25 +38,82 @@ const client = new SuiGrpcClient({
|
|
|
33
38
|
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
34
39
|
});
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
const {
|
|
41
|
+
const { balance } = await client.getBalance({ owner: '0x...' });
|
|
42
|
+
const { object } = await client.getObject({
|
|
43
|
+
objectId: '0x...',
|
|
44
|
+
include: { content: true },
|
|
45
|
+
});
|
|
46
|
+
```
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
## Top-level, core, and native APIs
|
|
49
|
+
|
|
50
|
+
### Top-level methods
|
|
51
|
+
|
|
52
|
+
Use top-level methods when writing app code against `SuiGrpcClient` or `SuiGraphQLClient`. These
|
|
53
|
+
methods use the same option and response shapes as the Core API, and a transport can add narrowly
|
|
54
|
+
scoped fields where it has extra native data. For `SuiJsonRpcClient`, use `client.core` for these
|
|
55
|
+
shapes or migrate its legacy top-level calls to gRPC or GraphQL.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const { objects } = await client.listOwnedObjects({
|
|
59
|
+
owner: '0x...',
|
|
60
|
+
include: { display: true },
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const result = await client.signAndExecuteTransaction({
|
|
64
|
+
transaction,
|
|
65
|
+
signer,
|
|
66
|
+
include: { effects: true, balanceChanges: true },
|
|
67
|
+
});
|
|
41
68
|
```
|
|
42
69
|
|
|
43
|
-
|
|
70
|
+
Common top-level methods include:
|
|
71
|
+
|
|
72
|
+
| Category | Methods |
|
|
73
|
+
| -------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| Objects | `getObject`, `getObjects`, `listOwnedObjects`, `listDynamicFields`, `getDynamicField` |
|
|
75
|
+
| Coins | `listCoins`, `getBalance`, `listBalances`, `getCoinMetadata` |
|
|
76
|
+
| Transactions | `getTransaction`, `executeTransaction`, `signAndExecuteTransaction`, `waitForTransaction` |
|
|
77
|
+
| Simulation | `simulateTransaction` |
|
|
78
|
+
| Queries | `listTransactions`, `listEvents` |
|
|
79
|
+
| Move and names | `getMoveFunction`, `resolveNameServiceAddress`, `defaultNameServiceName`, `mvr.resolvePackage`, `mvr.resolveType` |
|
|
80
|
+
| Verification | `verifyZkLoginSignature` |
|
|
81
|
+
|
|
82
|
+
### Core API
|
|
83
|
+
|
|
84
|
+
Use `client.core` when building SDKs or libraries that accept any client implementing
|
|
85
|
+
`ClientWithCoreApi`. The Core API is the shared contract that `SuiGrpcClient`, `SuiGraphQLClient`,
|
|
86
|
+
and the deprecated `SuiJsonRpcClient` implement.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
|
|
90
|
+
return client.core.getObject({
|
|
91
|
+
objectId,
|
|
92
|
+
include: { content: true },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
```
|
|
44
96
|
|
|
45
97
|
### Native API
|
|
46
98
|
|
|
47
99
|
Each client exposes the full capabilities of its underlying transport. Use the native API when you
|
|
48
|
-
need transport-specific features or want maximum control
|
|
100
|
+
need transport-specific features or want maximum control.
|
|
49
101
|
|
|
50
102
|
```typescript
|
|
51
103
|
|
|
104
|
+
const grpcClient = new SuiGrpcClient({
|
|
105
|
+
network: 'mainnet',
|
|
106
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
107
|
+
});
|
|
108
|
+
|
|
52
109
|
// gRPC - access various service clients to call any gRPC method
|
|
53
110
|
const { response } = await grpcClient.stateService.listOwnedObjects({ owner: '0x...' });
|
|
54
111
|
|
|
112
|
+
const graphqlClient = new SuiGraphQLClient({
|
|
113
|
+
network: 'mainnet',
|
|
114
|
+
url: 'https://graphql.mainnet.sui.io/graphql',
|
|
115
|
+
});
|
|
116
|
+
|
|
55
117
|
// GraphQL - write type-safe custom queries using the graphql function
|
|
56
118
|
const result = await graphqlClient.query({
|
|
57
119
|
query: graphql(`
|
|
@@ -60,25 +122,10 @@ const result = await graphqlClient.query({
|
|
|
60
122
|
}
|
|
61
123
|
`),
|
|
62
124
|
});
|
|
63
|
-
|
|
64
|
-
// JSON-RPC - call any JSON-RPC method
|
|
65
|
-
const coins = await jsonRpcClient.getCoins({ owner: '0x...' });
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Core API
|
|
69
|
-
|
|
70
|
-
All clients also implement the [Core API](/sui/clients/core) through `client.core`. This provides a
|
|
71
|
-
consistent interface for common operations that works identically across all transports:
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
// These methods work the same on any client
|
|
75
|
-
const { object } = await client.core.getObject({ objectId: '0x...' });
|
|
76
|
-
const balance = await client.core.getBalance({ owner: '0x...' });
|
|
77
|
-
await client.core.executeTransaction({ transaction, signatures });
|
|
78
125
|
```
|
|
79
126
|
|
|
80
|
-
|
|
81
|
-
|
|
127
|
+
For legacy JSON-RPC-only code, see the [`SuiJsonRpcClient` page](/sui/clients/json-rpc) and the
|
|
128
|
+
[JSON-RPC migration guide](/sui/migrations/sui-2.0/json-rpc-migration).
|
|
82
129
|
|
|
83
130
|
## Client extensions
|
|
84
131
|
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
# SuiJsonRpcClient
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Maintain legacy JSON-RPC code while migrating to SuiGrpcClient or SuiGraphQLClient
|
|
4
4
|
|
|
5
|
-
> **Warning:**
|
|
6
|
-
>
|
|
7
|
-
>
|
|
5
|
+
> **Warning:** JSON-RPC APIs are deprecated in the Sui TypeScript SDK. Use [`SuiGrpcClient`](/sui/clients/grpc)
|
|
6
|
+
> for most application code, or [`SuiGraphQLClient`](/sui/clients/graphql) for GraphQL-specific
|
|
7
|
+
> indexed queries.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
[
|
|
9
|
+
This page exists for maintaining legacy JSON-RPC code. New code should use
|
|
10
|
+
[`SuiGrpcClient`](/sui/clients/grpc) and its top-level methods by default. See
|
|
11
|
+
[Migrating from JSON-RPC](/sui/migrations/sui-2.0/json-rpc-migration) for replacement examples.
|
|
12
|
+
|
|
13
|
+
The `SuiJsonRpcClient` connects to a Sui network's JSON-RPC server. It also implements the
|
|
14
|
+
[Core API](/sui/clients/core), so SDKs that accept `ClientWithCoreApi` can support it during a
|
|
15
|
+
migration.
|
|
11
16
|
|
|
12
17
|
```typescript
|
|
13
18
|
|
|
@@ -22,9 +27,9 @@ const { object } = await client.core.getObject({ objectId: '0x...' });
|
|
|
22
27
|
|
|
23
28
|
## Connecting to a Sui network
|
|
24
29
|
|
|
25
|
-
To establish a
|
|
26
|
-
the relevant URL to the `url` parameter. The following example establishes a connection to
|
|
27
|
-
and
|
|
30
|
+
To establish a legacy JSON-RPC connection, import `SuiJsonRpcClient` from `@mysten/sui/jsonRpc` and
|
|
31
|
+
pass the relevant URL to the `url` parameter. The following example establishes a connection to
|
|
32
|
+
Devnet and gets all `Coin<coin_type>` objects owned by an address.
|
|
28
33
|
|
|
29
34
|
```typescript
|
|
30
35
|
|
|
@@ -62,6 +67,7 @@ available in the RPC.
|
|
|
62
67
|
|
|
63
68
|
const client = new SuiJsonRpcClient({
|
|
64
69
|
url: 'https://fullnode.devnet.sui.io:443',
|
|
70
|
+
network: 'devnet',
|
|
65
71
|
});
|
|
66
72
|
// asynchronously call suix_getCommitteeInfo
|
|
67
73
|
const committeeInfo = await client.call('suix_getCommitteeInfo', []);
|
|
@@ -72,20 +78,16 @@ For a full list of available RPC methods, see the
|
|
|
72
78
|
|
|
73
79
|
## Customizing the transport
|
|
74
80
|
|
|
75
|
-
The `SuiJsonRpcClient` uses a
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
pass any custom options, such as headers or timeout values.
|
|
81
|
+
The `SuiJsonRpcClient` uses a transport to manage connections to the RPC node. By default it creates
|
|
82
|
+
a `JsonRpcHTTPTransport` for HTTP JSON-RPC requests. You can construct a custom transport instance
|
|
83
|
+
if you need to pass options such as headers or a custom `fetch` implementation.
|
|
79
84
|
|
|
80
85
|
```typescript
|
|
81
86
|
|
|
82
87
|
const client = new SuiJsonRpcClient({
|
|
88
|
+
network: 'devnet',
|
|
83
89
|
transport: new JsonRpcHTTPTransport({
|
|
84
90
|
url: 'https://fullnode.devnet.sui.io:443',
|
|
85
|
-
websocket: {
|
|
86
|
-
reconnectTimeout: 1000,
|
|
87
|
-
url: 'wss://fullnode.devnet.sui.io:443',
|
|
88
|
-
},
|
|
89
91
|
rpc: {
|
|
90
92
|
headers: {
|
|
91
93
|
'x-custom-header': 'custom value',
|
|
@@ -150,8 +152,8 @@ const result = await client.executeTransactionBlock({
|
|
|
150
152
|
|
|
151
153
|
#### Arguments
|
|
152
154
|
|
|
153
|
-
- `transactionBlock`:
|
|
154
|
-
|
|
155
|
+
- `transactionBlock`: BCS serialized transaction data bytes as a `Uint8Array` or base64-encoded
|
|
156
|
+
string.
|
|
155
157
|
- `signature`: A signature, or list of signatures committed to the intent message of the transaction
|
|
156
158
|
data, as a base-64 encoded string.
|
|
157
159
|
- `options`:
|
|
@@ -178,15 +180,14 @@ const result = await client.signAndExecuteTransaction({
|
|
|
178
180
|
});
|
|
179
181
|
|
|
180
182
|
// IMPORTANT: Always check the transaction status
|
|
181
|
-
if (result
|
|
182
|
-
throw new Error(`Transaction failed: ${result.
|
|
183
|
+
if (result.effects?.status.status === 'failure') {
|
|
184
|
+
throw new Error(`Transaction failed: ${result.effects.status.error}`);
|
|
183
185
|
}
|
|
184
186
|
```
|
|
185
187
|
|
|
186
188
|
#### Arguments
|
|
187
189
|
|
|
188
|
-
- `transaction`: BCS serialized transaction data bytes as a Uint8Array
|
|
189
|
-
string.
|
|
190
|
+
- `transaction`: A `Transaction` or BCS serialized transaction data bytes as a `Uint8Array`.
|
|
190
191
|
- `signer`: A `Keypair` instance to sign the transaction
|
|
191
192
|
- `options`:
|
|
192
193
|
- `showBalanceChanges`: Whether to show balance_changes. Default to be False
|
|
@@ -208,15 +209,18 @@ const tx = new Transaction();
|
|
|
208
209
|
const result = await client.signAndExecuteTransaction({
|
|
209
210
|
transaction: tx,
|
|
210
211
|
signer: keypair,
|
|
212
|
+
options: {
|
|
213
|
+
showEffects: true,
|
|
214
|
+
},
|
|
211
215
|
});
|
|
212
216
|
|
|
213
217
|
// Check transaction status
|
|
214
|
-
if (result
|
|
215
|
-
throw new Error(`Transaction failed: ${result.
|
|
218
|
+
if (result.effects?.status.status === 'failure') {
|
|
219
|
+
throw new Error(`Transaction failed: ${result.effects.status.error}`);
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
const transaction = await client.waitForTransaction({
|
|
219
|
-
digest: result.
|
|
223
|
+
digest: result.digest,
|
|
220
224
|
options: {
|
|
221
225
|
showEffects: true,
|
|
222
226
|
},
|
package/dist/sui/executors.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Transaction Executors
|
|
2
2
|
|
|
3
|
-
> Manage transaction execution with queuing and parallel strategies
|
|
3
|
+
> Manage transaction execution with queuing and parallel strategies
|
|
4
4
|
|
|
5
5
|
The TypeScript SDK ships two `Transaction` executor classes that simplify the processes of
|
|
6
6
|
efficiently executing multiple transactions signed by the same address. These executors help manage
|
|
@@ -30,8 +30,8 @@ transactions to finish before sending the next one.
|
|
|
30
30
|
|
|
31
31
|
- `client`: An instance of a Sui client (such as `SuiGrpcClient`) used to execute transactions.
|
|
32
32
|
- `signer`: The signer/keypair used for signed transactions.
|
|
33
|
-
- `
|
|
34
|
-
not specify a budget (default `50_000_000n`).
|
|
33
|
+
- `defaultGasBudget`: The default budget for transactions, which will be used if the transaction
|
|
34
|
+
does not specify a budget (default `50_000_000n`).
|
|
35
35
|
- `gasMode`: Either `'coins'` (default) to use owned coins for gas, or `'addressBalance'` to pay gas
|
|
36
36
|
from the sender's address balance.
|
|
37
37
|
|
|
@@ -54,10 +54,18 @@ const tx2 = new Transaction();
|
|
|
54
54
|
const [coin2] = tx2.splitCoins(tx2.gas, [1]);
|
|
55
55
|
tx2.transferObjects([coin2], address2);
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const results = await Promise.all([
|
|
58
58
|
executor.executeTransaction(tx1),
|
|
59
59
|
executor.executeTransaction(tx2),
|
|
60
60
|
]);
|
|
61
|
+
|
|
62
|
+
const [digest1, digest2] = results.map((result) => {
|
|
63
|
+
if (result.$kind === 'FailedTransaction') {
|
|
64
|
+
throw new Error(`Transaction failed: ${result.FailedTransaction.status.error.message}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return result.Transaction.digest;
|
|
68
|
+
});
|
|
61
69
|
```
|
|
62
70
|
|
|
63
71
|
## `ParallelTransactionExecutor`
|
|
@@ -83,7 +91,7 @@ way that avoids conflicts between transactions using the same object ids.
|
|
|
83
91
|
|
|
84
92
|
`ParallelTransactionExecutor` can be configured with a number of options:
|
|
85
93
|
|
|
86
|
-
- `client`:
|
|
94
|
+
- `client`: A client implementing `ClientWithCoreApi`. `SuiGrpcClient` is the recommended default.
|
|
87
95
|
- `signer`: The signer/keypair used for signed transactions.
|
|
88
96
|
- `gasMode`: Either `'coins'` (default) to use owned coins for gas, or `'addressBalance'` to pay gas
|
|
89
97
|
from the sender's address balance. When using `'addressBalance'`, coin-specific options like
|
|
@@ -94,20 +102,19 @@ way that avoids conflicts between transactions using the same object ids.
|
|
|
94
102
|
`200_000_000n`),
|
|
95
103
|
- `minimumCoinBalance`: After executing a transaction, the gasCoin will be reused unless it's
|
|
96
104
|
balance is below this value (default `50_000_000n`),
|
|
97
|
-
- `
|
|
98
|
-
not specify a budget (default `minimumCoinBalance`),
|
|
105
|
+
- `defaultGasBudget`: The default budget for transactions, which will be used if the transaction
|
|
106
|
+
does not specify a budget (default `minimumCoinBalance`),
|
|
99
107
|
- `maxPoolSize`: The maximum number of gas coins to keep in the gas pool, which also limits the
|
|
100
108
|
maximum number of concurrent transactions (default 50),
|
|
101
109
|
- `sourceCoins`: An array of coins to use to create the gas pool, defaults to using all coins owned
|
|
102
110
|
by the signer.
|
|
103
|
-
- `epochBoundaryWindow`: Time to wait before or after the expected epoch boundary before re-fetching
|
|
104
|
-
the gas pool (in milliseconds). Building transactions will be paused for up to 2x this duration
|
|
105
|
-
around each epoch boundary to ensure the gas price is up-to-date for the next epoch. (default
|
|
106
|
-
`1000`)
|
|
107
111
|
|
|
108
112
|
```ts
|
|
109
113
|
|
|
110
|
-
const client = new
|
|
114
|
+
const client = new SuiGrpcClient({
|
|
115
|
+
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
116
|
+
network: 'devnet',
|
|
117
|
+
});
|
|
111
118
|
|
|
112
119
|
const executor = new ParallelTransactionExecutor({
|
|
113
120
|
client,
|
|
@@ -121,10 +128,18 @@ const tx2 = new Transaction();
|
|
|
121
128
|
const [coin2] = tx2.splitCoins(tx2.gas, [1]);
|
|
122
129
|
tx2.transferObjects([coin2], address2);
|
|
123
130
|
|
|
124
|
-
const
|
|
131
|
+
const results = await Promise.all([
|
|
125
132
|
executor.executeTransaction(tx1),
|
|
126
133
|
executor.executeTransaction(tx2),
|
|
127
134
|
]);
|
|
135
|
+
|
|
136
|
+
const [digest1, digest2] = results.map((result) => {
|
|
137
|
+
if (result.$kind === 'FailedTransaction') {
|
|
138
|
+
throw new Error(`Transaction failed: ${result.FailedTransaction.status.error.message}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return result.Transaction.digest;
|
|
142
|
+
});
|
|
128
143
|
```
|
|
129
144
|
|
|
130
145
|
## Building and executing transactions with executors
|
package/dist/sui/index.md
CHANGED
|
@@ -126,7 +126,7 @@ const grpcClient = new SuiGrpcClient({
|
|
|
126
126
|
baseUrl: 'https://fullnode.devnet.sui.io:443',
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
const { balance } = await grpcClient.
|
|
129
|
+
const { balance } = await grpcClient.getBalance({
|
|
130
130
|
owner: keypair.toSuiAddress(),
|
|
131
131
|
});
|
|
132
132
|
|
package/dist/sui/llms-index.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
- [Sui TypeScript SDK](..md): TypeScript SDK for building on the Sui blockchain
|
|
5
5
|
- [LLM Documentation](./llm-docs.md): Give AI agents access to Sui SDK documentation in your project.
|
|
6
|
-
- [Sui Clients](./clients.md): Choose and configure
|
|
7
|
-
- [Core API](./clients/core.md): Transport-agnostic Core API shared by
|
|
8
|
-
- [SuiGrpcClient](./clients/grpc.md): Connect to Sui through gRPC with SuiGrpcClient
|
|
9
|
-
- [SuiGraphQLClient](./clients/graphql.md): Connect to Sui through GraphQL with SuiGraphQLClient
|
|
10
|
-
- [SuiJsonRpcClient](./clients/json-rpc.md):
|
|
6
|
+
- [Sui Clients](./clients.md): Choose and configure SuiGrpcClient, SuiGraphQLClient, and legacy JSON-RPC clients
|
|
7
|
+
- [Core API](./clients/core.md): Transport-agnostic Core API shared by Sui clients
|
|
8
|
+
- [SuiGrpcClient](./clients/grpc.md): Connect to Sui through gRPC with the recommended SuiGrpcClient
|
|
9
|
+
- [SuiGraphQLClient](./clients/graphql.md): Connect to Sui through GraphQL with SuiGraphQLClient
|
|
10
|
+
- [SuiJsonRpcClient](./clients/json-rpc.md): Maintain legacy JSON-RPC code while migrating to SuiGrpcClient or SuiGraphQLClient
|
|
11
11
|
- [Building Transactions](./transactions/basics.md): Construct programmable transaction blocks with the Transaction API
|
|
12
12
|
- [Signing and Execution](./transactions/signing-and-execution.md): Sign transactions and execute them on the Sui network
|
|
13
13
|
- [Coins and Balances](./transactions/coins-and-balances.md): Work with coin objects and address balances in transactions
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
- [Derived Objects](./utils/derived_objects.md): Compute derived object IDs from parent objects for deterministic offline derivation.
|
|
27
27
|
- [BCS](./bcs.md): Binary Canonical Serialization for encoding Sui Move types.
|
|
28
28
|
- [ZkLogin](./zklogin.md): Zero-knowledge authentication with OAuth providers on Sui.
|
|
29
|
-
- [Transaction Executors](./executors.md): Manage transaction execution with queuing and parallel strategies
|
|
29
|
+
- [Transaction Executors](./executors.md): Manage transaction execution with queuing and parallel strategies
|
|
30
30
|
- [Transaction Plugins](./plugins.md): Extend transaction building with reusable plugins.
|
|
31
|
-
- [Building SDKs](./sdk-building.md): Build custom SDKs on top of the Sui TypeScript SDK
|
|
32
|
-
- [Migrate to 2.0](./migrations/sui-2.0.md): Migration guide for Sui TypeScript SDK 2.0 covering all @mysten packages
|
|
31
|
+
- [Building SDKs](./sdk-building.md): Build custom SDKs on top of the Sui TypeScript SDK
|
|
32
|
+
- [Migrate to 2.0](./migrations/sui-2.0.md): Migration guide for Sui TypeScript SDK 2.0 covering all @mysten packages
|
|
33
33
|
- [Agent Migration Prompt](./migrations/sui-2.0/agent-prompt.md): AI agent prompt for automated SDK 2.0 migration of your codebase.
|
|
34
|
-
- [@mysten/sui](./migrations/sui-2.0/sui.md): Migrate @mysten/sui from 1.x to 2.0 with
|
|
35
|
-
- [Migrating from JSON-RPC](./migrations/sui-2.0/json-rpc-migration.md): Migrate
|
|
36
|
-
- [@mysten/dapp-kit](./migrations/sui-2.0/dapp-kit.md): Migrate @mysten/dapp-kit to the new dapp-kit-react package in 2.0
|
|
37
|
-
- [@mysten/kiosk](./migrations/sui-2.0/kiosk.md): Migrate @mysten/kiosk to 2.0 with client extension pattern and KioskTransaction
|
|
38
|
-
- [@mysten/zksend](./migrations/sui-2.0/zksend.md): Migrate @mysten/zksend to 2.0 with client extension pattern and simplified API
|
|
39
|
-
- [@mysten/suins](./migrations/sui-2.0/suins.md): Migrate @mysten/suins to 2.0 with client extension pattern
|
|
40
|
-
- [@mysten/deepbook-v3](./migrations/sui-2.0/deepbook-v3.md): Migrate @mysten/deepbook-v3 to 2.0 with client extension pattern
|
|
41
|
-
- [@mysten/walrus](./migrations/sui-2.0/walrus.md): Migrate @mysten/walrus to 2.0 with required client parameter and updated API
|
|
34
|
+
- [@mysten/sui](./migrations/sui-2.0/sui.md): Migrate @mysten/sui from 1.x to 2.0 with gRPC clients, Core API, and BCS changes
|
|
35
|
+
- [Migrating from JSON-RPC](./migrations/sui-2.0/json-rpc-migration.md): Migrate deprecated JSON-RPC code to shared gRPC and GraphQL top-level methods
|
|
36
|
+
- [@mysten/dapp-kit](./migrations/sui-2.0/dapp-kit.md): Migrate @mysten/dapp-kit to the new dapp-kit-react package in 2.0
|
|
37
|
+
- [@mysten/kiosk](./migrations/sui-2.0/kiosk.md): Migrate @mysten/kiosk to 2.0 with client extension pattern and KioskTransaction
|
|
38
|
+
- [@mysten/zksend](./migrations/sui-2.0/zksend.md): Migrate @mysten/zksend to 2.0 with client extension pattern and simplified API
|
|
39
|
+
- [@mysten/suins](./migrations/sui-2.0/suins.md): Migrate @mysten/suins to 2.0 with client extension pattern
|
|
40
|
+
- [@mysten/deepbook-v3](./migrations/sui-2.0/deepbook-v3.md): Migrate @mysten/deepbook-v3 to 2.0 with client extension pattern
|
|
41
|
+
- [@mysten/walrus](./migrations/sui-2.0/walrus.md): Migrate @mysten/walrus to 2.0 with required client parameter and updated API
|
|
42
42
|
- [@mysten/seal](./migrations/sui-2.0/seal.md): Migrate @mysten/seal to 2.0 with the new registration function pattern.
|
|
43
43
|
- [Wallet Builders](./migrations/sui-2.0/wallet-builders.md): Migration guide for wallet extension developers upgrading to 2.0.
|
|
44
|
-
- [SDK Maintainers](./migrations/sui-2.0/sdk-maintainers.md): Migration guide for SDK maintainers and library authors upgrading to 2.0
|
|
44
|
+
- [SDK Maintainers](./migrations/sui-2.0/sdk-maintainers.md): Migration guide for SDK maintainers and library authors upgrading to 2.0
|
|
45
45
|
- [Migrate to 1.0](./migrations/sui-1.0.md): Migrate to Sui TypeScript SDK 1.0 with new features and API changes.
|
|
46
46
|
- [Migrate to 0.38.0](./migrations/0.38.md): Migrate from SDK version 0.37 to 0.38 with updated module structure and API changes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mysten/dapp-kit
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/dapp-kit to the new dapp-kit-react package in 2.0
|
|
3
|
+
> Migrate @mysten/dapp-kit to the new dapp-kit-react package in 2.0
|
|
4
4
|
|
|
5
5
|
This guide helps you migrate from the original `@mysten/dapp-kit` (legacy) to the new
|
|
6
6
|
`@mysten/dapp-kit-react` package.
|
|
@@ -271,7 +271,7 @@ The built-in data fetching hooks have been removed. Use TanStack Query's `useQue
|
|
|
271
271
|
- });
|
|
272
272
|
+ const { data, isLoading, error } = useQuery({
|
|
273
273
|
+ queryKey: ['object', objectId],
|
|
274
|
-
+ queryFn: () => client.
|
|
274
|
+
+ queryFn: () => client.getObject({ objectId }),
|
|
275
275
|
+ });
|
|
276
276
|
// ...
|
|
277
277
|
}
|
|
@@ -289,7 +289,7 @@ If you don't need React Query's caching and state management, you can fetch data
|
|
|
289
289
|
const [error, setError] = useState<string | null>(null);
|
|
290
290
|
|
|
291
291
|
useEffect(() => {
|
|
292
|
-
client
|
|
292
|
+
client
|
|
293
293
|
.getObject({ objectId })
|
|
294
294
|
.then((result) => setData(result.object ?? null))
|
|
295
295
|
.catch((err) => setError(err.message))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# @mysten/deepbook-v3
|
|
2
2
|
|
|
3
|
-
> Migrate @mysten/deepbook-v3 to 2.0 with client extension pattern
|
|
3
|
+
> Migrate @mysten/deepbook-v3 to 2.0 with client extension pattern
|
|
4
4
|
|
|
5
5
|
This package now exports a client extension that integrates with Sui clients.
|
|
6
6
|
|
|
7
7
|
```diff
|
|
8
8
|
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
9
9
|
- import { DeepBookClient } from '@mysten/deepbook-v3';
|
|
10
|
-
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
10
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
11
11
|
+ import { deepbook } from '@mysten/deepbook-v3';
|
|
12
12
|
|
|
13
13
|
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
|