From 5c4d3186d88abd4a1d4050623794a3ed1f356c6f Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Sun, 14 Apr 2024 19:56:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=E6=97=B6,=20=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=9C=B0?= =?UTF-8?q?=E5=9D=80,=20=E5=88=99=E9=87=8D=E5=A4=8D=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wallet/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wallet/index.js b/src/wallet/index.js index 7f30342..b2e6e6b 100644 --- a/src/wallet/index.js +++ b/src/wallet/index.js @@ -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 From c125a488c80ddb923f73037868e2a224682a614b Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Sun, 14 Apr 2024 20:06:20 +0800 Subject: [PATCH 2/2] src/utils/webapi.js --- src/utils/webapi.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/webapi.js b/src/utils/webapi.js index 09ae8b6..ede9d58 100644 --- a/src/utils/webapi.js +++ b/src/utils/webapi.js @@ -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;