From 2e68e79379bf7bc67a8f12bd20ab1cf2895d8f2b Mon Sep 17 00:00:00 2001 From: "yongen.loong" Date: Fri, 26 Jul 2024 00:22:56 +0800 Subject: [PATCH] fix: if faucet fails, should still return wallet --- data/wallet.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/data/wallet.ts b/data/wallet.ts index 8afc73b..fe267ba 100644 --- a/data/wallet.ts +++ b/data/wallet.ts @@ -19,12 +19,14 @@ export function useWallet() { if (existingWallets.length === 0) { const newWallet = AElf.wallet.createNewWallet(); await db.wallet.add({ privateKey: newWallet.privateKey }); - await( - await fetch( - `https://faucet.aelf.dev/api/claim?walletAddress=${newWallet.address}`, - { method: "POST" } - ) - ).json(); + try { + await( + await fetch( + `https://faucet.aelf.dev/api/claim?walletAddress=${newWallet.address}`, + { method: "POST" } + ) + ).json(); + } catch (err) {} return newWallet.privateKey as string; } else { return existingWallets[0].privateKey;