Skip to content

Commit

Permalink
fix: now advanced dialog has correct deposit (#2185)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Zhuravlev <[email protected]>
  • Loading branch information
johnthecat and Sergey Zhuravlev authored Aug 22, 2024
1 parent b3df41c commit 2eba3e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useI18n } from '@app/providers';
import { type Asset, type OngoingReferendum } from '@shared/core';
import { useModalClose } from '@shared/lib/hooks';
import { copyToClipboard, formatBalance } from '@shared/lib/utils';
import { copyToClipboard, formatAsset } from '@shared/lib/utils';
import { BaseModal, DetailRow, IconButton, Separator, Truncate } from '@shared/ui';
import { AddressWithName } from '@entities/wallet';
import { type AggregatedReferendum } from '../../types/structs';
Expand All @@ -16,21 +16,13 @@ export const AdvancedDialog = ({ asset, referendum, onClose }: Props) => {
const { t } = useI18n();
const [isOpen, closeModal] = useModalClose(true, onClose);

const { submissionDeposit, approvalThreshold, supportThreshold, tally, proposal } = referendum;
const { decisionDeposit, submissionDeposit, approvalThreshold, supportThreshold, tally, proposal } = referendum;
const approvalCurve = approvalThreshold?.curve?.type;
const supportCurve = supportThreshold?.curve?.type;

const electrorateBalance = formatBalance(tally.ayes.add(tally.nays).add(tally.support), asset.precision);
const electrorate = `${electrorateBalance.formatted} ${asset.symbol}`;

const turnoutBalance = supportThreshold
? formatBalance(supportThreshold.value.sub(tally.support), asset.precision)
: null;
const turnout = `${turnoutBalance?.formatted ?? 0} ${asset.symbol}`;

const deposit = submissionDeposit
? `${formatBalance(submissionDeposit.amount, asset.precision).formatted} ${asset.symbol}`
: null;
const electorate = formatAsset(tally.ayes.add(tally.nays).add(tally.support), asset);
const turnout = supportThreshold ? formatAsset(supportThreshold.value.sub(tally.support), asset) : null;
const deposit = decisionDeposit ? formatAsset(decisionDeposit.amount, asset) : null;

return (
<BaseModal
Expand Down Expand Up @@ -70,7 +62,7 @@ export const AdvancedDialog = ({ asset, referendum, onClose }: Props) => {

<DetailRow label={t('governance.advanced.fields.turnout')}>{turnout}</DetailRow>

<DetailRow label={t('governance.advanced.fields.electrorate')}>{electrorate}</DetailRow>
<DetailRow label={t('governance.advanced.fields.electorate')}>{electorate}</DetailRow>

<DetailRow label={t('governance.advanced.fields.callHash')}>
<div className="flex w-32 items-center gap-1 text-text-secondary">
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/shared/api/translation/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@
"approveCurve": "Approve curve",
"callHash": "Call hash",
"deposit": "Deposit",
"electrorate": "Electrorate",
"electorate": "Electorate",
"proposer": "Proposer",
"supportCurve": "Support curve",
"turnout": "Turnout"
Expand Down

0 comments on commit 2eba3e1

Please sign in to comment.