diff --git a/packages/react/README.md b/packages/react/README.md index 4cbfbd2ef..78df30962 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -119,8 +119,8 @@ import { useConnectWallet } from '@web3-onboard/react' type UseConnectWallet = (): [ { wallet: WalletState | null; connecting: boolean }, - (options: ConnectOptions) => Promise, - (wallet: DisconnectOptions) => Promise, + (options: ConnectOptions) => Promise, + (wallet: DisconnectOptions) => Promise, (addresses?: string[]) => Promise, (wallets: WalletInit[]) => void, (wallet: WalletState, address?: string) => void @@ -150,8 +150,8 @@ const [ wallet, // the wallet that has been connected or null if not yet connected connecting // boolean indicating if connection is in progress }, - connect, // function to call to initiate user to connect wallet - disconnect, // function to call with wallet to disconnect wallet + connect, // function to call to initiate user to connect wallet, returns a list of WalletState objects (connected wallets) + disconnect, // function to call with wallet to disconnect wallet, returns a list of WalletState objects (connected wallets) updateBalances, // function to be called with an optional array of wallet addresses connected through Onboard to update balance or empty/no params to update all connected wallets setWalletModules, // function to be called with an array of wallet modules to conditionally allow connection of wallet types i.e. setWalletModules([ledger, trezor, injected]) setPrimaryWallet // function that can set the primary wallet and/or primary account within that wallet. The wallet that is set needs to be passed in for the first parameter and if you would like to set the primary account, the address of that account also needs to be passed in diff --git a/packages/react/package.json b/packages/react/package.json index 183f28c39..7614e5c93 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/react", - "version": "2.2.6-alpha.1", + "version": "2.2.6-alpha.2", "description": "A collection of React hooks for integrating Web3-Onboard in to React and Next.js projects. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", "keywords": [ "Ethereum", diff --git a/packages/react/src/hooks/useConnectWallet.ts b/packages/react/src/hooks/useConnectWallet.ts index b02f32577..c7e7c96e1 100644 --- a/packages/react/src/hooks/useConnectWallet.ts +++ b/packages/react/src/hooks/useConnectWallet.ts @@ -11,8 +11,8 @@ import { useAppState } from './useAppState' export const useConnectWallet = (): [ { wallet: WalletState | null; connecting: boolean }, - (options?: ConnectOptions) => Promise, - (wallet: DisconnectOptions) => Promise, + (options?: ConnectOptions) => Promise, + (wallet: DisconnectOptions) => Promise, (addresses?: string[]) => Promise, (wallets: WalletInit[]) => void, (wallet: WalletState, address?: string) => void @@ -29,17 +29,21 @@ export const useConnectWallet = (): [ const connect = useCallback(async (options?: ConnectOptions) => { setConnecting(true) - await connectWallet(options) + const walletState = await connectWallet(options) setConnecting(false) + + return walletState }, []) const disconnect = useCallback(async ({ label }: DisconnectOptions) => { setConnecting(true) - await disconnectWallet({ label }) + const walletState = await disconnectWallet({ label }) setConnecting(false) + + return walletState }, []) const updateBalances = web3Onboard.state.actions.updateBalances