@mysten/sui 2.24.0 → 2.25.0
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 +60 -0
- package/dist/bcs/bcs.d.mts +6 -6
- package/dist/bcs/index.d.mts +36 -36
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs +4 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/mvr.d.mts.map +1 -1
- package/dist/client/mvr.mjs +1 -0
- package/dist/client/mvr.mjs.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +5 -1
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +15 -2
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +4 -4
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +50 -13
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/tada-env.d.mts +16 -0
- package/dist/grpc/client.d.mts +5 -1
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +14 -2
- package/dist/grpc/client.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/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 +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/jsonRpc/client.d.mts.map +1 -1
- package/dist/jsonRpc/client.mjs +60 -15
- package/dist/jsonRpc/client.mjs.map +1 -1
- package/dist/jsonRpc/core.d.mts +1 -1
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +18 -7
- package/dist/jsonRpc/core.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +3 -3
- package/dist/transactions/data/v1.d.mts +220 -220
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.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/docs/bcs.md +2 -2
- package/docs/clients/core.md +150 -710
- package/docs/clients/executing.md +113 -0
- package/docs/clients/graphql.md +80 -70
- package/docs/clients/grpc.md +223 -208
- package/docs/clients/index.md +56 -67
- package/docs/clients/querying.md +539 -0
- package/docs/llms-index.md +6 -5
- package/docs/migrations/sui-2.0/json-rpc-migration.md +3 -1
- package/docs/transactions/signing-and-execution.md +8 -28
- package/package.json +1 -1
- package/src/client/core.ts +1 -0
- package/src/client/mvr.ts +6 -0
- package/src/graphql/client.ts +29 -2
- package/src/graphql/core.ts +42 -10
- package/src/graphql/generated/schema.graphql +11 -1
- package/src/graphql/generated/tada-env.ts +20 -0
- package/src/grpc/client.ts +28 -2
- package/src/jsonRpc/client.ts +15 -0
- package/src/jsonRpc/core.ts +19 -6
- package/src/version.ts +1 -1
- package/docs/clients/json-rpc.md +0 -243
package/docs/clients/index.md
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
# Sui Clients
|
|
2
2
|
|
|
3
|
-
> Choose
|
|
3
|
+
> Choose between SuiGrpcClient and SuiGraphQLClient and understand their shared API
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
A client is how your code reads from and writes to the Sui network. There are two to choose from,
|
|
6
|
+
and they implement the same API (the same method names, options, and response shapes), so the choice
|
|
7
|
+
is about which transport suits your application, not about which features you get.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Client | Choose it for |
|
|
10
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------- |
|
|
11
|
+
| [`SuiGrpcClient`](/sui/clients/grpc) | The default. Reads from a full node, and the only client with real-time subscriptions |
|
|
12
|
+
| [`SuiGraphQLClient`](/sui/clients/graphql) | Reads from the indexer, and custom queries written against the GraphQL schema |
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
Both are fully supported primary choices. Pick `SuiGrpcClient` if you have no particular reason to
|
|
15
|
+
prefer one, and `SuiGraphQLClient` when your application wants to query the GraphQL schema directly.
|
|
16
|
+
Because they share an API, moving between them is mostly a matter of changing the constructor.
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Available clients
|
|
19
|
-
|
|
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 |
|
|
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.
|
|
18
|
+
> **Note:** JSON-RPC is deprecated. See the [migration guide](/sui/migrations/sui-2.0/json-rpc-migration) if
|
|
19
|
+
> you maintain existing JSON-RPC code.
|
|
31
20
|
|
|
32
21
|
## Quick start
|
|
33
22
|
|
|
@@ -39,20 +28,31 @@ const client = new SuiGrpcClient({
|
|
|
39
28
|
});
|
|
40
29
|
|
|
41
30
|
const { balance } = await client.getBalance({ owner: '0x...' });
|
|
31
|
+
|
|
42
32
|
const { object } = await client.getObject({
|
|
43
33
|
objectId: '0x...',
|
|
44
34
|
include: { content: true },
|
|
45
35
|
});
|
|
46
36
|
```
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
The same code against GraphQL differs only in how the client is created:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
|
|
42
|
+
const client = new SuiGraphQLClient({
|
|
43
|
+
network: 'mainnet',
|
|
44
|
+
url: 'https://graphql.mainnet.sui.io/graphql',
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Three ways to call a client
|
|
49
|
+
|
|
50
|
+
Each client exposes the same functionality through three surfaces, aimed at different callers.
|
|
49
51
|
|
|
50
52
|
### Top-level methods
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
methods
|
|
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.
|
|
54
|
+
The main API for application code. Read data, execute transactions, and query history by calling
|
|
55
|
+
methods directly on the client:
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
58
|
const { objects } = await client.listOwnedObjects({
|
|
@@ -67,23 +67,14 @@ const result = await client.signAndExecuteTransaction({
|
|
|
67
67
|
});
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
These are documented in [Querying data](/sui/clients/querying) and
|
|
71
|
+
[Signing and execution](/sui/transactions/signing-and-execution). Where a transport can return more
|
|
72
|
+
than the shared shape carries, it adds options here, such as `include: { protoJson: true }` on gRPC.
|
|
71
73
|
|
|
72
|
-
|
|
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` |
|
|
74
|
+
### `client.core`
|
|
81
75
|
|
|
82
|
-
|
|
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.
|
|
76
|
+
The transport-agnostic contract, for libraries that must work with whichever client their caller
|
|
77
|
+
supplies:
|
|
87
78
|
|
|
88
79
|
```typescript
|
|
89
80
|
|
|
@@ -94,27 +85,18 @@ and the deprecated `SuiJsonRpcClient` implement.
|
|
|
94
85
|
}
|
|
95
86
|
```
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Each client exposes the full capabilities of its underlying transport. Use the native API when you
|
|
100
|
-
need transport-specific features or want maximum control.
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
88
|
+
See the [Core API](/sui/clients/core) for the contract and the cross-transport differences to
|
|
89
|
+
account for. Application code does not need this. Call the top-level methods instead.
|
|
103
90
|
|
|
104
|
-
|
|
105
|
-
network: 'mainnet',
|
|
106
|
-
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
107
|
-
});
|
|
91
|
+
### Native APIs
|
|
108
92
|
|
|
109
|
-
|
|
110
|
-
const { response } = await grpcClient.stateService.listOwnedObjects({ owner: '0x...' });
|
|
93
|
+
Each client also exposes its transport in full, for the cases the shared API does not cover:
|
|
111
94
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
95
|
+
```typescript
|
|
96
|
+
// gRPC: generated service clients, read masks, and streams
|
|
97
|
+
const { response } = await grpcClient.ledgerService.getServiceInfo({});
|
|
116
98
|
|
|
117
|
-
// GraphQL
|
|
99
|
+
// GraphQL: type-safe custom queries
|
|
118
100
|
const result = await graphqlClient.query({
|
|
119
101
|
query: graphql(`
|
|
120
102
|
query {
|
|
@@ -124,19 +106,26 @@ const result = await graphqlClient.query({
|
|
|
124
106
|
});
|
|
125
107
|
```
|
|
126
108
|
|
|
127
|
-
|
|
128
|
-
[
|
|
109
|
+
gRPC adds [raw list RPCs](/sui/clients/grpc#using-service-clients) and
|
|
110
|
+
[subscriptions](/sui/clients/grpc#subscriptions); GraphQL adds
|
|
111
|
+
[custom queries](/sui/clients/graphql#writing-queries) against the schema.
|
|
129
112
|
|
|
130
113
|
## Client extensions
|
|
131
114
|
|
|
132
|
-
|
|
133
|
-
[@mysten/walrus](https://www.npmjs.com/package/@mysten/walrus) to
|
|
115
|
+
Both clients support extensions through `$extend`, which lets SDKs such as
|
|
116
|
+
[@mysten/walrus](https://www.npmjs.com/package/@mysten/walrus) add functionality to a client your
|
|
117
|
+
application already configured:
|
|
134
118
|
|
|
135
119
|
```typescript
|
|
136
120
|
|
|
137
121
|
const client = new SuiGrpcClient({ network: 'mainnet', baseUrl: '...' }).$extend(walrus());
|
|
138
122
|
|
|
139
|
-
await client.walrus.writeBlob({
|
|
123
|
+
const { blobId } = await client.walrus.writeBlob({
|
|
124
|
+
blob: file,
|
|
125
|
+
deletable: false,
|
|
126
|
+
epochs: 3,
|
|
127
|
+
signer: keypair,
|
|
128
|
+
});
|
|
140
129
|
```
|
|
141
130
|
|
|
142
|
-
See [Building SDKs](/sui/sdk-building) for
|
|
131
|
+
See [Building SDKs](/sui/sdk-building) for creating your own.
|