From 0ad9715afac4c6943c680b5ee462e9639593fa06 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 21 Oct 2024 13:25:30 +0200 Subject: [PATCH] `Unrecognized chain ID` error when adding network via mobile MetaMask Fixes #2267 --- lib/web3/useAddOrSwitchChain.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/web3/useAddOrSwitchChain.tsx b/lib/web3/useAddOrSwitchChain.tsx index 05811de6d7..efd294848e 100644 --- a/lib/web3/useAddOrSwitchChain.tsx +++ b/lib/web3/useAddOrSwitchChain.tsx @@ -1,3 +1,4 @@ +import _get from 'lodash/get'; import React from 'react'; import config from 'configs/app'; @@ -24,9 +25,10 @@ export default function useAddOrSwitchChain() { const errorObj = getErrorObj(error); const code = errorObj && 'code' in errorObj ? errorObj.code : undefined; + const originalErrorCode = _get(errorObj, 'data.originalError.code'); // This error code indicates that the chain has not been added to Wallet. - if (code === 4902) { + if (code === 4902 || originalErrorCode === 4902) { const params = [ { chainId: hexadecimalChainId, chainName: config.chain.name,