Commit 07101787 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

feat: don't allow disconnect/change on injected mobile wallets (#4015)

* feat: don't allow disconnect/change on injected mobile wallets

* new variable
parent 5535c83d
...@@ -7,6 +7,7 @@ import { ExternalLink as LinkIcon } from 'react-feather' ...@@ -7,6 +7,7 @@ import { ExternalLink as LinkIcon } from 'react-feather'
import { useAppDispatch } from 'state/hooks' import { useAppDispatch } from 'state/hooks'
import { updateSelectedWallet } from 'state/user/reducer' import { updateSelectedWallet } from 'state/user/reducer'
import styled, { ThemeContext } from 'styled-components/macro' import styled, { ThemeContext } from 'styled-components/macro'
import { isMobile } from 'utils/userAgent'
import { ReactComponent as Close } from '../../assets/images/x.svg' import { ReactComponent as Close } from '../../assets/images/x.svg'
import { coinbaseWallet, injected } from '../../connectors' import { coinbaseWallet, injected } from '../../connectors'
...@@ -230,6 +231,10 @@ export default function AccountDetails({ ...@@ -230,6 +231,10 @@ export default function AccountDetails({
const theme = useContext(ThemeContext) const theme = useContext(ThemeContext)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const isMetaMask = !!window.ethereum?.isMetaMask
const isCoinbaseWallet = !!window.ethereum?.isCoinbaseWallet
const isInjectedMobileBrowser = (isMetaMask || isCoinbaseWallet) && isMobile
function formatConnectorName() { function formatConnectorName() {
const { ethereum } = window const { ethereum } = window
const isMetaMask = !!(ethereum && ethereum.isMetaMask) const isMetaMask = !!(ethereum && ethereum.isMetaMask)
...@@ -265,6 +270,8 @@ export default function AccountDetails({ ...@@ -265,6 +270,8 @@ export default function AccountDetails({
<AccountGroupingRow> <AccountGroupingRow>
{formatConnectorName()} {formatConnectorName()}
<div> <div>
{!isInjectedMobileBrowser && (
<>
<WalletAction <WalletAction
style={{ fontSize: '.825rem', fontWeight: 400, marginRight: '8px' }} style={{ fontSize: '.825rem', fontWeight: 400, marginRight: '8px' }}
onClick={() => { onClick={() => {
...@@ -295,6 +302,8 @@ export default function AccountDetails({ ...@@ -295,6 +302,8 @@ export default function AccountDetails({
> >
<Trans>Change</Trans> <Trans>Change</Trans>
</WalletAction> </WalletAction>
</>
)}
</div> </div>
</AccountGroupingRow> </AccountGroupingRow>
<AccountGroupingRow data-testid="web3-account-identifier-row"> <AccountGroupingRow data-testid="web3-account-identifier-row">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment