登录签名时, 如果没有地址, 则重复获取
This commit is contained in:
parent
acc7b1c9bd
commit
5c4d3186d8
@ -5,7 +5,7 @@ import { loginNonce, hexToBase58, aesEncrypt, loginWithSignature } from '@/utils
|
||||
|
||||
import { SiweMessage } from '@/utils/siwe.js';
|
||||
import { GlobalData } from '@/utils/GlobalData.js';
|
||||
import { parseTokenData, base64ToHex } from '@/utils/utils.js';
|
||||
import { parseTokenData } from '@/utils/utils.js';
|
||||
import { setToken } from '@/utils/cookies.js';
|
||||
import store from '@/store'
|
||||
import { treasureAbi } from './abi.js'
|
||||
@ -54,6 +54,7 @@ const connectWc = async () => {
|
||||
icons: ['https://www.counterfire.games/favicon.ico'],
|
||||
},
|
||||
});
|
||||
await wc.connect()
|
||||
return wc;
|
||||
};
|
||||
export class Wallet {
|
||||
@ -223,6 +224,13 @@ export class Wallet {
|
||||
async loginWithEthereum(activity) {
|
||||
const web3 = new Web3(this.provider);
|
||||
let addresses = await web3.eth.getAccounts();
|
||||
let tryCount = 0;
|
||||
while (addresses.length === 0) {
|
||||
addresses = await web3.eth.getAccounts();
|
||||
if (tryCount++ > 10) {
|
||||
throw new Error('No address found');
|
||||
}
|
||||
}
|
||||
let address = web3.utils.toChecksumAddress(addresses[0]);
|
||||
store.commit('wallet/updateAddress', address)
|
||||
// return
|
||||
|
Loading…
x
Reference in New Issue
Block a user