Skip to content

Commit

Permalink
Merge branch 'develop' into chore/update-electron
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 authored Nov 2, 2023
2 parents 95d3fbb + f405fd2 commit 4922311
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions packages/desktop/views/dashboard/vesting/Vesting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import { getMarketAmountFromAssetValue } from '@core/market/utils'
import { activeProfile } from '@core/profile'
import { getBestTimeDuration } from '@core/utils'
import { formatTokenAmountBestMatch, selectedAccountAssets } from '@core/wallet'
import {
formatTokenAmountBestMatch,
getRequiredStorageDepositForMinimalBasicOutput,
selectedAccountAssets,
} from '@core/wallet'
import {
Button,
FontWeight,
Expand All @@ -31,12 +35,18 @@
MeatballMenuButton,
TooltipIcon,
} from '@ui'
import { onMount } from 'svelte'
const DEFAULT_EMPTY_VALUE_STRING = '----'
$: hasTransactionInProgress =
$selectedAccount?.isTransferring || $selectedAccount.hasConsolidatingOutputsTransactionInProgress
let modal: Modal
let timeUntilNextPayout = DEFAULT_EMPTY_VALUE_STRING
let minRequiredStorageDeposit: number | null
let hasOutputsToConsolidate = false
$: ({ baseCoin } = $selectedAccountAssets[$activeProfile?.network?.id])
$: hasTransactionInProgress =
$selectedAccount?.isTransferring || $selectedAccount.hasConsolidatingOutputsTransactionInProgress
$: $selectedAccount, areOutputsReadyForConsolidation()
$: vestingOverview = [
{
title: localize('views.vesting.overview.unlocked'),
Expand All @@ -56,10 +66,30 @@
: undefined,
},
]
let modal: Modal
let timeUntilNextPayout = DEFAULT_EMPTY_VALUE_STRING
$: $selectedAccountVestingPayouts, (timeUntilNextPayout = getTimeUntilNextPayout())
$: canCollect =
$selectedAccountVestingUnclaimedFunds > 0 &&
!hasTransactionInProgress &&
minRequiredStorageDeposit !== null &&
$selectedAccount?.balances?.baseCoin?.available > minRequiredStorageDeposit &&
hasOutputsToConsolidate
onMount(() => {
getMinRequiredStorageDeposit()
})
function areOutputsReadyForConsolidation(): void {
$selectedAccount
.prepareConsolidateOutputs({ force: false, outputThreshold: 2 })
.then(() => (hasOutputsToConsolidate = true))
.catch(() => (hasOutputsToConsolidate = false))
}
function getMinRequiredStorageDeposit() {
getRequiredStorageDepositForMinimalBasicOutput()
.then((deposit) => (minRequiredStorageDeposit = deposit))
.catch(() => (minRequiredStorageDeposit = null))
}
function getFiatAmount(amount: number): string {
return baseCoin ? formatCurrency(getMarketAmountFromAssetValue(amount, baseCoin)) : ''
Expand Down Expand Up @@ -156,7 +186,7 @@
<Button
onClick={onCollectClick}
classes="w-full"
disabled={$selectedAccountVestingUnclaimedFunds === 0 || hasTransactionInProgress}
disabled={!canCollect}
isBusy={hasTransactionInProgress}
>
{localize('views.vesting.collect')}
Expand Down

0 comments on commit 4922311

Please sign in to comment.