diff --git a/src/hooks/web3/useChangeNetwork.ts b/src/hooks/web3/useChangeNetwork.ts index f9f8437e99..156adef803 100644 --- a/src/hooks/web3/useChangeNetwork.ts +++ b/src/hooks/web3/useChangeNetwork.ts @@ -18,7 +18,7 @@ import { useLazyKyberswapConfig } from '../useKyberSwapConfig' let latestChainId: ChainId export function useChangeNetwork() { - const { chainId, walletEVM, walletSolana } = useActiveWeb3React() + const { chainId, walletEVM, walletSolana, isWrongNetwork } = useActiveWeb3React() const { connector, library } = useWeb3React() const fetchKyberswapConfig = useLazyKyberswapConfig() @@ -234,7 +234,7 @@ export function useChangeNetwork() { const wrappedSuccessCallback = () => successCallback(desiredChainId, waitUtilUpdatedChainId, customSuccessCallback) // if connected, nothing todo, success return - if (desiredChainId === chainId) { + if (desiredChainId === chainId && !isWrongNetwork) { customSuccessCallback?.() return } @@ -298,6 +298,7 @@ export function useChangeNetwork() { successCallback, failureCallback, addNewNetwork, + isWrongNetwork, ], )