Update switchEthereumChain unrecognized chain error (#11030)

feature/default_network_editable
Erik Marks 4 years ago committed by Dan Miller
parent 4ced29e3a2
commit 434249f171
  1. 9
      app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js

@ -63,7 +63,7 @@ async function switchEthereumChainHandler(
const existingNetwork = findCustomRpcBy({ chainId: _chainId });
if (existingNetwork !== null) {
if (existingNetwork) {
const currentChainId = getCurrentChainId();
if (currentChainId === _chainId) {
res.result = null;
@ -88,5 +88,10 @@ async function switchEthereumChainHandler(
}
return end();
}
return end(ethErrors.provider.userRejectedRequest());
return end(
ethErrors.provider.custom({
code: 4902, // To-be-standardized "unrecognized chain ID" error
message: `Unrecognized chain ID "${chainId}". Try adding the chain using ${MESSAGE_TYPE.ADD_ETHEREUM_CHAIN} first.`,
}),
);
}

Loading…
Cancel
Save