完善network的切换逻辑

This commit is contained in:
CounterFire2023 2024-07-22 10:55:31 +08:00
parent 6f2cd47476
commit 71f4d9d6b1

View File

@ -229,6 +229,7 @@ export class BlockChain {
*/
async checkAndChangeChain(targetChainId, provider) {
targetChainId = targetChainId || cfgChainId;
// passport只支持imtbl链, 不需要切换
if (!provider && this.store.walletType == 3) {
return
}
@ -238,6 +239,16 @@ export class BlockChain {
console.log(`current chain: ${chainId}, want: ${targetChainId}`)
chainId = await switchEthereumChain(provider.provider, targetChainId);
}
if (this.store.walletType == 3) {
const { provider, accounts } = await this.eoaWallet.web3Provider();
this.eoaProvider = provider;
} else {
const { provider, accounts } = await this.wallet.web3Provider();
this.web3Provider = provider;
this.eoaProvider = provider;
}
}
async checkPassportLogin() {