diff --git a/src/components/formatedElements/index.js b/src/components/formatedElements/index.js index b58bf03f3..7e2a8490c 100644 --- a/src/components/formatedElements/index.js +++ b/src/components/formatedElements/index.js @@ -1,3 +1,3 @@ -import FormatedCurrency from './formattedCurrency/formattedCurrencyView'; +import FormattedCurrency from './formattedCurrency/formattedCurrencyView'; -export { FormatedCurrency }; +export { FormattedCurrency }; diff --git a/src/components/index.js b/src/components/index.js index 8bf7cd499..70bccf833 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -9,7 +9,7 @@ import { ContainerHeader } from './containerHeader'; import { DateTimePicker } from './dateTimePicker'; import { DropdownButton } from './dropdownButton'; import { FilterBar } from './filterBar'; -import { FormatedCurrency } from './formatedElements'; +import { FormattedCurrency } from './formatedElements'; import { FormInput } from './formInput'; import { Header } from './header'; import { Icon } from './icon'; @@ -112,7 +112,7 @@ export { DateTimePicker, DropdownButton, FilterBar, - FormatedCurrency, + FormattedCurrency, FormInput, GrayWrapper, Header, diff --git a/src/components/leaderboard/container/leaderboardContainer.js b/src/components/leaderboard/container/leaderboardContainer.js index ba5d2476d..6f5657d8c 100644 --- a/src/components/leaderboard/container/leaderboardContainer.js +++ b/src/components/leaderboard/container/leaderboardContainer.js @@ -58,7 +58,6 @@ class LeaderboardContainer extends PureComponent { } let users; - console.log(index); if (!isConnected) { return; } diff --git a/src/components/upvote/view/upvoteView.js b/src/components/upvote/view/upvoteView.js index 9a1e1b8c6..aed095c3f 100644 --- a/src/components/upvote/view/upvoteView.js +++ b/src/components/upvote/view/upvoteView.js @@ -14,7 +14,7 @@ import { getEstimatedAmount } from '../../../utils/vote'; import { Icon } from '../../icon'; import { PulseAnimation } from '../../animations'; import { TextButton } from '../../buttons'; -import { FormatedCurrency } from '../../formatedElements'; +import { FormattedCurrency } from '../../formatedElements'; // STEEM import { vote } from '../../../providers/steem/dsteem'; @@ -259,7 +259,7 @@ class UpvoteView extends Component { } + text={} onPress={() => { openPopover(); this.setState({ isShowDetails: true }); diff --git a/src/containers/steemWalletContainer.js b/src/containers/steemWalletContainer.js index 73cc04fd1..194a1641d 100644 --- a/src/containers/steemWalletContainer.js +++ b/src/containers/steemWalletContainer.js @@ -121,6 +121,9 @@ const WalletContainer = ({ ), ); setEstimatedWalletValue && setEstimatedWalletValue(_walletData.estimatedValue); + setEstimatedSbdValue && setEstimatedSbdValue(_walletData.estimatedSbdValue); + setEstimatedSteemValue && setEstimatedSteemValue(_walletData.estimatedSteemValue); + setEstimatedSpValue && setEstimatedSpValue(_walletData.estimatedSpValue); }, [globalProps, intl.formatNumber, setEstimatedWalletValue, steemPerMVests], ); diff --git a/src/providers/esteem/esteem.js b/src/providers/esteem/esteem.js index a79821824..16162f78d 100644 --- a/src/providers/esteem/esteem.js +++ b/src/providers/esteem/esteem.js @@ -5,12 +5,16 @@ import serverList from '../../config/serverListApi'; import { jsonStringify } from '../../utils/jsonUtils'; import bugsnag from '../../config/bugsnag'; // market-data/currency-rate/USD/estm + +// SBD=$1 for post values export const getCurrencyRate = currency => api - .get(`/market-data/currency-rate/${currency.toUpperCase()}/steem`) + .get(`/market-data/currency-rate/${currency.toUpperCase()}/sbd?fixed=1`) .then(resp => resp.data) .catch(err => { console.log('err :', err); + //TODO: save currency rate of offline values + return 1; }); export const getCurrencyTokenRate = (currency, token) => diff --git a/src/realm/realm.js b/src/realm/realm.js index 5ce7a5606..cf8be128f 100644 --- a/src/realm/realm.js +++ b/src/realm/realm.js @@ -410,7 +410,6 @@ export const setNotificationSettings = async ({ type, action }) => { export const setCurrency = async currencyProps => { try { const setting = await getItemFromStorage(SETTINGS_SCHEMA); - setting.currency = currencyProps; await setItemToStorage(SETTINGS_SCHEMA, setting); @@ -420,6 +419,18 @@ export const setCurrency = async currencyProps => { } }; +export const getCurrency = async () => { + try { + const setting = await getItemFromStorage(SETTINGS_SCHEMA); + if (setting) { + return setting.currency; + } + return false; + } catch (error) { + return error; + } +}; + export const getLanguage = async () => { try { const setting = await getItemFromStorage(SETTINGS_SCHEMA); diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index 4b0934d27..dc444923e 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -485,7 +485,7 @@ class ApplicationContainer extends Component { } if (settings.nsfw !== '') dispatch(setNsfw(settings.nsfw)); - if (isConnected) { + if (settings.currency !== '') { dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd')); } diff --git a/src/screens/wallet/screen/sbdView.js b/src/screens/wallet/screen/sbdView.js index c08cc6f85..7600af841 100644 --- a/src/screens/wallet/screen/sbdView.js +++ b/src/screens/wallet/screen/sbdView.js @@ -1,7 +1,7 @@ import React from 'react'; import { View } from 'react-native'; -import { WalletHeader, FormatedCurrency } from '../../../components'; +import { WalletHeader, FormattedCurrency } from '../../../components'; import { SteemWalletContainer, AccountContainer } from '../../../containers'; import globalStyles from '../../../globalStyles'; @@ -45,7 +45,7 @@ const SbdView = ({ handleOnSelected, index, currentIndex }) => ( valueDescriptions={[ { textKey: 'estimated_value', - value: , + value: , subTextKey: 'estimated_value_desc', }, ]} diff --git a/src/screens/wallet/screen/spView.js b/src/screens/wallet/screen/spView.js index f8c6822cf..bfb74fbd9 100644 --- a/src/screens/wallet/screen/spView.js +++ b/src/screens/wallet/screen/spView.js @@ -1,7 +1,7 @@ import React from 'react'; import { View } from 'react-native'; -import { WalletHeader, FormatedCurrency } from '../../../components'; +import { WalletHeader, FormattedCurrency } from '../../../components'; import { SteemWalletContainer, AccountContainer } from '../../../containers'; import globalStyles from '../../../globalStyles'; @@ -46,11 +46,11 @@ const SpView = ({ handleOnSelected, index, currentIndex }) => ( valueDescriptions={[ { textKey: 'estimated_value', - value: , + value: , }, { textKey: 'estimated_amount', - value: , + value: , }, ]} /> diff --git a/src/screens/wallet/screen/steemView.js b/src/screens/wallet/screen/steemView.js index 0fa5f0924..612e96da9 100644 --- a/src/screens/wallet/screen/steemView.js +++ b/src/screens/wallet/screen/steemView.js @@ -1,7 +1,7 @@ import React from 'react'; import { View } from 'react-native'; -import { WalletHeader, FormatedCurrency } from '../../../components'; +import { WalletHeader, FormattedCurrency } from '../../../components'; import { SteemWalletContainer, AccountContainer } from '../../../containers'; import globalStyles from '../../../globalStyles'; @@ -49,7 +49,7 @@ const SteemView = ({ handleOnSelected, index, currentIndex }) => ( valueDescriptions={[ { textKey: 'estimated_value', - value: , + value: , subTextKey: 'estimated_value_desc', }, ]} diff --git a/src/utils/wallet.js b/src/utils/wallet.js index a1fbeece4..9da0ee4ae 100644 --- a/src/utils/wallet.js +++ b/src/utils/wallet.js @@ -4,6 +4,7 @@ import parseToken from './parseToken'; import { vestsToSp } from './conversions'; import { getState, getFeedHistory } from '../providers/steem/dsteem'; import { getCurrencyTokenRate } from '../providers/esteem/esteem'; +import { getCurrency } from '../realm/realm'; export const groomingTransactionData = (transaction, steemPerMVests, formatNumber) => { if (!transaction || !steemPerMVests) { @@ -156,9 +157,10 @@ export const groomingWalletData = async (user, globalProps) => { const totalSbd = walletData.sbdBalance + walletData.savingBalanceSbd; walletData.estimatedValue = totalSteem * pricePerSteem + totalSbd; + const userCurrency = await getCurrency(); - const ppSbd = await getCurrencyTokenRate('usd', 'sbd'); - const ppSteem = await getCurrencyTokenRate('usd', 'steem'); + const ppSbd = await getCurrencyTokenRate(userCurrency, 'sbd'); + const ppSteem = await getCurrencyTokenRate(userCurrency, 'steem'); walletData.estimatedSteemValue = (walletData.balance + walletData.savingBalance) * ppSteem; walletData.estimatedSbdValue = totalSbd * ppSbd;