From 80af9c120ec212ca1702cefb57f9bcc3c21683a1 Mon Sep 17 00:00:00 2001 From: Balazs Toldi Date: Wed, 1 Jun 2022 12:20:30 +0200 Subject: [PATCH] Better login --- dapp/index.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dapp/index.html b/dapp/index.html index f3c8d9e..80fcd8d 100644 --- a/dapp/index.html +++ b/dapp/index.html @@ -150,7 +150,7 @@ let priceDivider = await contract.methods.getPriceDivider().call(); accounts = await ethereum.request({ method: 'eth_requestAccounts' }); document.getElementById("address").value = accounts[0]; - + let allowed = new web3.utils.BN(await tokenContract.methods.allowance(accounts[0], ContractAddress).call()); let sellWei = new web3.utils.BN(await web3.utils.toWei(sellAmount, 'ether')); if (allowed.gte(sellWei)) { @@ -181,7 +181,7 @@ document.getElementById("address").value = accounts[0]; hideLogin(); showSwap(); - if(contract == undefined){ + if (contract == undefined) { initContracts(); } } @@ -243,9 +243,11 @@ initContracts(); web3.eth.getAccounts().then(account => { console.log(account); - document.getElementById("address").value = account[0]; - hideLogin(); - showSwap(); + if (account.length > 0) { + document.getElementById("address").value = account[0]; + hideLogin(); + showSwap(); + } }); } else {