/
VotingPower.svelte
44 lines (40 loc) · 1.8 KB
/
VotingPower.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script lang="ts">
import { Text, Button } from 'shared/components'
import { ButtonSize, FontWeight, TextType } from './enums'
import { selectedAccount } from '@core/account'
import { localize } from '@core/i18n'
import { formatTokenAmountBestMatch, visibleSelectedAccountAssets } from '@core/wallet'
import { openPopup, PopupId } from '@auxiliary/popup'
const asset = $visibleSelectedAccountAssets?.baseCoin
$: votingPower = parseInt($selectedAccount?.votingPower, 10)
$: maxVotingPower = parseInt($selectedAccount?.balances?.baseCoin?.available) + votingPower
$: formattedVotingPower = formatTokenAmountBestMatch(votingPower, asset?.metadata)
$: formattedMaxVotingPower = formatTokenAmountBestMatch(maxVotingPower, asset?.metadata)
$: hasTransactionInProgress =
$selectedAccount?.hasVotingPowerTransactionInProgress ||
$selectedAccount?.hasVotingTransactionInProgress ||
$selectedAccount?.isTransferring
function handleManageVotingPower(): void {
openPopup({
id: PopupId.ManageVotingPower,
})
}
</script>
<voting-power>
<Text fontSize="14" fontWeight={FontWeight.semibold} classes="mb-4">
{localize('views.governance.votingPower.title')}
</Text>
<Text type={TextType.h1}>{formattedVotingPower}</Text>
<Text fontWeight={FontWeight.medium} overrideColor classes="mb-4 text-gray-600 dark:text-white">
{localize('views.governance.votingPower.maximal', { values: { value: formattedMaxVotingPower } })}
</Text>
<Button
size={ButtonSize.Medium}
onClick={handleManageVotingPower}
classes="w-full"
disabled={hasTransactionInProgress}
isBusy={hasTransactionInProgress}
>
{localize('views.governance.votingPower.manage')}
</Button>
</voting-power>