The above error was generated when trying to switch chains. Because makeError fails at ethers\lib.commonjs\utils\errors.js, the error object is not correctly formed. We can parse the error object out of the error string as a fallback here.
Note that since this error was not being re-thrown, the catch block in the portfolio that checks the error code E.code === 4902 was not returning true resulting in wallet_addEthereumChain not being called.
The user impact is that chains that were not already added to the users wallet could not be added/switched to in the portfolio.
Summary
closes https://github.com/HyperPlay-Gaming/product-management/issues/765
Ethers has several situations where it throws an error like the following
e.g. https://github.com/ethers-io/ethers.js/issues/4576
The above error was generated when trying to switch chains. Because
makeError
fails atethers\lib.commonjs\utils\errors.js
, the error object is not correctly formed. We can parse the error object out of the error string as a fallback here.Note that since this error was not being re-thrown, the catch block in the portfolio that checks the error code
E.code === 4902
was not returning true resulting inwallet_addEthereumChain
not being called.The user impact is that chains that were not already added to the users wallet could not be added/switched to in the portfolio.