Merge remote-tracking branch 'origin/development' into nt/custom-filters

This commit is contained in:
Nouman Tahir 2021-04-22 02:49:33 +05:00
commit 6326b862cd
16 changed files with 448 additions and 447 deletions

View File

@ -5,17 +5,22 @@ import { View } from 'react-native';
import { GrayWrapper, WalletLineItem } from '../../basicUIElements'; import { GrayWrapper, WalletLineItem } from '../../basicUIElements';
// Utilities // Utilities
import { vestsToSp } from '../../../utils/conversions'; import { vestsToHp } from '../../../utils/conversions';
// Styles // Styles
import styles from './walletDetailsStyles'; import styles from './walletDetailsStyles';
const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => { const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
const steemDropdown = ['purchase_estm', 'transfer_token', 'transfer_to_saving', 'powerUp']; const hiveDropdown = [
const sbdDropdown = ['purchase_estm', 'transfer_token', 'transfer_to_saving', 'convert']; 'purchase_estm',
const savingSteemDropdown = ['withdraw_steem']; 'transfer_token',
const savingSbdDropdown = ['withdraw_sbd']; 'transfer_to_savings',
const steemPowerDropdown = ['delegate', 'power_down']; 'transfer_to_vesting',
];
const hbdDropdown = ['purchase_estm', 'transfer_token', 'transfer_to_savings', 'convert'];
const savingHiveDropdown = ['withdraw_hive'];
const savingHbdDropdown = ['withdraw_hbd'];
const hivePowerDropdown = ['delegate', 'power_down'];
return ( return (
<View style={styles.container}> <View style={styles.container}>
@ -26,10 +31,8 @@ const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
rightText={`${Math.round(walletData.balance * 1000) / 1000} HIVE`} rightText={`${Math.round(walletData.balance * 1000) / 1000} HIVE`}
isBoldText isBoldText
isHasdropdown={isShowDropdowns} isHasdropdown={isShowDropdowns}
dropdownOptions={steemDropdown.map((item) => dropdownOptions={hiveDropdown.map((item) => intl.formatMessage({ id: `transfer.${item}` }))}
intl.formatMessage({ id: `transfer.${item}` }), onDropdownSelect={(index) => navigate(hiveDropdown[index], 'HIVE')}
)}
onDropdownSelect={(index) => navigate(steemDropdown[index], 'HIVE')}
/> />
<GrayWrapper isGray> <GrayWrapper isGray>
<WalletLineItem <WalletLineItem
@ -39,21 +42,21 @@ const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
isBlackText isBlackText
iconName="ios-information-circle-outline" iconName="ios-information-circle-outline"
rightText={`${ rightText={`${
Math.round(vestsToSp(walletData.vestingShares, walletData.steemPerMVests) * 1000) / 1000 Math.round(vestsToHp(walletData.vestingShares, walletData.hivePerMVests) * 1000) / 1000
} HP`} } HP`}
isBoldText isBoldText
isHasdropdown={isShowDropdowns} isHasdropdown={isShowDropdowns}
dropdownOptions={steemPowerDropdown.map((item) => dropdownOptions={hivePowerDropdown.map((item) =>
intl.formatMessage({ id: `transfer.${item}` }), intl.formatMessage({ id: `transfer.${item}` }),
)} )}
onDropdownSelect={(a) => navigate(steemPowerDropdown[a], 'HIVE_POWER')} onDropdownSelect={(a) => navigate(hivePowerDropdown[a], 'HIVE_POWER')}
/> />
{walletData.vestingSharesDelegated > 0 && ( {walletData.vestingSharesDelegated > 0 && (
<WalletLineItem <WalletLineItem
rightText={`- ${ rightText={`- ${
Math.round( Math.round(
vestsToSp(walletData.vestingSharesDelegated, walletData.steemPerMVests) * 1000, vestsToHp(walletData.vestingSharesDelegated, walletData.hivePerMVests) * 1000,
) / 1000 ) / 1000
} HP`} } HP`}
style={styles.walletLineDetail} style={styles.walletLineDetail}
@ -63,7 +66,7 @@ const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
<WalletLineItem <WalletLineItem
rightText={`+ ${ rightText={`+ ${
Math.round( Math.round(
vestsToSp(walletData.vestingSharesReceived, walletData.steemPerMVests) * 1000, vestsToHp(walletData.vestingSharesReceived, walletData.hivePerMVests) * 1000,
) / 1000 ) / 1000
} HP`} } HP`}
style={styles.walletLineDetail} style={styles.walletLineDetail}
@ -73,7 +76,7 @@ const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
<WalletLineItem <WalletLineItem
rightText={`= ${ rightText={`= ${
Math.round( Math.round(
vestsToSp(walletData.vestingSharesTotal, walletData.steemPerMVests) * 1000, vestsToHp(walletData.vestingSharesTotal, walletData.hivePerMVests) * 1000,
) / 1000 ) / 1000
} HP`} } HP`}
rightTextColor="#357ce6" rightTextColor="#357ce6"
@ -88,11 +91,11 @@ const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
})} })}
isBlackText isBlackText
iconName="ios-information-circle-outline" iconName="ios-information-circle-outline"
rightText={`$${Math.round(walletData.sbdBalance * 1000) / 1000}`} rightText={`$${Math.round(walletData.hbdBalance * 1000) / 1000}`}
isBoldText isBoldText
isHasdropdown={isShowDropdowns} isHasdropdown={isShowDropdowns}
dropdownOptions={sbdDropdown.map((item) => intl.formatMessage({ id: `transfer.${item}` }))} dropdownOptions={hbdDropdown.map((item) => intl.formatMessage({ id: `transfer.${item}` }))}
onDropdownSelect={(a) => navigate(sbdDropdown[a], 'HBD')} onDropdownSelect={(a) => navigate(hbdDropdown[a], 'HBD')}
/> />
<GrayWrapper isGray> <GrayWrapper isGray>
<WalletLineItem <WalletLineItem
@ -104,19 +107,19 @@ const WalletDetailsView = ({ walletData, intl, navigate, isShowDropdowns }) => {
rightText={`${Math.round(walletData.savingBalance * 1000) / 1000} HIVE`} rightText={`${Math.round(walletData.savingBalance * 1000) / 1000} HIVE`}
isBoldText isBoldText
isHasdropdown={isShowDropdowns} isHasdropdown={isShowDropdowns}
dropdownOptions={savingSteemDropdown.map((item) => dropdownOptions={savingHiveDropdown.map((item) =>
intl.formatMessage({ id: `transfer.${item}` }), intl.formatMessage({ id: `transfer.${item}` }),
)} )}
onDropdownSelect={(a) => navigate(savingSteemDropdown[a], 'SAVING_HIVE')} onDropdownSelect={(a) => navigate(savingHiveDropdown[a], 'SAVING_HIVE')}
/> />
<WalletLineItem <WalletLineItem
rightText={`$${Math.round(walletData.savingBalanceSbd * 1000) / 1000}`} rightText={`$${Math.round(walletData.savingBalanceHbd * 1000) / 1000}`}
style={styles.walletLineDetail} style={styles.walletLineDetail}
isHasdropdown={isShowDropdowns} isHasdropdown={isShowDropdowns}
dropdownOptions={savingSbdDropdown.map((item) => dropdownOptions={savingHbdDropdown.map((item) =>
intl.formatMessage({ id: `transfer.${item}` }), intl.formatMessage({ id: `transfer.${item}` }),
)} )}
onDropdownSelect={(a) => navigate(savingSbdDropdown[a], 'SAVING_HBD')} onDropdownSelect={(a) => navigate(savingHbdDropdown[a], 'SAVING_HBD')}
/> />
</GrayWrapper> </GrayWrapper>
{walletData.showPowerDown && ( {walletData.showPowerDown && (

View File

@ -5,7 +5,7 @@
"comment_benefactor_reward": "Benefactor Reward", "comment_benefactor_reward": "Benefactor Reward",
"claim_reward_balance": "Claim Reward ", "claim_reward_balance": "Claim Reward ",
"transfer": "Transfer", "transfer": "Transfer",
"transfer_to_vesting": "To Vesting", "power_up": "To Vesting",
"transfer_from_savings": "From Savings", "transfer_from_savings": "From Savings",
"withdraw_vesting": "Power Down", "withdraw_vesting": "Power Down",
"fill_order": "Fill Order", "fill_order": "Fill Order",
@ -62,14 +62,14 @@
"purchase_estm": "GET POINTS", "purchase_estm": "GET POINTS",
"points": "Gift Points to someone", "points": "Gift Points to someone",
"transfer_to_saving": "To Saving", "transfer_to_saving": "To Saving",
"powerUp": "Power Up", "transfer_to_vesting": "Power Up",
"withdraw_to_saving": "Withdraw Saving", "withdraw_to_saving": "Withdraw Saving",
"steemconnect_title": "Hivesigner Transfer", "steemconnect_title": "Hivesigner Transfer",
"next": "NEXT", "next": "NEXT",
"delegate": "Delegate", "delegate": "Delegate",
"power_down": "Power Down", "power_down": "Power Down",
"withdraw_steem": "Withdraw HIVE", "withdraw_hive": "Withdraw HIVE",
"withdraw_sbd": "Withdraw HBD", "withdraw_hbd": "Withdraw HBD",
"transfer_to_savings": "To Savings", "transfer_to_savings": "To Savings",
"convert": "Convert", "convert": "Convert",
"escrow_transfer": "Escrow Transfer", "escrow_transfer": "Escrow Transfer",
@ -85,21 +85,21 @@
"title": "Points", "title": "Points",
"buy": "GET POINTS" "buy": "GET POINTS"
}, },
"savingsteem": { "savinghive": {
"title": "HIVE Savings" "title": "HIVE Savings"
}, },
"savingsbd": { "savinghbd": {
"title": "HBD Savings" "title": "HBD Savings"
}, },
"steem": { "hive": {
"title": "HIVE", "title": "HIVE",
"buy": "GET HIVE" "buy": "GET HIVE"
}, },
"sbd": { "hbd": {
"title": "HBD", "title": "HBD",
"buy": "GET HBD" "buy": "GET HBD"
}, },
"steem_power": { "hive_power": {
"title": "HIVE POWER" "title": "HIVE POWER"
}, },
"btc": { "btc": {
@ -162,11 +162,11 @@
"follow_communities": "Join some communities to fill your feed", "follow_communities": "Join some communities to fill your feed",
"havent_commented": "haven't commented anything yet", "havent_commented": "haven't commented anything yet",
"havent_posted": "haven't posted anything yet", "havent_posted": "haven't posted anything yet",
"steem_power": "Hive Power", "hive_power": "Hive Power",
"next_power_text": "Next power down is in", "next_power_text": "Next power down is in",
"days": "days", "days": "days",
"day": "day", "day": "day",
"steem_dollars": "Hive Dollars", "hive_dollars": "Hive Dollars",
"savings": "Savings", "savings": "Savings",
"edit": { "edit": {
"display_name": "Display Name", "display_name": "Display Name",
@ -511,8 +511,8 @@
"purchase_estm": "Purchase Points", "purchase_estm": "Purchase Points",
"convert": "Convert HBD to HIVE", "convert": "Convert HBD to HIVE",
"points": "Gift Points to someone", "points": "Gift Points to someone",
"transfer_to_saving": "Transfer To Saving", "transfer_to_savings": "Transfer To Saving",
"powerUp": "Power Up", "transfer_to_vesting": "Power Up",
"withdraw_to_saving": "Withdraw To Saving", "withdraw_to_saving": "Withdraw To Saving",
"steemconnect_title": "Hivesigner Transfer", "steemconnect_title": "Hivesigner Transfer",
"estimated_weekly": "Estimated Weekly", "estimated_weekly": "Estimated Weekly",
@ -525,10 +525,11 @@
"next": "NEXT", "next": "NEXT",
"delegate": "Delegate", "delegate": "Delegate",
"power_down": "Power Down", "power_down": "Power Down",
"withdraw_steem": "Withdraw HIVE", "withdraw_hive": "Withdraw HIVE",
"withdraw_sbd": "Withdraw HIVE Dollar", "withdraw_hbd": "Withdraw HIVE Dollar",
"incoming_funds": "Incoming Funds", "incoming_funds": "Incoming Funds",
"stop": "Stop", "stop": "Stop",
"sc_power_down_error": "This feature is not implemented for Hivesigner login, yet",
"address_view": "View address" "address_view": "View address"
}, },
"boost": { "boost": {

View File

@ -85,18 +85,18 @@ class TransferContainer extends Component {
transferType === 'transfer_token') && transferType === 'transfer_token') &&
fundType === 'HBD' fundType === 'HBD'
) { ) {
balance = account[0].sbd_balance.replace(fundType, ''); balance = account[0].hbd_balance.replace(fundType, '');
} }
if (transferType === 'points' && fundType === 'ESTM') { if (transferType === 'points' && fundType === 'ESTM') {
this._getUserPointsBalance(username); this._getUserPointsBalance(username);
} }
if (transferType === 'transfer_to_saving' && fundType === 'HIVE') { if (transferType === 'transfer_to_savings' && fundType === 'HIVE') {
balance = account[0].balance.replace(fundType, ''); balance = account[0].balance.replace(fundType, '');
} }
if (transferType === 'transfer_to_saving' && fundType === 'HBD') { if (transferType === 'transfer_to_savings' && fundType === 'HBD') {
balance = account[0].sbd_balance.replace(fundType, ''); balance = account[0].hbd_balance.replace(fundType, '');
} }
if (transferType === 'powerUp' && fundType === 'HIVE') { if (transferType === 'transfer_to_vesting' && fundType === 'HIVE') {
balance = account[0].balance.replace(fundType, ''); balance = account[0].balance.replace(fundType, '');
} }
if (transferType === 'address_view' && fundType === 'BTC') { if (transferType === 'address_view' && fundType === 'BTC') {
@ -142,7 +142,6 @@ class TransferContainer extends Component {
} }
data.amount = `${data.amount} ${fundType}`; data.amount = `${data.amount} ${fundType}`;
switch (transferType) { switch (transferType) {
case 'transfer_token': case 'transfer_token':
func = transferToken; func = transferToken;
@ -154,17 +153,17 @@ class TransferContainer extends Component {
func = convert; func = convert;
data.requestId = new Date().getTime() >>> 0; data.requestId = new Date().getTime() >>> 0;
break; break;
case 'transfer_to_saving': case 'transfer_to_savings':
func = transferToSavings; func = transferToSavings;
break; break;
case 'powerUp': case 'transfer_to_vesting':
func = transferToVesting; func = transferToVesting;
break; break;
case 'withdraw_steem' || 'withdraw_hive': case 'withdraw_hive':
func = transferFromSavings; func = transferFromSavings;
data.requestId = new Date().getTime() >>> 0; data.requestId = new Date().getTime() >>> 0;
break; break;
case 'withdraw_sbd' || 'withdraw_hbd': case 'withdraw_hbd':
func = transferFromSavings; func = transferFromSavings;
data.requestId = new Date().getTime() >>> 0; data.requestId = new Date().getTime() >>> 0;
break; break;
@ -222,7 +221,7 @@ class TransferContainer extends Component {
}; };
render() { render() {
const { accounts, navigation, children, steemPerMVests, currentAccount } = this.props; const { accounts, navigation, children, hivePerMVests, currentAccount } = this.props;
const { balance, fundType, selectedAccount, tokenAddress } = this.state; const { balance, fundType, selectedAccount, tokenAddress } = this.state;
const transferType = navigation.getParam('transferType', ''); const transferType = navigation.getParam('transferType', '');
@ -236,7 +235,7 @@ class TransferContainer extends Component {
fundType, fundType,
transferType, transferType,
selectedAccount, selectedAccount,
steemPerMVests, hivePerMVests,
fetchBalance: this.fetchBalance, fetchBalance: this.fetchBalance,
getAccountsWithUsername: this._getAccountsWithUsername, getAccountsWithUsername: this._getAccountsWithUsername,
transferToAccount: this._transferToAccount, transferToAccount: this._transferToAccount,
@ -253,7 +252,7 @@ const mapStateToProps = (state) => ({
accounts: state.account.otherAccounts, accounts: state.account.otherAccounts,
currentAccount: state.account.currentAccount, currentAccount: state.account.currentAccount,
pinCode: state.application.pin, pinCode: state.application.pin,
steemPerMVests: state.account.globalProps.steemPerMVests, hivePerMVests: state.account.globalProps.hivePerMVests,
}); });
export default connect(mapStateToProps)(injectIntl(TransferContainer)); export default connect(mapStateToProps)(injectIntl(TransferContainer));

View File

@ -5,7 +5,7 @@ import { useIntl } from 'react-intl';
import get from 'lodash/get'; import get from 'lodash/get';
import { toastNotification } from '../redux/actions/uiAction'; import { toastNotification } from '../redux/actions/uiAction';
// Dsteem // dhive
import { getAccount, claimRewardBalance, getBtcAddress } from '../providers/hive/dhive'; import { getAccount, claimRewardBalance, getBtcAddress } from '../providers/hive/dhive';
// Actions // Actions
@ -14,18 +14,23 @@ import { openPinCodeModal } from '../redux/actions/applicationActions';
// Utils // Utils
import { groomingWalletData, groomingTransactionData, transferTypes } from '../utils/wallet'; import { groomingWalletData, groomingTransactionData, transferTypes } from '../utils/wallet';
import parseToken from '../utils/parseToken'; import parseToken from '../utils/parseToken';
import { vestsToSp } from '../utils/conversions'; import { vestsToHp } from '../utils/conversions';
import { navigate } from '../navigation/service'; import { navigate } from '../navigation/service';
import { getEstimatedAmount } from '../utils/vote'; import { getEstimatedAmount } from '../utils/vote';
// Constants // Constants
import ROUTES from '../constants/routeNames'; import ROUTES from '../constants/routeNames';
const HIVE_DROPDOWN = ['purchase_estm', 'transfer_token', 'transfer_to_saving', 'powerUp']; const HIVE_DROPDOWN = [
'purchase_estm',
'transfer_token',
'transfer_to_savings',
'transfer_to_vesting',
];
const BTC_DROPDOWN = ['transfer_token']; const BTC_DROPDOWN = ['transfer_token'];
const HBD_DROPDOWN = ['purchase_estm', 'transfer_token', 'transfer_to_saving', 'convert']; const HBD_DROPDOWN = ['purchase_estm', 'transfer_token', 'transfer_to_savings', 'convert'];
const SAVING_HIVE_DROPDOWN = ['withdraw_steem']; const SAVING_HIVE_DROPDOWN = ['withdraw_hive'];
const SAVING_HBD_DROPDOWN = ['withdraw_sbd']; const SAVING_HBD_DROPDOWN = ['withdraw_hbd'];
const HIVE_POWER_DROPDOWN = ['delegate', 'power_down']; const HIVE_POWER_DROPDOWN = ['delegate', 'power_down'];
const WalletContainer = ({ const WalletContainer = ({
@ -36,7 +41,7 @@ const WalletContainer = ({
pinCode, pinCode,
selectedUser, selectedUser,
setEstimatedWalletValue, setEstimatedWalletValue,
steemPerMVests, hivePerMVests,
isPinCodeOpen, isPinCodeOpen,
currency, currency,
}) => { }) => {
@ -45,18 +50,18 @@ const WalletContainer = ({
const [refreshing, setRefreshing] = useState(false); const [refreshing, setRefreshing] = useState(false);
const [walletData, setWalletData] = useState(null); const [walletData, setWalletData] = useState(null);
const [userActivities, setUserActivities] = useState([]); const [userActivities, setUserActivities] = useState([]);
const [sbdBalance, setSbdBalance] = useState(0); const [hbdBalance, setHbdBalance] = useState(0);
const [tokenBalance, setTokenBalance] = useState(0); const [tokenBalance, setTokenBalance] = useState(0);
const [tokenAddress, setTokenAddress] = useState(''); const [tokenAddress, setTokenAddress] = useState('');
const [steemBalance, setSteemBalance] = useState(0); const [hiveBalance, setHiveBalance] = useState(0);
const [spBalance, setSpBalance] = useState(0); const [hpBalance, setHpBalance] = useState(0);
const [steemSavingBalance, setSteemSavingBalance] = useState(0); const [hiveSavingBalance, setHiveSavingBalance] = useState(0);
const [sbdSavingBalance, setSbdSavingBalance] = useState(0); const [hbdSavingBalance, setHbdSavingBalance] = useState(0);
const [estimatedValue, setEstimatedValue] = useState(0); const [estimatedValue, setEstimatedValue] = useState(0);
const [estimatedSteemValue, setEstimatedSteemValue] = useState(0); const [estimatedHiveValue, setEstimatedHiveValue] = useState(0);
const [estimatedSbdValue, setEstimatedSbdValue] = useState(0); const [estimatedHbdValue, setEstimatedHbdValue] = useState(0);
const [estimatedTokenValue, setEstimatedTokenValue] = useState(0); const [estimatedTokenValue, setEstimatedTokenValue] = useState(0);
const [estimatedSpValue, setEstimatedSpValue] = useState(0); const [estimatedHpValue, setEstimatedHpValue] = useState(0);
const [unclaimedBalance, setUnclaimedBalance] = useState(''); const [unclaimedBalance, setUnclaimedBalance] = useState('');
const [estimatedAmount, setEstimatedAmount] = useState(0); const [estimatedAmount, setEstimatedAmount] = useState(0);
const [delegationsAmount, setDelegationsAmount] = useState(0); const [delegationsAmount, setDelegationsAmount] = useState(0);
@ -78,41 +83,41 @@ const WalletContainer = ({
); );
setTransferHistory(_transferHistory); setTransferHistory(_transferHistory);
setSbdBalance(Math.round(get(walletData, 'sbdBalance', 0) * 1000) / 1000); setHbdBalance(Math.round(get(walletData, 'hbdBalance', 0) * 1000) / 1000);
setTokenBalance(Math.round(get(walletData, 'tokenBalance', 0) * 1000) / 1000); setTokenBalance(Math.round(get(walletData, 'tokenBalance', 0) * 1000) / 1000);
setTokenAddress(get(walletData, 'tokenAddress', '')); setTokenAddress(get(walletData, 'tokenAddress', ''));
setSteemBalance(Math.round(get(walletData, 'balance', 0) * 1000) / 1000); setHiveBalance(Math.round(get(walletData, 'balance', 0) * 1000) / 1000);
setSteemSavingBalance(Math.round(get(walletData, 'savingBalance', 0) * 1000) / 1000); setHiveSavingBalance(Math.round(get(walletData, 'savingBalance', 0) * 1000) / 1000);
setSbdSavingBalance(Math.round(get(walletData, 'savingBalanceSbd', 0) * 1000) / 1000); setHbdSavingBalance(Math.round(get(walletData, 'savingBalanceHbd', 0) * 1000) / 1000);
setSpBalance( setHpBalance(
Math.round( Math.round(
vestsToSp(get(walletData, 'vestingShares', 0), get(walletData, 'steemPerMVests', 0)) * 1000, vestsToHp(get(walletData, 'vestingShares', 0), get(walletData, 'hivePerMVests', 0)) * 1000,
) / 1000, ) / 1000,
); );
setEstimatedValue(get(walletData, 'estimatedValue', 0)); setEstimatedValue(get(walletData, 'estimatedValue', 0));
setEstimatedSteemValue(get(walletData, 'estimatedSteemValue', 0)); setEstimatedHiveValue(get(walletData, 'estimatedHiveValue', 0));
setEstimatedSbdValue(get(walletData, 'estimatedSbdValue', 0)); setEstimatedHbdValue(get(walletData, 'estimatedHbdValue', 0));
setEstimatedTokenValue(get(walletData, 'estimatedTokenValue', 0)); setEstimatedTokenValue(get(walletData, 'estimatedTokenValue', 0));
setEstimatedSpValue(get(walletData, 'estimatedSpValue', 0)); setEstimatedHpValue(get(walletData, 'estimatedHpValue', 0));
setDelegationsAmount( setDelegationsAmount(
vestsToSp( vestsToHp(
get(walletData, 'vestingSharesReceived', 0) - get(walletData, 'vestingSharesDelegated', 0), get(walletData, 'vestingSharesReceived', 0) - get(walletData, 'vestingSharesDelegated', 0),
get(walletData, 'steemPerMVests', 0), get(walletData, 'hivePerMVests', 0),
).toFixed(3), ).toFixed(3),
); );
if ( if (
get(walletData, 'rewardSteemBalance', 0) || get(walletData, 'rewardHiveBalance', 0) ||
get(walletData, 'rewardSbdBalance', 0) || get(walletData, 'rewardHbdBalance', 0) ||
get(walletData, 'rewardVestingSteem', 0) get(walletData, 'rewardVestingHive', 0)
) { ) {
const getBalance = (val, cur) => (val ? Math.round(val * 1000) / 1000 + cur : ''); const getBalance = (val, cur) => (val ? Math.round(val * 1000) / 1000 + cur : '');
setUnclaimedBalance( setUnclaimedBalance(
`${getBalance(get(walletData, 'rewardSteemBalance', 0), ' HIVE')} ${getBalance( `${getBalance(get(walletData, 'rewardHiveBalance', 0), ' HIVE')} ${getBalance(
get(walletData, 'rewardSbdBalance', 0), get(walletData, 'rewardHbdBalance', 0),
' HBD', ' HBD',
)} ${getBalance(get(walletData, 'rewardVestingSteem', 0), ' HP')}`, )} ${getBalance(get(walletData, 'rewardVestingHive', 0), ' HP')}`,
); );
} }
}, [userActivities, walletData]); }, [userActivities, walletData]);
@ -127,19 +132,19 @@ const WalletContainer = ({
setIsLoading(false); setIsLoading(false);
setUserActivities( setUserActivities(
get(_walletData, 'transactions', []).map((item) => get(_walletData, 'transactions', []).map((item) =>
groomingTransactionData(item, steemPerMVests), groomingTransactionData(item, hivePerMVests),
), ),
); );
setEstimatedWalletValue && setEstimatedWalletValue(_walletData.estimatedValue); setEstimatedWalletValue && setEstimatedWalletValue(_walletData.estimatedValue);
const getBalance = (val, cur) => (val ? Math.round(val * 1000) / 1000 + cur : ''); const getBalance = (val, cur) => (val ? Math.round(val * 1000) / 1000 + cur : '');
setUnclaimedBalance( setUnclaimedBalance(
`${getBalance(get(_walletData, 'rewardSteemBalance', 0), ' HIVE')} ${getBalance( `${getBalance(get(_walletData, 'rewardHiveBalance', 0), ' HIVE')} ${getBalance(
get(_walletData, 'rewardSbdBalance', 0), get(_walletData, 'rewardHbdBalance', 0),
' HBD', ' HBD',
)} ${getBalance(get(_walletData, 'rewardVestingSteem', 0), ' HP')}`, )} ${getBalance(get(_walletData, 'rewardVestingHive', 0), ' HP')}`,
); );
}, },
[globalProps, setEstimatedWalletValue, steemPerMVests], [globalProps, setEstimatedWalletValue, hivePerMVests],
); );
const _isHasUnclaimedRewards = (account) => { const _isHasUnclaimedRewards = (account) => {
@ -164,11 +169,11 @@ const WalletContainer = ({
isHasUnclaimedRewards = _isHasUnclaimedRewards(account[0]); isHasUnclaimedRewards = _isHasUnclaimedRewards(account[0]);
if (isHasUnclaimedRewards) { if (isHasUnclaimedRewards) {
const { const {
reward_hive_balance: steemBal, reward_hive_balance: hiveBal,
reward_hbd_balance: sbdBal, reward_hbd_balance: hbdBal,
reward_vesting_balance: vestingBal, reward_vesting_balance: vestingBal,
} = account[0]; } = account[0];
return claimRewardBalance(currentAccount, pinCode, steemBal, sbdBal, vestingBal); return claimRewardBalance(currentAccount, pinCode, hiveBal, hbdBal, vestingBal);
} }
setIsClaiming(false); setIsClaiming(false);
}) })
@ -238,19 +243,13 @@ const WalletContainer = ({
transferType === 'purchase_estm') && transferType === 'purchase_estm') &&
fundType === 'HBD' fundType === 'HBD'
) { ) {
balance = Math.round(walletData.sbdBalance * 1000) / 1000; balance = Math.round(walletData.hbdBalance * 1000) / 1000;
} }
if ( if (transferType === 'withdraw_hive' && fundType === 'HIVE') {
(transferType === 'withdraw_steem' || transferType === 'withdraw_hive') &&
fundType === 'HIVE'
) {
balance = Math.round(walletData.savingBalance * 1000) / 1000; balance = Math.round(walletData.savingBalance * 1000) / 1000;
} }
if ( if (transferType === 'withdraw_hbd' && fundType === 'HBD') {
(transferType === 'withdraw_sbd' || transferType === 'withdraw_hbd') && balance = Math.round(walletData.savingBalanceHbd * 1000) / 1000;
fundType === 'HBD'
) {
balance = Math.round(walletData.savingBalanceSbd * 1000) / 1000;
} }
if (isPinCodeOpen) { if (isPinCodeOpen) {
@ -285,29 +284,29 @@ const WalletContainer = ({
selectedUsername: get(selectedUser, 'name', ''), selectedUsername: get(selectedUser, 'name', ''),
isLoading, isLoading,
walletData, walletData,
steemPerMVests, hivePerMVests,
userActivities, userActivities,
transferHistory, transferHistory,
steemBalance, hiveBalance,
spBalance, hpBalance,
sbdBalance, hbdBalance,
tokenBalance, tokenBalance,
getTokenAddress, getTokenAddress,
steemSavingBalance, hiveSavingBalance,
sbdSavingBalance, hbdSavingBalance,
estimatedValue, estimatedValue,
estimatedSteemValue, estimatedHiveValue,
estimatedSbdValue, estimatedHbdValue,
estimatedTokenValue, estimatedTokenValue,
estimatedSpValue, estimatedHpValue,
delegationsAmount, delegationsAmount,
navigate: _navigate, navigate: _navigate,
steemDropdown: HIVE_DROPDOWN, hiveDropdown: HIVE_DROPDOWN,
sbdDropdown: HBD_DROPDOWN, hbdDropdown: HBD_DROPDOWN,
btcDropdown: BTC_DROPDOWN, btcDropdown: BTC_DROPDOWN,
savingSteemDropdown: SAVING_HIVE_DROPDOWN, savingHiveDropdown: SAVING_HIVE_DROPDOWN,
savingSbdDropdown: SAVING_HBD_DROPDOWN, savingHbdDropdown: SAVING_HBD_DROPDOWN,
steemPowerDropdown: HIVE_POWER_DROPDOWN, hivePowerDropdown: HIVE_POWER_DROPDOWN,
unclaimedBalance: unclaimedBalance && unclaimedBalance.trim(), unclaimedBalance: unclaimedBalance && unclaimedBalance.trim(),
estimatedAmount, estimatedAmount,
}) })
@ -319,7 +318,7 @@ const mapStateToProps = (state) => ({
pinCode: state.application.pin, pinCode: state.application.pin,
globalProps: state.account.globalProps, globalProps: state.account.globalProps,
currency: state.application.currency.currency, currency: state.application.currency.currency,
steemPerMVests: state.account.globalProps.steemPerMVests, hivePerMVests: state.account.globalProps.hivePerMVests,
isPinCodeOpen: state.application.isPinCodeOpen, isPinCodeOpen: state.application.isPinCodeOpen,
}); });

View File

@ -78,29 +78,27 @@ export const fetchGlobalProps = async () => {
globalDynamic = await getDynamicGlobalProperties(); globalDynamic = await getDynamicGlobalProperties();
await setCache('globalDynamic', globalDynamic); await setCache('globalDynamic', globalDynamic);
feedHistory = await getFeedHistory(); feedHistory = await getFeedHistory();
await setCache('feedHistory', feedHistory);
rewardFund = await getRewardFund(); rewardFund = await getRewardFund();
await setCache('rewardFund', rewardFund);
} catch (e) { } catch (e) {
return; return;
} }
const steemPerMVests = const hivePerMVests =
(parseToken(get(globalDynamic, 'total_vesting_fund_hive')) / (parseToken(get(globalDynamic, 'total_vesting_fund_hive')) /
parseToken(get(globalDynamic, 'total_vesting_shares'))) * parseToken(get(globalDynamic, 'total_vesting_shares'))) *
1e6; 1e6;
const sbdPrintRate = get(globalDynamic, 'hbd_print_rate'); const hbdPrintRate = get(globalDynamic, 'hbd_print_rate');
const base = parseAsset(get(feedHistory, 'current_median_history.base')).amount; const base = parseAsset(get(feedHistory, 'current_median_history.base')).amount;
const quote = parseAsset(get(feedHistory, 'current_median_history.quote')).amount; const quote = parseAsset(get(feedHistory, 'current_median_history.quote')).amount;
const fundRecentClaims = get(rewardFund, 'recent_claims'); const fundRecentClaims = get(rewardFund, 'recent_claims');
const fundRewardBalance = parseToken(get(rewardFund, 'reward_balance')); const fundRewardBalance = parseToken(get(rewardFund, 'reward_balance'));
const globalProps = { const globalProps = {
steemPerMVests, hivePerMVests,
base, base,
quote, quote,
fundRecentClaims, fundRecentClaims,
fundRewardBalance, fundRewardBalance,
sbdPrintRate, hbdPrintRate,
}; };
return globalProps; return globalProps;
@ -186,7 +184,12 @@ export const getUser = async (user, loggedIn = true) => {
return null; return null;
} }
const globalProperties = getCache('globalDynamic'); let globalProperties;
try {
globalProperties = await getDynamicGlobalProperties();
} catch (error) {
globalProperties = getCache('globalDynamic');
}
const rcPower = const rcPower =
(user && (user &&
@ -1357,7 +1360,7 @@ const _reblog = async (account, pinCode, author, permlink) => {
); );
}; };
export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rewardVests) => { export const claimRewardBalance = (account, pinCode, rewardHive, rewardHbd, rewardVests) => {
const pin = getDigitPinCode(pinCode); const pin = getDigitPinCode(pinCode);
const key = getAnyPrivateKey(get(account, 'local'), pin); const key = getAnyPrivateKey(get(account, 'local'), pin);
@ -1367,7 +1370,7 @@ export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rew
accessToken: token, accessToken: token,
}); });
return api.claimRewardBalance(get(account, 'name'), rewardSteem, rewardSbd, rewardVests); return api.claimRewardBalance(get(account, 'name'), rewardHive, rewardHbd, rewardVests);
} }
if (key) { if (key) {
@ -1378,8 +1381,8 @@ export const claimRewardBalance = (account, pinCode, rewardSteem, rewardSbd, rew
'claim_reward_balance', 'claim_reward_balance',
{ {
account: account.name, account: account.name,
reward_hive: rewardSteem, reward_hive: rewardHive,
reward_hbd: rewardSbd, reward_hbd: rewardHbd,
reward_vests: rewardVests, reward_vests: rewardVests,
}, },
], ],

View File

@ -21,18 +21,18 @@ const Transfer = ({ navigation }) => (
handleOnModalClose, handleOnModalClose,
accountType, accountType,
currentAccountName, currentAccountName,
steemPerMVests, hivePerMVests,
setWithdrawVestingRoute, setWithdrawVestingRoute,
}) => { }) => {
switch (transferType) { switch (transferType) {
case 'transfer_token': case 'transfer_token':
case 'purchase_estm': case 'purchase_estm':
case 'convert': case 'convert':
case 'transfer_to_saving': case 'transfer_to_savings':
case 'powerUp': case 'transfer_to_vesting':
case 'points': case 'points':
case 'withdraw_steem': case 'withdraw_hive':
case 'withdraw_sbd': case 'withdraw_hbd':
return ( return (
<TransferView <TransferView
accounts={accounts} accounts={accounts}
@ -60,7 +60,7 @@ const Transfer = ({ navigation }) => (
transferToAccount={transferToAccount} transferToAccount={transferToAccount}
accountType={accountType} accountType={accountType}
handleOnModalClose={handleOnModalClose} handleOnModalClose={handleOnModalClose}
steemPerMVests={steemPerMVests} hivePerMVests={hivePerMVests}
/> />
); );
case 'power_down': case 'power_down':
@ -77,7 +77,7 @@ const Transfer = ({ navigation }) => (
accountType={accountType} accountType={accountType}
currentAccountName={currentAccountName} currentAccountName={currentAccountName}
selectedAccount={selectedAccount} selectedAccount={selectedAccount}
steemPerMVests={steemPerMVests} hivePerMVests={hivePerMVests}
setWithdrawVestingRoute={setWithdrawVestingRoute} setWithdrawVestingRoute={setWithdrawVestingRoute}
/> />
); );

View File

@ -24,7 +24,7 @@ import {
import parseToken from '../../../utils/parseToken'; import parseToken from '../../../utils/parseToken';
import { isEmptyDate } from '../../../utils/time'; import { isEmptyDate } from '../../../utils/time';
import { vestsToSp } from '../../../utils/conversions'; import { vestsToHp } from '../../../utils/conversions';
// Styles // Styles
import styles from './transferStyles'; import styles from './transferStyles';
@ -138,11 +138,11 @@ class DelegateScreen extends Component {
currentAccountName, currentAccountName,
selectedAccount, selectedAccount,
handleOnModalClose, handleOnModalClose,
steemPerMVests, hivePerMVests,
accountType,
} = this.props; } = this.props;
const { amount, isTransfering, from, destination, steemConnectTransfer } = this.state; const { amount, isTransfering, from, destination, steemConnectTransfer } = this.state;
let availableVestingShares = 0; let availableVestingShares = 0;
if (!isEmptyDate(get(selectedAccount, 'next_vesting_withdrawal'))) { if (!isEmptyDate(get(selectedAccount, 'next_vesting_withdrawal'))) {
// powering down // powering down
availableVestingShares = availableVestingShares =
@ -162,7 +162,7 @@ class DelegateScreen extends Component {
fixedAmount, fixedAmount,
)}`; )}`;
const spCalculated = vestsToSp(amount, steemPerMVests); const spCalculated = vestsToHp(amount, hivePerMVests);
return ( return (
<Fragment> <Fragment>

View File

@ -24,7 +24,7 @@ import WithdrawAccountModal from './withdrawAccountModal';
import parseToken from '../../../utils/parseToken'; import parseToken from '../../../utils/parseToken';
import parseDate from '../../../utils/parseDate'; import parseDate from '../../../utils/parseDate';
import { vestsToSp } from '../../../utils/conversions'; import { vestsToHp } from '../../../utils/conversions';
import { isEmptyDate } from '../../../utils/time'; import { isEmptyDate } from '../../../utils/time';
import styles from './transferStyles'; import styles from './transferStyles';
@ -80,6 +80,7 @@ class PowerDownView extends Component {
intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'alert.warning' }),
intl.formatMessage({ id: 'transfer.sc_power_down_error' }), intl.formatMessage({ id: 'transfer.sc_power_down_error' }),
); );
this.setState({ steemConnectTransfer: true, isTransfering: false });
} else { } else {
transferToAccount(from, destinationAccounts, amount, ''); transferToAccount(from, destinationAccounts, amount, '');
} }
@ -198,7 +199,7 @@ class PowerDownView extends Component {
getAccountsWithUsername, getAccountsWithUsername,
transferType, transferType,
currentAccountName, currentAccountName,
steemPerMVests, hivePerMVests,
} = this.props; } = this.props;
const { amount, isTransfering, isOpenWithdrawAccount } = this.state; const { amount, isTransfering, isOpenWithdrawAccount } = this.state;
let poweringDownVests = 0; let poweringDownVests = 0;
@ -210,7 +211,7 @@ class PowerDownView extends Component {
if (poweringDown) { if (poweringDown) {
poweringDownVests = parseToken(get(selectedAccount, 'vesting_withdraw_rate')); poweringDownVests = parseToken(get(selectedAccount, 'vesting_withdraw_rate'));
poweringDownFund = vestsToSp(poweringDownVests, steemPerMVests).toFixed(3); poweringDownFund = vestsToHp(poweringDownVests, hivePerMVests).toFixed(3);
} else { } else {
availableVestingShares = availableVestingShares =
parseToken(get(selectedAccount, 'vesting_shares')) - parseToken(get(selectedAccount, 'vesting_shares')) -
@ -219,7 +220,7 @@ class PowerDownView extends Component {
parseToken(get(selectedAccount, 'delegated_vesting_shares')); parseToken(get(selectedAccount, 'delegated_vesting_shares'));
} }
const spCalculated = vestsToSp(amount, steemPerMVests); const spCalculated = vestsToHp(amount, hivePerMVests);
const fundPerWeek = Math.round((spCalculated / 13) * 1000) / 1000; const fundPerWeek = Math.round((spCalculated / 13) * 1000) / 1000;
return ( return (

View File

@ -1,4 +1,4 @@
import React, { Fragment, Component } from 'react'; import React, { Fragment, Component, useState, useRef, useEffect } from 'react';
import { Text, View, ScrollView, TouchableOpacity } from 'react-native'; import { Text, View, ScrollView, TouchableOpacity } from 'react-native';
import { WebView } from 'react-native-webview'; import { WebView } from 'react-native-webview';
import ActionSheet from 'react-native-actionsheet'; import ActionSheet from 'react-native-actionsheet';
@ -21,96 +21,98 @@ import {
import styles from './transferStyles'; import styles from './transferStyles';
/* Props const TransferView = ({
* ------------------------------------------------ currentAccountName,
* @prop { type } name - Description.... transferType,
*/ getAccountsWithUsername,
balance,
class TransferView extends Component { transferToAccount,
constructor(props) { accountType,
super(props); accounts,
this.state = { intl,
from: props.currentAccountName, handleOnModalClose,
destination: fundType,
props.transferType === 'powerUp' || selectedAccount,
props.transferType === 'withdraw_steem' || fetchBalance,
props.transferType === 'withdraw_steem' }) => {
? props.currentAccountName const [from, setFrom] = useState(currentAccountName);
: props.transferType === 'purchase_estm' const [destination, setDestination] = useState(
transferType === 'transfer_to_vesting' ||
transferType === 'transfer_to_savings' ||
transferType === 'withdraw_vesting' ||
transferType === 'withdraw_hive' ||
transferType === 'withdraw_hbd' ||
transferType === 'convert'
? currentAccountName
: transferType === 'purchase_estm'
? 'esteem.app' ? 'esteem.app'
: props.transferType === 'convert'
? props.currentAccountName
: '', : '',
amount: '', );
memo: props.transferType === 'purchase_estm' ? 'estm-purchase' : '', const [amount, setAmount] = useState('');
isUsernameValid: !!( const [memo, setMemo] = useState(transferType === 'purchase_estm' ? 'estm-purchase' : '');
props.transferType === 'purchase_estm' || const [isUsernameValid, setIsUsernameValid] = useState(
props.transferType === 'convert' || !!(
props.transferType === 'powerUp' || transferType === 'purchase_estm' ||
props.transferType === 'withdraw_steem' || transferType === 'transfer_to_vesting' ||
(props.transferType === 'withdraw_steem' && props.currentAccountName) transferType === 'transfer_to_savings' ||
transferType === 'withdraw_vesting' ||
transferType === 'withdraw_hive' ||
transferType === 'withdraw_hbd' ||
(transferType === 'convert' && currentAccountName)
), ),
steemConnectTransfer: false, );
isTransfering: false, const [hsTransfer, setHsTransfer] = useState(false);
}; const [isTransfering, setIsTransfering] = useState(false);
} const confirm = useRef(null);
// Component Life Cycles //useEffect(() => {
//}, []);
// Component Functions
_setState = (key, value) => {
const { getAccountsWithUsername, balance } = this.props;
if (key) {
switch (key) {
case 'destination':
getAccountsWithUsername(value).then((res) => {
const isValid = res.includes(value);
this.setState({ isUsernameValid: isValid });
});
this.setState({ [key]: value });
break;
case 'amount':
if (parseFloat(Number(value)) <= parseFloat(balance)) {
this.setState({ [key]: value });
}
break;
default:
this.setState({ [key]: value });
break;
}
}
};
_handleTransferAction = () => {
const { transferToAccount, accountType } = this.props;
const { from, destination, amount, memo } = this.state;
this.setState({ isTransfering: true });
const _handleTransferAction = () => {
setIsTransfering(true);
if (accountType === AUTH_TYPE.STEEM_CONNECT) { if (accountType === AUTH_TYPE.STEEM_CONNECT) {
this.setState({ steemConnectTransfer: true }); setHsTransfer(true);
} else { } else {
transferToAccount(from, destination, amount, memo); transferToAccount(from, destination, amount, memo);
} }
}; };
_handleOnAmountChange = (state, amount) => { const _handleOnChange = (state, val) => {
let _amount = amount.toString(); let _amount = val.toString();
if (_amount.includes(',')) { if (_amount.includes(',')) {
_amount = amount.replace(',', '.'); _amount = val.replace(',', '.');
} }
if (state === 'amount') {
if (parseFloat(Number(_amount)) <= parseFloat(balance)) {
setAmount(_amount);
}
}
if (state === 'destination') {
getAccountsWithUsername(val).then((res) => {
const isValid = res.includes(val);
this._setState(state, _amount); setIsUsernameValid(isValid);
});
setDestination(_amount);
}
if (state === 'memo') {
setMemo(_amount);
}
}; };
_renderInput = (placeholder, state, keyboardType, isTextArea) => ( const _renderInput = (placeholder, state, keyboardType, isTextArea) => (
<TextInput <TextInput
style={[isTextArea ? styles.textarea : styles.input]} style={[isTextArea ? styles.textarea : styles.input]}
onChangeText={(amount) => this._handleOnAmountChange(state, amount)} onChangeText={(amount) => _handleOnChange(state, amount)}
value={this.state[state]} value={
state === 'destination'
? destination
: state === 'amount'
? amount
: state === 'memo'
? memo
: ''
}
placeholder={placeholder} placeholder={placeholder}
placeholderTextColor="#c1c5c7" placeholderTextColor="#c1c5c7"
autoCapitalize="none" autoCapitalize="none"
@ -119,8 +121,7 @@ class TransferView extends Component {
keyboardType={keyboardType} keyboardType={keyboardType}
/> />
); );
const _renderDropdown = (accounts, currentAccountName) => (
_renderDropdown = (accounts, currentAccountName) => (
<DropdownButton <DropdownButton
dropdownButtonStyle={styles.dropdownButtonStyle} dropdownButtonStyle={styles.dropdownButtonStyle}
rowTextStyle={styles.rowTextStyle} rowTextStyle={styles.rowTextStyle}
@ -130,44 +131,21 @@ class TransferView extends Component {
options={accounts.map((item) => item.username)} options={accounts.map((item) => item.username)}
defaultText={currentAccountName} defaultText={currentAccountName}
selectedOptionIndex={accounts.findIndex((item) => item.username === currentAccountName)} selectedOptionIndex={accounts.findIndex((item) => item.username === currentAccountName)}
onSelect={(index, value) => this._handleOnDropdownChange(value)} onSelect={(index, value) => _handleOnDropdownChange(value)}
/> />
); );
_handleOnDropdownChange = (value) => { const _handleOnDropdownChange = (value) => {
const { fetchBalance, transferType } = this.props;
fetchBalance(value); fetchBalance(value);
this.setState({ from: value }); setFrom(value);
if (transferType === 'convert') { if (transferType === 'convert') {
this.setState({ destination: value }); setDestination(value);
} }
}; };
_renderDescription = (text) => <Text style={styles.description}>{text}</Text>; const _renderDescription = (text) => <Text style={styles.description}>{text}</Text>;
render() {
const {
accounts,
intl,
handleOnModalClose,
balance,
fundType,
transferType,
currentAccountName,
selectedAccount,
} = this.props;
const {
destination,
isUsernameValid,
amount,
steemConnectTransfer,
memo,
isTransfering,
from,
} = this.state;
let path; let path;
if (hsTransfer) {
if (transferType === 'points') { if (transferType === 'points') {
const json = JSON.stringify({ const json = JSON.stringify({
sender: get(selectedAccount, 'name'), sender: get(selectedAccount, 'name'),
@ -181,14 +159,36 @@ class TransferView extends Component {
)}%22%5D&required_posting_auths=%5B%5D&id=esteem_point_transfer&json=${encodeURIComponent( )}%22%5D&required_posting_auths=%5B%5D&id=esteem_point_transfer&json=${encodeURIComponent(
json, json,
)}`; )}`;
} else if (transferType === 'transfer_to_savings') {
path = `sign/transfer_to_savings?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent(
`${amount} ${fundType}`,
)}&memo=${encodeURIComponent(memo)}`;
} else if (transferType === 'delegate_vesting_shares') {
path = `sign/delegate_vesting_shares?delegator=${currentAccountName}&delegatee=${destination}&vesting_shares=${encodeURIComponent(
`${amount} ${fundType}`,
)}`;
} else if (transferType === 'transfer_to_vesting') {
path = `sign/transfer_to_vesting?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent(
`${amount} ${fundType}`,
)}`;
} else if (transferType === 'withdraw_hive' || transferType === 'withdraw_hbd') {
path = `sign/transfer_from_savings?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent(
`${amount} ${fundType}`,
)}&request_id=${new Date().getTime() >>> 0}`;
} else if (transferType === 'convert') {
path = `sign/convert?owner=${currentAccountName}&amount=${encodeURIComponent(
`${amount} ${fundType}`,
)}&requestid=${new Date().getTime() >>> 0}`;
} else if (transferType === 'withdraw_vesting') {
path = `sign/withdraw_vesting?account=${currentAccountName}&vesting_shares=${encodeURIComponent(
`${amount} ${fundType}`,
)}`;
} else { } else {
path = `sign/transfer?from=${ path = `sign/transfer?from=${currentAccountName}&to=${destination}&amount=${encodeURIComponent(
accounts[0].username
}&to=${destination}&amount=${encodeURIComponent(
`${amount} ${fundType}`, `${amount} ${fundType}`,
)}&memo=${encodeURIComponent(memo)}`; )}&memo=${encodeURIComponent(memo)}`;
} }
}
return ( return (
<Fragment> <Fragment>
<BasicHeader title={intl.formatMessage({ id: `transfer.${transferType}` })} /> <BasicHeader title={intl.formatMessage({ id: `transfer.${transferType}` })} />
@ -202,13 +202,13 @@ class TransferView extends Component {
<View style={styles.middleContent}> <View style={styles.middleContent}>
<TransferFormItem <TransferFormItem
label={intl.formatMessage({ id: 'transfer.from' })} label={intl.formatMessage({ id: 'transfer.from' })}
rightComponent={() => this._renderDropdown(accounts, currentAccountName)} rightComponent={() => _renderDropdown(accounts, currentAccountName)}
/> />
{transferType !== 'convert' && ( {transferType !== 'convert' && (
<TransferFormItem <TransferFormItem
label={intl.formatMessage({ id: 'transfer.to' })} label={intl.formatMessage({ id: 'transfer.to' })}
rightComponent={() => rightComponent={() =>
this._renderInput( _renderInput(
intl.formatMessage({ id: 'transfer.to_placeholder' }), intl.formatMessage({ id: 'transfer.to_placeholder' }),
'destination', 'destination',
'default', 'default',
@ -219,17 +219,13 @@ class TransferView extends Component {
<TransferFormItem <TransferFormItem
label={intl.formatMessage({ id: 'transfer.amount' })} label={intl.formatMessage({ id: 'transfer.amount' })}
rightComponent={() => rightComponent={() =>
this._renderInput( _renderInput(intl.formatMessage({ id: 'transfer.amount' }), 'amount', 'numeric')
intl.formatMessage({ id: 'transfer.amount' }),
'amount',
'numeric',
)
} }
/> />
<TransferFormItem <TransferFormItem
rightComponent={() => ( rightComponent={() => (
<TouchableOpacity onPress={() => this._handleOnAmountChange('amount', balance)}> <TouchableOpacity onPress={() => _handleOnChange('amount', balance)}>
{this._renderDescription( {_renderDescription(
`${intl.formatMessage({ `${intl.formatMessage({
id: 'transfer.amount_desc', id: 'transfer.amount_desc',
})} ${balance} ${fundType === 'ESTM' ? 'Points' : fundType}`, })} ${balance} ${fundType === 'ESTM' ? 'Points' : fundType}`,
@ -237,11 +233,13 @@ class TransferView extends Component {
</TouchableOpacity> </TouchableOpacity>
)} )}
/> />
{(transferType === 'points' || transferType === 'transfer_token') && ( {(transferType === 'points' ||
transferType === 'transfer_token' ||
transferType === 'transfer_to_savings') && (
<TransferFormItem <TransferFormItem
label={intl.formatMessage({ id: 'transfer.memo' })} label={intl.formatMessage({ id: 'transfer.memo' })}
rightComponent={() => rightComponent={() =>
this._renderInput( _renderInput(
intl.formatMessage({ id: 'transfer.memo_placeholder' }), intl.formatMessage({ id: 'transfer.memo_placeholder' }),
'memo', 'memo',
'default', 'default',
@ -253,14 +251,14 @@ class TransferView extends Component {
{(transferType === 'points' || transferType === 'transfer_token') && ( {(transferType === 'points' || transferType === 'transfer_token') && (
<TransferFormItem <TransferFormItem
rightComponent={() => rightComponent={() =>
this._renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' })) _renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' }))
} }
/> />
)} )}
{transferType === 'convert' && ( {transferType === 'convert' && (
<TransferFormItem <TransferFormItem
rightComponent={() => rightComponent={() =>
this._renderDescription(intl.formatMessage({ id: 'transfer.convert_desc' })) _renderDescription(intl.formatMessage({ id: 'transfer.convert_desc' }))
} }
/> />
)} )}
@ -269,7 +267,7 @@ class TransferView extends Component {
<MainButton <MainButton
style={styles.button} style={styles.button}
isDisable={!(amount >= 0.001 && isUsernameValid)} isDisable={!(amount >= 0.001 && isUsernameValid)}
onPress={() => this.ActionSheet.show()} onPress={() => confirm.current.show()}
isLoading={isTransfering} isLoading={isTransfering}
> >
<Text style={styles.buttonText}>{intl.formatMessage({ id: 'transfer.next' })}</Text> <Text style={styles.buttonText}>{intl.formatMessage({ id: 'transfer.next' })}</Text>
@ -278,7 +276,7 @@ class TransferView extends Component {
</ScrollView> </ScrollView>
</View> </View>
<ActionSheet <ActionSheet
ref={(o) => (this.ActionSheet = o)} ref={confirm}
options={[ options={[
intl.formatMessage({ id: 'alert.confirm' }), intl.formatMessage({ id: 'alert.confirm' }),
intl.formatMessage({ id: 'alert.cancel' }), intl.formatMessage({ id: 'alert.cancel' }),
@ -287,12 +285,12 @@ class TransferView extends Component {
cancelButtonIndex={1} cancelButtonIndex={1}
destructiveButtonIndex={0} destructiveButtonIndex={0}
onPress={(index) => { onPress={(index) => {
index === 0 ? this._handleTransferAction() : null; index === 0 ? _handleTransferAction() : null;
}} }}
/> />
{path && ( {path && (
<Modal <Modal
isOpen={steemConnectTransfer} isOpen={hsTransfer}
isFullScreen isFullScreen
isCloseButton isCloseButton
handleOnModalClose={handleOnModalClose} handleOnModalClose={handleOnModalClose}
@ -303,7 +301,6 @@ class TransferView extends Component {
)} )}
</Fragment> </Fragment>
); );
} };
}
export default injectIntl(TransferView); export default injectIntl(TransferView);

View File

@ -6,7 +6,7 @@ import { WalletContainer, AccountContainer } from '../../../containers';
import globalStyles from '../../../globalStyles'; import globalStyles from '../../../globalStyles';
const SbdView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) => ( const HbdView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) => (
<View style={globalStyles.swipeItemWrapper}> <View style={globalStyles.swipeItemWrapper}>
<AccountContainer> <AccountContainer>
{({ currentAccount }) => ( {({ currentAccount }) => (
@ -17,12 +17,12 @@ const SbdView = ({ handleOnSelected, index, currentIndex, refreshing: reload })
handleOnWalletRefresh, handleOnWalletRefresh,
refreshing, refreshing,
transferHistory, transferHistory,
sbdBalance, hbdBalance,
isLoading, isLoading,
sbdSavingBalance, hbdSavingBalance,
estimatedSbdValue, estimatedHbdValue,
sbdDropdown, hbdDropdown,
savingSbdDropdown, savingHbdDropdown,
navigate, navigate,
}) => ( }) => (
<WalletHeader <WalletHeader
@ -36,17 +36,17 @@ const SbdView = ({ handleOnSelected, index, currentIndex, refreshing: reload })
refreshing={refreshing} refreshing={refreshing}
unclaimedBalance={0} unclaimedBalance={0}
userBalance={[ userBalance={[
{ balance: sbdBalance, nameKey: 'sbd', options: sbdDropdown }, { balance: hbdBalance, nameKey: 'hbd', options: hbdDropdown },
{ balance: sbdSavingBalance, nameKey: 'savingsbd', options: savingSbdDropdown }, { balance: hbdSavingBalance, nameKey: 'savinghbd', options: savingHbdDropdown },
]} ]}
handleOnDropdownSelected={(option) => navigate(option, 'HBD')} handleOnDropdownSelected={(option) => navigate(option, 'HBD')}
type="sbd" type="hbd"
currentIndex={currentIndex} currentIndex={currentIndex}
showIconList={false} showIconList={false}
valueDescriptions={[ valueDescriptions={[
{ {
textKey: 'estimated_value', textKey: 'estimated_value',
value: <FormattedCurrency isApproximate isToken value={estimatedSbdValue} />, value: <FormattedCurrency isApproximate isToken value={estimatedHbdValue} />,
subTextKey: 'estimated_value_desc', subTextKey: 'estimated_value_desc',
}, },
]} ]}
@ -58,4 +58,4 @@ const SbdView = ({ handleOnSelected, index, currentIndex, refreshing: reload })
</View> </View>
); );
export default SbdView; export default HbdView;

View File

@ -6,7 +6,7 @@ import { WalletContainer, AccountContainer } from '../../../containers';
import globalStyles from '../../../globalStyles'; import globalStyles from '../../../globalStyles';
const SteemView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) => ( const HiveView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) => (
<View style={globalStyles.swipeItemWrapper}> <View style={globalStyles.swipeItemWrapper}>
<AccountContainer> <AccountContainer>
{({ currentAccount }) => ( {({ currentAccount }) => (
@ -17,12 +17,12 @@ const SteemView = ({ handleOnSelected, index, currentIndex, refreshing: reload }
handleOnWalletRefresh, handleOnWalletRefresh,
refreshing, refreshing,
transferHistory, transferHistory,
steemBalance, hiveBalance,
isLoading, isLoading,
steemSavingBalance, hiveSavingBalance,
estimatedSteemValue, estimatedHiveValue,
steemDropdown, hiveDropdown,
savingSteemDropdown, savingHiveDropdown,
navigate, navigate,
}) => ( }) => (
<WalletHeader <WalletHeader
@ -36,21 +36,21 @@ const SteemView = ({ handleOnSelected, index, currentIndex, refreshing: reload }
refreshing={refreshing} refreshing={refreshing}
unclaimedBalance={0} unclaimedBalance={0}
userBalance={[ userBalance={[
{ balance: steemBalance, nameKey: 'steem', options: steemDropdown }, { balance: hiveBalance, nameKey: 'hive', options: hiveDropdown },
{ {
balance: steemSavingBalance, balance: hiveSavingBalance,
nameKey: 'savingsteem', nameKey: 'savinghive',
options: savingSteemDropdown, options: savingHiveDropdown,
}, },
]} ]}
handleOnDropdownSelected={(option) => navigate(option, 'HIVE')} handleOnDropdownSelected={(option) => navigate(option, 'HIVE')}
type="steem" type="hive"
currentIndex={currentIndex} currentIndex={currentIndex}
showIconList={false} showIconList={false}
valueDescriptions={[ valueDescriptions={[
{ {
textKey: 'estimated_value', textKey: 'estimated_value',
value: <FormattedCurrency isApproximate isToken value={estimatedSteemValue} />, value: <FormattedCurrency isApproximate isToken value={estimatedHiveValue} />,
subTextKey: 'estimated_value_desc', subTextKey: 'estimated_value_desc',
}, },
]} ]}
@ -62,4 +62,4 @@ const SteemView = ({ handleOnSelected, index, currentIndex, refreshing: reload }
</View> </View>
); );
export default SteemView; export default HiveView;

View File

@ -6,7 +6,7 @@ import { WalletContainer, AccountContainer } from '../../../containers';
import globalStyles from '../../../globalStyles'; import globalStyles from '../../../globalStyles';
const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) => ( const HpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) => (
<View style={globalStyles.swipeItemWrapper}> <View style={globalStyles.swipeItemWrapper}>
<AccountContainer> <AccountContainer>
{({ currentAccount }) => ( {({ currentAccount }) => (
@ -17,11 +17,11 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
handleOnWalletRefresh, handleOnWalletRefresh,
refreshing, refreshing,
userActivities, userActivities,
spBalance, hpBalance,
isLoading, isLoading,
estimatedSpValue, estimatedHpValue,
delegationsAmount, delegationsAmount,
steemPowerDropdown, hivePowerDropdown,
unclaimedBalance, unclaimedBalance,
navigate, navigate,
estimatedAmount, estimatedAmount,
@ -39,10 +39,10 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
unclaimedBalance={unclaimedBalance} unclaimedBalance={unclaimedBalance}
showBuyButton={unclaimedBalance.length > 0} showBuyButton={unclaimedBalance.length > 0}
userBalance={[ userBalance={[
{ balance: spBalance, nameKey: 'steem_power', options: steemPowerDropdown }, { balance: hpBalance, nameKey: 'hive_power', options: hivePowerDropdown },
]} ]}
handleOnDropdownSelected={(option) => navigate(option, 'HIVE_POWER')} handleOnDropdownSelected={(option) => navigate(option, 'HIVE_POWER')}
type="steem_power" type="hive_power"
currentIndex={currentIndex} currentIndex={currentIndex}
showIconList={false} showIconList={false}
valueDescriptions={[ valueDescriptions={[
@ -57,7 +57,7 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
}, },
{ {
textKey: 'estimated_value', textKey: 'estimated_value',
value: <FormattedCurrency isApproximate isToken value={estimatedSpValue} />, value: <FormattedCurrency isApproximate isToken value={estimatedHpValue} />,
}, },
{ {
textKey: 'estimated_amount', textKey: 'estimated_amount',
@ -72,4 +72,4 @@ const SpView = ({ handleOnSelected, index, currentIndex, refreshing: reload }) =
</View> </View>
); );
export default SpView; export default HpView;

View File

@ -9,9 +9,9 @@ import { LoggedInContainer } from '../../../containers';
// Components // Components
import { Header, Transaction, HorizontalIconList } from '../../../components'; import { Header, Transaction, HorizontalIconList } from '../../../components';
import EstmView from './estmView'; import EstmView from './estmView';
import SteemView from './steemView'; import HiveView from './hiveView';
import SpView from './spView'; import HpView from './hpView';
import SbdView from './sbdView'; import HbdView from './hbdView';
// Styles // Styles
import globalStyles from '../../../globalStyles'; import globalStyles from '../../../globalStyles';
@ -62,19 +62,19 @@ const WalletScreen = () => {
refreshing={refreshing} refreshing={refreshing}
currentIndex={currentIndex} currentIndex={currentIndex}
/> />
<SteemView <HiveView
index={1} index={1}
handleOnSelected={_handleSwipeItemChange} handleOnSelected={_handleSwipeItemChange}
refreshing={refreshing} refreshing={refreshing}
currentIndex={currentIndex} currentIndex={currentIndex}
/> />
<SbdView <HbdView
index={2} index={2}
handleOnSelected={_handleSwipeItemChange} handleOnSelected={_handleSwipeItemChange}
refreshing={refreshing} refreshing={refreshing}
currentIndex={currentIndex} currentIndex={currentIndex}
/> />
<SpView <HpView
index={3} index={3}
refreshing={refreshing} refreshing={refreshing}
handleOnSelected={_handleSwipeItemChange} handleOnSelected={_handleSwipeItemChange}

View File

@ -1,9 +1,9 @@
export const vestsToSp = (vests, steemPerMVests) => { export const vestsToHp = (vests, hivePerMVests) => {
if (!vests || !steemPerMVests) { if (!vests || !hivePerMVests) {
return 0; return 0;
} }
return (vests / 1e6) * steemPerMVests; return (vests / 1e6) * hivePerMVests;
}; };
export const vestsToRshares = (vests, votingPower, votePerc) => { export const vestsToRshares = (vests, votingPower, votePerc) => {

View File

@ -5,13 +5,13 @@ const PERIOD = 432000;
export const getVotingPower = (account) => { export const getVotingPower = (account) => {
const { vp_manabar } = account; const { vp_manabar } = account;
const { percentage } = vp_manabar; const { percentage } = vp_manabar || 0;
return percentage / 100 || 0; return percentage / 100 || 0;
}; };
export const getRcPower = (account) => { export const getRcPower = (account) => {
const { rc_manabar } = account; const { rc_manabar } = account;
const { percentage } = rc_manabar; const { percentage } = rc_manabar || 0;
return percentage / 100 || 0; return percentage / 100 || 0;
}; };

View File

@ -1,7 +1,7 @@
import get from 'lodash/get'; import get from 'lodash/get';
import parseDate from './parseDate'; import parseDate from './parseDate';
import parseToken from './parseToken'; import parseToken from './parseToken';
import { vestsToSp } from './conversions'; import { vestsToHp } from './conversions';
import { getFeedHistory, getAccount, getAccountHistory } from '../providers/hive/dhive'; import { getFeedHistory, getAccount, getAccountHistory } from '../providers/hive/dhive';
import { getCurrencyTokenRate } from '../providers/ecency/ecency'; import { getCurrencyTokenRate } from '../providers/ecency/ecency';
@ -27,8 +27,8 @@ export const transferTypes = [
'fill_vesting_withdraw', 'fill_vesting_withdraw',
]; ];
export const groomingTransactionData = (transaction, steemPerMVests) => { export const groomingTransactionData = (transaction, hivePerMVests) => {
if (!transaction || !steemPerMVests) { if (!transaction || !hivePerMVests) {
return []; return [];
} }
@ -50,7 +50,7 @@ export const groomingTransactionData = (transaction, steemPerMVests) => {
const { reward } = opData; const { reward } = opData;
const { comment_author: commentAuthor, comment_permlink: commentPermlink } = opData; const { comment_author: commentAuthor, comment_permlink: commentPermlink } = opData;
result.value = `${vestsToSp(parseToken(reward), steemPerMVests) result.value = `${vestsToHp(parseToken(reward), hivePerMVests)
.toFixed(3) .toFixed(3)
.replace(',', '.')} HP`; .replace(',', '.')} HP`;
result.details = commentAuthor ? `@${commentAuthor}/${commentPermlink}` : null; result.details = commentAuthor ? `@${commentAuthor}/${commentPermlink}` : null;
@ -58,21 +58,21 @@ export const groomingTransactionData = (transaction, steemPerMVests) => {
case 'author_reward': case 'author_reward':
case 'comment_benefactor_reward': case 'comment_benefactor_reward':
let { let {
sbd_payout: sbdPayout = opData.hbd_payout, hbd_payout: hbdPayout,
steem_payout: steemPayout = opData.hive_payout, hive_payout: hivePayout,
vesting_payout: vestingPayout, vesting_payout: vestingPayout,
} = opData; } = opData;
const { author, permlink } = opData; const { author, permlink } = opData;
sbdPayout = parseToken(sbdPayout).toFixed(3).replace(',', '.'); hbdPayout = parseToken(hbdPayout).toFixed(3).replace(',', '.');
steemPayout = parseToken(steemPayout).toFixed(3).replace(',', '.'); hivePayout = parseToken(hivePayout).toFixed(3).replace(',', '.');
vestingPayout = vestsToSp(parseToken(vestingPayout), steemPerMVests) vestingPayout = vestsToHp(parseToken(vestingPayout), hivePerMVests)
.toFixed(3) .toFixed(3)
.replace(',', '.'); .replace(',', '.');
result.value = `${sbdPayout > 0 ? `${sbdPayout} HBD` : ''} ${ result.value = `${hbdPayout > 0 ? `${hbdPayout} HBD` : ''} ${
steemPayout > 0 ? `${steemPayout} HIVE` : '' hivePayout > 0 ? `${hivePayout} HIVE` : ''
} ${vestingPayout > 0 ? `${vestingPayout} HP` : ''}`; } ${vestingPayout > 0 ? `${vestingPayout} HP` : ''}`;
result.details = author && permlink ? `@${author}/${permlink}` : null; result.details = author && permlink ? `@${author}/${permlink}` : null;
@ -81,14 +81,14 @@ export const groomingTransactionData = (transaction, steemPerMVests) => {
} }
break; break;
case 'claim_reward_balance': case 'claim_reward_balance':
let { reward_hbd: rewardSdb, reward_hive: rewardSteem, reward_vests: rewardVests } = opData; let { reward_hbd: rewardHdb, reward_hive: rewardHive, reward_vests: rewardVests } = opData;
rewardSdb = parseToken(rewardSdb).toFixed(3).replace(',', '.'); rewardHdb = parseToken(rewardHdb).toFixed(3).replace(',', '.');
rewardSteem = parseToken(rewardSteem).toFixed(3).replace(',', '.'); rewardHive = parseToken(rewardHive).toFixed(3).replace(',', '.');
rewardVests = vestsToSp(parseToken(rewardVests), steemPerMVests).toFixed(3).replace(',', '.'); rewardVests = vestsToHp(parseToken(rewardVests), hivePerMVests).toFixed(3).replace(',', '.');
result.value = `${rewardSdb > 0 ? `${rewardSdb} HBD` : ''} ${ result.value = `${rewardHdb > 0 ? `${rewardHdb} HBD` : ''} ${
rewardSteem > 0 ? `${rewardSteem} HIVE` : '' rewardHive > 0 ? `${rewardHive} HIVE` : ''
} ${rewardVests > 0 ? `${rewardVests} HP` : ''}`; } ${rewardVests > 0 ? `${rewardVests} HP` : ''}`;
break; break;
case 'transfer': case 'transfer':
@ -107,9 +107,7 @@ export const groomingTransactionData = (transaction, steemPerMVests) => {
let { vesting_shares: opVestingShares } = opData; let { vesting_shares: opVestingShares } = opData;
opVestingShares = parseToken(opVestingShares); opVestingShares = parseToken(opVestingShares);
result.value = `${vestsToSp(opVestingShares, steemPerMVests) result.value = `${vestsToHp(opVestingShares, hivePerMVests).toFixed(3).replace(',', '.')} HP`;
.toFixed(3)
.replace(',', '.')} HP`;
result.icon = 'attach-money'; result.icon = 'attach-money';
result.details = acc ? `@${acc}` : null; result.details = acc ? `@${acc}` : null;
break; break;
@ -188,47 +186,47 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => {
const [userdata] = state; const [userdata] = state;
// TODO: move them to utils these so big for a lifecycle function // TODO: move them to utils these so big for a lifecycle function
walletData.rewardSteemBalance = parseToken(userdata.reward_hive_balance); walletData.rewardHiveBalance = parseToken(userdata.reward_hive_balance);
walletData.rewardSbdBalance = parseToken(userdata.reward_hbd_balance); walletData.rewardHbdBalance = parseToken(userdata.reward_hbd_balance);
walletData.rewardVestingSteem = parseToken(userdata.reward_vesting_hive); walletData.rewardVestingHive = parseToken(userdata.reward_vesting_hive);
walletData.hasUnclaimedRewards = walletData.hasUnclaimedRewards =
walletData.rewardSteemBalance > 0 || walletData.rewardHiveBalance > 0 ||
walletData.rewardSbdBalance > 0 || walletData.rewardHbdBalance > 0 ||
walletData.rewardVestingSteem > 0; walletData.rewardVestingHive > 0;
walletData.balance = parseToken(userdata.balance); walletData.balance = parseToken(userdata.balance);
walletData.vestingShares = parseToken(userdata.vesting_shares); walletData.vestingShares = parseToken(userdata.vesting_shares);
walletData.vestingSharesDelegated = parseToken(userdata.delegated_vesting_shares); walletData.vestingSharesDelegated = parseToken(userdata.delegated_vesting_shares);
walletData.vestingSharesReceived = parseToken(userdata.received_vesting_shares); walletData.vestingSharesReceived = parseToken(userdata.received_vesting_shares);
walletData.vestingSharesTotal = walletData.vestingSharesTotal =
walletData.vestingShares - walletData.vestingSharesDelegated + walletData.vestingSharesReceived; walletData.vestingShares - walletData.vestingSharesDelegated + walletData.vestingSharesReceived;
walletData.sbdBalance = parseToken(userdata.hbd_balance); walletData.hbdBalance = parseToken(userdata.hbd_balance);
walletData.savingBalance = parseToken(userdata.savings_balance); walletData.savingBalance = parseToken(userdata.savings_balance);
walletData.savingBalanceSbd = parseToken(userdata.savings_hbd_balance); walletData.savingBalanceHbd = parseToken(userdata.savings_hbd_balance);
const feedHistory = await getFeedHistory(); const feedHistory = await getFeedHistory();
const base = parseToken(feedHistory.current_median_history.base); const base = parseToken(feedHistory.current_median_history.base);
const quote = parseToken(feedHistory.current_median_history.quote); const quote = parseToken(feedHistory.current_median_history.quote);
walletData.steemPerMVests = globalProps.steemPerMVests; walletData.hivePerMVests = globalProps.hivePerMVests;
const pricePerSteem = base / quote; const pricePerHive = base / quote;
const totalSteem = const totalHive =
vestsToSp(walletData.vestingShares, walletData.steemPerMVests) + vestsToHp(walletData.vestingShares, walletData.hivePerMVests) +
walletData.balance + walletData.balance +
walletData.savingBalance; walletData.savingBalance;
const totalSbd = walletData.sbdBalance + walletData.savingBalanceSbd; const totalHbd = walletData.hbdBalance + walletData.savingBalanceHbd;
walletData.estimatedValue = totalSteem * pricePerSteem + totalSbd; walletData.estimatedValue = totalHive * pricePerHive + totalHbd;
const ppSbd = await getCurrencyTokenRate(userCurrency, 'hbd'); const ppHbd = await getCurrencyTokenRate(userCurrency, 'hbd');
const ppSteem = await getCurrencyTokenRate(userCurrency, 'hive'); const ppHive = await getCurrencyTokenRate(userCurrency, 'hive');
walletData.estimatedSteemValue = (walletData.balance + walletData.savingBalance) * ppSteem; walletData.estimatedHiveValue = (walletData.balance + walletData.savingBalance) * ppHive;
walletData.estimatedSbdValue = totalSbd * ppSbd; walletData.estimatedHbdValue = totalHbd * ppHbd;
walletData.estimatedSpValue = walletData.estimatedHpValue =
vestsToSp(walletData.vestingShares, walletData.steemPerMVests) * ppSteem; vestsToHp(walletData.vestingShares, walletData.hivePerMVests) * ppHive;
walletData.showPowerDown = userdata.next_vesting_withdrawal !== '1969-12-31T23:59:59'; walletData.showPowerDown = userdata.next_vesting_withdrawal !== '1969-12-31T23:59:59';
const timeDiff = Math.abs(parseDate(userdata.next_vesting_withdrawal) - new Date()); const timeDiff = Math.abs(parseDate(userdata.next_vesting_withdrawal) - new Date());