diff --git a/packages/ethers/src/client.ts b/packages/ethers/src/client.ts index e9b122dd34..6b9711b930 100644 --- a/packages/ethers/src/client.ts +++ b/packages/ethers/src/client.ts @@ -1255,7 +1255,8 @@ export class Web3Modal extends Web3ModalScaffold { EthersStoreUtil.setChainId(chainId) // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (switchError: any) { - if (/(?user rejected)/u.test(switchError?.message)) { + const message = switchError?.message as string + if (/(?user rejected)/u.test(message?.toLowerCase())) { throw new Error('Chain is not supported') } await EthersHelpersUtil.addEthereumChain( diff --git a/packages/ethers5/src/client.ts b/packages/ethers5/src/client.ts index 9c25f87ba1..9373367849 100644 --- a/packages/ethers5/src/client.ts +++ b/packages/ethers5/src/client.ts @@ -972,7 +972,8 @@ export class Web3Modal extends Web3ModalScaffold { EthersStoreUtil.setChainId(chainId) // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (switchError: any) { - if (/(?user rejected)/u.test(switchError?.message)) { + const message = switchError?.message as string + if (/(?user rejected)/u.test(message?.toLowerCase())) { throw new Error('Chain is not supported') } await EthersHelpersUtil.addEthereumChain(