@mysten/dapp-kit 1.0.4 → 1.0.5
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 +14 -0
- package/package.json +10 -13
- package/dist/components/AccountDropdownMenu.css.d.ts +0 -7
- package/dist/components/AccountDropdownMenu.css.d.ts.map +0 -1
- package/dist/components/AccountDropdownMenu.d.ts +0 -11
- package/dist/components/AccountDropdownMenu.d.ts.map +0 -1
- package/dist/components/ConnectButton.d.ts +0 -10
- package/dist/components/ConnectButton.d.ts.map +0 -1
- package/dist/components/SuiClientProvider.d.ts +0 -26
- package/dist/components/SuiClientProvider.d.ts.map +0 -1
- package/dist/components/WalletProvider.d.ts +0 -27
- package/dist/components/WalletProvider.d.ts.map +0 -1
- package/dist/components/connect-modal/ConnectModal.css.d.ts +0 -12
- package/dist/components/connect-modal/ConnectModal.css.d.ts.map +0 -1
- package/dist/components/connect-modal/ConnectModal.d.ts +0 -24
- package/dist/components/connect-modal/ConnectModal.d.ts.map +0 -1
- package/dist/components/connect-modal/InfoSection.css.d.ts +0 -2
- package/dist/components/connect-modal/InfoSection.css.d.ts.map +0 -1
- package/dist/components/connect-modal/InfoSection.d.ts +0 -7
- package/dist/components/connect-modal/InfoSection.d.ts.map +0 -1
- package/dist/components/connect-modal/views/ConnectionStatus.css.d.ts +0 -6
- package/dist/components/connect-modal/views/ConnectionStatus.css.d.ts.map +0 -1
- package/dist/components/connect-modal/views/ConnectionStatus.d.ts +0 -9
- package/dist/components/connect-modal/views/ConnectionStatus.d.ts.map +0 -1
- package/dist/components/connect-modal/views/GettingStarted.css.d.ts +0 -4
- package/dist/components/connect-modal/views/GettingStarted.css.d.ts.map +0 -1
- package/dist/components/connect-modal/views/GettingStarted.d.ts +0 -2
- package/dist/components/connect-modal/views/GettingStarted.d.ts.map +0 -1
- package/dist/components/connect-modal/views/WhatIsAWallet.css.d.ts +0 -3
- package/dist/components/connect-modal/views/WhatIsAWallet.css.d.ts.map +0 -1
- package/dist/components/connect-modal/views/WhatIsAWallet.d.ts +0 -2
- package/dist/components/connect-modal/views/WhatIsAWallet.d.ts.map +0 -1
- package/dist/components/connect-modal/wallet-list/WalletList.css.d.ts +0 -2
- package/dist/components/connect-modal/wallet-list/WalletList.css.d.ts.map +0 -1
- package/dist/components/connect-modal/wallet-list/WalletList.d.ts +0 -10
- package/dist/components/connect-modal/wallet-list/WalletList.d.ts.map +0 -1
- package/dist/components/connect-modal/wallet-list/WalletListItem.css.d.ts +0 -5
- package/dist/components/connect-modal/wallet-list/WalletListItem.css.d.ts.map +0 -1
- package/dist/components/connect-modal/wallet-list/WalletListItem.d.ts +0 -10
- package/dist/components/connect-modal/wallet-list/WalletListItem.d.ts.map +0 -1
- package/dist/components/icons/BackIcon.d.ts +0 -3
- package/dist/components/icons/BackIcon.d.ts.map +0 -1
- package/dist/components/icons/CheckIcon.d.ts +0 -3
- package/dist/components/icons/CheckIcon.d.ts.map +0 -1
- package/dist/components/icons/ChevronIcon.d.ts +0 -3
- package/dist/components/icons/ChevronIcon.d.ts.map +0 -1
- package/dist/components/icons/CloseIcon.d.ts +0 -3
- package/dist/components/icons/CloseIcon.d.ts.map +0 -1
- package/dist/components/styling/InjectedThemeStyles.d.ts +0 -7
- package/dist/components/styling/InjectedThemeStyles.d.ts.map +0 -1
- package/dist/components/styling/StyleMarker.css.d.ts +0 -2
- package/dist/components/styling/StyleMarker.css.d.ts.map +0 -1
- package/dist/components/styling/StyleMarker.d.ts +0 -3
- package/dist/components/styling/StyleMarker.d.ts.map +0 -1
- package/dist/components/ui/Button.css.d.ts +0 -34
- package/dist/components/ui/Button.css.d.ts.map +0 -1
- package/dist/components/ui/Button.d.ts +0 -9
- package/dist/components/ui/Button.d.ts.map +0 -1
- package/dist/components/ui/Heading.css.d.ts +0 -34
- package/dist/components/ui/Heading.css.d.ts.map +0 -1
- package/dist/components/ui/Heading.d.ts +0 -13
- package/dist/components/ui/Heading.d.ts.map +0 -1
- package/dist/components/ui/IconButton.css.d.ts +0 -2
- package/dist/components/ui/IconButton.css.d.ts.map +0 -1
- package/dist/components/ui/IconButton.d.ts +0 -7
- package/dist/components/ui/IconButton.d.ts.map +0 -1
- package/dist/components/ui/Text.css.d.ts +0 -34
- package/dist/components/ui/Text.css.d.ts.map +0 -1
- package/dist/components/ui/Text.d.ts +0 -13
- package/dist/components/ui/Text.d.ts.map +0 -1
- package/dist/constants/styleDataAttribute.d.ts +0 -6
- package/dist/constants/styleDataAttribute.d.ts.map +0 -1
- package/dist/constants/walletDefaults.d.ts +0 -7
- package/dist/constants/walletDefaults.d.ts.map +0 -1
- package/dist/constants/walletMutationKeys.d.ts +0 -14
- package/dist/constants/walletMutationKeys.d.ts.map +0 -1
- package/dist/contexts/walletContext.d.ts +0 -14
- package/dist/contexts/walletContext.d.ts.map +0 -1
- package/dist/errors/walletErrors.d.ts +0 -23
- package/dist/errors/walletErrors.d.ts.map +0 -1
- package/dist/hooks/networkConfig.d.ts +0 -11
- package/dist/hooks/networkConfig.d.ts.map +0 -1
- package/dist/hooks/useResolveSuiNSNames.d.ts +0 -4
- package/dist/hooks/useResolveSuiNSNames.d.ts.map +0 -1
- package/dist/hooks/useSuiClient.d.ts +0 -4
- package/dist/hooks/useSuiClient.d.ts.map +0 -1
- package/dist/hooks/useSuiClientInfiniteQuery.d.ts +0 -26
- package/dist/hooks/useSuiClientInfiniteQuery.d.ts.map +0 -1
- package/dist/hooks/useSuiClientMutation.d.ts +0 -5
- package/dist/hooks/useSuiClientMutation.d.ts.map +0 -1
- package/dist/hooks/useSuiClientQueries.d.ts +0 -28
- package/dist/hooks/useSuiClientQueries.d.ts.map +0 -1
- package/dist/hooks/useSuiClientQuery.d.ts +0 -39
- package/dist/hooks/useSuiClientQuery.d.ts.map +0 -1
- package/dist/hooks/wallet/useAccounts.d.ts +0 -6
- package/dist/hooks/wallet/useAccounts.d.ts.map +0 -1
- package/dist/hooks/wallet/useAutoConnectWallet.d.ts +0 -2
- package/dist/hooks/wallet/useAutoConnectWallet.d.ts.map +0 -1
- package/dist/hooks/wallet/useConnectWallet.d.ts +0 -16
- package/dist/hooks/wallet/useConnectWallet.d.ts.map +0 -1
- package/dist/hooks/wallet/useCurrentAccount.d.ts +0 -6
- package/dist/hooks/wallet/useCurrentAccount.d.ts.map +0 -1
- package/dist/hooks/wallet/useCurrentWallet.d.ts +0 -26
- package/dist/hooks/wallet/useCurrentWallet.d.ts.map +0 -1
- package/dist/hooks/wallet/useDisconnectWallet.d.ts +0 -10
- package/dist/hooks/wallet/useDisconnectWallet.d.ts.map +0 -1
- package/dist/hooks/wallet/useSignAndExecuteTransaction.d.ts +0 -30
- package/dist/hooks/wallet/useSignAndExecuteTransaction.d.ts.map +0 -1
- package/dist/hooks/wallet/useSignPersonalMessage.d.ts +0 -14
- package/dist/hooks/wallet/useSignPersonalMessage.d.ts.map +0 -1
- package/dist/hooks/wallet/useSignTransaction.d.ts +0 -18
- package/dist/hooks/wallet/useSignTransaction.d.ts.map +0 -1
- package/dist/hooks/wallet/useSlushWallet.d.ts +0 -6
- package/dist/hooks/wallet/useSlushWallet.d.ts.map +0 -1
- package/dist/hooks/wallet/useSwitchAccount.d.ts +0 -15
- package/dist/hooks/wallet/useSwitchAccount.d.ts.map +0 -1
- package/dist/hooks/wallet/useUnsafeBurnerWallet.d.ts +0 -2
- package/dist/hooks/wallet/useUnsafeBurnerWallet.d.ts.map +0 -1
- package/dist/hooks/wallet/useWalletPropertiesChanged.d.ts +0 -5
- package/dist/hooks/wallet/useWalletPropertiesChanged.d.ts.map +0 -1
- package/dist/hooks/wallet/useWalletStore.d.ts +0 -3
- package/dist/hooks/wallet/useWalletStore.d.ts.map +0 -1
- package/dist/hooks/wallet/useWallets.d.ts +0 -5
- package/dist/hooks/wallet/useWallets.d.ts.map +0 -1
- package/dist/hooks/wallet/useWalletsChanged.d.ts +0 -6
- package/dist/hooks/wallet/useWalletsChanged.d.ts.map +0 -1
- package/dist/index.d.ts +0 -26
- package/dist/index.d.ts.map +0 -1
- package/dist/themes/lightTheme.d.ts +0 -3
- package/dist/themes/lightTheme.d.ts.map +0 -1
- package/dist/themes/themeContract.d.ts +0 -141
- package/dist/themes/themeContract.d.ts.map +0 -1
- package/dist/types/utilityTypes.d.ts +0 -2
- package/dist/types/utilityTypes.d.ts.map +0 -1
- package/dist/types.d.ts +0 -3
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/assertUnreachable.d.ts +0 -5
- package/dist/utils/assertUnreachable.d.ts.map +0 -1
- package/dist/utils/stateStorage.d.ts +0 -3
- package/dist/utils/stateStorage.d.ts.map +0 -1
- package/dist/utils/walletUtils.d.ts +0 -4
- package/dist/utils/walletUtils.d.ts.map +0 -1
- package/dist/walletStore.d.ts +0 -45
- package/dist/walletStore.d.ts.map +0 -1
- package/docs/index.md +0 -91
- package/docs/llms-index.md +0 -27
- package/docs/rpc-hooks.md +0 -161
- package/docs/slush.md +0 -29
- package/docs/sui-client-provider.md +0 -191
- package/docs/themes.md +0 -115
- package/docs/wallet-components/ConnectButton.md +0 -22
- package/docs/wallet-components/ConnectModal.md +0 -66
- package/docs/wallet-hooks/useAccounts.md +0 -36
- package/docs/wallet-hooks/useAutoConnectWallet.md +0 -29
- package/docs/wallet-hooks/useConnectWallet.md +0 -48
- package/docs/wallet-hooks/useCurrentAccount.md +0 -36
- package/docs/wallet-hooks/useCurrentWallet.md +0 -59
- package/docs/wallet-hooks/useDisconnectWallet.md +0 -26
- package/docs/wallet-hooks/useSignAndExecuteTransaction.md +0 -124
- package/docs/wallet-hooks/useSignPersonalMessage.md +0 -59
- package/docs/wallet-hooks/useSignTransaction.md +0 -67
- package/docs/wallet-hooks/useSwitchAccount.md +0 -47
- package/docs/wallet-hooks/useWallets.md +0 -38
- package/docs/wallet-provider.md +0 -37
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# SuiClientProvider
|
|
2
|
-
|
|
3
|
-
> React provider for Sui client configuration
|
|
4
|
-
|
|
5
|
-
The `SuiClientProvider` manages the active `SuiJsonRpcClient` that hooks and components use in the
|
|
6
|
-
dApp Kit.
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
|
|
10
|
-
Place the `SuiClientProvider` at the root of your app and wrap all components that use the dApp Kit
|
|
11
|
-
hooks.
|
|
12
|
-
|
|
13
|
-
`SuiClientProvider` accepts a list of network configurations to create `SuiJsonRpcClient` instances
|
|
14
|
-
for the currently active network.
|
|
15
|
-
|
|
16
|
-
```tsx
|
|
17
|
-
// Config options for the networks you want to connect to
|
|
18
|
-
const { networkConfig } = createNetworkConfig({
|
|
19
|
-
localnet: { url: getJsonRpcFullnodeUrl('localnet') },
|
|
20
|
-
mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
function App() {
|
|
24
|
-
return (
|
|
25
|
-
<SuiClientProvider networks={networkConfig} defaultNetwork="localnet">
|
|
26
|
-
<YourApp />
|
|
27
|
-
</SuiClientProvider>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Props
|
|
33
|
-
|
|
34
|
-
- `networks`: A map of networks you can use. The keys are the network names, and the values can be
|
|
35
|
-
either a configuration object (`SuiClientOptions`) or a `SuiJsonRpcClient` instance.
|
|
36
|
-
- `defaultNetwork`: The name of the network to use by default when using the `SuiClientProvider` as
|
|
37
|
-
an uncontrolled component.
|
|
38
|
-
- `network`: The name of the network to use when using the `SuiClientProvider` as a controlled
|
|
39
|
-
component.
|
|
40
|
-
- `onNetworkChange`: A callback when the active network changes.
|
|
41
|
-
- `createClient`: A callback when a new `SuiJsonRpcClient` is created (for example, when the active
|
|
42
|
-
network changes). It receives the network name and configuration object as arguments, returning a
|
|
43
|
-
`SuiJsonRpcClient` instance.
|
|
44
|
-
|
|
45
|
-
## Controlled component
|
|
46
|
-
|
|
47
|
-
The following example demonstrates a `SuiClientProvider` used as a controlled component.
|
|
48
|
-
|
|
49
|
-
```tsx
|
|
50
|
-
// Config options for the networks you want to connect to
|
|
51
|
-
const { networkConfig } = createNetworkConfig({
|
|
52
|
-
localnet: { url: getJsonRpcFullnodeUrl('localnet') },
|
|
53
|
-
mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
function App() {
|
|
57
|
-
const [activeNetwork, setActiveNetwork] = useState('localnet' as keyof typeof networks);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<SuiClientProvider
|
|
61
|
-
networks={networkConfig}
|
|
62
|
-
network={activeNetwork}
|
|
63
|
-
onNetworkChange={(network) => {
|
|
64
|
-
setActiveNetwork(network);
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
<YourApp />
|
|
68
|
-
</SuiClientProvider>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## SuiJsonRpcClient customization
|
|
74
|
-
|
|
75
|
-
The following example demonstrates how to create a custom `SuiJsonRpcClient`.
|
|
76
|
-
|
|
77
|
-
```tsx
|
|
78
|
-
// Config options for the networks you want to connect to
|
|
79
|
-
const networks = {
|
|
80
|
-
localnet: { url: getJsonRpcFullnodeUrl('localnet') },
|
|
81
|
-
mainnet: { url: getJsonRpcFullnodeUrl('mainnet') },
|
|
82
|
-
} satisfies Record<string, SuiClientOptions>;
|
|
83
|
-
|
|
84
|
-
function App() {
|
|
85
|
-
return (
|
|
86
|
-
<SuiClientProvider
|
|
87
|
-
networks={networks}
|
|
88
|
-
defaultNetwork="localnet"
|
|
89
|
-
createClient={(network, config) => {
|
|
90
|
-
return new SuiJsonRpcClient({
|
|
91
|
-
transport: new SuiHTTPTransport({
|
|
92
|
-
url: 'https://api.safecoin.org',
|
|
93
|
-
rpc: {
|
|
94
|
-
headers: {
|
|
95
|
-
Authorization: 'xyz',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
}),
|
|
99
|
-
});
|
|
100
|
-
}}
|
|
101
|
-
>
|
|
102
|
-
<YourApp />
|
|
103
|
-
</SuiClientProvider>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Using the SuiJsonRpcClient from the provider
|
|
109
|
-
|
|
110
|
-
To use the `SuiJsonRpcClient` from the provider, import the `useSuiClient` function from the
|
|
111
|
-
`@mysten/dapp-kit` module.
|
|
112
|
-
|
|
113
|
-
```tsx
|
|
114
|
-
function MyComponent() {
|
|
115
|
-
const client = useSuiClient();
|
|
116
|
-
|
|
117
|
-
// use the client
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Creating a network selector
|
|
122
|
-
|
|
123
|
-
The dApp Kit doesn't provide its own network switcher, but you can use the `useSuiClientContext`
|
|
124
|
-
hook to get the list of networks and set the active one:
|
|
125
|
-
|
|
126
|
-
```tsx
|
|
127
|
-
function NetworkSelector() {
|
|
128
|
-
const ctx = useSuiClientContext();
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<div>
|
|
132
|
-
{Object.keys(ctx.networks).map((network) => (
|
|
133
|
-
<button key={network} onClick={() => ctx.selectNetwork(network)}>
|
|
134
|
-
{`select ${network}`}
|
|
135
|
-
</button>
|
|
136
|
-
))}
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Using network specific configuration
|
|
143
|
-
|
|
144
|
-
If your dApp runs on multiple networks, the IDs for packages and other configurations might change,
|
|
145
|
-
depending on which network you're using. You can use `createNetworkConfig` to create per-network
|
|
146
|
-
configurations that your components can access.
|
|
147
|
-
|
|
148
|
-
The `createNetworkConfig` function returns the provided configuration, along with hooks you can use
|
|
149
|
-
to get the variables defined in your configuration.
|
|
150
|
-
|
|
151
|
-
- `useNetworkConfig` returns the full network configuration object
|
|
152
|
-
- `useNetworkVariables` returns the full variables object from the network configuration
|
|
153
|
-
- `useNetworkVariable` returns a specific variable from the network configuration
|
|
154
|
-
|
|
155
|
-
```tsx
|
|
156
|
-
// Config options for the networks you want to connect to
|
|
157
|
-
const { networkConfig, useNetworkVariable } = createNetworkConfig({
|
|
158
|
-
localnet: {
|
|
159
|
-
url: getJsonRpcFullnodeUrl('localnet'),
|
|
160
|
-
variables: {
|
|
161
|
-
myMovePackageId: '0x123',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
mainnet: {
|
|
165
|
-
url: getJsonRpcFullnodeUrl('mainnet'),
|
|
166
|
-
variables: {
|
|
167
|
-
myMovePackageId: '0x456',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
const queryClient = new QueryClient();
|
|
173
|
-
|
|
174
|
-
function App() {
|
|
175
|
-
return (
|
|
176
|
-
<QueryClientProvider client={queryClient}>
|
|
177
|
-
<SuiClientProvider networks={networkConfig} defaultNetwork="localnet">
|
|
178
|
-
<WalletProvider>
|
|
179
|
-
<YourApp />
|
|
180
|
-
</WalletProvider>
|
|
181
|
-
</SuiClientProvider>
|
|
182
|
-
</QueryClientProvider>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function YourApp() {
|
|
187
|
-
const id = useNetworkVariable('myMovePackageId');
|
|
188
|
-
|
|
189
|
-
return <div>Package ID: {id}</div>;
|
|
190
|
-
}
|
|
191
|
-
```
|
package/docs/themes.md
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Themes
|
|
2
|
-
|
|
3
|
-
> theming API for dApp Kit components
|
|
4
|
-
|
|
5
|
-
You can provide a theme to the `WalletProvider` component to customize the components in dApp Kit.
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
const App = () => {
|
|
9
|
-
return (
|
|
10
|
-
<WalletProvider theme={lightTheme}>
|
|
11
|
-
<YourApp />
|
|
12
|
-
</WalletProvider>
|
|
13
|
-
);
|
|
14
|
-
};
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Dynamic themes
|
|
18
|
-
|
|
19
|
-
To dynamically change the theme, you can provide multiple themes to the `WalletProvider` component:
|
|
20
|
-
|
|
21
|
-
```tsx
|
|
22
|
-
const App = () => {
|
|
23
|
-
return (
|
|
24
|
-
<WalletProvider
|
|
25
|
-
theme={[
|
|
26
|
-
{
|
|
27
|
-
// default to light theme
|
|
28
|
-
variables: lightTheme,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
// Adds theme inside a media query
|
|
32
|
-
mediaQuery: '(prefers-color-scheme: dark)',
|
|
33
|
-
variables: darkTheme,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
// prefixes the theme styles with the given selector
|
|
37
|
-
// this allows controlling the theme by adding a class to the body
|
|
38
|
-
selector: '.pink-theme',
|
|
39
|
-
variables: pinkTheme,
|
|
40
|
-
},
|
|
41
|
-
]}
|
|
42
|
-
>
|
|
43
|
-
<YourApp />
|
|
44
|
-
</WalletProvider>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Theme variables
|
|
50
|
-
|
|
51
|
-
To define a custom theme, implement the `ThemeVars` interface with CSS variable values for your
|
|
52
|
-
theme:
|
|
53
|
-
|
|
54
|
-
```tsx
|
|
55
|
-
|
|
56
|
-
// Light theme copied from dapp-kit
|
|
57
|
-
|
|
58
|
-
blurs: {
|
|
59
|
-
modalOverlay: 'blur(0)',
|
|
60
|
-
},
|
|
61
|
-
backgroundColors: {
|
|
62
|
-
primaryButton: '#F6F7F9',
|
|
63
|
-
primaryButtonHover: '#F0F2F5',
|
|
64
|
-
outlineButtonHover: '#F4F4F5',
|
|
65
|
-
modalOverlay: 'rgba(24 36 53 / 20%)',
|
|
66
|
-
modalPrimary: 'white',
|
|
67
|
-
modalSecondary: '#F7F8F8',
|
|
68
|
-
iconButton: 'transparent',
|
|
69
|
-
iconButtonHover: '#F0F1F2',
|
|
70
|
-
dropdownMenu: '#FFFFFF',
|
|
71
|
-
dropdownMenuSeparator: '#F3F6F8',
|
|
72
|
-
walletItemSelected: 'white',
|
|
73
|
-
walletItemHover: '#3C424226',
|
|
74
|
-
},
|
|
75
|
-
borderColors: {
|
|
76
|
-
outlineButton: '#E4E4E7',
|
|
77
|
-
},
|
|
78
|
-
colors: {
|
|
79
|
-
primaryButton: '#373737',
|
|
80
|
-
outlineButton: '#373737',
|
|
81
|
-
iconButton: '#000000',
|
|
82
|
-
body: '#182435',
|
|
83
|
-
bodyMuted: '#767A81',
|
|
84
|
-
bodyDanger: '#FF794B',
|
|
85
|
-
},
|
|
86
|
-
radii: {
|
|
87
|
-
small: '6px',
|
|
88
|
-
medium: '8px',
|
|
89
|
-
large: '12px',
|
|
90
|
-
xlarge: '16px',
|
|
91
|
-
},
|
|
92
|
-
shadows: {
|
|
93
|
-
primaryButton: '0px 4px 12px rgba(0, 0, 0, 0.1)',
|
|
94
|
-
walletItemSelected: '0px 2px 6px rgba(0, 0, 0, 0.05)',
|
|
95
|
-
},
|
|
96
|
-
fontWeights: {
|
|
97
|
-
normal: '400',
|
|
98
|
-
medium: '500',
|
|
99
|
-
bold: '600',
|
|
100
|
-
},
|
|
101
|
-
fontSizes: {
|
|
102
|
-
small: '14px',
|
|
103
|
-
medium: '16px',
|
|
104
|
-
large: '18px',
|
|
105
|
-
xlarge: '20px',
|
|
106
|
-
},
|
|
107
|
-
typography: {
|
|
108
|
-
fontFamily:
|
|
109
|
-
'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
110
|
-
fontStyle: 'normal',
|
|
111
|
-
lineHeight: '1.3',
|
|
112
|
-
letterSpacing: '1',
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
```
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# ConnectButton
|
|
2
|
-
|
|
3
|
-
> React connect button component
|
|
4
|
-
|
|
5
|
-
The `ConnectButton` shows the user a button to connect and disconnect a wallet. It automatically
|
|
6
|
-
uses the connected state to show a **connect** or **disconnect** button.
|
|
7
|
-
|
|
8
|
-
```tsx
|
|
9
|
-
|
|
10
|
-
return <ConnectButton />;
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### Props
|
|
15
|
-
|
|
16
|
-
All props are optional.
|
|
17
|
-
|
|
18
|
-
- `connectText = "Connect Wallet"` - The text that displays in the button when the user is not
|
|
19
|
-
currently connected to a wallet.
|
|
20
|
-
- `walletFilter` - A filter function that receives a wallet instance, and returns a boolean
|
|
21
|
-
indicating whether the wallet should be displayed in the wallet list. By default, all wallets are
|
|
22
|
-
displayed.
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# ConnectModal
|
|
2
|
-
|
|
3
|
-
> React connect modal component
|
|
4
|
-
|
|
5
|
-
ControlledConnectModalExample, UncontrolledConnectModalExample, } from
|
|
6
|
-
'../../../../examples/wallet-components-client';
|
|
7
|
-
|
|
8
|
-
The `ConnectModal` component opens a modal that guides the user through connecting their wallet to
|
|
9
|
-
the dApp.
|
|
10
|
-
|
|
11
|
-
## Controlled example
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
|
|
15
|
-
const currentAccount = useCurrentAccount();
|
|
16
|
-
const [open, setOpen] = useState(false);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<ConnectModal
|
|
20
|
-
trigger={
|
|
21
|
-
<button disabled={!!currentAccount}> {currentAccount ? 'Connected' : 'Connect'}</button>
|
|
22
|
-
}
|
|
23
|
-
open={open}
|
|
24
|
-
onOpenChange={(isOpen) => setOpen(isOpen)}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Click **Connect** to connect your wallet and see the previous code in action:
|
|
31
|
-
|
|
32
|
-
## Uncontrolled example
|
|
33
|
-
|
|
34
|
-
```tsx
|
|
35
|
-
|
|
36
|
-
const currentAccount = useCurrentAccount();
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<ConnectModal
|
|
40
|
-
trigger={
|
|
41
|
-
<button disabled={!!currentAccount}> {currentAccount ? 'Connected' : 'Connect'}</button>
|
|
42
|
-
}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Click **Connect** to connect your wallet and see the previous code in action:
|
|
49
|
-
|
|
50
|
-
## Controlled props
|
|
51
|
-
|
|
52
|
-
- `open` - The controlled open state of the dialog.
|
|
53
|
-
- `onOpenChange` - Event handler called when the open state of the dialog changes.
|
|
54
|
-
- `trigger` - The trigger button that opens the dialog.
|
|
55
|
-
- `walletFilter` - A filter function that receives a wallet instance, and returns a boolean
|
|
56
|
-
indicating whether the wallet should be displayed in the wallet list. By default, all wallets are
|
|
57
|
-
displayed.
|
|
58
|
-
|
|
59
|
-
## Uncontrolled props
|
|
60
|
-
|
|
61
|
-
- `defaultOpen` - The open state of the dialog when it is initially rendered. Use when you do not
|
|
62
|
-
need to control its open state.
|
|
63
|
-
- `trigger` - The trigger button that opens the dialog.
|
|
64
|
-
- `walletFilter` - A filter function that receives a wallet instance, and returns a boolean
|
|
65
|
-
indicating whether the wallet should be displayed in the wallet list. By default, all wallets are
|
|
66
|
-
displayed.
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# useAccounts
|
|
2
|
-
|
|
3
|
-
> List wallet accounts
|
|
4
|
-
|
|
5
|
-
The `useAccounts` hook retrieves a list of connected accounts the dApp authorizes.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
|
|
9
|
-
function MyComponent() {
|
|
10
|
-
const accounts = useAccounts();
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div>
|
|
14
|
-
<ConnectButton />
|
|
15
|
-
<h2>Available accounts:</h2>
|
|
16
|
-
{accounts.length === 0 && <div>No accounts detected</div>}
|
|
17
|
-
<ul>
|
|
18
|
-
{accounts.map((account) => (
|
|
19
|
-
<li key={account.address}>- {account.address}</li>
|
|
20
|
-
))}
|
|
21
|
-
</ul>
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Example
|
|
28
|
-
|
|
29
|
-
## Account properties
|
|
30
|
-
|
|
31
|
-
- `address`: The address of the account, corresponding with a public key.
|
|
32
|
-
- `publicKey`: The public key of the account, represented as a `Uint8Array`.
|
|
33
|
-
- `chains`: The chains the account supports.
|
|
34
|
-
- `features`: The features the account supports.
|
|
35
|
-
- `label`: An optional user-friendly descriptive label or name for the account.
|
|
36
|
-
- `icon`: An optional user-friendly icon for the account.
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# useAutoConnectWallet
|
|
2
|
-
|
|
3
|
-
> Automatically reconnect to the last connected wallet
|
|
4
|
-
|
|
5
|
-
The `useAutoConnectWallet` hook retrieves the status for the initial wallet auto-connection process.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
|
|
9
|
-
function MyComponent() {
|
|
10
|
-
const autoConnectionStatus = useAutoConnectWallet();
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div>
|
|
14
|
-
<ConnectButton />
|
|
15
|
-
<div>Auto-connection status: {autoConnectionStatus}</div>
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Example
|
|
22
|
-
|
|
23
|
-
## Auto-connection status properties
|
|
24
|
-
|
|
25
|
-
- `disabled` - When the auto-connection functionality is disabled.
|
|
26
|
-
- `idle` - When the initial auto-connection attempt hasn't been made yet.
|
|
27
|
-
- `attempted` - When an auto-connection attempt has been made. This means either that there is no
|
|
28
|
-
previously connected wallet, the previously connected wallet was not found, or that it has
|
|
29
|
-
successfully connected to a wallet.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# useConnectWallet
|
|
2
|
-
|
|
3
|
-
> Connect a wallet to the dApp
|
|
4
|
-
|
|
5
|
-
The `useConnectWallet` hook is a mutation hook for establishing a connection to a specific wallet.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
|
|
9
|
-
function MyComponent() {
|
|
10
|
-
const wallets = useWallets();
|
|
11
|
-
const { mutate: connect } = useConnectWallet();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div style={{ padding: 20 }}>
|
|
15
|
-
<ConnectButton />
|
|
16
|
-
<ul>
|
|
17
|
-
{wallets.map((wallet) => (
|
|
18
|
-
<li key={wallet.name}>
|
|
19
|
-
<button
|
|
20
|
-
onClick={() => {
|
|
21
|
-
connect(
|
|
22
|
-
{ wallet },
|
|
23
|
-
{
|
|
24
|
-
onSuccess: () => console.log('connected'),
|
|
25
|
-
},
|
|
26
|
-
);
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
Connect to {wallet.name}
|
|
30
|
-
</button>
|
|
31
|
-
</li>
|
|
32
|
-
))}
|
|
33
|
-
</ul>
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Example
|
|
40
|
-
|
|
41
|
-
## Connect arguments
|
|
42
|
-
|
|
43
|
-
- `args` - Arguments passed to the `connect` function of the wallet.
|
|
44
|
-
- `wallet` - The wallet to connect to.
|
|
45
|
-
- `accountAddress` - (optional) The address in the wallet to connect to.
|
|
46
|
-
|
|
47
|
-
- `options` - Options passed the `useMutation` hook from
|
|
48
|
-
[@tanstack/react-query](https://tanstack.com/query/latest/docs/react/guides/mutations).
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# useCurrentAccount
|
|
2
|
-
|
|
3
|
-
> Get the current wallet account
|
|
4
|
-
|
|
5
|
-
The `useCurrentAccount` hook retrieves the wallet account that is currently selected, if one exists.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
|
|
9
|
-
function MyComponent() {
|
|
10
|
-
const account = useCurrentAccount();
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div>
|
|
14
|
-
<ConnectButton />
|
|
15
|
-
{!account && <div>No account connected</div>}
|
|
16
|
-
{account && (
|
|
17
|
-
<div>
|
|
18
|
-
<h2>Current account:</h2>
|
|
19
|
-
<div>Address: {account.address}</div>
|
|
20
|
-
</div>
|
|
21
|
-
)}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Example
|
|
28
|
-
|
|
29
|
-
## Account properties
|
|
30
|
-
|
|
31
|
-
- `address`: The address of the account, corresponding with a public key.
|
|
32
|
-
- `publicKey`: The public key of the account, represented as a `Uint8Array`.
|
|
33
|
-
- `chains`: The chains the account supports.
|
|
34
|
-
- `features`: The features the account supports.
|
|
35
|
-
- `label`: An optional user-friendly descriptive label or name for the account.
|
|
36
|
-
- `icon`: An optional user-friendly icon for the account.
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# useCurrentWallet
|
|
2
|
-
|
|
3
|
-
> Get the current wallet connection
|
|
4
|
-
|
|
5
|
-
The `useCurrentWallet` hook retrieves the wallet that is currently connected to the dApp, if one
|
|
6
|
-
exists.
|
|
7
|
-
|
|
8
|
-
```ts
|
|
9
|
-
|
|
10
|
-
function MyComponent() {
|
|
11
|
-
const { currentWallet, connectionStatus } = useCurrentWallet();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
15
|
-
<ConnectButton />
|
|
16
|
-
{connectionStatus === 'connected' ? (
|
|
17
|
-
<div>
|
|
18
|
-
<h2>Current wallet:</h2>
|
|
19
|
-
<div>Name: {currentWallet.name}</div>
|
|
20
|
-
<div>
|
|
21
|
-
Accounts:
|
|
22
|
-
<ul>
|
|
23
|
-
{currentWallet.accounts.map((account) => (
|
|
24
|
-
<li key={account.address}>- {account.address}</li>
|
|
25
|
-
))}
|
|
26
|
-
</ul>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
) : (
|
|
30
|
-
<div>Connection status: {connectionStatus}</div>
|
|
31
|
-
)}
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Example
|
|
38
|
-
|
|
39
|
-
## Wallet properties
|
|
40
|
-
|
|
41
|
-
- `name` - The name of the wallet.
|
|
42
|
-
- `version` - The version of the wallet as a string.
|
|
43
|
-
- `icon` - A data URL of the wallet icon as an SVG.
|
|
44
|
-
- `accounts` - An array of accounts that are available in the wallet.
|
|
45
|
-
- `features` - An object with all the
|
|
46
|
-
[wallet-standard](https://github.com/wallet-standard/wallet-standard) features implemented by the
|
|
47
|
-
wallet.
|
|
48
|
-
- `chains` - An array of chain identifiers that the wallet supports.
|
|
49
|
-
|
|
50
|
-
## Connection status properties
|
|
51
|
-
|
|
52
|
-
- `connectionStatus`
|
|
53
|
-
- `disconnected` - When no wallet is connected to the dApp.
|
|
54
|
-
- `connecting` - When a wallet connection attempt is in progress.
|
|
55
|
-
- `connected` - When a wallet is connected to the dApp.
|
|
56
|
-
|
|
57
|
-
- `isDisconnected` - A derived boolean from the status variable above, provided for convenience.
|
|
58
|
-
- `isConnecting` - A derived boolean from the status variable above, provided for convenience.
|
|
59
|
-
- `isConnected` - A derived boolean from the status variable above, provided for convenience.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# useDisconnectWallet
|
|
2
|
-
|
|
3
|
-
> Disconnect the current wallet
|
|
4
|
-
|
|
5
|
-
The `useDisconnectWallet` hook is a mutation hook for disconnecting from an active wallet
|
|
6
|
-
connection, if currently connected.
|
|
7
|
-
|
|
8
|
-
```ts
|
|
9
|
-
|
|
10
|
-
function MyComponent() {
|
|
11
|
-
const { mutate: disconnect } = useDisconnectWallet();
|
|
12
|
-
return (
|
|
13
|
-
<div>
|
|
14
|
-
<ConnectButton />
|
|
15
|
-
|
|
16
|
-
<button onClick={() => disconnect()}>Disconnect</button>
|
|
17
|
-
</div>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Example
|
|
23
|
-
|
|
24
|
-
## Arguments
|
|
25
|
-
|
|
26
|
-
There are no arguments for `useDisconnectWallet`.
|