Skip to content

Commit

Permalink
balance check
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Aug 22, 2023
1 parent 82350b5 commit a61ebd7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions web/src/lib/ui/panels/ActionPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@
commitFlow.requireConfirmation();
}
const symbol = initialContractsInfos.contracts.Stratagems.linkedData.currency.symbol;
$: cost =
BigInt($actionState.length) *
BigInt(initialContractsInfos.contracts.Stratagems.linkedData.numTokensPerGems.slice(0, -1));
$: costString = formatUnits(
cost,
Number(initialContractsInfos.contracts.Stratagems.linkedData.currency.decimals.slice(0, -1)),
);
$: currentBalance = $balance.balance;
$: currentBalnceString = formatUnits(
currentBalance,
Number(initialContractsInfos.contracts.Stratagems.linkedData.currency.decimals.slice(0, -1)),
);
$: enough = currentBalance >= cost; // TODO + gascost for ETH
</script>

{#if $actionState.length > 0}
Expand All @@ -31,13 +41,14 @@
<h2 class="card-title text-primary">Your Move:</h2>
<p class="text-secondary">
You'll stake {costString}
{initialContractsInfos.contracts.Stratagems.linkedData.currency.symbol}. you have {formatEther(
$balance.balance,
)} ETH.
{symbol}. you have {currentBalnceString}
{symbol}.
</p>
<div class="mt-4 card-actions justify-end">
<button class="pointer-events-auto btn btn-neutral" on:click={clear}>Clear</button>
<button class="pointer-events-auto btn btn-primary" on:click={commit}>Commit</button>
<button class={`pointer-events-auto btn btn-primary ${enough ? '' : 'btn-disabled'}`} on:click={commit}
>Commit</button
>
</div>
</div>
</div>
Expand Down

0 comments on commit a61ebd7

Please sign in to comment.