@mysten/docs 0.1.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/README.md +24 -0
- package/dist/bcs/index.md +358 -0
- package/dist/bcs/llms-index.md +4 -0
- package/dist/codegen/index.md +441 -0
- package/dist/codegen/llms-index.md +4 -0
- package/dist/dapp-kit/actions/connect-wallet.md +69 -0
- package/dist/dapp-kit/actions/disconnect-wallet.md +38 -0
- package/dist/dapp-kit/actions/sign-and-execute-transaction.md +96 -0
- package/dist/dapp-kit/actions/sign-personal-message.md +58 -0
- package/dist/dapp-kit/actions/sign-transaction.md +65 -0
- package/dist/dapp-kit/actions/switch-account.md +37 -0
- package/dist/dapp-kit/actions/switch-network.md +37 -0
- package/dist/dapp-kit/dapp-kit-instance.md +162 -0
- package/dist/dapp-kit/getting-started/create-dapp.md +151 -0
- package/dist/dapp-kit/getting-started/next-js.md +162 -0
- package/dist/dapp-kit/getting-started/react.md +172 -0
- package/dist/dapp-kit/getting-started/vue.md +193 -0
- package/dist/dapp-kit/index.md +70 -0
- package/dist/dapp-kit/llms-index.md +26 -0
- package/dist/dapp-kit/react/components/connect-button.md +42 -0
- package/dist/dapp-kit/react/components/connect-modal.md +51 -0
- package/dist/dapp-kit/react/components/index.md +13 -0
- package/dist/dapp-kit/react/dapp-kit-provider.md +86 -0
- package/dist/dapp-kit/react/hooks/index.md +25 -0
- package/dist/dapp-kit/react/hooks/use-current-account.md +33 -0
- package/dist/dapp-kit/react/hooks/use-current-client.md +36 -0
- package/dist/dapp-kit/react/hooks/use-current-network.md +28 -0
- package/dist/dapp-kit/react/hooks/use-current-wallet.md +36 -0
- package/dist/dapp-kit/react/hooks/use-dapp-kit.md +100 -0
- package/dist/dapp-kit/react/hooks/use-wallet-connection.md +48 -0
- package/dist/dapp-kit/react/hooks/use-wallets.md +33 -0
- package/dist/dapp-kit/state.md +169 -0
- package/dist/dapp-kit/theming.md +196 -0
- package/dist/dapp-kit/web-components/connect-button.md +89 -0
- package/dist/dapp-kit/web-components/connect-modal.md +177 -0
- package/dist/kiosk/advanced-examples.md +101 -0
- package/dist/kiosk/from-v1.md +320 -0
- package/dist/kiosk/index.md +22 -0
- package/dist/kiosk/kiosk-client/introduction.md +52 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/examples.md +119 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/kiosk-transaction.md +103 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +235 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +110 -0
- package/dist/kiosk/kiosk-client/querying.md +237 -0
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/introduction.md +79 -0
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/using-the-manager.md +115 -0
- package/dist/kiosk/llms-index.md +8 -0
- package/dist/llms-index.md +125 -0
- package/dist/payment-kit/getting-started.md +256 -0
- package/dist/payment-kit/index.md +132 -0
- package/dist/payment-kit/llms-index.md +8 -0
- package/dist/payment-kit/payment-kit-sdk.md +747 -0
- package/dist/payment-kit/payment-processing.md +372 -0
- package/dist/payment-kit/registry-management.md +529 -0
- package/dist/seal/index.md +85 -0
- package/dist/seal/llms-index.md +4 -0
- package/dist/slush-wallet/dapp.md +95 -0
- package/dist/slush-wallet/deep-linking.md +465 -0
- package/dist/slush-wallet/index.md +7 -0
- package/dist/slush-wallet/llms-index.md +6 -0
- package/dist/sui/bcs.md +134 -0
- package/dist/sui/clients/core.md +606 -0
- package/dist/sui/clients/graphql.md +101 -0
- package/dist/sui/clients/grpc.md +155 -0
- package/dist/sui/clients/index.md +95 -0
- package/dist/sui/clients/json-rpc.md +239 -0
- package/dist/sui/cryptography/keypairs.md +267 -0
- package/dist/sui/cryptography/multisig.md +194 -0
- package/dist/sui/cryptography/passkey.md +111 -0
- package/dist/sui/cryptography/webcrypto-signer.md +81 -0
- package/dist/sui/executors.md +148 -0
- package/dist/sui/faucet.md +26 -0
- package/dist/sui/hello-sui.md +115 -0
- package/dist/sui/index.md +53 -0
- package/dist/sui/install.md +61 -0
- package/dist/sui/llm-docs.md +32 -0
- package/dist/sui/llms-index.md +44 -0
- package/dist/sui/migrations/0.38.md +58 -0
- package/dist/sui/migrations/sui-1.0.md +455 -0
- package/dist/sui/migrations/sui-2.0/agent-prompt.md +42 -0
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +350 -0
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +33 -0
- package/dist/sui/migrations/sui-2.0/index.md +158 -0
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +386 -0
- package/dist/sui/migrations/sui-2.0/kiosk.md +120 -0
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +90 -0
- package/dist/sui/migrations/sui-2.0/seal.md +14 -0
- package/dist/sui/migrations/sui-2.0/sui.md +341 -0
- package/dist/sui/migrations/sui-2.0/suins.md +43 -0
- package/dist/sui/migrations/sui-2.0/wallet-builders.md +66 -0
- package/dist/sui/migrations/sui-2.0/walrus.md +41 -0
- package/dist/sui/migrations/sui-2.0/zksend.md +95 -0
- package/dist/sui/plugins.md +258 -0
- package/dist/sui/sdk-building.md +344 -0
- package/dist/sui/transaction-building/basics.md +299 -0
- package/dist/sui/transaction-building/gas.md +62 -0
- package/dist/sui/transaction-building/intents.md +62 -0
- package/dist/sui/transaction-building/offline.md +73 -0
- package/dist/sui/transaction-building/sponsored-transactions.md +22 -0
- package/dist/sui/utils/derived_objects.md +59 -0
- package/dist/sui/utils/index.md +52 -0
- package/dist/sui/zklogin.md +83 -0
- package/dist/walrus/index.md +527 -0
- package/dist/walrus/llms-index.md +4 -0
- package/dist/zksend/index.md +27 -0
- package/dist/zksend/link-builder.md +192 -0
- package/dist/zksend/llms-index.md +5 -0
- package/package.json +66 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# @mysten/dapp-kit
|
|
2
|
+
|
|
3
|
+
> Migrate @mysten/dapp-kit to 2.0
|
|
4
|
+
|
|
5
|
+
This guide helps you migrate from the original `@mysten/dapp-kit` (legacy) to the new
|
|
6
|
+
`@mysten/dapp-kit-react` package.
|
|
7
|
+
|
|
8
|
+
> **Note:** The legacy `@mysten/dapp-kit` package will continue to work with the latest SDK, but it only
|
|
9
|
+
> supports JSON-RPC and will not receive further updates. We recommend migrating to
|
|
10
|
+
> `@mysten/dapp-kit-react` for new features and gRPC support.
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The new dApp Kit SDK represents a complete rewrite with these key changes:
|
|
15
|
+
|
|
16
|
+
- **Framework agnostic**: Split into `@mysten/dapp-kit-core` (framework-agnostic) and
|
|
17
|
+
`@mysten/dapp-kit-react` (React bindings)
|
|
18
|
+
- **No React Query dependency**: Direct promise-based API instead of mutation hooks
|
|
19
|
+
- **Web Components**: UI components built with Lit Elements for cross-framework compatibility
|
|
20
|
+
- **Smaller bundle size**: No React Query dependency, lighter state management with nanostores
|
|
21
|
+
- **Better SSR support**: Compatible with SSR frameworks like Next.js
|
|
22
|
+
- **Cross-framework compatibility**: Core functionality can be used in vanilla JS, Vue, React, and
|
|
23
|
+
other frameworks
|
|
24
|
+
|
|
25
|
+
## Step-by-Step Migration
|
|
26
|
+
|
|
27
|
+
### 1. Update Dependencies
|
|
28
|
+
|
|
29
|
+
Remove the old package and install the new ones:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm uninstall @mysten/dapp-kit
|
|
33
|
+
npm i @mysten/dapp-kit-react @mysten/dapp-kit-core @mysten/sui
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Create dApp Kit Instance
|
|
37
|
+
|
|
38
|
+
Create a new instance of the dApp Kit using the `createDAppKit` function and register the global
|
|
39
|
+
type.
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
// dapp-kit.ts
|
|
43
|
+
|
|
44
|
+
const GRPC_URLS = {
|
|
45
|
+
testnet: 'https://fullnode.testnet.sui.io:443',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
networks: ['testnet'],
|
|
49
|
+
createClient(network) {
|
|
50
|
+
return new SuiGrpcClient({ network, baseUrl: GRPC_URLS[network] });
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// global type registration necessary for the hooks to work correctly
|
|
55
|
+
declare module '@mysten/dapp-kit-react' {
|
|
56
|
+
interface Register {
|
|
57
|
+
dAppKit: typeof dAppKit;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Register Types
|
|
63
|
+
|
|
64
|
+
The `declare module` block in the previous step registers your dApp Kit instance's type globally.
|
|
65
|
+
This enables all hooks like `useDAppKit()`, `useCurrentNetwork()`, and `useCurrentClient()` to
|
|
66
|
+
automatically infer the correct types based on your configuration (e.g., your specific networks and
|
|
67
|
+
client type).
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
declare module '@mysten/dapp-kit-react' {
|
|
71
|
+
interface Register {
|
|
72
|
+
dAppKit: typeof dAppKit;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Without this registration, hooks return generic types and you lose type safety for things like
|
|
78
|
+
network names. If you prefer not to use global type registration, you can pass the `dAppKit`
|
|
79
|
+
instance explicitly to each hook instead:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
const connection = useWalletConnection({ dAppKit });
|
|
83
|
+
const network = useCurrentNetwork({ dAppKit });
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 4. Replace Provider Setup
|
|
87
|
+
|
|
88
|
+
Replace the nested dApp Kit providers with a single unified provider. You can keep your existing
|
|
89
|
+
`QueryClientProvider` for data fetching.
|
|
90
|
+
|
|
91
|
+
```diff
|
|
92
|
+
// App.tsx
|
|
93
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
94
|
+
- import { SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
|
|
95
|
+
+ import { DAppKitProvider } from '@mysten/dapp-kit-react';
|
|
96
|
+
+ import { dAppKit } from './dapp-kit.ts';
|
|
97
|
+
|
|
98
|
+
export function App() {
|
|
99
|
+
const queryClient = new QueryClient();
|
|
100
|
+
- const networkConfig = {
|
|
101
|
+
- mainnet: { url: 'https://mainnet.sui.io:443' },
|
|
102
|
+
- testnet: { url: 'https://testnet.sui.io:443' },
|
|
103
|
+
- };
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<QueryClientProvider client={queryClient}>
|
|
107
|
+
- <SuiClientProvider networks={networkConfig} defaultNetwork="mainnet">
|
|
108
|
+
- <WalletProvider>
|
|
109
|
+
- <App />
|
|
110
|
+
- </WalletProvider>
|
|
111
|
+
- </SuiClientProvider>
|
|
112
|
+
+ <DAppKitProvider dAppKit={dAppKit}>
|
|
113
|
+
+ <App />
|
|
114
|
+
+ </DAppKitProvider>
|
|
115
|
+
</QueryClientProvider>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 5. Configuration Option Changes
|
|
121
|
+
|
|
122
|
+
The `createDAppKit` function has different configuration options than the old `WalletProvider`:
|
|
123
|
+
|
|
124
|
+
| Old (`WalletProvider`) | New (`createDAppKit`) | Notes |
|
|
125
|
+
| ---------------------- | --------------------- | -------------------------------------------------------------------- |
|
|
126
|
+
| - | `networks` (required) | List of network identifiers your app supports |
|
|
127
|
+
| - | `createClient` | Function to create a client for each network |
|
|
128
|
+
| - | `defaultNetwork` | Network to use by default (defaults to first in `networks`) |
|
|
129
|
+
| `autoConnect` (false) | `autoConnect` (true) | Default changed from `false` to `true` |
|
|
130
|
+
| `enableUnsafeBurner` | `enableBurnerWallet` | Renamed |
|
|
131
|
+
| `slushWallet` | `slushWalletConfig` | Renamed |
|
|
132
|
+
| `storage` | `storage` | Unchanged |
|
|
133
|
+
| `storageKey` | `storageKey` | Unchanged |
|
|
134
|
+
| `preferredWallets` | - | Removed |
|
|
135
|
+
| `walletFilter` | - | Removed (wallets filtered by network compatibility) |
|
|
136
|
+
| `theme` | - | Removed (UI components are now web components with built-in styling) |
|
|
137
|
+
| - | `walletInitializers` | New option for registering custom wallets |
|
|
138
|
+
|
|
139
|
+
### 6. Update Hook Usage
|
|
140
|
+
|
|
141
|
+
The new dApp Kit has a dramatically simplified hook API. Most hooks from the original version have
|
|
142
|
+
been replaced with direct action calls through `useDAppKit()`.
|
|
143
|
+
|
|
144
|
+
**Available hooks in the new version:**
|
|
145
|
+
|
|
146
|
+
- `useDAppKit()` - Access the dAppKit instance for calling actions
|
|
147
|
+
- `useCurrentClient()` - Get the blockchain client (renamed from `useSuiClient`)
|
|
148
|
+
- `useCurrentAccount()` - Get the current connected account
|
|
149
|
+
- `useCurrentWallet()` - Get the current connected wallet
|
|
150
|
+
- `useWallets()` - Get the list of available wallets
|
|
151
|
+
- `useWalletConnection()` - Get the current wallet connection status
|
|
152
|
+
- `useCurrentNetwork()` - Get the current network
|
|
153
|
+
|
|
154
|
+
**Removed hooks:**
|
|
155
|
+
|
|
156
|
+
All wallet action hooks have been replaced with direct action calls via `useDAppKit()`:
|
|
157
|
+
|
|
158
|
+
- `useConnectWallet` -> Use `dAppKit.connectWallet()`
|
|
159
|
+
- `useDisconnectWallet` -> Use `dAppKit.disconnectWallet()`
|
|
160
|
+
- `useSignTransaction` -> Use `dAppKit.signTransaction()`
|
|
161
|
+
- `useSignAndExecuteTransaction` -> Use `dAppKit.signAndExecuteTransaction()`
|
|
162
|
+
- `useSignPersonalMessage` -> Use `dAppKit.signPersonalMessage()`
|
|
163
|
+
- `useSwitchAccount` -> Use `dAppKit.switchAccount()`
|
|
164
|
+
|
|
165
|
+
All data fetching hooks have been removed (giving you flexibility to use your preferred solution):
|
|
166
|
+
|
|
167
|
+
- `useSuiClientQuery` -> Use `useCurrentClient()` with your data fetching solution
|
|
168
|
+
- `useSuiClientMutation` -> Use `useCurrentClient()` with your data fetching solution
|
|
169
|
+
- `useSuiClientInfiniteQuery` -> Use `useCurrentClient()` with your data fetching solution
|
|
170
|
+
- `useSuiClientQueries` -> Use `useCurrentClient()` with your data fetching solution
|
|
171
|
+
- `useResolveSuiNSNames` -> Use `useCurrentClient()` directly
|
|
172
|
+
|
|
173
|
+
Other removed hooks:
|
|
174
|
+
|
|
175
|
+
- `useAutoConnectWallet` -> Auto-connect is enabled by default
|
|
176
|
+
- `useAccounts` -> Use `useWalletConnection()` to access `connection.wallet.accounts`
|
|
177
|
+
- `useWalletStore` -> Use specific hooks like `useWalletConnection()` instead
|
|
178
|
+
|
|
179
|
+
### 7. Replace Mutation Patterns
|
|
180
|
+
|
|
181
|
+
The built-in mutation hooks have been removed. Use TanStack Query's `useMutation` with
|
|
182
|
+
`useDAppKit()` to get similar functionality.
|
|
183
|
+
|
|
184
|
+
**Chain parameter replaced with network:**
|
|
185
|
+
|
|
186
|
+
In the old dapp-kit, you could optionally pass a `chain` parameter (e.g., `sui:mainnet`) to methods
|
|
187
|
+
like `signTransaction` and `signAndExecuteTransaction`. In the new dapp-kit, use the `network`
|
|
188
|
+
parameter instead - the chain is automatically derived from the network.
|
|
189
|
+
|
|
190
|
+
```diff
|
|
191
|
+
- const { mutateAsync: signAndExecute } = useSignAndExecuteTransaction();
|
|
192
|
+
- await signAndExecute({ transaction, chain: 'sui:mainnet' });
|
|
193
|
+
+ const dAppKit = useDAppKit();
|
|
194
|
+
+ await dAppKit.signAndExecuteTransaction({ transaction, network: 'mainnet' });
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Mutation example:**
|
|
198
|
+
|
|
199
|
+
```diff
|
|
200
|
+
- import { useSignAndExecuteTransaction } from '@mysten/dapp-kit';
|
|
201
|
+
+ import { useMutation } from '@tanstack/react-query';
|
|
202
|
+
+ import { useDAppKit } from '@mysten/dapp-kit-react';
|
|
203
|
+
import type { Transaction } from '@mysten/sui/transactions';
|
|
204
|
+
|
|
205
|
+
export function ExampleComponent({ transaction }: { transaction: Transaction }) {
|
|
206
|
+
- const { mutateAsync: signAndExecute } = useSignAndExecuteTransaction();
|
|
207
|
+
+ const dAppKit = useDAppKit();
|
|
208
|
+
+
|
|
209
|
+
+ const { mutateAsync: signAndExecute } = useMutation({
|
|
210
|
+
+ mutationFn: (tx: Transaction) => dAppKit.signAndExecuteTransaction({ transaction: tx }),
|
|
211
|
+
+ });
|
|
212
|
+
|
|
213
|
+
const handleClick = async () => {
|
|
214
|
+
- await signAndExecute(
|
|
215
|
+
- { transaction },
|
|
216
|
+
- {
|
|
217
|
+
- onSuccess: (result: any) => console.log(result),
|
|
218
|
+
- onError: (error: any) => console.error(error),
|
|
219
|
+
- },
|
|
220
|
+
- );
|
|
221
|
+
+ await signAndExecute(transaction, {
|
|
222
|
+
+ onSuccess: (result) => console.log(result),
|
|
223
|
+
+ onError: (error) => console.error(error),
|
|
224
|
+
+ });
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
return <button onClick={handleClick}>Sign and Execute</button>;
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Alternative: Direct promise-based calls**
|
|
232
|
+
|
|
233
|
+
If you don't need React Query's state management, you can call `dAppKit` methods directly:
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
|
|
237
|
+
const dAppKit = useDAppKit();
|
|
238
|
+
|
|
239
|
+
const handleClick = async () => {
|
|
240
|
+
try {
|
|
241
|
+
const result = await dAppKit.signAndExecuteTransaction({ transaction });
|
|
242
|
+
console.log(result);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error(error);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
return <button onClick={handleClick}>Sign and Execute</button>;
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 8. Replace Data Fetching Patterns
|
|
253
|
+
|
|
254
|
+
The built-in data fetching hooks have been removed. Use TanStack Query's `useQuery` with
|
|
255
|
+
`useCurrentClient()` to get similar functionality:
|
|
256
|
+
|
|
257
|
+
```diff
|
|
258
|
+
- import { useSuiClientQuery } from '@mysten/dapp-kit';
|
|
259
|
+
+ import { useQuery } from '@tanstack/react-query';
|
|
260
|
+
+ import { useCurrentClient } from '@mysten/dapp-kit-react';
|
|
261
|
+
|
|
262
|
+
export function ExampleComponent({ objectId }: { objectId: string }) {
|
|
263
|
+
+ const client = useCurrentClient();
|
|
264
|
+
+
|
|
265
|
+
- const { data, isLoading, error } = useSuiClientQuery('getObject', {
|
|
266
|
+
- id: objectId,
|
|
267
|
+
- });
|
|
268
|
+
+ const { data, isLoading, error } = useQuery({
|
|
269
|
+
+ queryKey: ['object', objectId],
|
|
270
|
+
+ queryFn: () => client.core.getObject({ objectId }),
|
|
271
|
+
+ });
|
|
272
|
+
// ...
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Alternative: Direct data fetching**
|
|
277
|
+
|
|
278
|
+
If you don't need React Query's caching and state management, you can fetch data directly:
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
|
|
282
|
+
const client = useCurrentClient();
|
|
283
|
+
const [data, setData] = useState(null);
|
|
284
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
285
|
+
const [error, setError] = useState<string | null>(null);
|
|
286
|
+
|
|
287
|
+
useEffect(() => {
|
|
288
|
+
client.core
|
|
289
|
+
.getObject({ objectId })
|
|
290
|
+
.then((result) => setData(result.object ?? null))
|
|
291
|
+
.catch((err) => setError(err.message))
|
|
292
|
+
.finally(() => setIsLoading(false));
|
|
293
|
+
}, [client, objectId]);
|
|
294
|
+
// ...
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### 9. Update The Remaining Code
|
|
299
|
+
|
|
300
|
+
The following hooks from the original dApp Kit are not available anymore:
|
|
301
|
+
|
|
302
|
+
- `useSuiClientQuery` → Use `useQuery` from `@tanstack/react-query`
|
|
303
|
+
- `useSuiClientMutation` → Use `useMutation` from `@tanstack/react-query`
|
|
304
|
+
- `useSuiClientInfiniteQuery` → Use `useInfiniteQuery` from `@tanstack/react-query`
|
|
305
|
+
- `useResolveSuiNSNames` → Use `useCurrentClient()` with the suins extension
|
|
306
|
+
|
|
307
|
+
> **Warning:** The `reportTransactionEffects` feature is planned for deprecation in the [Wallet
|
|
308
|
+
> Standard](https://docs.sui.io/standards/wallet-standard) and so the dApp Kit provides no
|
|
309
|
+
> replacement.
|
|
310
|
+
|
|
311
|
+
The following have been removed:
|
|
312
|
+
|
|
313
|
+
- `useReportTransactionEffects` hook
|
|
314
|
+
- `reportTransactionEffects` callback from `useSignTransaction`
|
|
315
|
+
- Automatic transaction effects reporting from `useSignAndExecuteTransaction`
|
|
316
|
+
|
|
317
|
+
## CSS and Theming Changes
|
|
318
|
+
|
|
319
|
+
The new dApp Kit no longer bundles a CSS file. If you were importing the old CSS file, remove the
|
|
320
|
+
import:
|
|
321
|
+
|
|
322
|
+
```diff
|
|
323
|
+
- import '@mysten/dapp-kit/dist/full/index.css';
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
The new dApp Kit uses web components with built-in styling that can be customized using CSS custom
|
|
327
|
+
properties. See the [Theming documentation](/dapp-kit/theming) for details on customizing the
|
|
328
|
+
appearance of dApp Kit components.
|
|
329
|
+
|
|
330
|
+
**Quick theme setup:**
|
|
331
|
+
|
|
332
|
+
```css
|
|
333
|
+
:root {
|
|
334
|
+
--primary: #4f46e5;
|
|
335
|
+
--primary-foreground: #ffffff;
|
|
336
|
+
--background: #ffffff;
|
|
337
|
+
--foreground: #0f172a;
|
|
338
|
+
--border: #e2e8f0;
|
|
339
|
+
--radius: 0.5rem;
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Removing TanStack Query
|
|
344
|
+
|
|
345
|
+
If you were only using `@tanstack/react-query` for dApp Kit and don't need it for other parts of
|
|
346
|
+
your application, you can now remove it:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
npm uninstall @tanstack/react-query
|
|
350
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @mysten/deepbook-v3
|
|
2
|
+
|
|
3
|
+
> Migrate @mysten/deepbook-v3 to 2.0
|
|
4
|
+
|
|
5
|
+
This package now exports a client extension that integrates with Sui clients.
|
|
6
|
+
|
|
7
|
+
```diff
|
|
8
|
+
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
9
|
+
- import { DeepBookClient } from '@mysten/deepbook-v3';
|
|
10
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc'; // or SuiJsonRpcClient, SuiGraphQLClient
|
|
11
|
+
+ import { deepbook } from '@mysten/deepbook-v3';
|
|
12
|
+
|
|
13
|
+
- const suiClient = new SuiClient({ url: getFullnodeUrl('mainnet') });
|
|
14
|
+
- const deepBookClient = new DeepBookClient({
|
|
15
|
+
- client: suiClient,
|
|
16
|
+
- address: myAddress,
|
|
17
|
+
- env: 'mainnet',
|
|
18
|
+
- balanceManagers: { ... },
|
|
19
|
+
- });
|
|
20
|
+
+ const client = new SuiGrpcClient({
|
|
21
|
+
+ baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
22
|
+
+ network: 'mainnet',
|
|
23
|
+
+ }).$extend(
|
|
24
|
+
+ deepbook({
|
|
25
|
+
+ address: myAddress,
|
|
26
|
+
+ // network is auto-detected from the client
|
|
27
|
+
+ balanceManagers: { ... },
|
|
28
|
+
+ }),
|
|
29
|
+
+ );
|
|
30
|
+
|
|
31
|
+
- await deepBookClient.checkManagerBalance(manager, asset);
|
|
32
|
+
+ await client.deepbook.checkManagerBalance(manager, asset);
|
|
33
|
+
```
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Migrate to 2.0
|
|
2
|
+
|
|
3
|
+
> Migration guide for Sui TypeScript SDK 2.0
|
|
4
|
+
|
|
5
|
+
This guide covers the breaking changes across the latest release of all the `@mysten/*` packages.
|
|
6
|
+
|
|
7
|
+
The primary goal of this release is to support the new GRPC and GraphQL APIs across all the mysten
|
|
8
|
+
SDKs. These releases also include removals of deprecated APIs, some renaming for better consistency,
|
|
9
|
+
and significant internal refactoring to improve maintainability. Starting with this release, Mysten
|
|
10
|
+
packages will now be published as ESM only packages.
|
|
11
|
+
|
|
12
|
+
## Quick Reference
|
|
13
|
+
|
|
14
|
+
| Package | Key Changes |
|
|
15
|
+
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
16
|
+
| [@mysten/sui](/sui/migrations/sui-2.0/sui) | Client API stabilization, SuiClient removal, BCS schema alignment, transaction executors |
|
|
17
|
+
| [@mysten/dapp-kit](/sui/migrations/sui-2.0/dapp-kit) | Complete rewrite with framework-agnostic core |
|
|
18
|
+
| [@mysten/kiosk](/sui/migrations/sui-2.0/kiosk) | Client extension pattern, low-level helpers removed, KioskTransaction pattern |
|
|
19
|
+
| [@mysten/zksend](/sui/migrations/sui-2.0/zksend) | Client extension pattern |
|
|
20
|
+
| [@mysten/suins](/sui/migrations/sui-2.0/suins) | Client extension pattern |
|
|
21
|
+
| [@mysten/deepbook-v3](/sui/migrations/sui-2.0/deepbook-v3) | Client extension pattern |
|
|
22
|
+
| [@mysten/walrus](/sui/migrations/sui-2.0/walrus) | Client extension pattern, requires client instead of RPC URL |
|
|
23
|
+
| [@mysten/seal](/sui/migrations/sui-2.0/seal) | Client extension pattern |
|
|
24
|
+
| [@mysten/wallet-standard](/sui/migrations/sui-2.0/wallet-builders) | Removal of reportTransactionEffects, new core API response format |
|
|
25
|
+
| [Migrating from JSON-RPC](/sui/migrations/sui-2.0/json-rpc-migration) | Migrate from deprecated JSON-RPC to gRPC and GraphQL |
|
|
26
|
+
|
|
27
|
+
## Common Migration Patterns
|
|
28
|
+
|
|
29
|
+
### ESM Migration
|
|
30
|
+
|
|
31
|
+
All `@mysten/*` packages are now ESM only. If your project does not already use ESM, you will need
|
|
32
|
+
to add `"type": "module"` to your `package.json`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"type": "module"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If you are using TypeScript with `moduleResolution` `"Node"`, `"Classic"`, or `"Node10"`, you will
|
|
41
|
+
need to update your `tsconfig.json` to use `"NodeNext"`, `"Node16"`, or `"Bundler"`:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"compilerOptions": {
|
|
46
|
+
"moduleResolution": "NodeNext",
|
|
47
|
+
"module": "NodeNext"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This enables proper resolution of the SDK's subpath exports (e.g., `@mysten/sui/client`,
|
|
53
|
+
`@mysten/sui/transactions`).
|
|
54
|
+
|
|
55
|
+
If you maintain a library that depends on any of the `@mysten/*` packages, you may also need to
|
|
56
|
+
update your library to be ESM only to ensure it works correctly everywhere.
|
|
57
|
+
|
|
58
|
+
Applications using bundlers and recent Node.js versions (>=22) may still work when using `require`
|
|
59
|
+
to load ESM packages, but we recommend migrating to ESM.
|
|
60
|
+
|
|
61
|
+
**Why ESM only?** Many packages in the ecosystem (specifically critical cryptography dependencies)
|
|
62
|
+
are now published as ESM only. Supporting CommonJS has prevented us from using the latest versions
|
|
63
|
+
of these dependencies, making our SDKs harder to maintain and risking missing critical security
|
|
64
|
+
updates.
|
|
65
|
+
|
|
66
|
+
### Client Migration
|
|
67
|
+
|
|
68
|
+
The most common change across all SDKs is migrating from `SuiClient` to `SuiJsonRpcClient`:
|
|
69
|
+
|
|
70
|
+
```diff
|
|
71
|
+
- import { SuiClient, getFullnodeUrl } from '@mysten/sui/client';
|
|
72
|
+
+ import { SuiJsonRpcClient, getJsonRpcFullnodeUrl } from '@mysten/sui/jsonRpc';
|
|
73
|
+
|
|
74
|
+
- const client = new SuiClient({ url: getFullnodeUrl('mainnet') });
|
|
75
|
+
+ const client = new SuiJsonRpcClient({
|
|
76
|
+
+ url: getJsonRpcFullnodeUrl('mainnet'),
|
|
77
|
+
+ network: 'mainnet',
|
|
78
|
+
+ });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
We also recommend moving from the deprecated JSON RPC Apis to the new gRPC API as soon as possible:
|
|
82
|
+
|
|
83
|
+
```diff
|
|
84
|
+
- import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
|
|
85
|
+
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
86
|
+
|
|
87
|
+
- const client = new SuiJsonRpcClient({ url, network: 'mainnet' });
|
|
88
|
+
+ const client = new SuiGrpcClient({ baseUrl, network: 'mainnet' });
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The gRPC runs on full nodes so in most cases you should be able to use the same URLs when migrating
|
|
92
|
+
to gRPC.
|
|
93
|
+
|
|
94
|
+
### Network Parameter Required
|
|
95
|
+
|
|
96
|
+
All client constructors now require an explicit `network` parameter:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
const client = new SuiJsonRpcClient({
|
|
100
|
+
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
101
|
+
network: 'mainnet', // Required
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const graphqlClient = new SuiGraphQLClient({
|
|
105
|
+
url: 'https://sui-mainnet.mystenlabs.com/graphql',
|
|
106
|
+
network: 'mainnet', // Required
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const grpcClient = new SuiGrpcClient({
|
|
110
|
+
baseUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
111
|
+
network: 'mainnet', // Required
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### ClientWithCoreApi Interface
|
|
116
|
+
|
|
117
|
+
Many SDK methods now accept any client implementing `ClientWithCoreApi`, enabling use with JSON-RPC,
|
|
118
|
+
GraphQL, or gRPC transports:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
|
|
122
|
+
// All of these work with APIs that accept ClientWithCoreApi
|
|
123
|
+
const jsonRpcClient = new SuiJsonRpcClient({ url, network: 'mainnet' });
|
|
124
|
+
const graphqlClient = new SuiGraphQLClient({ url, network: 'mainnet' });
|
|
125
|
+
const grpcClient = new SuiGrpcClient({ baseUrl, network: 'mainnet' });
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Package-Specific Guides
|
|
129
|
+
|
|
130
|
+
For detailed migration instructions, see the SDK-specific guides:
|
|
131
|
+
|
|
132
|
+
- **[@mysten/sui](/sui/migrations/sui-2.0/sui)** - Core SDK changes including client API, BCS
|
|
133
|
+
schemas, transactions, zkLogin, and GraphQL
|
|
134
|
+
- **[@mysten/dapp-kit](/sui/migrations/sui-2.0/dapp-kit)** - Complete migration guide for the new
|
|
135
|
+
dApp Kit architecture
|
|
136
|
+
- **[@mysten/kiosk](/sui/migrations/sui-2.0/kiosk)** - Kiosk SDK now exports a client extension,
|
|
137
|
+
low-level helpers removed
|
|
138
|
+
- **[@mysten/zksend](/sui/migrations/sui-2.0/zksend)** - zkSend SDK now exports a client extension
|
|
139
|
+
- **[@mysten/suins](/sui/migrations/sui-2.0/suins)** - SuiNS now exports a client extension
|
|
140
|
+
- **[@mysten/deepbook-v3](/sui/migrations/sui-2.0/deepbook-v3)** - DeepBook DEX now exports a client
|
|
141
|
+
extension
|
|
142
|
+
- **[@mysten/walrus](/sui/migrations/sui-2.0/walrus)** - Walrus storage now exports a client
|
|
143
|
+
extension
|
|
144
|
+
- **[@mysten/seal](/sui/migrations/sui-2.0/seal)** - Seal encryption now exports a client extension
|
|
145
|
+
|
|
146
|
+
## Transport Migration
|
|
147
|
+
|
|
148
|
+
- **[Migrating from JSON-RPC](/sui/migrations/sui-2.0/json-rpc-migration)** - Migrate from the
|
|
149
|
+
deprecated JSON-RPC client to gRPC and GraphQL
|
|
150
|
+
|
|
151
|
+
## Ecosystem Migration Guides
|
|
152
|
+
|
|
153
|
+
For wallet builders and SDK maintainers building on the Sui ecosystem:
|
|
154
|
+
|
|
155
|
+
- **[Wallet Builders](/sui/migrations/sui-2.0/wallet-builders)** - Guide for wallet implementations
|
|
156
|
+
adapting to `reportTransactionEffects` removal and new core API response format
|
|
157
|
+
- **[SDK Maintainers](/sui/migrations/sui-2.0/sdk-maintainers)** - Guide for SDK authors migrating
|
|
158
|
+
to `ClientWithCoreApi` and the new transport-agnostic architecture
|