fix(network switch): do not show failed to switch networks for successful network switches
This commit is contained in:
parent
458e04f94c
commit
13c42a384b
@ -24,8 +24,8 @@ export default function FailedNetworkSwitchPopup({ chainId }: { chainId: Support
|
||||
<AutoColumn gap="8px">
|
||||
<ThemedText.Body fontWeight={500}>
|
||||
<Trans>
|
||||
Your wallet does not support switching networks from the Uniswap Interface. In order to use Uniswap on{' '}
|
||||
{chainInfo.label}, you must change the network in your wallet.
|
||||
Failed to switch networks from the Uniswap Interface. In order to use Uniswap on {chainInfo.label}, you must
|
||||
change the network in your wallet.
|
||||
</Trans>
|
||||
</ThemedText.Body>
|
||||
</AutoColumn>
|
||||
|
@ -37,15 +37,16 @@ export async function switchToNetwork({ library, chainId }: SwitchNetworkArgumen
|
||||
},
|
||||
],
|
||||
})
|
||||
const { chainId: chainIdAfterSwitch } = await library.getNetwork()
|
||||
if (chainIdAfterSwitch !== chainId) {
|
||||
// metamask (only known implementer) automatically switches after a network is added
|
||||
// the second call is done here because that behavior is not a part of the spec and cannot be relied upon in the future
|
||||
// metamask's behavior when switching to the current network is just to return null (a no-op)
|
||||
try {
|
||||
await library.provider.request({
|
||||
method: 'wallet_switchEthereumChain',
|
||||
params: [{ chainId: formattedChainId }],
|
||||
})
|
||||
} catch (error) {
|
||||
console.debug('Added network but could not switch chains', error)
|
||||
}
|
||||
} else {
|
||||
throw error
|
||||
|
Loading…
Reference in New Issue
Block a user