From da70e4d43c0487b30bb34add707667c831375258 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 18 Jul 2019 18:38:49 +0200 Subject: [PATCH] only send auto faucet request if account balance is empty --- client/src/context/BurnerWalletProvider.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/context/BurnerWalletProvider.ts b/client/src/context/BurnerWalletProvider.ts index 1f0b445..0f88be6 100644 --- a/client/src/context/BurnerWalletProvider.ts +++ b/client/src/context/BurnerWalletProvider.ts @@ -37,9 +37,11 @@ export class BurnerWalletProvider { localStorage.setItem('logType', 'BurnerWallet') const provider = new HDWalletProvider(mnemonic, `${nodeUri}`, 0, 1) this.web3 = new Web3(provider) + const accounts = await this.web3.eth.getAccounts() + const balance = await this.web3.eth.getBalance(accounts[0]) - // fill with Ether - await requestFromFaucet(provider.addresses[0]) + // fill with Ether if account balance is empty + balance === '0' && (await requestFromFaucet(provider.addresses[0])) } public async logout() {