File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ export const init = (options: InitOptions): OnboardAPI => {
20
20
21
21
export const useConnectWallet = ( ) : [
22
22
{ wallet : WalletState | null ; connecting : boolean } ,
23
- ( options : ConnectOptions ) => Promise < void >
23
+ ( options : ConnectOptions ) => Promise < void > ,
24
+ ( wallet : WalletState ) => Promise < void >
24
25
] => {
25
26
if ( ! web3Onboard ) throw new Error ( 'Must initialize before using hooks.' )
26
27
@@ -41,7 +42,20 @@ export const useConnectWallet = (): [
41
42
}
42
43
} , [ ] )
43
44
44
- return [ { wallet, connecting } , connect ]
45
+ const disconnect = useCallback ( async wallet => {
46
+ setConnecting ( true )
47
+
48
+ await (
49
+ web3Onboard as OnboardAPI
50
+ ) . disconnectWallet ( { label : wallet . label } )
51
+
52
+ setConnectedWallet ( null )
53
+
54
+ setConnecting ( false )
55
+
56
+ } , [ ] )
57
+
58
+ return [ { wallet, connecting } , connect , disconnect ]
45
59
}
46
60
47
61
type SetChainOptions = {
You can’t perform that action at this time.
0 commit comments