@mysten/dapp-kit 1.0.5 → 1.0.6
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 +12 -0
- package/dist/components/AccountDropdownMenu.css.d.ts +7 -0
- package/dist/components/AccountDropdownMenu.css.d.ts.map +1 -0
- package/dist/components/AccountDropdownMenu.d.ts +11 -0
- package/dist/components/AccountDropdownMenu.d.ts.map +1 -0
- package/dist/components/ConnectButton.d.ts +10 -0
- package/dist/components/ConnectButton.d.ts.map +1 -0
- package/dist/components/SuiClientProvider.d.ts +26 -0
- package/dist/components/SuiClientProvider.d.ts.map +1 -0
- package/dist/components/WalletProvider.d.ts +27 -0
- package/dist/components/WalletProvider.d.ts.map +1 -0
- package/dist/components/connect-modal/ConnectModal.css.d.ts +12 -0
- package/dist/components/connect-modal/ConnectModal.css.d.ts.map +1 -0
- package/dist/components/connect-modal/ConnectModal.d.ts +24 -0
- package/dist/components/connect-modal/ConnectModal.d.ts.map +1 -0
- package/dist/components/connect-modal/InfoSection.css.d.ts +2 -0
- package/dist/components/connect-modal/InfoSection.css.d.ts.map +1 -0
- package/dist/components/connect-modal/InfoSection.d.ts +7 -0
- package/dist/components/connect-modal/InfoSection.d.ts.map +1 -0
- package/dist/components/connect-modal/views/ConnectionStatus.css.d.ts +6 -0
- package/dist/components/connect-modal/views/ConnectionStatus.css.d.ts.map +1 -0
- package/dist/components/connect-modal/views/ConnectionStatus.d.ts +9 -0
- package/dist/components/connect-modal/views/ConnectionStatus.d.ts.map +1 -0
- package/dist/components/connect-modal/views/GettingStarted.css.d.ts +4 -0
- package/dist/components/connect-modal/views/GettingStarted.css.d.ts.map +1 -0
- package/dist/components/connect-modal/views/GettingStarted.d.ts +2 -0
- package/dist/components/connect-modal/views/GettingStarted.d.ts.map +1 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.css.d.ts +3 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.css.d.ts.map +1 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.d.ts +2 -0
- package/dist/components/connect-modal/views/WhatIsAWallet.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletList.css.d.ts +2 -0
- package/dist/components/connect-modal/wallet-list/WalletList.css.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletList.d.ts +10 -0
- package/dist/components/connect-modal/wallet-list/WalletList.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.css.d.ts +5 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.css.d.ts.map +1 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.d.ts +10 -0
- package/dist/components/connect-modal/wallet-list/WalletListItem.d.ts.map +1 -0
- package/dist/components/icons/BackIcon.d.ts +3 -0
- package/dist/components/icons/BackIcon.d.ts.map +1 -0
- package/dist/components/icons/CheckIcon.d.ts +3 -0
- package/dist/components/icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/ChevronIcon.d.ts +3 -0
- package/dist/components/icons/ChevronIcon.d.ts.map +1 -0
- package/dist/components/icons/CloseIcon.d.ts +3 -0
- package/dist/components/icons/CloseIcon.d.ts.map +1 -0
- package/dist/components/styling/InjectedThemeStyles.d.ts +7 -0
- package/dist/components/styling/InjectedThemeStyles.d.ts.map +1 -0
- package/dist/components/styling/StyleMarker.css.d.ts +2 -0
- package/dist/components/styling/StyleMarker.css.d.ts.map +1 -0
- package/dist/components/styling/StyleMarker.d.ts +3 -0
- package/dist/components/styling/StyleMarker.d.ts.map +1 -0
- package/dist/components/ui/Button.css.d.ts +34 -0
- package/dist/components/ui/Button.css.d.ts.map +1 -0
- package/dist/components/ui/Button.d.ts +9 -0
- package/dist/components/ui/Button.d.ts.map +1 -0
- package/dist/components/ui/Heading.css.d.ts +34 -0
- package/dist/components/ui/Heading.css.d.ts.map +1 -0
- package/dist/components/ui/Heading.d.ts +13 -0
- package/dist/components/ui/Heading.d.ts.map +1 -0
- package/dist/components/ui/IconButton.css.d.ts +2 -0
- package/dist/components/ui/IconButton.css.d.ts.map +1 -0
- package/dist/components/ui/IconButton.d.ts +7 -0
- package/dist/components/ui/IconButton.d.ts.map +1 -0
- package/dist/components/ui/Text.css.d.ts +34 -0
- package/dist/components/ui/Text.css.d.ts.map +1 -0
- package/dist/components/ui/Text.d.ts +13 -0
- package/dist/components/ui/Text.d.ts.map +1 -0
- package/dist/constants/styleDataAttribute.d.ts +6 -0
- package/dist/constants/styleDataAttribute.d.ts.map +1 -0
- package/dist/constants/walletDefaults.d.ts +7 -0
- package/dist/constants/walletDefaults.d.ts.map +1 -0
- package/dist/constants/walletMutationKeys.d.ts +14 -0
- package/dist/constants/walletMutationKeys.d.ts.map +1 -0
- package/dist/contexts/walletContext.d.ts +14 -0
- package/dist/contexts/walletContext.d.ts.map +1 -0
- package/dist/errors/walletErrors.d.ts +23 -0
- package/dist/errors/walletErrors.d.ts.map +1 -0
- package/dist/hooks/networkConfig.d.ts +11 -0
- package/dist/hooks/networkConfig.d.ts.map +1 -0
- package/dist/hooks/useResolveSuiNSNames.d.ts +4 -0
- package/dist/hooks/useResolveSuiNSNames.d.ts.map +1 -0
- package/dist/hooks/useSuiClient.d.ts +4 -0
- package/dist/hooks/useSuiClient.d.ts.map +1 -0
- package/dist/hooks/useSuiClientInfiniteQuery.d.ts +26 -0
- package/dist/hooks/useSuiClientInfiniteQuery.d.ts.map +1 -0
- package/dist/hooks/useSuiClientMutation.d.ts +5 -0
- package/dist/hooks/useSuiClientMutation.d.ts.map +1 -0
- package/dist/hooks/useSuiClientQueries.d.ts +28 -0
- package/dist/hooks/useSuiClientQueries.d.ts.map +1 -0
- package/dist/hooks/useSuiClientQuery.d.ts +39 -0
- package/dist/hooks/useSuiClientQuery.d.ts.map +1 -0
- package/dist/hooks/wallet/useAccounts.d.ts +6 -0
- package/dist/hooks/wallet/useAccounts.d.ts.map +1 -0
- package/dist/hooks/wallet/useAutoConnectWallet.d.ts +2 -0
- package/dist/hooks/wallet/useAutoConnectWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useConnectWallet.d.ts +16 -0
- package/dist/hooks/wallet/useConnectWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useCurrentAccount.d.ts +6 -0
- package/dist/hooks/wallet/useCurrentAccount.d.ts.map +1 -0
- package/dist/hooks/wallet/useCurrentWallet.d.ts +26 -0
- package/dist/hooks/wallet/useCurrentWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useDisconnectWallet.d.ts +10 -0
- package/dist/hooks/wallet/useDisconnectWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useSignAndExecuteTransaction.d.ts +30 -0
- package/dist/hooks/wallet/useSignAndExecuteTransaction.d.ts.map +1 -0
- package/dist/hooks/wallet/useSignPersonalMessage.d.ts +14 -0
- package/dist/hooks/wallet/useSignPersonalMessage.d.ts.map +1 -0
- package/dist/hooks/wallet/useSignTransaction.d.ts +18 -0
- package/dist/hooks/wallet/useSignTransaction.d.ts.map +1 -0
- package/dist/hooks/wallet/useSlushWallet.d.ts +6 -0
- package/dist/hooks/wallet/useSlushWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useSwitchAccount.d.ts +15 -0
- package/dist/hooks/wallet/useSwitchAccount.d.ts.map +1 -0
- package/dist/hooks/wallet/useUnsafeBurnerWallet.d.ts +2 -0
- package/dist/hooks/wallet/useUnsafeBurnerWallet.d.ts.map +1 -0
- package/dist/hooks/wallet/useWalletPropertiesChanged.d.ts +5 -0
- package/dist/hooks/wallet/useWalletPropertiesChanged.d.ts.map +1 -0
- package/dist/hooks/wallet/useWalletStore.d.ts +3 -0
- package/dist/hooks/wallet/useWalletStore.d.ts.map +1 -0
- package/dist/hooks/wallet/useWallets.d.ts +5 -0
- package/dist/hooks/wallet/useWallets.d.ts.map +1 -0
- package/dist/hooks/wallet/useWalletsChanged.d.ts +6 -0
- package/dist/hooks/wallet/useWalletsChanged.d.ts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/themes/lightTheme.d.ts +3 -0
- package/dist/themes/lightTheme.d.ts.map +1 -0
- package/dist/themes/themeContract.d.ts +141 -0
- package/dist/themes/themeContract.d.ts.map +1 -0
- package/dist/types/utilityTypes.d.ts +2 -0
- package/dist/types/utilityTypes.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/assertUnreachable.d.ts +5 -0
- package/dist/utils/assertUnreachable.d.ts.map +1 -0
- package/dist/utils/stateStorage.d.ts +3 -0
- package/dist/utils/stateStorage.d.ts.map +1 -0
- package/dist/utils/walletUtils.d.ts +4 -0
- package/dist/utils/walletUtils.d.ts.map +1 -0
- package/dist/walletStore.d.ts +45 -0
- package/dist/walletStore.d.ts.map +1 -0
- package/docs/index.md +93 -0
- package/docs/llms-index.md +22 -0
- package/docs/rpc-hooks.md +166 -0
- package/docs/slush.md +29 -0
- package/docs/sui-client-provider.md +196 -0
- package/docs/themes.md +117 -0
- package/docs/wallet-components/ConnectButton.md +22 -0
- package/docs/wallet-components/ConnectModal.md +67 -0
- package/docs/wallet-hooks/useAccounts.md +36 -0
- package/docs/wallet-hooks/useAutoConnectWallet.md +29 -0
- package/docs/wallet-hooks/useConnectWallet.md +48 -0
- package/docs/wallet-hooks/useCurrentAccount.md +36 -0
- package/docs/wallet-hooks/useCurrentWallet.md +59 -0
- package/docs/wallet-hooks/useDisconnectWallet.md +26 -0
- package/docs/wallet-hooks/useSignAndExecuteTransaction.md +124 -0
- package/docs/wallet-hooks/useSignPersonalMessage.md +59 -0
- package/docs/wallet-hooks/useSignTransaction.md +67 -0
- package/docs/wallet-hooks/useSwitchAccount.md +47 -0
- package/docs/wallet-hooks/useWallets.md +38 -0
- package/docs/wallet-provider.md +38 -0
- package/package.json +5 -5
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# useSignAndExecuteTransaction
|
|
2
|
+
|
|
3
|
+
> Legacy React hook to sign and execute a transaction block on the Sui network.
|
|
4
|
+
|
|
5
|
+
Use the `useSignAndExecuteTransaction` hook to prompt the user to sign and execute a transaction
|
|
6
|
+
block with their wallet.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
|
|
10
|
+
function MyComponent() {
|
|
11
|
+
const { mutate: signAndExecuteTransaction } = useSignAndExecuteTransaction();
|
|
12
|
+
const [digest, setDigest] = useState('');
|
|
13
|
+
const currentAccount = useCurrentAccount();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ padding: 20 }}>
|
|
17
|
+
<ConnectButton />
|
|
18
|
+
{currentAccount && (
|
|
19
|
+
<>
|
|
20
|
+
<div>
|
|
21
|
+
<button
|
|
22
|
+
onClick={() => {
|
|
23
|
+
signAndExecuteTransaction(
|
|
24
|
+
{
|
|
25
|
+
transaction: new Transaction(),
|
|
26
|
+
chain: 'sui:devnet',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
onSuccess: (result) => {
|
|
30
|
+
console.log('executed transaction', result);
|
|
31
|
+
setDigest(result.digest);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
Sign and execute transaction
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
<div>Digest: {digest}</div>
|
|
41
|
+
</>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Example
|
|
49
|
+
|
|
50
|
+
## Return additional data, or executing through GraphQL
|
|
51
|
+
|
|
52
|
+
To customize how transactions are executed, and what data is returned when executing a transaction,
|
|
53
|
+
you can pass a custom `execute` function.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
|
|
57
|
+
ConnectButton,
|
|
58
|
+
useSuiClient,
|
|
59
|
+
useCurrentAccount,
|
|
60
|
+
useSignAndExecuteTransaction,
|
|
61
|
+
} from '@mysten/dapp-kit';
|
|
62
|
+
|
|
63
|
+
function MyComponent() {
|
|
64
|
+
const client = useSuiClient();
|
|
65
|
+
const { mutate: signAndExecuteTransaction } = useSignAndExecuteTransaction({
|
|
66
|
+
execute: async ({ bytes, signature }) =>
|
|
67
|
+
await client.executeTransactionBlock({
|
|
68
|
+
transactionBlock: bytes,
|
|
69
|
+
signature,
|
|
70
|
+
options: {
|
|
71
|
+
// Raw effects are required so the effects can be reported back to the wallet
|
|
72
|
+
showRawEffects: true,
|
|
73
|
+
// Select additional data to return
|
|
74
|
+
showObjectChanges: true,
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const [digest, setDigest] = useState('');
|
|
80
|
+
const currentAccount = useCurrentAccount();
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div style={{ padding: 20 }}>
|
|
84
|
+
<ConnectButton />
|
|
85
|
+
{currentAccount && (
|
|
86
|
+
<>
|
|
87
|
+
<div>
|
|
88
|
+
<button
|
|
89
|
+
onClick={() => {
|
|
90
|
+
signAndExecuteTransaction(
|
|
91
|
+
{
|
|
92
|
+
transaction: new Transaction(),
|
|
93
|
+
chain: 'sui:devnet',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
onSuccess: (result) => {
|
|
97
|
+
console.log('object changes', result.objectChanges);
|
|
98
|
+
setDigest(result.digest);
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
Sign and execute transaction
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
<div>Digest: {digest}</div>
|
|
108
|
+
</>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Arguments
|
|
116
|
+
|
|
117
|
+
- `transaction`: The transaction to sign and execute.
|
|
118
|
+
- `chain`: (optional) The chain identifier the transaction should be signed for. Defaults to the
|
|
119
|
+
active network of the app.
|
|
120
|
+
- `execute`: (optional) A custom function to execute the transaction
|
|
121
|
+
|
|
122
|
+
In addition to these options, you can also pass any options that the
|
|
123
|
+
[SuiJsonRpcClient.signAndExecuteTransaction](/typedoc/classes/_mysten_sui.client.SuiJsonRpcClient.html#signAndExecuteTransactionBlock)
|
|
124
|
+
method accepts.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# useSignPersonalMessage
|
|
2
|
+
|
|
3
|
+
> Legacy React hook to sign a personal message with the connected wallet.
|
|
4
|
+
|
|
5
|
+
Use the `useSignPersonalMessage` hook to prompt the user to sign a message with their wallet.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
|
|
9
|
+
function MyComponent() {
|
|
10
|
+
const { mutate: signPersonalMessage } = useSignPersonalMessage();
|
|
11
|
+
const [message, setMessage] = useState('hello, World!');
|
|
12
|
+
const [signature, setSignature] = useState('');
|
|
13
|
+
const currentAccount = useCurrentAccount();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div style={{ padding: 20 }}>
|
|
17
|
+
<ConnectButton />
|
|
18
|
+
{currentAccount && (
|
|
19
|
+
<>
|
|
20
|
+
<div>
|
|
21
|
+
<label>
|
|
22
|
+
Message:{' '}
|
|
23
|
+
<input type="text" value={message} onChange={(ev) => setMessage(ev.target.value)} />
|
|
24
|
+
</label>
|
|
25
|
+
</div>
|
|
26
|
+
<button
|
|
27
|
+
onClick={() => {
|
|
28
|
+
signPersonalMessage(
|
|
29
|
+
{
|
|
30
|
+
message: new TextEncoder().encode(message),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
onSuccess: (result) => setSignature(result.signature),
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
Sign message
|
|
39
|
+
</button>
|
|
40
|
+
<div>Signature: {signature}</div>
|
|
41
|
+
</>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Example
|
|
49
|
+
|
|
50
|
+
## Arguments
|
|
51
|
+
|
|
52
|
+
- `message`: The message to sign, as a `Uint8Array`.
|
|
53
|
+
- `chain`: (optional) The chain identifier the message should be signed for. Defaults to the active
|
|
54
|
+
network of the app.
|
|
55
|
+
|
|
56
|
+
## Result
|
|
57
|
+
|
|
58
|
+
- `signature`: The signature of the message, as a `Base64`-encoded `string`.
|
|
59
|
+
- `bytes`: The bytes of the message, as a `Base64`-encoded `string`.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# useSignTransaction
|
|
2
|
+
|
|
3
|
+
> Legacy React hook to sign a transaction without executing it on the Sui network.
|
|
4
|
+
|
|
5
|
+
Use the `useSignTransaction` hook to prompt the user to sign a transaction with their wallet.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
|
|
9
|
+
ConnectButton,
|
|
10
|
+
useCurrentAccount,
|
|
11
|
+
useSignTransaction,
|
|
12
|
+
useSuiClient,
|
|
13
|
+
} from '@mysten/dapp-kit';
|
|
14
|
+
|
|
15
|
+
function MyComponent() {
|
|
16
|
+
const { mutateAsync: signTransaction } = useSignTransaction();
|
|
17
|
+
const [signature, setSignature] = useState('');
|
|
18
|
+
const client = useSuiClient();
|
|
19
|
+
const currentAccount = useCurrentAccount();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div style={{ padding: 20 }}>
|
|
23
|
+
<ConnectButton />
|
|
24
|
+
{currentAccount && (
|
|
25
|
+
<>
|
|
26
|
+
<div>
|
|
27
|
+
<button
|
|
28
|
+
onClick={async () => {
|
|
29
|
+
const { bytes, signature } = await signTransaction({
|
|
30
|
+
transaction: new Transaction(),
|
|
31
|
+
chain: 'sui:devnet',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const executeResult = await client.executeTransactionBlock({
|
|
35
|
+
transactionBlock: bytes,
|
|
36
|
+
signature,
|
|
37
|
+
options: {
|
|
38
|
+
showRawEffects: true,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
console.log(executeResult);
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
Sign empty transaction
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
<div>Signature: {signature}</div>
|
|
49
|
+
</>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Example
|
|
57
|
+
|
|
58
|
+
## Arguments
|
|
59
|
+
|
|
60
|
+
- `transactionBlock`: The transaction to sign.
|
|
61
|
+
- `chain`: (optional) The chain identifier the transaction should be signed for. Defaults to the
|
|
62
|
+
active network of the app.
|
|
63
|
+
|
|
64
|
+
## Result
|
|
65
|
+
|
|
66
|
+
- `signature`: The signature of the message, as a Base64-encoded `string`.
|
|
67
|
+
- `bytes`: The serialized transaction bytes, as a Base64-encoded `string`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# useSwitchAccount
|
|
2
|
+
|
|
3
|
+
> Legacy React mutation hook to switch the active wallet account.
|
|
4
|
+
|
|
5
|
+
The `useSwitchAccount` hook is a mutation hook for establishing a connection to a specific wallet.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
|
|
9
|
+
function MyComponent() {
|
|
10
|
+
const { mutate: switchAccount } = useSwitchAccount();
|
|
11
|
+
const accounts = useAccounts();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div style={{ padding: 20 }}>
|
|
15
|
+
<ConnectButton />
|
|
16
|
+
<ul>
|
|
17
|
+
{accounts.map((account) => (
|
|
18
|
+
<li key={account.address}>
|
|
19
|
+
<button
|
|
20
|
+
onClick={() => {
|
|
21
|
+
switchAccount(
|
|
22
|
+
{ account },
|
|
23
|
+
{
|
|
24
|
+
onSuccess: () => console.log(`switched to ${account.address}`),
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
Switch to {account.address}
|
|
30
|
+
</button>
|
|
31
|
+
</li>
|
|
32
|
+
))}
|
|
33
|
+
</ul>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Example
|
|
40
|
+
|
|
41
|
+
## Arguments
|
|
42
|
+
|
|
43
|
+
- `args`: Arguments passed to the `connect` function of the wallet.
|
|
44
|
+
- `account`: The account to switch to.
|
|
45
|
+
|
|
46
|
+
- `options`: Options passed the `useMutation` hook from
|
|
47
|
+
[@tanstack/react-query](https://tanstack.com/query/latest/docs/react/guides/mutations).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# useWallets
|
|
2
|
+
|
|
3
|
+
> Legacy React hook to list available wallet extensions sorted by priority.
|
|
4
|
+
|
|
5
|
+
The `useWallets` hook returns an array of wallets that are available to the user. The wallets are
|
|
6
|
+
sorted by their priority, with the highest priority wallet being the first in the array.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
|
|
10
|
+
function MyComponent() {
|
|
11
|
+
const wallets = useWallets();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<h2>Installed wallets</h2>
|
|
16
|
+
{wallets.length === 0 && <div>No wallets installed</div>}
|
|
17
|
+
<ul>
|
|
18
|
+
{wallets.map((wallet) => (
|
|
19
|
+
<li key={wallet.name}>{wallet.name}</li>
|
|
20
|
+
))}
|
|
21
|
+
</ul>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
## Wallet properties
|
|
30
|
+
|
|
31
|
+
- `name`: The name of the wallet.
|
|
32
|
+
- `version`: The version of the wallet as a string.
|
|
33
|
+
- `icon`: A data URL of the wallet icon as an SVG.
|
|
34
|
+
- `accounts`: An array of accounts that are available in the wallet.
|
|
35
|
+
- `features`: An object with all the
|
|
36
|
+
[wallet-standard](https://github.com/wallet-standard/wallet-standard) features implemented by the
|
|
37
|
+
wallet.
|
|
38
|
+
- `chains`: An array of chain identifiers that the wallet supports.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# WalletProvider
|
|
2
|
+
|
|
3
|
+
> React context provider for wallet connections in legacy dApp Kit.
|
|
4
|
+
|
|
5
|
+
Use `WalletProvider` to set up the necessary context for your React app. Use it at the root of your
|
|
6
|
+
app, so that you can use any of the dApp Kit wallet components underneath it.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
|
|
10
|
+
function App() {
|
|
11
|
+
return (
|
|
12
|
+
<WalletProvider>
|
|
13
|
+
<YourApp />
|
|
14
|
+
</WalletProvider>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The `WalletProvider` manages all wallet state for you, and makes the current wallet state available
|
|
20
|
+
to other dApp Kit hooks and components.
|
|
21
|
+
|
|
22
|
+
### Props
|
|
23
|
+
|
|
24
|
+
All props are optional.
|
|
25
|
+
|
|
26
|
+
- `preferredWallets`: A list of wallets that are sorted to the top of the wallet list.
|
|
27
|
+
- `walletFilter`: A filter function that accepts a wallet and returns a boolean. This filters the
|
|
28
|
+
list of wallets presented to users when selecting a wallet to connect from, ensuring that only
|
|
29
|
+
wallets that meet the app requirements can connect.
|
|
30
|
+
- `enableUnsafeBurner`: Enables the development-only unsafe burner wallet, useful for testing.
|
|
31
|
+
- `autoConnect`: Enables automatically reconnecting to the most recently used wallet account upon
|
|
32
|
+
mounting.
|
|
33
|
+
- `slushWallet`: Enables and configures the Slush wallet. Read more about how to
|
|
34
|
+
[use the Slush integration](./slush).
|
|
35
|
+
- `storage`: Configures how the most recently connected-to wallet account is stored. Set to `null`
|
|
36
|
+
to disable persisting state entirely. Defaults to using `localStorage` if it is available.
|
|
37
|
+
- `storageKey`: The key to use to store the most recently connected wallet account.
|
|
38
|
+
- `theme`: The theme to use for styling UI components. Defaults to using the light theme.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "A collection of React hooks and components for interacting with the Sui blockchain and wallets.",
|
|
5
5
|
"homepage": "https://sdk.mystenlabs.com/dapp-kit",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.6",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"CHANGELOG.md",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
"@vanilla-extract/recipes": "^0.5.7",
|
|
66
66
|
"clsx": "^2.1.1",
|
|
67
67
|
"zustand": "^5.0.10",
|
|
68
|
-
"@mysten/utils": "^0.3.
|
|
69
|
-
"@mysten/wallet
|
|
70
|
-
"@mysten/
|
|
68
|
+
"@mysten/utils": "^0.3.3",
|
|
69
|
+
"@mysten/slush-wallet": "^1.0.5",
|
|
70
|
+
"@mysten/wallet-standard": "^0.20.3"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@tanstack/react-query": "^5.0.0",
|
|
74
74
|
"react": "*",
|
|
75
|
-
"@mysten/sui": "^2.16.
|
|
75
|
+
"@mysten/sui": "^2.16.2"
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": [
|
|
78
78
|
"*.css.ts",
|