@mysten/sui 2.23.1 → 2.24.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 +16 -0
- package/README.md +9 -9
- package/dist/bcs/index.d.mts +36 -36
- package/dist/client/core.d.mts +1 -0
- package/dist/client/core.d.mts.map +1 -1
- package/dist/client/core.mjs.map +1 -1
- package/dist/client/types.d.mts +7 -0
- package/dist/client/types.d.mts.map +1 -1
- package/dist/cryptography/signature.d.mts +6 -6
- package/dist/graphql/client.d.mts +1 -0
- package/dist/graphql/client.d.mts.map +1 -1
- package/dist/graphql/client.mjs +3 -0
- package/dist/graphql/client.mjs.map +1 -1
- package/dist/graphql/core.d.mts +1 -0
- package/dist/graphql/core.d.mts.map +1 -1
- package/dist/graphql/core.mjs +10 -1
- package/dist/graphql/core.mjs.map +1 -1
- package/dist/graphql/generated/queries.d.mts.map +1 -1
- package/dist/graphql/generated/queries.mjs +8 -1
- package/dist/graphql/generated/queries.mjs.map +1 -1
- package/dist/grpc/client.d.mts +1 -0
- package/dist/grpc/client.d.mts.map +1 -1
- package/dist/grpc/client.mjs +3 -0
- package/dist/grpc/client.mjs.map +1 -1
- package/dist/grpc/core.d.mts +1 -0
- package/dist/grpc/core.d.mts.map +1 -1
- package/dist/grpc/core.mjs +32 -12
- package/dist/grpc/core.mjs.map +1 -1
- package/dist/grpc/proto/sui/rpc/v2/ledger_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/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/core.d.mts +6 -0
- package/dist/jsonRpc/core.d.mts.map +1 -1
- package/dist/jsonRpc/core.mjs +15 -4
- 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/docs/clients/core.md +31 -10
- package/docs/clients/graphql.md +43 -8
- package/docs/clients/grpc.md +91 -9
- package/docs/clients/index.md +86 -39
- package/docs/clients/json-rpc.md +30 -26
- package/docs/executors.md +28 -13
- package/docs/index.md +1 -1
- package/docs/llms-index.md +17 -17
- package/docs/migrations/sui-2.0/dapp-kit.md +3 -3
- package/docs/migrations/sui-2.0/deepbook-v3.md +2 -2
- package/docs/migrations/sui-2.0/index.md +46 -25
- package/docs/migrations/sui-2.0/json-rpc-migration.md +460 -284
- package/docs/migrations/sui-2.0/kiosk.md +10 -9
- package/docs/migrations/sui-2.0/sdk-maintainers.md +17 -11
- package/docs/migrations/sui-2.0/sui.md +47 -29
- package/docs/migrations/sui-2.0/suins.md +2 -2
- package/docs/migrations/sui-2.0/walrus.md +3 -3
- package/docs/migrations/sui-2.0/zksend.md +9 -8
- package/docs/sdk-building.md +7 -5
- package/package.json +1 -1
- package/src/client/core.ts +4 -0
- package/src/client/types.ts +11 -0
- package/src/graphql/client.ts +6 -0
- package/src/graphql/core.ts +15 -0
- package/src/graphql/generated/queries.ts +14 -0
- package/src/graphql/queries/nameService.graphql +6 -0
- package/src/grpc/client.ts +6 -0
- package/src/grpc/core.ts +51 -12
- package/src/jsonRpc/core.ts +50 -14
- package/src/version.ts +1 -1
package/docs/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/docs/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/docs/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') });
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Migrate to 2.0
|
|
2
2
|
|
|
3
|
-
> Migration guide for Sui TypeScript SDK 2.0 covering all @mysten packages
|
|
3
|
+
> Migration guide for Sui TypeScript SDK 2.0 covering all @mysten packages
|
|
4
4
|
|
|
5
5
|
This guide covers the breaking changes across the latest release of all the `@mysten/*` packages.
|
|
6
6
|
|
|
7
|
-
The primary goal of this release is to support the
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
The primary goal of this release is to support the gRPC and GraphQL APIs across all Mysten SDKs.
|
|
8
|
+
These releases also include removals of deprecated APIs, some renaming for better consistency, and
|
|
9
|
+
significant internal refactoring to improve maintainability. Starting with this release, Mysten
|
|
10
10
|
packages will now be published as ESM only packages.
|
|
11
11
|
|
|
12
12
|
## Quick reference
|
|
@@ -65,39 +65,51 @@ updates.
|
|
|
65
65
|
|
|
66
66
|
### Client migration
|
|
67
67
|
|
|
68
|
-
The
|
|
68
|
+
The recommended app migration is to create one `SuiGrpcClient` and use its top-level methods:
|
|
69
69
|
|
|
70
70
|
```diff
|
|
71
71
|
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
72
|
-
+ import {
|
|
72
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
73
73
|
|
|
74
74
|
- const client = new SuiClient({ url: getFullnodeUrl('mainnet') });
|
|
75
|
-
+ const client = new
|
|
76
|
-
+
|
|
75
|
+
+ const client = new SuiGrpcClient({
|
|
76
|
+
+ baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
77
77
|
+ network: 'mainnet',
|
|
78
78
|
+ });
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
Then migrate old JSON-RPC method names to the gRPC top-level methods:
|
|
82
82
|
|
|
83
83
|
```diff
|
|
84
|
-
-
|
|
85
|
-
+
|
|
84
|
+
- const coins = await client.getCoins({ owner });
|
|
85
|
+
+ const coins = await client.listCoins({ owner });
|
|
86
|
+
|
|
87
|
+
- const txs = await client.queryTransactionBlocks({ filter, options });
|
|
88
|
+
+ const txs = await client.listTransactions({ filter, include });
|
|
89
|
+
|
|
90
|
+
- const events = await client.queryEvents({ query, order: 'descending' });
|
|
91
|
+
+ const events = await client.listEvents({ filter, order: 'descending' });
|
|
86
92
|
|
|
87
|
-
- const
|
|
88
|
-
+ const
|
|
93
|
+
- const transaction = await client.getTransactionBlock({ digest, options });
|
|
94
|
+
+ const transaction = await client.getTransaction({ digest, include });
|
|
89
95
|
```
|
|
90
96
|
|
|
91
|
-
The gRPC runs on full nodes so in most cases you
|
|
92
|
-
to gRPC.
|
|
97
|
+
The gRPC API runs on full nodes, so in most cases you can use the same full node host when migrating
|
|
98
|
+
from JSON-RPC to gRPC. Standard transaction and event queries are top-level methods on both
|
|
99
|
+
`SuiGrpcClient` and `SuiGraphQLClient`. Use custom GraphQL queries for indexed data, historical
|
|
100
|
+
object versions, or selection sets that are not covered by the shared methods.
|
|
101
|
+
|
|
102
|
+
`SuiJsonRpcClient` still exists under `@mysten/sui/jsonRpc` for legacy code, but JSON-RPC APIs are
|
|
103
|
+
deprecated in the Sui TypeScript SDK. See
|
|
104
|
+
[Migrating from JSON-RPC](/sui/migrations/sui-2.0/json-rpc-migration) for detailed replacements.
|
|
93
105
|
|
|
94
106
|
### Network parameter required
|
|
95
107
|
|
|
96
108
|
All client constructors now require an explicit `network` parameter:
|
|
97
109
|
|
|
98
110
|
```ts
|
|
99
|
-
const
|
|
100
|
-
|
|
111
|
+
const grpcClient = new SuiGrpcClient({
|
|
112
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
101
113
|
network: 'mainnet', // Required
|
|
102
114
|
});
|
|
103
115
|
|
|
@@ -106,23 +118,32 @@ const graphqlClient = new SuiGraphQLClient({
|
|
|
106
118
|
network: 'mainnet', // Required
|
|
107
119
|
});
|
|
108
120
|
|
|
109
|
-
const
|
|
110
|
-
|
|
121
|
+
const jsonRpcClient = new SuiJsonRpcClient({
|
|
122
|
+
url: 'https://fullnode.mainnet.sui.io:443',
|
|
111
123
|
network: 'mainnet', // Required
|
|
112
124
|
});
|
|
113
125
|
```
|
|
114
126
|
|
|
115
127
|
### `ClientWithCoreApi` Interface
|
|
116
128
|
|
|
117
|
-
Many SDK methods now accept any client implementing `ClientWithCoreApi
|
|
118
|
-
|
|
129
|
+
Many SDK methods now accept any client implementing `ClientWithCoreApi`. SDKs use
|
|
130
|
+
`client.core.<method>()` so they can work across `SuiGrpcClient`, `SuiGraphQLClient`, and the
|
|
131
|
+
deprecated `SuiJsonRpcClient` while apps keep using the top-level methods on their chosen client:
|
|
119
132
|
|
|
120
133
|
```ts
|
|
121
134
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
const client = new SuiGrpcClient({
|
|
136
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
137
|
+
network: 'mainnet',
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// App code: use top-level methods.
|
|
141
|
+
const { balance } = await client.getBalance({ owner });
|
|
142
|
+
|
|
143
|
+
// SDK code: accept ClientWithCoreApi and use client.core.
|
|
144
|
+
async function readForSdk(client: ClientWithCoreApi, objectId: string) {
|
|
145
|
+
return client.core.getObject({ objectId });
|
|
146
|
+
}
|
|
126
147
|
```
|
|
127
148
|
|
|
128
149
|
## Package-specific guides
|