mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
processing hive power base data
This commit is contained in:
parent
e7cdf9c8a4
commit
07c0e8fb36
@ -12,6 +12,7 @@ export interface CoinData {
|
||||
currentPrice:number;
|
||||
balance:number;
|
||||
savings:number;
|
||||
unclaimedBalance:string,
|
||||
estimateValue:number;
|
||||
vsCurrency:string;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export const CoinCard = ({
|
||||
onPress
|
||||
}:CoinCardProps) => {
|
||||
|
||||
console.log(chartData);
|
||||
|
||||
if(!notCrypto && !chartData.length){
|
||||
return null
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ const WalletScreen = ({navigation}) => {
|
||||
|
||||
const _tokenMarketData:number[] = priceHistories[item.id] ? priceHistories[item.id].data : [];
|
||||
const _currentValue = item.id == 'ecency' ? 1/150 : (coinData.currentPrice || 0);
|
||||
const _balance = item.id === 'ececny' ? 3 : (coinData.balance + coinData.savings);
|
||||
const _balance = item.id === 'ecency' ? 3 : (coinData.balance + (coinData.savings || 0));
|
||||
|
||||
//calculate percentage change
|
||||
//TODO: verify or find a way to get exact percent change. current change value slightly differs from coingecko wep app values
|
||||
|
@ -7,6 +7,7 @@ import { getCurrencyTokenRate } from '../providers/ecency/ecency';
|
||||
import { CoinBase, CoinData } from '../redux/reducers/walletReducer';
|
||||
import { GlobalProps } from '../redux/reducers/accountReducer';
|
||||
import { COIN_IDS } from '../constants/defaultCoins';
|
||||
import { getEstimatedAmount } from './vote';
|
||||
|
||||
export const transferTypes = [
|
||||
'curation_reward',
|
||||
@ -259,10 +260,12 @@ export const fetchCoinsData = async (
|
||||
)
|
||||
: Promise<{[key:string]:CoinData}> => {
|
||||
|
||||
const coinData = {} as {[key:string]:CoinData};
|
||||
const {base, quote, hivePerMVests} = globalProps
|
||||
|
||||
const coinData = {} as {[key:string]:CoinData};
|
||||
const walletData = {} as any;
|
||||
|
||||
|
||||
if (!username) {
|
||||
return walletData;
|
||||
}
|
||||
@ -286,7 +289,8 @@ export const fetchCoinsData = async (
|
||||
estimateValue: (balance + savings) * ppHive,
|
||||
savings:Math.round(savings * 1000) / 1000,
|
||||
vsCurrency:vsCurrency,
|
||||
currentPrice:ppHive
|
||||
currentPrice:ppHive,
|
||||
unclaimedBalance:'',
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -300,20 +304,33 @@ export const fetchCoinsData = async (
|
||||
estimateValue: (balance + savings) * ppHbd,
|
||||
savings:Math.round(savings * 1000) / 1000,
|
||||
vsCurrency:vsCurrency,
|
||||
currentPrice:ppHbd
|
||||
currentPrice:ppHbd,
|
||||
unclaimedBalance:'',
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COIN_IDS.HP:{
|
||||
//TODO: set correct values
|
||||
const balance = parseToken(userdata.hbd_balance);
|
||||
const savings = parseToken(userdata.savings_hbd_balance);
|
||||
const _getBalance = (val:number, cur:string) => (val ? Math.round(val * 1000) / 1000 + cur : '');
|
||||
const balance = Math.round(
|
||||
vestsToHp(parseToken(userdata.vesting_shares), hivePerMVests) * 1000,
|
||||
) / 1000;
|
||||
|
||||
const unclaimedBalance =
|
||||
`${_getBalance(parseToken(userdata.reward_hive_balance), ' HIVE')} ` +
|
||||
`${_getBalance(parseToken(userdata.reward_hive_balance),' HBD')} ` +
|
||||
`${_getBalance(parseToken(userdata.reward_vesting_hive), ' HP')}`
|
||||
|
||||
//TODO: assess how we can make this value change live.
|
||||
const estimateValueStr = getEstimatedAmount(userdata, globalProps);
|
||||
|
||||
|
||||
coinData[coinBase.id] = {
|
||||
balance: Math.round(balance * 1000) / 1000,
|
||||
estimateValue: (balance + savings) * ppHbd,
|
||||
savings:Math.round(savings * 1000) / 1000,
|
||||
estimateValue: parseFloat(estimateValueStr),
|
||||
unclaimedBalance,
|
||||
vsCurrency:vsCurrency,
|
||||
currentPrice:ppHbd
|
||||
currentPrice:ppHbd,
|
||||
savings:0,
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -343,7 +360,7 @@ export const fetchCoinsData = async (
|
||||
walletData.savingBalanceHbd = parseToken(userdata.savings_hbd_balance);
|
||||
|
||||
|
||||
const {base, quote, hivePerMVests} = globalProps
|
||||
|
||||
walletData.hivePerMVests = hivePerMVests;
|
||||
const pricePerHive = base / quote;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user