Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[414] remove NetworkSelector on sc wallet session #507

Merged
merged 12 commits into from
May 5, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { UnsupportedChainIdError, useWeb3React } from 'web3-react-core'
import { useAddPopup, useRemovePopup } from 'state/application/hooks'
import { useEffect } from 'react'
import { getExplorerBaseUrl } from 'utils/explorer'
import { useWalletInfo } from '@src/custom/hooks/useWalletInfo'
W3stside marked this conversation as resolved.
Show resolved Hide resolved

/* const ActiveRowLinkList = styled.div`
display: flex;
Expand Down Expand Up @@ -287,8 +288,8 @@ export const getChainNameFromId = (id: string | number) => {
}

export default function NetworkSelector() {
// mod: add account
const { account, chainId, library } = useActiveWeb3React()
// mod: add account & lib abd useWalletInfo
const { account, chainId, library, isSmartContractWallet } = useWalletInfo()
// mod: refactored inner logic into useChangeNetworks hook
const { node, open, toggle, info, handleChainSwitch } = useChangeNetworks({ account, chainId, library })

Expand Down Expand Up @@ -386,7 +387,7 @@ export default function NetworkSelector() {
}
}, [chainId, history, urlChainId, urlChain]) */

if (!chainId || !info || !library || isUnsupportedNetwork) {
if (!chainId || !info || !library || isUnsupportedNetwork || isSmartContractWallet) {
return null
}

Expand Down
4 changes: 3 additions & 1 deletion src/custom/hooks/useWalletInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ConnectedWalletInfo {
account?: string | null
activeNetwork: boolean // active default connection
provider?: WalletProvider
library?: Web3Provider
isSmartContractWallet: boolean
walletName?: string
ensName?: string
Expand Down Expand Up @@ -72,7 +73,7 @@ async function getWcPeerMetadata(connector: WalletConnectConnector): Promise<{ w
}

export function useWalletInfo(): ConnectedWalletInfo {
const { active, account, connector, chainId } = useWeb3React()
const { active, account, connector, chainId, library } = useWeb3React()
const web3Instance = useActiveWeb3Instance()
const [walletName, setWalletName] = useState<string>()
const [icon, setIcon] = useState<string>()
Expand Down Expand Up @@ -136,6 +137,7 @@ export function useWalletInfo(): ConnectedWalletInfo {
account,
activeNetwork: contextNetwork.active,
provider,
library,
isSmartContractWallet,
walletName,
icon,
Expand Down