Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions packages/desktop/components/popups/BalanceBreakdownPopup.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script lang="ts">
import { closePopup, openPopup, PopupId } from '@auxiliary/popup'
import { isVestingOutputId, selectedWalletVestingOverview } from '@contexts/vesting'
import { selectedWallet } from '@core/wallet'
import { localize } from '@core/i18n'
import { checkActiveProfileAuth } from '@core/profile'
import { getManaBalance } from '@core/network'
import { checkActiveProfileAuth } from '@core/profile'
import { selectedWallet } from '@core/wallet'
import { consolidateOutputs } from '@core/wallet/actions/consolidateOutputs'
import { getStorageDepositFromOutput } from '@core/wallet/utils/generateActivity/helper'
import { UnlockCondition, UnlockConditionType, CommonOutput } from '@iota/sdk/out/types'
import features from '@features/features'
import { CommonOutput, OutputType, UnlockCondition, UnlockConditionType } from '@iota/sdk/out/types'
import { BalanceSummarySection, Button, FontWeight, Text, TextType } from '@ui'
import { TextHintVariant } from '@ui/enums'
import features from '@features/features'

interface BalanceBreakdown {
amount: number
Expand All @@ -32,13 +32,15 @@
async function setBreakdown(): Promise<void> {
const availableBreakdown = getAvailableBreakdown()
const pendingBreakdown = await getPendingBreakdown()
const lockedBreakdown = getLockedBreakdown()
const storageDepositBreakdown = getStorageDepositBreakdown()
const vestingBreakdown = getVestingBreakdown()
const manaBreakdown = getManaBreakdown()

breakdown = {
available: availableBreakdown,
pending: pendingBreakdown,
locked: lockedBreakdown,
storageDeposit: storageDepositBreakdown,
mana: manaBreakdown,
...(features.vesting.enabled && { vesting: vestingBreakdown }),
Expand All @@ -53,11 +55,13 @@
const totalPasiveMana = getManaBalance(walletBalance?.mana?.total)
const availablePasiveBalance = getManaBalance(walletBalance?.mana?.available)
const totalMana = totalPasiveMana + (walletBalance?.totalWalletBic ?? 0)
const manaRewards = Number(walletBalance?.mana?.rewards ?? 0)

const subBreakdown = {
availableMana: { amount: availablePasiveBalance },
lockedMana: { amount: totalPasiveMana - availablePasiveBalance },
bicMana: { amount: walletBalance?.totalWalletBic },
manaRewards: { amount: manaRewards },
}
return { amount: totalMana, subBreakdown, isBaseToken: false }
}
Expand Down Expand Up @@ -102,6 +106,23 @@
return { amount: pendingOutputsStorageDeposit, subBreakdown }
}

function getLockedBreakdown(): BalanceBreakdown {
const delegationOutputs =
$selectedWallet?.walletUnspentOutputs?.filter((output) => output?.output?.type === OutputType.Delegation) ||
[]
const implicitAccounts = $selectedWallet?.implicitAccountOutputs || []
const delegatedAmount = Number(delegationOutputs.reduce((acc, prev) => acc + Number(prev.output.amount), 0))
const implicitAccountsAmount = Number(
implicitAccounts.reduce((acc, prev) => acc + Number(prev.output.amount), 0)
)
const totalLockedAmount = delegatedAmount + implicitAccountsAmount
const subBreakdown = {
delegation: { amount: delegatedAmount },
implicitAccounts: { amount: implicitAccountsAmount },
}
return { amount: totalLockedAmount, subBreakdown }
}

function getStorageDepositBreakdown(): BalanceBreakdown {
const storageDeposits = walletBalance?.requiredStorageDeposit
const totalStorageDeposit = storageDeposits
Expand Down
16 changes: 12 additions & 4 deletions packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@
},
"locked": {
"title": "Locked",
"subtitle": "Temporarily locked for governance"
"subtitle": "Temporarily locked in delegation or pending accounts"
},
"storageDeposit": {
"title": "Storage deposit",
Expand Down Expand Up @@ -829,9 +829,13 @@
"title": "SDRUC",
"subtitle": "Temporarily locked in Storage Deposit Return"
},
"governance": {
"title": "Governance",
"subtitle": "Reserved for voting power"
"delegation": {
"title": "Delegation",
"subtitle": "Delegated funds"
},
"implicitAccounts": {
"title": "Pending accounts",
"subtitle": "Pending accounts"
},
"vesting": {
"title": "Vesting",
Expand All @@ -849,6 +853,10 @@
"title": "BIC Mana",
"subtitle": "Block Issuance Credits Mana"
},
"manaRewards": {
"title": "Mana Rewards",
"subtitle": "Mana Rewards (Delegation & Staking)"
},
"availableMana": {
"title": "Available Mana",
"subtitle": "Mana available to send and issue blocks"
Expand Down