From f4ec281b5281588dbc1648a0a92f813feb9bb2de Mon Sep 17 00:00:00 2001 From: feruz Date: Tue, 10 Dec 2019 21:09:16 +0200 Subject: [PATCH 1/5] fix estimated sp value, show delegations --- src/config/locales/en-US.json | 1 + src/containers/steemWalletContainer.js | 9 +++++++++ src/screens/wallet/screen/spView.js | 12 +++++++++++- src/utils/wallet.js | 4 ++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 503354c7b..47df3a64a 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -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", diff --git a/src/containers/steemWalletContainer.js b/src/containers/steemWalletContainer.js index 5ae905e3e..f91158fe3 100644 --- a/src/containers/steemWalletContainer.js +++ b/src/containers/steemWalletContainer.js @@ -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, diff --git a/src/screens/wallet/screen/spView.js b/src/screens/wallet/screen/spView.js index fb664ad6a..6d5398e74 100644 --- a/src/screens/wallet/screen/spView.js +++ b/src/screens/wallet/screen/spView.js @@ -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: ( + + {delegationsAmount} + {' SP'} + + ), + }, { textKey: 'estimated_value', value: , diff --git a/src/utils/wallet.js b/src/utils/wallet.js index 19ec30712..087a1d141 100644 --- a/src/utils/wallet.js +++ b/src/utils/wallet.js @@ -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()); From e681395822830c8a03673aa45819117587184544 Mon Sep 17 00:00:00 2001 From: feruz Date: Tue, 10 Dec 2019 21:21:03 +0200 Subject: [PATCH 2/5] fix estimated sp value --- src/utils/wallet.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/wallet.js b/src/utils/wallet.js index 087a1d141..8e5c804cb 100644 --- a/src/utils/wallet.js +++ b/src/utils/wallet.js @@ -187,7 +187,6 @@ 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 +214,7 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => { walletData.estimatedSteemValue = (walletData.balance + walletData.savingBalance) * ppSteem; walletData.estimatedSbdValue = totalSbd * ppSbd; walletData.estimatedSpValue = - vestsToSp(walletData.vestingSharesOwned, walletData.steemPerMVests) * ppSteem; + vestsToSp(walletData.vestingShares, 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()); From 601239caa932b3112668ee2cf44a3d61edf13841 Mon Sep 17 00:00:00 2001 From: feruz Date: Wed, 11 Dec 2019 07:09:16 +0200 Subject: [PATCH 3/5] filter exact currency in transactions --- .../UserInterfaceState.xcuserstate | Bin 29845 -> 29845 bytes src/components/transaction/transactionView.js | 4 +++- src/containers/steemWalletContainer.js | 20 ++++++------------ src/screens/wallet/screen/walletScreen.js | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ios/eSteem.xcworkspace/xcuserdata/f.xcuserdatad/UserInterfaceState.xcuserstate b/ios/eSteem.xcworkspace/xcuserdata/f.xcuserdatad/UserInterfaceState.xcuserstate index 13311f04859383e3e8fb3b5f317316518765c219..b4671fc3f9c80fc9cbfeb1becd7eea749e8b0a21 100644 GIT binary patch delta 28 kcmbRGl5y%w#tl!C*)9aR&G>eH^6O+(CPS0WLMhDx0ME$`>i_@% delta 28 kcmbRGl5y%w#tl!C+0L(Btp258^6O+(CKJoeLMhDx0MQ2w=l}o! diff --git a/src/components/transaction/transactionView.js b/src/components/transaction/transactionView.js index 5ca355b71..79dceb125 100644 --- a/src/components/transaction/transactionView.js +++ b/src/components/transaction/transactionView.js @@ -16,6 +16,7 @@ import globalStyles from '../../globalStyles'; const TransactionView = ({ transactions, type, refreshing, setRefreshing, isLoading }) => { const intl = useIntl(); + const transaction_types = ['ESTM', 'STEEM', 'SBD', 'SP']; const _renderLoading = () => { if (isLoading) { @@ -44,7 +45,8 @@ const TransactionView = ({ transactions, type, refreshing, setRefreshing, isLoad const _renderItem = (item, index) => { return ( - Object.keys(item).length > 0 && ( + Object.keys(item).length > 0 && + item.value.indexOf(transaction_types[type]) > -1 && ( { - _getWalletData(selectedUser); - }, [_getWalletData, selectedUser]); - useEffect(() => { const _transferHistory = userActivities.filter( item => @@ -107,6 +103,12 @@ const WalletContainer = ({ setEstimatedSteemValue(get(walletData, 'estimatedSteemValue', 0)); setEstimatedSbdValue(get(walletData, 'estimatedSbdValue', 0)); setEstimatedSpValue(get(walletData, 'estimatedSpValue', 0)); + setDelegationsAmount( + vestsToSp( + get(walletData, 'vestingSharesReceived', 0) - get(walletData, 'vestingSharesDelegated', 0), + get(walletData, 'steemPerMVests', 0), + ).toFixed(3), + ); setUnclaimedBalance( `${ @@ -141,16 +143,6 @@ const WalletContainer = ({ ), ); setEstimatedWalletValue && setEstimatedWalletValue(_walletData.estimatedValue); - 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], ); diff --git a/src/screens/wallet/screen/walletScreen.js b/src/screens/wallet/screen/walletScreen.js index d076736d2..a9ba1320f 100644 --- a/src/screens/wallet/screen/walletScreen.js +++ b/src/screens/wallet/screen/walletScreen.js @@ -100,7 +100,7 @@ const WalletScreen = () => { scrollEventThrottle={16} > Date: Wed, 11 Dec 2019 07:59:20 +0200 Subject: [PATCH 4/5] fix balance reload --- src/utils/wallet.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/utils/wallet.js b/src/utils/wallet.js index 8e5c804cb..876a9be00 100644 --- a/src/utils/wallet.js +++ b/src/utils/wallet.js @@ -172,24 +172,25 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => { const state = await getState(`/@${get(user, 'name')}/transfers`); const { accounts } = state; + const userdata = get(accounts, get(user, 'name'), ''); // TODO: move them to utils these so big for a lifecycle function - walletData.rewardSteemBalance = parseToken(user.reward_steem_balance); - walletData.rewardSbdBalance = parseToken(user.reward_sbd_balance); - walletData.rewardVestingSteem = parseToken(user.reward_vesting_steem); + walletData.rewardSteemBalance = parseToken(userdata.reward_steem_balance); + walletData.rewardSbdBalance = parseToken(userdata.reward_sbd_balance); + walletData.rewardVestingSteem = parseToken(userdata.reward_vesting_steem); walletData.hasUnclaimedRewards = walletData.rewardSteemBalance > 0 || walletData.rewardSbdBalance > 0 || walletData.rewardVestingSteem > 0; - walletData.balance = parseToken(user.balance); - walletData.vestingShares = parseToken(user.vesting_shares); - walletData.vestingSharesDelegated = parseToken(user.delegated_vesting_shares); - walletData.vestingSharesReceived = parseToken(user.received_vesting_shares); + walletData.balance = parseToken(userdata.balance); + walletData.vestingShares = parseToken(userdata.vesting_shares); + walletData.vestingSharesDelegated = parseToken(userdata.delegated_vesting_shares); + walletData.vestingSharesReceived = parseToken(userdata.received_vesting_shares); walletData.vestingSharesTotal = walletData.vestingShares - walletData.vestingSharesDelegated + walletData.vestingSharesReceived; - walletData.sbdBalance = parseToken(user.sbd_balance); - walletData.savingBalance = parseToken(user.savings_balance); - walletData.savingBalanceSbd = parseToken(user.savings_sbd_balance); + walletData.sbdBalance = parseToken(userdata.sbd_balance); + walletData.savingBalance = parseToken(userdata.savings_balance); + walletData.savingBalanceSbd = parseToken(userdata.savings_sbd_balance); const feedHistory = await getFeedHistory(); const base = parseToken(feedHistory.current_median_history.base); From 0ed46dab4216b6750a102c9cf163a7237e694709 Mon Sep 17 00:00:00 2001 From: feruz Date: Wed, 11 Dec 2019 08:09:17 +0200 Subject: [PATCH 5/5] error handle --- src/utils/wallet.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utils/wallet.js b/src/utils/wallet.js index 876a9be00..c19f85145 100644 --- a/src/utils/wallet.js +++ b/src/utils/wallet.js @@ -172,6 +172,9 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => { const state = await getState(`/@${get(user, 'name')}/transfers`); const { accounts } = state; + if (!accounts) { + return walletData; + } const userdata = get(accounts, get(user, 'name'), ''); // TODO: move them to utils these so big for a lifecycle function @@ -217,15 +220,12 @@ export const groomingWalletData = async (user, globalProps, userCurrency) => { walletData.estimatedSpValue = vestsToSp(walletData.vestingShares, 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()); + walletData.showPowerDown = userdata.next_vesting_withdrawal !== '1969-12-31T23:59:59'; + const timeDiff = Math.abs(parseDate(userdata.next_vesting_withdrawal) - new Date()); walletData.nextVestingWithdrawal = Math.round(timeDiff / (1000 * 3600)); - const { transfer_history: transferHistory, other_history: virtualHistory } = get( - accounts, - user.name, - [], - ); + const { transfer_history: transferHistory, other_history: virtualHistory } = userdata; + const realHistory = transferHistory ? transferHistory.slice(Math.max(transferHistory.length - 50, 0)) : [];