1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Update switchEthereumChain unrecognized chain error (#11030)

This commit is contained in:
Erik Marks 2021-05-10 15:29:07 -07:00 committed by GitHub
parent 36869a4350
commit 2289e47e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.`,
}),
);
}