fix estimated sp value, show delegations

This commit is contained in:
feruz 2019-12-10 21:09:16 +02:00
parent 6e6428d3d6
commit f4ec281b52
4 changed files with 23 additions and 3 deletions

View File

@ -19,6 +19,7 @@
"outgoing_transfer_title": "Outgoing transfer",
"checkin_extra": "Bonus",
"delegation": "Delegation",
"delegations": "Delegations",
"delegation_title": "Delegation reward",
"delegation_desc": "Earn ESTM everyday for delegation",
"post_title": "Points for post",

View File

@ -55,6 +55,7 @@ const WalletContainer = ({
const [estimatedSpValue, setEstimatedSpValue] = useState(0);
const [unclaimedBalance, setUnclaimedBalance] = useState('');
const [estimatedAmount, setEstimatedAmount] = useState(0);
const [delegationsAmount, setDelegationsAmount] = useState(0);
const [transferHistory, setTransferHistory] = useState([]);
const intl = useIntl();
const dispatch = useDispatch();
@ -143,6 +144,13 @@ const WalletContainer = ({
setEstimatedSbdValue && setEstimatedSbdValue(_walletData.estimatedSbdValue);
setEstimatedSteemValue && setEstimatedSteemValue(_walletData.estimatedSteemValue);
setEstimatedSpValue && setEstimatedSpValue(_walletData.estimatedSpValue);
setDelegationsAmount &&
setDelegationsAmount(
vestsToSp(
_walletData.vestingSharesReceived - _walletData.vestingSharesDelegated,
steemPerMVests,
).toFixed(3),
);
},
[globalProps, intl.formatNumber, setEstimatedWalletValue, steemPerMVests],
);
@ -282,6 +290,7 @@ const WalletContainer = ({
estimatedSteemValue,
estimatedSbdValue,
estimatedSpValue,
delegationsAmount,
navigate: _navigate,
steemDropdown: STEEM_DROPDOWN,
sbdDropdown: SBD_DROPDOWN,

View File

@ -1,5 +1,5 @@
import React from 'react';
import { View } from 'react-native';
import { View, Text } from 'react-native';
import { WalletHeader, FormattedCurrency } from '../../../components';
import { SteemWalletContainer, AccountContainer } from '../../../containers';
@ -20,6 +20,7 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
spBalance,
isLoading,
estimatedSpValue,
delegationsAmount,
steemPowerDropdown,
unclaimedBalance,
navigate,
@ -45,6 +46,15 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
currentIndex={currentIndex}
showIconList={false}
valueDescriptions={[
{
textKey: 'delegations',
value: (
<Text>
{delegationsAmount}
{' SP'}
</Text>
),
},
{
textKey: 'estimated_value',
value: <FormattedCurrency isApproximate isToken value={estimatedSpValue} />,

View File

@ -187,7 +187,7 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => {
walletData.vestingSharesReceived = parseToken(user.received_vesting_shares);
walletData.vestingSharesTotal =
walletData.vestingShares - walletData.vestingSharesDelegated + walletData.vestingSharesReceived;
walletData.vestingSharesOwned = walletData.vestingShares - walletData.vestingSharesDelegated;
walletData.sbdBalance = parseToken(user.sbd_balance);
walletData.savingBalance = parseToken(user.savings_balance);
walletData.savingBalanceSbd = parseToken(user.savings_sbd_balance);
@ -215,7 +215,7 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => {
walletData.estimatedSteemValue = (walletData.balance + walletData.savingBalance) * ppSteem;
walletData.estimatedSbdValue = totalSbd * ppSbd;
walletData.estimatedSpValue =
vestsToSp(walletData.vestingSharesTotal, walletData.steemPerMVests) * ppSteem;
vestsToSp(walletData.vestingSharesOwned, walletData.steemPerMVests) * ppSteem;
walletData.showPowerDown = user.next_vesting_withdrawal !== '1969-12-31T23:59:59';
const timeDiff = Math.abs(parseDate(user.next_vesting_withdrawal) - new Date());