Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: storage deposit breakdown per output #5368

Merged
merged 2 commits into from Dec 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,7 +22,7 @@
const SECONDARY_COLOR = 'gray-600'
const SECONDARY_DARK_COLOR = 'gray-400'
const SECONDARY_FONT_SIZE = '13'
const SECONDARY_FONT_WEIGHT = FontWeight.medium
const SECONDARY_FONT_WEIGHT = FontWeight.normal
const SECONDARY_LINE_HEIGHT = '4'
</script>

Expand Down
Expand Up @@ -6,11 +6,12 @@
import { selectedAccountAssets } from '@core/wallet'
import { consolidateOutputs } from '@core/wallet/actions/consolidateOutputs'
import { getStorageDepositFromOutput } from '@core/wallet/utils/generateActivity/helper'
import type { AccountBalance } from '@iota/wallet'
import { BalanceSummarySection, Button, FontWeight, HR, Text } from 'shared/components'

$: ({ baseCoin } = $selectedAccountAssets)

let accountBalance
let accountBalance: AccountBalance
$: $selectedAccount, void getAccountBalance()
async function getAccountBalance(): Promise<void> {
accountBalance = await $selectedAccount.getBalance()
Expand All @@ -28,10 +29,13 @@
}
}
}
$: totalStorageDeposit = Object.values($selectedAccount.balances.requiredStorageDeposit).reduce(
(total: number, value: string): number => total + Number(value),
potentiallyLockedOutputsStorageDeposit
)

$: totalStorageDeposit = accountBalance?.requiredStorageDeposit
? Object.values(accountBalance?.requiredStorageDeposit).reduce(
(total: number, value: string): number => total + Number(value),
potentiallyLockedOutputsStorageDeposit
)
: potentiallyLockedOutputsStorageDeposit

function handleConsolidation(): void {
openPopup({
Expand All @@ -56,20 +60,50 @@
<Text type="h3" fontWeight={FontWeight.semibold} lineHeight="6">
{localize('popups.storageDepositBreakdown.title')}
</Text>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.pendingTransactions.title')}
subtitle={localize('popups.storageDepositBreakdown.pendingTransactions.subtitle')}
amount={potentiallyLockedOutputsStorageDeposit}
asset={baseCoin}
/>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.totalStorageDeposit')}
amount={totalStorageDeposit}
asset={baseCoin}
totalRow
/>
<div class="flex flex-col space-y-4">
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.basicOutputs.title')}
subtitle={localize('popups.storageDepositBreakdown.basicOutputs.subtitle')}
amount={Number(accountBalance?.requiredStorageDeposit?.basic ?? 0)}
asset={baseCoin}
/>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.nftOutputs.title')}
subtitle={localize('popups.storageDepositBreakdown.nftOutputs.subtitle')}
amount={Number(accountBalance?.requiredStorageDeposit?.nft ?? 0)}
asset={baseCoin}
/>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.aliasOutputs.title')}
subtitle={localize('popups.storageDepositBreakdown.aliasOutputs.subtitle')}
amount={Number(accountBalance?.requiredStorageDeposit?.alias ?? 0)}
asset={baseCoin}
/>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.foundryOutputs.title')}
subtitle={localize('popups.storageDepositBreakdown.foundryOutputs.subtitle')}
amount={Number(accountBalance?.requiredStorageDeposit?.foundry ?? 0)}
asset={baseCoin}
/>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.pendingTransactions.title')}
subtitle={localize('popups.storageDepositBreakdown.pendingTransactions.subtitle')}
amount={potentiallyLockedOutputsStorageDeposit}
asset={baseCoin}
/>
<HR hidden />
<BalanceSummarySection
title={localize('popups.storageDepositBreakdown.totalStorageDeposit')}
amount={totalStorageDeposit}
asset={baseCoin}
totalRow
/>
</div>
<Button onClick={handleConsolidation}>
{localize('popups.storageDepositBreakdown.minimizeStorageDepositButton')}
</Button>
Expand Down
20 changes: 18 additions & 2 deletions packages/shared/locales/en.json
Expand Up @@ -633,9 +633,25 @@
"storageDepositBreakdown": {
"title": "Storage deposit breakdown",
"totalStorageDeposit": "Total storage deposit",
"basicOutputs": {
"title": "Native Tokens",
"subtitle": "Reserved for Native Token storage"
},
"nftOutputs": {
"title": "NFTs",
"subtitle": "Reserved for NFT storage"
},
"aliasOutputs": {
"title": "Aliases",
"subtitle": "Reserved for Alias storage"
},
"foundryOutputs": {
"title": "Foundries",
"subtitle": "Reserved for Native Token Foundry storage"
},
"pendingTransactions": {
"title": "Locked in pending transactions",
"subtitle": "For sending native assets and small IOTA amounts"
"title": "Transactions",
"subtitle": "Temporarily locked in unclaimed transactions"
},
"minimizeStorageDepositButton": "Minimize storage deposit"
},
Expand Down