@mysten/docs 0.1.18 → 0.1.19
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/bcs/index.md +1 -1
- package/dist/bcs/llms-index.md +1 -1
- package/dist/codegen/index.md +53 -53
- package/dist/codegen/llms-index.md +1 -1
- package/dist/dapp-kit/actions/connect-wallet.md +4 -4
- package/dist/dapp-kit/actions/disconnect-wallet.md +8 -7
- package/dist/dapp-kit/actions/sign-and-execute-transaction.md +14 -14
- package/dist/dapp-kit/actions/sign-personal-message.md +8 -8
- package/dist/dapp-kit/actions/sign-transaction.md +7 -7
- package/dist/dapp-kit/actions/switch-account.md +6 -6
- package/dist/dapp-kit/actions/switch-network.md +5 -5
- package/dist/dapp-kit/dapp-kit-instance.md +19 -18
- package/dist/dapp-kit/getting-started/create-dapp.md +12 -12
- package/dist/dapp-kit/getting-started/next-js.md +12 -11
- package/dist/dapp-kit/getting-started/react.md +25 -25
- package/dist/dapp-kit/getting-started/vue.md +12 -12
- package/dist/dapp-kit/index.md +4 -4
- package/dist/dapp-kit/llms-index.md +23 -23
- package/dist/dapp-kit/react/components/connect-button.md +3 -3
- package/dist/dapp-kit/react/components/connect-modal.md +3 -3
- package/dist/dapp-kit/react/components/index.md +2 -2
- package/dist/dapp-kit/react/dapp-kit-provider.md +6 -6
- package/dist/dapp-kit/react/hooks/index.md +4 -3
- package/dist/dapp-kit/react/hooks/use-current-account.md +3 -3
- package/dist/dapp-kit/react/hooks/use-current-client.md +3 -3
- package/dist/dapp-kit/react/hooks/use-current-network.md +3 -3
- package/dist/dapp-kit/react/hooks/use-current-wallet.md +3 -3
- package/dist/dapp-kit/react/hooks/use-dapp-kit.md +5 -5
- package/dist/dapp-kit/react/hooks/use-wallet-connection.md +3 -3
- package/dist/dapp-kit/react/hooks/use-wallets.md +3 -3
- package/dist/dapp-kit/state.md +16 -16
- package/dist/dapp-kit/theming.md +27 -27
- package/dist/dapp-kit/web-components/connect-button.md +9 -9
- package/dist/dapp-kit/web-components/connect-modal.md +16 -16
- package/dist/kiosk/advanced-examples.md +1 -1
- package/dist/kiosk/from-v1.md +1 -1
- package/dist/kiosk/index.md +5 -5
- package/dist/kiosk/kiosk-client/introduction.md +6 -6
- package/dist/kiosk/kiosk-client/kiosk-transaction/examples.md +3 -3
- package/dist/kiosk/kiosk-client/kiosk-transaction/kiosk-transaction.md +1 -1
- package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +11 -11
- package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +1 -1
- package/dist/kiosk/kiosk-client/querying.md +1 -1
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/introduction.md +1 -1
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/using-the-manager.md +1 -3
- package/dist/kiosk/llms-index.md +5 -5
- package/dist/llms-index.md +83 -83
- package/dist/payment-kit/getting-started.md +13 -13
- package/dist/payment-kit/index.md +13 -13
- package/dist/payment-kit/llms-index.md +5 -5
- package/dist/payment-kit/payment-kit-sdk.md +18 -18
- package/dist/payment-kit/payment-processing.md +34 -34
- package/dist/payment-kit/registry-management.md +35 -35
- package/dist/seal/index.md +5 -5
- package/dist/seal/llms-index.md +1 -1
- package/dist/slush-wallet/dapp.md +10 -10
- package/dist/slush-wallet/deep-linking.md +54 -54
- package/dist/slush-wallet/index.md +2 -2
- package/dist/slush-wallet/llms-index.md +3 -3
- package/dist/sui/bcs.md +11 -11
- package/dist/sui/clients/core.md +57 -56
- package/dist/sui/clients/graphql.md +3 -3
- package/dist/sui/clients/grpc.md +10 -10
- package/dist/sui/clients/index.md +14 -14
- package/dist/sui/clients/json-rpc.md +16 -16
- package/dist/sui/cryptography/keypairs.md +6 -6
- package/dist/sui/cryptography/multisig.md +4 -4
- package/dist/sui/cryptography/passkey.md +15 -14
- package/dist/sui/cryptography/webcrypto-signer.md +4 -4
- package/dist/sui/executors.md +18 -16
- package/dist/sui/faucet.md +3 -3
- package/dist/sui/hello-sui.md +5 -5
- package/dist/sui/index.md +12 -12
- package/dist/sui/install.md +3 -3
- package/dist/sui/llm-docs.md +9 -9
- package/dist/sui/llms-index.md +41 -41
- package/dist/sui/migrations/0.38.md +6 -6
- package/dist/sui/migrations/sui-1.0.md +32 -32
- package/dist/sui/migrations/sui-2.0/agent-prompt.md +3 -3
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +43 -43
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +1 -1
- package/dist/sui/migrations/sui-2.0/index.md +37 -37
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +53 -47
- package/dist/sui/migrations/sui-2.0/kiosk.md +8 -8
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +7 -7
- package/dist/sui/migrations/sui-2.0/seal.md +1 -1
- package/dist/sui/migrations/sui-2.0/sui.md +16 -16
- package/dist/sui/migrations/sui-2.0/suins.md +4 -3
- package/dist/sui/migrations/sui-2.0/wallet-builders.md +5 -5
- package/dist/sui/migrations/sui-2.0/walrus.md +3 -3
- package/dist/sui/migrations/sui-2.0/zksend.md +5 -5
- package/dist/sui/plugins.md +14 -14
- package/dist/sui/sdk-building.md +32 -32
- package/dist/sui/transaction-building/basics.md +13 -13
- package/dist/sui/transaction-building/gas.md +2 -3
- package/dist/sui/transaction-building/intents.md +4 -4
- package/dist/sui/transaction-building/offline.md +8 -8
- package/dist/sui/transaction-building/sponsored-transactions.md +1 -1
- package/dist/sui/utils/derived_objects.md +10 -10
- package/dist/sui/utils/index.md +1 -1
- package/dist/sui/zklogin.md +1 -1
- package/dist/walrus/index.md +1 -1
- package/dist/walrus/llms-index.md +1 -1
- package/dist/zksend/index.md +2 -2
- package/dist/zksend/link-builder.md +5 -4
- package/dist/zksend/llms-index.md +2 -2
- package/package.json +6 -6
package/dist/bcs/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BCS - Binary Canonical Serialization
|
|
2
2
|
|
|
3
|
-
> Encode and decode Sui Move types with Binary Canonical Serialization
|
|
3
|
+
> Encode and decode Sui Move types with Binary Canonical Serialization.
|
|
4
4
|
|
|
5
5
|
This small and lightweight library implements
|
|
6
6
|
[Binary Canonical Serialization (BCS)](https://github.com/zefchain/bcs) in TypeScript, making BCS
|
package/dist/bcs/llms-index.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# BCS
|
|
2
2
|
> Encoding and decoding Sui objects
|
|
3
3
|
|
|
4
|
-
- [BCS - Binary Canonical Serialization](..md): Encode and decode Sui Move types with Binary Canonical Serialization
|
|
4
|
+
- [BCS - Binary Canonical Serialization](..md): Encode and decode Sui Move types with Binary Canonical Serialization.
|
package/dist/codegen/index.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Sui TypeScript Codegen
|
|
2
2
|
|
|
3
|
-
> Generate type-safe TypeScript bindings from
|
|
3
|
+
> Generate type-safe TypeScript bindings from onchain Sui Move packages.
|
|
4
4
|
|
|
5
5
|
The `@mysten/codegen` package automatically generates type-safe TypeScript code from your Move
|
|
6
6
|
packages, enabling seamless interaction with your smart contracts from TypeScript applications.
|
|
7
7
|
|
|
8
|
-
> **Warning:** This package is currently in development and
|
|
8
|
+
> **Warning:** This package is currently in development and might have breaking changes.
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- **Type-safe Move calls**: Generate TypeScript functions with full type safety for calling your
|
|
13
13
|
Move functions
|
|
14
|
-
- **BCS type definitions**: Automatic BCS struct definitions for parsing
|
|
14
|
+
- **BCS type definitions**: Automatic BCS struct definitions for parsing onchain data
|
|
15
15
|
- **Auto-completion**: IDE support with intelligent code completion for Move function arguments
|
|
16
16
|
- **Package resolution**: Support for both MVR-registered packages and local packages
|
|
17
17
|
|
|
@@ -23,9 +23,9 @@ Install the codegen package as a dev dependency:
|
|
|
23
23
|
npm install -D @mysten/codegen
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
## Quick
|
|
26
|
+
## Quick start
|
|
27
27
|
|
|
28
|
-
### 1
|
|
28
|
+
### Step 1: Create a configuration file
|
|
29
29
|
|
|
30
30
|
Create a `sui-codegen.config.ts` file in your project root:
|
|
31
31
|
|
|
@@ -43,7 +43,7 @@ const config: SuiCodegenConfig = {
|
|
|
43
43
|
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
### 2
|
|
46
|
+
### Step 2: Generate TypeScript code
|
|
47
47
|
|
|
48
48
|
Add a script to your `package.json`:
|
|
49
49
|
|
|
@@ -61,35 +61,35 @@ Then run:
|
|
|
61
61
|
pnpm codegen
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
This generates TypeScript code in your configured output directory (
|
|
64
|
+
This generates TypeScript code in your configured output directory (for example, `./src/contracts`).
|
|
65
65
|
|
|
66
|
-
## Configuration
|
|
66
|
+
## Configuration options
|
|
67
67
|
|
|
68
68
|
The `SuiCodegenConfig` type supports the following options:
|
|
69
69
|
|
|
70
70
|
| Option | Type | Default | Description |
|
|
71
71
|
| ------------------------------ | ---------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
72
|
-
| `output` | `string` |
|
|
73
|
-
| `packages` | `PackageConfig[]` |
|
|
72
|
+
| `output` | `string` | - | The directory where generated code will be written |
|
|
73
|
+
| `packages` | `PackageConfig[]` | - | Array of Move packages to generate code for |
|
|
74
74
|
| `prune` | `boolean` | `true` | When enabled, only generates code for the main package and omits dependency modules (dependency types referenced by included types are still generated under `deps/`) |
|
|
75
75
|
| `generateSummaries` | `boolean` | `true` | Automatically run `sui move summary` before generating code. Creates a `package_summaries` directory in your Move package which can be added to `.gitignore` |
|
|
76
|
-
| `generate` | `GenerateOptions` |
|
|
76
|
+
| `generate` | `GenerateOptions` | - | Default [generate options](#the-generate-option) (types, functions) for all packages |
|
|
77
77
|
| `importExtension` | `'.js' \| '.ts' \| ''` | `'.js'` | File extension used in generated import statements |
|
|
78
78
|
| `includePhantomTypeParameters` | `boolean` | `false` | Include [phantom type parameters](#phantom-types) as function arguments in generated BCS types |
|
|
79
79
|
|
|
80
|
-
### Package
|
|
80
|
+
### Package configuration
|
|
81
81
|
|
|
82
82
|
Each entry in the `packages` array configures a Move package to generate code from. Packages can be
|
|
83
|
-
local (from source) or
|
|
83
|
+
local (from source) or onchain (fetched from a network).
|
|
84
84
|
|
|
85
|
-
#### Local
|
|
85
|
+
#### Local packages
|
|
86
86
|
|
|
87
|
-
| Option | Type | Required | Description
|
|
88
|
-
| ------------- | ------------------------ | -------- |
|
|
89
|
-
| `package` | `string` | yes | Package identifier (
|
|
90
|
-
| `path` | `string` | yes | Path to the Move package directory
|
|
91
|
-
| `packageName` | `string` | no | Custom name for generated code directory
|
|
92
|
-
| `generate` | `PackageGenerateOptions` | no | Control what gets generated from this package
|
|
87
|
+
| Option | Type | Required | Description |
|
|
88
|
+
| ------------- | ------------------------ | -------- | --------------------------------------------------------- |
|
|
89
|
+
| `package` | `string` | yes | Package identifier (for example, `@local-pkg/my-package`) |
|
|
90
|
+
| `path` | `string` | yes | Path to the Move package directory |
|
|
91
|
+
| `packageName` | `string` | no | Custom name for generated code directory |
|
|
92
|
+
| `generate` | `PackageGenerateOptions` | no | Control what gets generated from this package |
|
|
93
93
|
|
|
94
94
|
```typescript
|
|
95
95
|
{
|
|
@@ -98,9 +98,9 @@ local (from source) or on-chain (fetched from a network).
|
|
|
98
98
|
}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
####
|
|
101
|
+
#### Onchain packages
|
|
102
102
|
|
|
103
|
-
For packages already deployed
|
|
103
|
+
For packages already deployed onchain, generate code directly from a package ID or MVR name without
|
|
104
104
|
needing local source code:
|
|
105
105
|
|
|
106
106
|
| Option | Type | Required | Description |
|
|
@@ -126,7 +126,7 @@ settings override less specific ones.
|
|
|
126
126
|
|
|
127
127
|
When no `generate` option is set, everything is generated (all types and functions). Package-level
|
|
128
128
|
`types` and `functions` also default to `true`. In the record form of `modules`, per-module `types`
|
|
129
|
-
and `functions` default to `false
|
|
129
|
+
and `functions` default to `false`, so you opt in to exactly what you need from each module. Use
|
|
130
130
|
`true` as a shorthand to include everything from a module with package-level defaults.
|
|
131
131
|
|
|
132
132
|
At the **global** and **package** levels, `types` and `functions` only accept boolean values (or an
|
|
@@ -156,30 +156,30 @@ modules: {
|
|
|
156
156
|
|
|
157
157
|
Controls which BCS type definitions (structs and enums) are generated:
|
|
158
158
|
|
|
159
|
-
- `true
|
|
160
|
-
- `false
|
|
161
|
-
- `string[]
|
|
159
|
+
- `true`: generate all types
|
|
160
|
+
- `false`: skip type generation
|
|
161
|
+
- `string[]`: generate only the listed types by name (module level only)
|
|
162
162
|
|
|
163
163
|
### Functions
|
|
164
164
|
|
|
165
165
|
Controls which Move function wrappers are generated:
|
|
166
166
|
|
|
167
|
-
- `true
|
|
168
|
-
- `false
|
|
169
|
-
- `string[]
|
|
170
|
-
only)
|
|
171
|
-
- `{ private: 'entry' }
|
|
172
|
-
- `{ private: true }
|
|
173
|
-
- `{ private: false }
|
|
167
|
+
- `true`: generate all public functions and private entry functions
|
|
168
|
+
- `false`: skip function generation
|
|
169
|
+
- `string[]`: generate only the listed functions by name; includes private functions (module level
|
|
170
|
+
only)
|
|
171
|
+
- `{ private: 'entry' }`: generate public functions plus private entry functions
|
|
172
|
+
- `{ private: true }`: generate all functions including private
|
|
173
|
+
- `{ private: false }`: only generate public functions
|
|
174
174
|
|
|
175
175
|
### Modules
|
|
176
176
|
|
|
177
177
|
Controls which modules from the package are included. Only available at the package level, not at
|
|
178
178
|
the global level.
|
|
179
179
|
|
|
180
|
-
- Not set (default)
|
|
181
|
-
- `string[]
|
|
182
|
-
- `Record<string, true | { types?, functions? }
|
|
180
|
+
- Not set (default): include all modules
|
|
181
|
+
- `string[]`: only include the listed modules
|
|
182
|
+
- `Record<string, true | { types?, functions? }>`: only include the listed modules, with per-module
|
|
183
183
|
overrides for `types` and `functions`. Use `true` as a shorthand to include everything from a
|
|
184
184
|
module with package-level defaults
|
|
185
185
|
|
|
@@ -198,8 +198,8 @@ Only generate code from specific modules of the Sui framework:
|
|
|
198
198
|
}
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
Only generate a single type from a dependency (functions are omitted automatically
|
|
202
|
-
is configured and `functions` is not specified):
|
|
201
|
+
Only generate a single type from a dependency (functions are omitted automatically because
|
|
202
|
+
`generate` is configured and `functions` is not specified):
|
|
203
203
|
|
|
204
204
|
```typescript
|
|
205
205
|
{
|
|
@@ -267,7 +267,7 @@ src/contracts/
|
|
|
267
267
|
|
|
268
268
|
Set `prune: false` to generate all dependency modules with their full types and functions.
|
|
269
269
|
|
|
270
|
-
## Phantom
|
|
270
|
+
## Phantom types
|
|
271
271
|
|
|
272
272
|
In Move, phantom type parameters are type parameters that only appear at the type level and don't
|
|
273
273
|
affect the runtime data layout of a struct. For example, `Balance<T>` has a phantom type parameter
|
|
@@ -279,9 +279,9 @@ public struct Balance<phantom T> has store {
|
|
|
279
279
|
}
|
|
280
280
|
```
|
|
281
281
|
|
|
282
|
-
### Default
|
|
282
|
+
### Default behavior
|
|
283
283
|
|
|
284
|
-
By default, codegen excludes phantom type parameters from the generated BCS type functions
|
|
284
|
+
By default, codegen excludes phantom type parameters from the generated BCS type functions because
|
|
285
285
|
they don't affect serialization. The generated type is a constant rather than a function:
|
|
286
286
|
|
|
287
287
|
```typescript
|
|
@@ -293,13 +293,13 @@ they don't affect serialization. The generated type is a constant rather than a
|
|
|
293
293
|
});
|
|
294
294
|
```
|
|
295
295
|
|
|
296
|
-
This works correctly for parsing
|
|
296
|
+
This works correctly for parsing onchain data because phantom types don't change the binary layout.
|
|
297
297
|
|
|
298
|
-
> **Note:** With the default behavior, phantom parameters appear as literals in the type name (
|
|
299
|
-
> `Balance<phantom T>`). These names are useful for debugging but are not valid
|
|
298
|
+
> **Note:** With the default behavior, phantom parameters appear as literals in the type name (for example,
|
|
299
|
+
> `Balance<phantom T>`). These names are useful for debugging but are not valid onchain type tags. If
|
|
300
300
|
> you need valid type names with resolved phantom parameters, enable `includePhantomTypeParameters`.
|
|
301
301
|
|
|
302
|
-
### Including
|
|
302
|
+
### Including phantom type parameters
|
|
303
303
|
|
|
304
304
|
If you need the phantom type parameters as function arguments (for example, to preserve type
|
|
305
305
|
information for other tooling), enable `includePhantomTypeParameters`:
|
|
@@ -327,9 +327,9 @@ With this option enabled, phantom type parameters become function arguments:
|
|
|
327
327
|
}
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
## Using
|
|
330
|
+
## Using generated code
|
|
331
331
|
|
|
332
|
-
### Calling Move
|
|
332
|
+
### Calling Move functions
|
|
333
333
|
|
|
334
334
|
The generated code provides type-safe functions for calling Move functions:
|
|
335
335
|
|
|
@@ -346,9 +346,9 @@ tx.add(
|
|
|
346
346
|
);
|
|
347
347
|
```
|
|
348
348
|
|
|
349
|
-
### Parsing BCS
|
|
349
|
+
### Parsing BCS data
|
|
350
350
|
|
|
351
|
-
Use generated BCS types to parse
|
|
351
|
+
Use generated BCS types to parse onchain object data. Fetch the object with
|
|
352
352
|
`include: { content: true }` and pass `object.content` to the generated type's `.parse()` method:
|
|
353
353
|
|
|
354
354
|
```typescript
|
|
@@ -372,13 +372,13 @@ async function readCounter(client: ClientWithCoreApi, id: string) {
|
|
|
372
372
|
> contains a full object envelope with additional metadata that will cause parsing to fail. See the
|
|
373
373
|
> [Core API docs](/sui/clients/core#objectbcs) for details.
|
|
374
374
|
|
|
375
|
-
## Client
|
|
375
|
+
## Client configuration
|
|
376
376
|
|
|
377
377
|
### Using with MVR (Move Version Registry)
|
|
378
378
|
|
|
379
379
|
If your package is registered on MVR, the generated code works without additional configuration.
|
|
380
380
|
|
|
381
|
-
### Local
|
|
381
|
+
### Local packages
|
|
382
382
|
|
|
383
383
|
For local packages using `@local-pkg/*` identifiers, configure your client with package overrides:
|
|
384
384
|
|
|
@@ -431,9 +431,9 @@ const dAppKit = createDAppKit({
|
|
|
431
431
|
});
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
-
## Related
|
|
434
|
+
## Related resources
|
|
435
435
|
|
|
436
|
-
- [create-dapp](/dapp-kit/getting-started/create-dapp) - Bootstrap a working
|
|
436
|
+
- [create-dapp](/dapp-kit/getting-started/create-dapp) - Bootstrap a working app with codegen
|
|
437
437
|
already configured
|
|
438
438
|
- [Sui Move documentation](https://docs.sui.io/concepts/sui-move-concepts)
|
|
439
439
|
- [BCS documentation](/bcs)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# TypeScript Codegen
|
|
2
2
|
> Generate type-safe TypeScript code from Sui Move packages
|
|
3
3
|
|
|
4
|
-
- [Sui TypeScript Codegen](..md): Generate type-safe TypeScript bindings from
|
|
4
|
+
- [Sui TypeScript Codegen](..md): Generate type-safe TypeScript bindings from onchain Sui Move packages.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Connect Wallet
|
|
2
2
|
|
|
3
|
-
> Programmatically connect to a Sui wallet
|
|
3
|
+
> Programmatically connect to a Sui wallet using the dApp Kit connectWallet action.
|
|
4
4
|
|
|
5
5
|
The dApp Kit SDK provides an action for wallet connection, allowing users to connect, disconnect,
|
|
6
6
|
and switch between wallets and accounts.
|
|
@@ -33,15 +33,15 @@ console.log('Connected accounts:', result.accounts);
|
|
|
33
33
|
|
|
34
34
|
## Parameters
|
|
35
35
|
|
|
36
|
-
- **`wallet
|
|
36
|
+
- **`wallet`:** The `UiWallet` instance to connect to
|
|
37
37
|
- **`account`** (optional) - A specific `UiWalletAccount` to set as the selected account. Defaults
|
|
38
38
|
to the first authorized account
|
|
39
39
|
|
|
40
|
-
## Return
|
|
40
|
+
## Return value
|
|
41
41
|
|
|
42
42
|
Returns a `Promise` that resolves to an object containing:
|
|
43
43
|
|
|
44
|
-
- **`accounts
|
|
44
|
+
- **`accounts`:** Array of authorized `UiWalletAccount` instances
|
|
45
45
|
|
|
46
46
|
## Example
|
|
47
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Disconnect Wallet
|
|
2
2
|
|
|
3
|
-
> Programmatically disconnect from a Sui wallet
|
|
3
|
+
> Programmatically disconnect from a Sui wallet using the dApp Kit disconnectWallet action.
|
|
4
4
|
|
|
5
5
|
The `disconnectWallet` action terminates the connection with the currently connected wallet.
|
|
6
6
|
|
|
@@ -13,9 +13,9 @@ The `disconnectWallet` action terminates the connection with the currently conne
|
|
|
13
13
|
> if the wallet notification fails, the local state is always cleared to ensure a clean
|
|
14
14
|
> disconnection.
|
|
15
15
|
>
|
|
16
|
-
>
|
|
17
|
-
>
|
|
18
|
-
> wallet itself
|
|
16
|
+
> Wallets might or might not implement the `disconnect` feature. Calling `disconnectWallet`
|
|
17
|
+
> does not necessarily mean that the wallet accounts are disconnected from the app within the
|
|
18
|
+
> wallet itself. This is determined by each wallet's implementation.
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
21
|
|
|
@@ -30,9 +30,10 @@ await dAppKit.disconnectWallet();
|
|
|
30
30
|
|
|
31
31
|
None.
|
|
32
32
|
|
|
33
|
-
## Return
|
|
33
|
+
## Return value
|
|
34
34
|
|
|
35
35
|
Returns a `Promise` that resolves to `void` when the disconnection is complete.
|
|
36
36
|
|
|
37
|
-
> The action
|
|
38
|
-
> disconnect failures are logged but don't prevent the local connection state from
|
|
37
|
+
> The action might throw `WalletNotConnectedError` if no wallet is connected. However,
|
|
38
|
+
> wallet-specific disconnect failures are logged but don't prevent the local connection state from
|
|
39
|
+
> being cleared.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Sign and Execute Transaction
|
|
2
2
|
|
|
3
|
-
> Sign and execute a transaction using the connected wallet
|
|
3
|
+
> Sign and execute a transaction on the Sui network using the connected wallet.
|
|
4
4
|
|
|
5
5
|
The `signAndExecuteTransaction` action prompts the connected wallet to sign and immediately execute
|
|
6
|
-
a transaction on the Sui network. This is the most common way to execute transactions in your
|
|
6
|
+
a transaction on the Sui network. This is the most common way to execute transactions in your app.
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
@@ -30,11 +30,11 @@ console.log('Transaction digest:', result.Transaction.digest);
|
|
|
30
30
|
|
|
31
31
|
## Parameters
|
|
32
32
|
|
|
33
|
-
- **`transaction
|
|
33
|
+
- **`transaction`:** `Transaction | string`: The transaction to sign and execute. Can be either a
|
|
34
34
|
Transaction instance or base64-encoded bcs bytes for the transaction.
|
|
35
|
-
- **`signal`** (optional)
|
|
35
|
+
- **`signal`** (optional): `AbortSignal`: An abort signal to cancel the transaction request.
|
|
36
36
|
|
|
37
|
-
## Return
|
|
37
|
+
## Return value
|
|
38
38
|
|
|
39
39
|
Returns a `Promise` that resolves to a `TransactionResult` discriminated union:
|
|
40
40
|
|
|
@@ -46,14 +46,14 @@ type TransactionResult =
|
|
|
46
46
|
|
|
47
47
|
The `Transaction` object contains:
|
|
48
48
|
|
|
49
|
-
- **`digest
|
|
50
|
-
- **`signatures
|
|
51
|
-
- **`epoch
|
|
52
|
-
- **`status
|
|
49
|
+
- **`digest`:** `string`: The transaction digest (unique identifier for the executed transaction)
|
|
50
|
+
- **`signatures`:** `string[]`: The signatures as base64-encoded strings
|
|
51
|
+
- **`epoch`:** `string | null`: The epoch in which the transaction was executed
|
|
52
|
+
- **`status`:** `ExecutionStatus`: The execution status with `success: boolean` and
|
|
53
53
|
`error: string | null`
|
|
54
|
-
- **`effects
|
|
54
|
+
- **`effects`:** `TransactionEffects | null`: The parsed transaction effects (may be `null` if
|
|
55
55
|
effects parsing fails for unknown effect versions)
|
|
56
|
-
- **`transaction
|
|
56
|
+
- **`transaction`:** `TransactionData`: The parsed transaction data
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
const result = await dAppKit.signAndExecuteTransaction({ transaction });
|
|
@@ -70,7 +70,7 @@ console.log('Signatures:', tx.signatures);
|
|
|
70
70
|
console.log('Epoch:', tx.epoch);
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
## Transaction
|
|
73
|
+
## Transaction building
|
|
74
74
|
|
|
75
75
|
When passing a Transaction instance, the action automatically:
|
|
76
76
|
|
|
@@ -79,12 +79,12 @@ When passing a Transaction instance, the action automatically:
|
|
|
79
79
|
3. Converts it to the appropriate format for the wallet
|
|
80
80
|
4. Submits the transaction to the network
|
|
81
81
|
|
|
82
|
-
## Wallet
|
|
82
|
+
## Wallet compatibility
|
|
83
83
|
|
|
84
84
|
- The action transparently handles both `sui:signAndExecuteTransaction` and
|
|
85
85
|
`sui:signAndExecuteTransactionBlock` wallet-standard features
|
|
86
86
|
- The wallet handles network submission and response
|
|
87
|
-
- Some wallets (Enoki, Enoki Connect, WalletConnect)
|
|
87
|
+
- Some wallets (Enoki, Enoki Connect, and WalletConnect) might use the dApp Kit client and execute
|
|
88
88
|
transactions within the application as an implementation detail
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sign Personal Message
|
|
2
2
|
|
|
3
|
-
> Sign an arbitrary message with the connected wallet
|
|
3
|
+
> Sign an arbitrary message with the connected wallet for authentication or proof of ownership.
|
|
4
4
|
|
|
5
5
|
The `signPersonalMessage` action prompts the connected wallet to sign a personal message. This is
|
|
6
6
|
useful for authentication, proof of ownership, or other scenarios where you need cryptographic proof
|
|
@@ -25,16 +25,16 @@ console.log('Signature:', result.signature);
|
|
|
25
25
|
|
|
26
26
|
## Parameters
|
|
27
27
|
|
|
28
|
-
- **`message
|
|
28
|
+
- **`message`:** `Uint8Array` - The message to sign as a byte array
|
|
29
29
|
|
|
30
|
-
## Return
|
|
30
|
+
## Return value
|
|
31
31
|
|
|
32
32
|
Returns a `Promise` that resolves to an object containing:
|
|
33
33
|
|
|
34
|
-
- **`bytes
|
|
35
|
-
- **`signature
|
|
34
|
+
- **`bytes`:** `string` - Base64 encoded message bytes
|
|
35
|
+
- **`signature`:** `string` - Base64 encoded signature
|
|
36
36
|
|
|
37
|
-
## Message
|
|
37
|
+
## Message format
|
|
38
38
|
|
|
39
39
|
The message parameter must be a `Uint8Array`. Common patterns for creating byte arrays:
|
|
40
40
|
|
|
@@ -48,9 +48,9 @@ const jsonMessage = new TextEncoder().encode(
|
|
|
48
48
|
await dAppKit.signPersonalMessage({ message: jsonMessage });
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
## Security
|
|
51
|
+
## Security considerations
|
|
52
52
|
|
|
53
|
-
### Message
|
|
53
|
+
### Message content
|
|
54
54
|
|
|
55
55
|
- Always display the message content clearly to users before signing
|
|
56
56
|
- Avoid signing opaque or encoded data that users cannot understand
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sign Transaction
|
|
2
2
|
|
|
3
|
-
> Sign a transaction without executing it
|
|
3
|
+
> Sign a Sui transaction without executing it for deferred or multi-signature scenarios.
|
|
4
4
|
|
|
5
5
|
The `signTransaction` action prompts the connected wallet to sign a transaction without executing
|
|
6
6
|
it. This is useful when you need a signed transaction for later execution or for multi-signature
|
|
@@ -26,16 +26,16 @@ const { bytes, signature } = await dAppKit.signTransaction({
|
|
|
26
26
|
|
|
27
27
|
## Parameters
|
|
28
28
|
|
|
29
|
-
- **`transaction
|
|
29
|
+
- **`transaction`:** `Transaction | string` - The transaction to sign. Can be either a Transaction
|
|
30
30
|
instance or base64-encoded bcs bytes for the transaction.
|
|
31
31
|
- **`signal`** (optional) - `AbortSignal` - An abort signal to cancel the signing request.
|
|
32
32
|
|
|
33
|
-
## Return
|
|
33
|
+
## Return value
|
|
34
34
|
|
|
35
35
|
Returns a `Promise` that resolves to an object containing:
|
|
36
36
|
|
|
37
|
-
- **`bytes
|
|
38
|
-
- **`signature
|
|
37
|
+
- **`bytes`:** `string` - The signed transaction as a base64-encoded BCS string
|
|
38
|
+
- **`signature`:** `string` - The signature as a base64-encoded string
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
41
|
const result = await dAppKit.signTransaction({ transaction });
|
|
@@ -43,7 +43,7 @@ console.log('Signed transaction bytes:', result.bytes);
|
|
|
43
43
|
console.log('Signature:', result.signature);
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
## Transaction
|
|
46
|
+
## Transaction building
|
|
47
47
|
|
|
48
48
|
When passing a Transaction instance, the action automatically:
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ When passing a Transaction instance, the action automatically:
|
|
|
51
51
|
2. Builds the transaction using the current network's client
|
|
52
52
|
3. Converts it to the appropriate format for the wallet
|
|
53
53
|
|
|
54
|
-
## Wallet
|
|
54
|
+
## Wallet compatibility
|
|
55
55
|
|
|
56
56
|
- The action transparently handles both `sui:signTransaction` and `sui:signTransactionBlock`
|
|
57
57
|
wallet-standard features
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Switch Account
|
|
2
2
|
|
|
3
|
-
> Switch the active account in the connected wallet
|
|
3
|
+
> Switch the active account in the connected wallet using the dApp Kit switchAccount action.
|
|
4
4
|
|
|
5
5
|
The `switchAccount` action changes the currently selected account to a different account from the
|
|
6
6
|
connected wallet.
|
|
7
7
|
|
|
8
|
-
> **Note:** The
|
|
9
|
-
> application. Changing the active account in the
|
|
10
|
-
>
|
|
8
|
+
> **Note:** The current account is a dApp Kit concept that tracks which account is active within your
|
|
9
|
+
> application. Changing the active account in the app does not affect the wallet itself, and wallets
|
|
10
|
+
> are not notified when the active account changes.
|
|
11
11
|
|
|
12
12
|
> Account switching is integrated into the [Connect Button](../web-components/connect-button) Web
|
|
13
13
|
> Component. When a wallet is connected with multiple accounts, the button provides an account
|
|
@@ -29,9 +29,9 @@ dAppKit.switchAccount({
|
|
|
29
29
|
|
|
30
30
|
## Parameters
|
|
31
31
|
|
|
32
|
-
- **`account
|
|
32
|
+
- **`account`:** `UiWalletAccount` - The account to switch to. Must be an account that belongs to
|
|
33
33
|
the currently connected wallet.
|
|
34
34
|
|
|
35
|
-
## Return
|
|
35
|
+
## Return value
|
|
36
36
|
|
|
37
37
|
Returns `void`. The action completes synchronously and updates the connection state immediately.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Switch Network
|
|
2
2
|
|
|
3
|
-
> Switch the active network for the dApp Kit instance
|
|
3
|
+
> Switch the active network for the dApp Kit instance between mainnet, testnet, and other networks.
|
|
4
4
|
|
|
5
5
|
The `switchNetwork` action changes the currently selected network that the dApp Kit client is
|
|
6
6
|
configured to use.
|
|
7
7
|
|
|
8
|
-
> **Note:** Network switching only affects your
|
|
9
|
-
> this change, and wallets are not notified when the network changes in the
|
|
8
|
+
> **Note:** Network switching only affects your app's client connection. The wallet itself is not affected by
|
|
9
|
+
> this change, and wallets are not notified when the network changes in the app.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -29,9 +29,9 @@ dAppKit.switchNetwork('testnet');
|
|
|
29
29
|
|
|
30
30
|
## Parameters
|
|
31
31
|
|
|
32
|
-
- **`network
|
|
32
|
+
- **`network`:** `TNetworks[number]`: The network to switch to. Must be one of the networks
|
|
33
33
|
configured when creating the dApp Kit instance.
|
|
34
34
|
|
|
35
|
-
## Return
|
|
35
|
+
## Return value
|
|
36
36
|
|
|
37
37
|
Returns `void`. The action completes synchronously and updates the network state immediately.
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> Create and configure a DAppKit instance for wallet and client management
|
|
4
4
|
|
|
5
|
-
The `createDAppKit` function is the foundation of your Sui
|
|
5
|
+
The `createDAppKit` function is the foundation of your Sui app. It creates an instance that manages
|
|
6
6
|
wallet connections, network configuration, and provides access to the Sui client.
|
|
7
7
|
|
|
8
|
-
## Creating a dApp Kit
|
|
8
|
+
## Creating a dApp Kit instance
|
|
9
9
|
|
|
10
10
|
The core of the dApp Kit SDK is the `createDAppKit` function, which creates an instance that manages
|
|
11
|
-
all
|
|
11
|
+
all app functionality:
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
14
|
|
|
@@ -35,22 +35,23 @@ This instance provides:
|
|
|
35
35
|
|
|
36
36
|
## Parameters
|
|
37
37
|
|
|
38
|
-
- **autoConnect** (optional)
|
|
38
|
+
- **autoConnect** (optional): Enables automatically connecting to the most recently used wallet
|
|
39
39
|
account (default: `true`)
|
|
40
|
-
- **networks
|
|
41
|
-
|
|
42
|
-
- **
|
|
43
|
-
- **
|
|
44
|
-
- **
|
|
40
|
+
- **networks:** A list of networks supported by the application (for example,
|
|
41
|
+
`['mainnet', 'testnet']`)
|
|
42
|
+
- **defaultNetwork** (optional): Initial network to use (default: first network in the array)
|
|
43
|
+
- **createClient:** Creates a new client instance for the given network
|
|
44
|
+
- **enableBurnerWallet** (optional): Enable development-only burner wallet (default: `false`)
|
|
45
|
+
- **storage** (optional): Configures how the most recently connected to wallet account is stored
|
|
45
46
|
(default: `localStorage`, set to `null` to disable)
|
|
46
|
-
- **storageKey** (optional)
|
|
47
|
+
- **storageKey** (optional): The key to use to store the most recently connected wallet account
|
|
47
48
|
(default: `'mysten-dapp-kit:selected-wallet-and-address'`)
|
|
48
|
-
- **walletInitializers** (optional)
|
|
49
|
+
- **walletInitializers** (optional): A list of wallet initializers used for registering additional
|
|
49
50
|
wallet standard wallets.
|
|
50
|
-
- **slushWalletConfig** (optional)
|
|
51
|
+
- **slushWalletConfig** (optional): Configuration for Slush wallet (set to `null` to disable the
|
|
51
52
|
wallet)
|
|
52
53
|
|
|
53
|
-
## Return
|
|
54
|
+
## Return value
|
|
54
55
|
|
|
55
56
|
```ts
|
|
56
57
|
{
|
|
@@ -77,7 +78,7 @@ This instance provides:
|
|
|
77
78
|
|
|
78
79
|
Read more about [actions](./actions/connect-wallet) and [stores](./state).
|
|
79
80
|
|
|
80
|
-
## Basic
|
|
81
|
+
## Basic usage
|
|
81
82
|
|
|
82
83
|
```ts
|
|
83
84
|
// dapp-kit.ts
|
|
@@ -111,7 +112,7 @@ const GRPC_URLS = {
|
|
|
111
112
|
> If you use the React bindings, see [Getting Started in React](./getting-started/react) and
|
|
112
113
|
> [DAppKitProvider](./react/dapp-kit-provider).
|
|
113
114
|
|
|
114
|
-
## Development
|
|
115
|
+
## Development configuration
|
|
115
116
|
|
|
116
117
|
For development environments, enable the burner wallet:
|
|
117
118
|
|
|
@@ -124,11 +125,11 @@ For development environments, enable the burner wallet:
|
|
|
124
125
|
});
|
|
125
126
|
```
|
|
126
127
|
|
|
127
|
-
## Auto-
|
|
128
|
+
## Auto-connect behavior
|
|
128
129
|
|
|
129
130
|
By default, dApp Kit automatically reconnects to the previously connected wallet.
|
|
130
131
|
|
|
131
|
-
### Disabling
|
|
132
|
+
### Disabling auto-connect
|
|
132
133
|
|
|
133
134
|
```typescript
|
|
134
135
|
|
|
@@ -139,7 +140,7 @@ By default, dApp Kit automatically reconnects to the previously connected wallet
|
|
|
139
140
|
});
|
|
140
141
|
```
|
|
141
142
|
|
|
142
|
-
## Custom
|
|
143
|
+
## Custom wallet integration
|
|
143
144
|
|
|
144
145
|
Add support for custom wallets using wallet initializers:
|
|
145
146
|
|