From a61ebd7cc145d4bf504e6c0ff43604a1f4620eed Mon Sep 17 00:00:00 2001 From: wighawag Date: Tue, 22 Aug 2023 17:05:09 +0100 Subject: [PATCH] balance check --- web/src/lib/ui/panels/ActionPanel.svelte | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/web/src/lib/ui/panels/ActionPanel.svelte b/web/src/lib/ui/panels/ActionPanel.svelte index ba312bfa..9d4f8ba0 100644 --- a/web/src/lib/ui/panels/ActionPanel.svelte +++ b/web/src/lib/ui/panels/ActionPanel.svelte @@ -14,6 +14,8 @@ commitFlow.requireConfirmation(); } + const symbol = initialContractsInfos.contracts.Stratagems.linkedData.currency.symbol; + $: cost = BigInt($actionState.length) * BigInt(initialContractsInfos.contracts.Stratagems.linkedData.numTokensPerGems.slice(0, -1)); @@ -21,6 +23,14 @@ 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 {#if $actionState.length > 0} @@ -31,13 +41,14 @@

Your Move:

You'll stake {costString} - {initialContractsInfos.contracts.Stratagems.linkedData.currency.symbol}. you have {formatEther( - $balance.balance, - )} ETH. + {symbol}. you have {currentBalnceString} + {symbol}.

- +