Merge branch 'wallet-improvements' of https://github.com/esteemapp/esteem-mobile into wallet-improvements

This commit is contained in:
feruz 2019-12-09 21:35:58 +02:00
commit cc07e4271a
4 changed files with 10 additions and 9 deletions

View File

@ -37,6 +37,7 @@ const WalletContainer = ({
setEstimatedWalletValue, setEstimatedWalletValue,
steemPerMVests, steemPerMVests,
isPinCodeOpen, isPinCodeOpen,
currency,
}) => { }) => {
const [isClaiming, setIsClaiming] = useState(false); const [isClaiming, setIsClaiming] = useState(false);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
@ -129,7 +130,7 @@ const WalletContainer = ({
const _getWalletData = useCallback( const _getWalletData = useCallback(
async _selectedUser => { async _selectedUser => {
const _walletData = await groomingWalletData(_selectedUser, globalProps); const _walletData = await groomingWalletData(_selectedUser, globalProps, currency);
setWalletData(_walletData); setWalletData(_walletData);
setIsLoading(false); setIsLoading(false);
@ -297,6 +298,7 @@ const mapStateToProps = state => ({
currentAccount: state.account.currentAccount, currentAccount: state.account.currentAccount,
pinCode: state.application.pin, pinCode: state.application.pin,
globalProps: state.account.globalProps, globalProps: state.account.globalProps,
currency: state.application.currency.currency,
steemPerMVests: state.account.globalProps.steemPerMVests, steemPerMVests: state.account.globalProps.steemPerMVests,
isPinCodeOpen: state.application.isPinCodeOpen, isPinCodeOpen: state.application.isPinCodeOpen,
}); });

View File

@ -4,25 +4,23 @@ import imageApi from '../../config/imageApi';
import serverList from '../../config/serverListApi'; import serverList from '../../config/serverListApi';
import { jsonStringify } from '../../utils/jsonUtils'; import { jsonStringify } from '../../utils/jsonUtils';
import bugsnag from '../../config/bugsnag'; import bugsnag from '../../config/bugsnag';
// market-data/currency-rate/USD/estm
// SBD=$1 for post values
export const getCurrencyRate = currency => export const getCurrencyRate = currency =>
api api
.get(`/market-data/currency-rate/${currency.toUpperCase()}/sbd?fixed=1`) .get(`/market-data/currency-rate/${currency}/sbd?fixed=1`)
.then(resp => resp.data) .then(resp => resp.data)
.catch(err => { .catch(err => {
console.log('err :', err); bugsnag.notify(err);
//TODO: save currency rate of offline values //TODO: save currency rate of offline values
return 1; return 1;
}); });
export const getCurrencyTokenRate = (currency, token) => export const getCurrencyTokenRate = (currency, token) =>
api api
.get(`/market-data/currency-rate/${currency.toUpperCase()}/${token}`) .get(`/market-data/currency-rate/${currency}/${token}`)
.then(resp => resp.data) .then(resp => resp.data)
.catch(err => { .catch(err => {
console.log('err :', err); bugsnag.notify(err);
}); });
/** /**

View File

@ -423,6 +423,8 @@ export const getCurrency = async () => {
try { try {
const setting = await getItemFromStorage(SETTINGS_SCHEMA); const setting = await getItemFromStorage(SETTINGS_SCHEMA);
if (setting) { if (setting) {
console.log(setting);
console.log('ugur');
return setting.currency; return setting.currency;
} }
return false; return false;

View File

@ -116,7 +116,7 @@ export const groomingTransactionData = (transaction, steemPerMVests, formatNumbe
return result; return result;
}; };
export const groomingWalletData = async (user, globalProps) => { export const groomingWalletData = async (user, globalProps, userCurrency) => {
const walletData = {}; const walletData = {};
if (!user) { if (!user) {
@ -161,7 +161,6 @@ export const groomingWalletData = async (user, globalProps) => {
const totalSbd = walletData.sbdBalance + walletData.savingBalanceSbd; const totalSbd = walletData.sbdBalance + walletData.savingBalanceSbd;
walletData.estimatedValue = totalSteem * pricePerSteem + totalSbd; walletData.estimatedValue = totalSteem * pricePerSteem + totalSbd;
const userCurrency = await getCurrency();
const ppSbd = await getCurrencyTokenRate(userCurrency, 'sbd'); const ppSbd = await getCurrencyTokenRate(userCurrency, 'sbd');
const ppSteem = await getCurrencyTokenRate(userCurrency, 'steem'); const ppSteem = await getCurrencyTokenRate(userCurrency, 'steem');