@mysten/sui 2.24.0 → 2.26.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/bcs/bcs.d.mts +6 -6
  3. package/dist/client/core.d.mts.map +1 -1
  4. package/dist/client/core.mjs +4 -1
  5. package/dist/client/core.mjs.map +1 -1
  6. package/dist/client/errors.d.mts +31 -2
  7. package/dist/client/errors.d.mts.map +1 -1
  8. package/dist/client/errors.mjs +15 -13
  9. package/dist/client/errors.mjs.map +1 -1
  10. package/dist/client/index.d.mts +2 -2
  11. package/dist/client/index.mjs +2 -2
  12. package/dist/client/mvr.d.mts.map +1 -1
  13. package/dist/client/mvr.mjs +1 -0
  14. package/dist/client/mvr.mjs.map +1 -1
  15. package/dist/cryptography/signature.d.mts +6 -6
  16. package/dist/graphql/client.d.mts +5 -1
  17. package/dist/graphql/client.d.mts.map +1 -1
  18. package/dist/graphql/client.mjs +15 -2
  19. package/dist/graphql/client.mjs.map +1 -1
  20. package/dist/graphql/core.d.mts +4 -4
  21. package/dist/graphql/core.d.mts.map +1 -1
  22. package/dist/graphql/core.mjs +61 -18
  23. package/dist/graphql/core.mjs.map +1 -1
  24. package/dist/graphql/generated/tada-env.d.mts +16 -0
  25. package/dist/grpc/client.d.mts +5 -1
  26. package/dist/grpc/client.d.mts.map +1 -1
  27. package/dist/grpc/client.mjs +14 -2
  28. package/dist/grpc/client.mjs.map +1 -1
  29. package/dist/grpc/core.d.mts.map +1 -1
  30. package/dist/grpc/core.mjs +29 -12
  31. package/dist/grpc/core.mjs.map +1 -1
  32. package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
  33. package/dist/grpc/proto/sui/rpc/v2/name_service.client.d.mts +4 -4
  34. package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
  35. package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
  36. package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
  37. package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  38. package/dist/jsonRpc/client.d.mts.map +1 -1
  39. package/dist/jsonRpc/client.mjs +60 -15
  40. package/dist/jsonRpc/client.mjs.map +1 -1
  41. package/dist/jsonRpc/core.d.mts +1 -1
  42. package/dist/jsonRpc/core.d.mts.map +1 -1
  43. package/dist/jsonRpc/core.mjs +73 -22
  44. package/dist/jsonRpc/core.mjs.map +1 -1
  45. package/dist/transactions/Transaction.d.mts +6 -6
  46. package/dist/transactions/data/v1.d.mts +220 -220
  47. package/dist/transactions/data/v1.d.mts.map +1 -1
  48. package/dist/transactions/data/v2.d.mts +16 -16
  49. package/dist/transactions/data/v2.d.mts.map +1 -1
  50. package/dist/version.mjs +1 -1
  51. package/dist/version.mjs.map +1 -1
  52. package/dist/zklogin/bcs.d.mts +14 -14
  53. package/docs/bcs.md +2 -2
  54. package/docs/clients/core.md +150 -710
  55. package/docs/clients/executing.md +113 -0
  56. package/docs/clients/graphql.md +80 -70
  57. package/docs/clients/grpc.md +223 -208
  58. package/docs/clients/index.md +56 -67
  59. package/docs/clients/querying.md +539 -0
  60. package/docs/llms-index.md +6 -5
  61. package/docs/migrations/sui-2.0/json-rpc-migration.md +3 -1
  62. package/docs/transactions/signing-and-execution.md +8 -28
  63. package/package.json +1 -1
  64. package/src/client/core.ts +1 -0
  65. package/src/client/errors.ts +39 -23
  66. package/src/client/index.ts +9 -1
  67. package/src/client/mvr.ts +6 -0
  68. package/src/graphql/client.ts +29 -2
  69. package/src/graphql/core.ts +53 -16
  70. package/src/graphql/generated/schema.graphql +11 -1
  71. package/src/graphql/generated/tada-env.ts +20 -0
  72. package/src/grpc/client.ts +28 -2
  73. package/src/grpc/core.ts +90 -65
  74. package/src/jsonRpc/client.ts +15 -0
  75. package/src/jsonRpc/core.ts +102 -24
  76. package/src/version.ts +1 -1
  77. package/docs/clients/json-rpc.md +0 -243
@@ -1,33 +1,22 @@
1
1
  # Sui Clients
2
2
 
3
- > Choose and configure SuiGrpcClient, SuiGraphQLClient, and legacy JSON-RPC clients
3
+ > Choose between SuiGrpcClient and SuiGraphQLClient and understand their shared API
4
4
 
5
- The Sui TypeScript SDK provides multiple client implementations for interacting with the Sui
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.
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
- The gRPC and GraphQL clients expose three useful surfaces:
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
- - 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
+ 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
- The deprecated `SuiJsonRpcClient` also exposes `client.core`, but its top-level methods retain their
16
- legacy JSON-RPC names and response shapes.
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
- ## Top-level, core, and native APIs
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
- 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.
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
- Common top-level methods include:
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
- | 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` |
74
+ ### `client.core`
81
75
 
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.
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
- ### Native API
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
- const grpcClient = new SuiGrpcClient({
105
- network: 'mainnet',
106
- baseUrl: 'https://fullnode.mainnet.sui.io:443',
107
- });
91
+ ### Native APIs
108
92
 
109
- // gRPC - access various service clients to call any gRPC method
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
- const graphqlClient = new SuiGraphQLClient({
113
- network: 'mainnet',
114
- url: 'https://graphql.mainnet.sui.io/graphql',
115
- });
95
+ ```typescript
96
+ // gRPC: generated service clients, read masks, and streams
97
+ const { response } = await grpcClient.ledgerService.getServiceInfo({});
116
98
 
117
- // GraphQL - write type-safe custom queries using the graphql function
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
- 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).
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
- All clients support extensions through the `$extend` method, enabling SDKs like
133
- [@mysten/walrus](https://www.npmjs.com/package/@mysten/walrus) to add functionality:
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 more on creating client extensions.
131
+ See [Building SDKs](/sui/sdk-building) for creating your own.