SP estimation on delegation page

This commit is contained in:
feruz 2019-12-10 06:45:27 +02:00
parent aee3dbc0d4
commit 0c20b434ea
3 changed files with 18 additions and 2 deletions

View File

@ -57,6 +57,7 @@ const Transfer = ({ navigation }) => (
transferToAccount={transferToAccount}
accountType={accountType}
handleOnModalClose={handleOnModalClose}
steemPerMVests={steemPerMVests}
/>
);
case 'power_down':

View File

@ -24,6 +24,7 @@ import {
import parseToken from '../../../utils/parseToken';
import { isEmptyDate } from '../../../utils/time';
import { vestsToSp } from '../../../utils/conversions';
// Styles
import styles from './transferStyles';
@ -131,7 +132,14 @@ class DelegateScreen extends Component {
_renderInformationText = text => <Text style={styles.amountText}>{text}</Text>;
render() {
const { intl, accounts, currentAccountName, selectedAccount, handleOnModalClose } = this.props;
const {
intl,
accounts,
currentAccountName,
selectedAccount,
handleOnModalClose,
steemPerMVests,
} = this.props;
const { amount, isTransfering, from, destination, steemConnectTransfer } = this.state;
let availableVestingShares = 0;
@ -154,6 +162,8 @@ class DelegateScreen extends Component {
fixedAmount,
)}`;
const spCalculated = vestsToSp(amount, steemPerMVests);
return (
<Fragment>
<BasicHeader title={intl.formatMessage({ id: 'transfer.delegate' })} />
@ -182,6 +192,10 @@ class DelegateScreen extends Component {
label={intl.formatMessage({ id: 'transfer.amount' })}
rightComponent={() => this._renderInformationText(`${amount.toFixed(6)} VESTS`)}
/>
<TransferFormItem
rightComponent={() => this._renderInformationText(`${spCalculated.toFixed(3)} SP`)}
/>
<Slider
style={styles.slider}
trackStyle={styles.track}

View File

@ -203,12 +203,14 @@ class PowerDownView extends Component {
const { amount, isTransfering, isOpenWithdrawAccount } = this.state;
let poweringDownVests = 0;
let availableVestingShares = 0;
let poweringDownFund = 0;
const poweringDown = !isEmptyDate(get(selectedAccount, 'next_vesting_withdrawal'));
const nextPowerDown = parseDate(get(selectedAccount, 'next_vesting_withdrawal'));
if (poweringDown) {
poweringDownVests = parseToken(get(selectedAccount, 'vesting_withdraw_rate'));
poweringDownFund = vestsToSp(poweringDownVests, steemPerMVests).toFixed(3);
} else {
availableVestingShares =
parseToken(get(selectedAccount, 'vesting_shares')) -
@ -219,7 +221,6 @@ class PowerDownView extends Component {
const spCalculated = vestsToSp(amount, steemPerMVests);
const fundPerWeek = Math.round((spCalculated / 13) * 1000) / 1000;
const poweringDownFund = vestsToSp(poweringDownVests, steemPerMVests).toFixed(3);
return (
<Fragment>