Skip to content

Commit

Permalink
feat(logic): optimise logic (#10)
Browse files Browse the repository at this point in the history
optimise logic
  • Loading branch information
XdpCs authored May 1, 2024
1 parent bdcd996 commit 73c1da0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,13 @@ <h1>Withdraw FLT</h1>
const lockedBalances = await contractFltDrop.lockedBalances(account);
console.log(`Lock Time: ${lockedBalances.unlockTime}`);
showLockTime.textContent = blockchainTimestampToDateTime(lockedBalances.unlockTime.toString());
connectButton.style.display = 'none';
withdrawButton.style.display = '';
if (lockedBalance > 0) {
connectButton.style.display = 'none';
withdrawButton.style.display = '';
} else {
alert("There are no FLT tokens available for withdrawal.");
}

} catch (error) {
console.error("Error connecting to wallet:", error);
alert("Error connecting to wallet. Please make sure you have an Ethereum wallet installed and unlocked.");
Expand All @@ -162,7 +167,7 @@ <h1>Withdraw FLT</h1>
async function withdrawOnClick() {
console.log("Withdrawing FLT...");
try {
if (lockedBalance === 0) {
if (lockedBalance == 0) {
throw new Error('There are no FLT tokens available for withdrawal.');
}
const provider = new ethers.BrowserProvider(window.ethereum);
Expand All @@ -175,7 +180,7 @@ <h1>Withdraw FLT</h1>
await tx.wait();
alert("FLT tokens withdrawn successfully.");
} catch (error) {
console.error("Withdrawal error:", error);
console.error("Withdrawal error:", error.message);
alert("Withdrawal error: " + error.message);
}
}
Expand Down

0 comments on commit 73c1da0

Please sign in to comment.