From 1c3a4c937af9afd33534717f12fc9f49c0fce418 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 21 Oct 2019 12:58:12 +0200 Subject: [PATCH] Update balance total to be free, reserved & bonded (#1748) --- packages/app-address-book/src/Address.tsx | 2 +- .../app-staking/src/Actions/Account/index.tsx | 16 ++-- packages/react-components/src/AddressInfo.tsx | 91 +++++++++++-------- 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/packages/app-address-book/src/Address.tsx b/packages/app-address-book/src/Address.tsx index 583e14b5b6..83a4ffe3fa 100644 --- a/packages/app-address-book/src/Address.tsx +++ b/packages/app-address-book/src/Address.tsx @@ -20,7 +20,7 @@ interface Props extends I18nProps { className?: string; } -const WITH_BALANCE = { available: true, free: true, total: true }; +const WITH_BALANCE = { available: true, bonded: true, free: true, total: true }; const WITH_EXTENDED = { nonce: true }; const isEditable = true; diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index f984237ad4..15c9f3af74 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -62,6 +62,14 @@ interface State { validatorPrefs?: ValidatorPrefs; } +const DEFAULT_BALANCES = { + available: true, + bonded: false, + total: false, + redeemable: false, + unlocking: false +}; + function toIdString (id?: AccountId | null): string | null { return id ? id.toString() @@ -143,13 +151,7 @@ class Account extends React.PureComponent { type='account' value={stashId} withAddressOrName - withBalance={{ - available: true, - bonded: false, - free: false, - redeemable: false, - unlocking: false - }} + withBalance={DEFAULT_BALANCES} > index !== 0); - const extra = extras.reduce((total, value): BN => total.add(value), new BN(0)).gtn(0) - ? `(+${extras.map((bonded): string => formatBalance(bonded)).join(', ')})` - : ''; + other = bonded + .filter((_, index): boolean => index !== 0) + .filter((value): boolean => value.gtn(0)); - value = `${formatBalance(bonded[0])} ${extra}`; + own = bonded[0]; } else if (staking_info && staking_info.stakingLedger && staking_info.accountId.eq(staking_info.stashId)) { - value = formatBalance(staking_info.stakingLedger.active); + own = staking_info.stakingLedger.active.unwrap(); } - return value - ? ( - <> -