Merge branch 'master' of http://git.kingsome.cn/yuyongdong/UAW
This commit is contained in:
commit
c338437564
@ -35,10 +35,9 @@ const httpGet = async (url) => {
|
||||
const base58Alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
|
||||
export const hexToBase58 = (hexString) => {
|
||||
const bytes = hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
|
||||
|
||||
hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
|
||||
let base58String = '';
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
let num = BigInt('0x' + hexString);
|
||||
while (num > 0n) {
|
||||
const remainder = num % 58n;
|
||||
|
@ -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