diff --git a/src/components/layout/unexpected_chain.tsx b/src/components/layout/unexpected_chain.tsx index 3bae8408..15cf16b0 100644 --- a/src/components/layout/unexpected_chain.tsx +++ b/src/components/layout/unexpected_chain.tsx @@ -22,9 +22,14 @@ export default function UnexpectedChain() { method: 'wallet_switchEthereumChain', params: [{ chainId: toHexString(chainId ?? '0') }], }); - } catch(switchError) { - // @ts-ignore - if (allowAutoAdd && switchError.code === 4902) { + } catch(switchError: any) { + const isMissingChainError = + switchError.code === 4902 || + switchError?.data?.originalError?.code === 4902 || + switchError?.info?.error?.code === 4902 || + switchError?.message?.includes('Unrecognized chain ID'); + + if (allowAutoAdd && isMissingChainError) { addNetwork(); } }