diff --git a/README.md b/README.md index f3783b5..8e0e21c 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ It returns an object representing the connected account (“wallet”), containi - `ethereum`: the connected [Ethereum provider](https://eips.ethereum.org/EIPS/eip-1193). - `getBlockNumber()`: this function returns the current block number. This is a function because the block number updates often, which could trigger as many extra renders. Making an explicit call for the block number allows users of `useWallet()` to avoid extra renders when the block number is not needed. - `isConnected()`: this function returns whether the wallet is connected. +- `networkName`: a human-readable name corresponding to the Chain ID. - `reset()`: call this function to “disconnect” from the current provider. This will also clean the latest error value stored in `use-wallet`'s state. - `status`: contains the current status of the wallet connection. The possible values are: - "disconnected": no wallet connected (default state). diff --git a/src/index.tsx b/src/index.tsx index 9ee2b4f..28cbf9b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -331,6 +331,7 @@ function UseWalletProvider({ error, ethereum, isConnected: () => status === 'connected', + networkName: chains.getChainInformation(chainId).type, providerInfo: connector ? getProviderFromUseWalletId(connector) : getProviderFromUseWalletId('unknown'), diff --git a/src/types.ts b/src/types.ts index 05ae64c..75e5497 100644 --- a/src/types.ts +++ b/src/types.ts @@ -49,6 +49,7 @@ export type Wallet = { ethereum?: any getBlockNumber?: () => number | null isConnected: () => boolean + networkName: string | null reset: () => void status: Status type: AccountType | null