我们开发了一条自定义的公链, 当从BSC链进入到我们的Dapp里 点击按钮切换到我们链时出现了一个错误提示
我们开发用提示框在用户界面上提示了 error.message 是 the method wallet_switchethereumchain does not exist/is not available
-------------代码片段--------------
window.ethereum.request({
method: ‘wallet_switchEthereumChain’,
params: [{chainId: chainIdToHex}],
}).then(() => {
resolve()
}).catch(e => {
console.log(e)
console.log(‘switchNetwork error’)
if (e.code === 4902 || e.code === -32603) {
// 用户没有添加这个链, 在这里去添加
}
// 用户取消
if (e === ‘rejected’ || e.code === 4001) {
Toast.clear()
reject(e)
return
}
Toast.fail(e.message) // 上面的错误 应该是这里提示的
reject(e)
})
-------------代码片段--------------
之前一直没有出现过这种问题, 我不知道是否是用户的TP钱包 更新了新版本所导致的