mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +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;
|
currentPrice:number;
|
||||||
balance:number;
|
balance:number;
|
||||||
savings:number;
|
savings:number;
|
||||||
|
unclaimedBalance:string,
|
||||||
estimateValue:number;
|
estimateValue:number;
|
||||||
vsCurrency:string;
|
vsCurrency:string;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export const CoinCard = ({
|
|||||||
onPress
|
onPress
|
||||||
}:CoinCardProps) => {
|
}:CoinCardProps) => {
|
||||||
|
|
||||||
console.log(chartData);
|
|
||||||
if(!notCrypto && !chartData.length){
|
if(!notCrypto && !chartData.length){
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ const WalletScreen = ({navigation}) => {
|
|||||||
|
|
||||||
const _tokenMarketData:number[] = priceHistories[item.id] ? priceHistories[item.id].data : [];
|
const _tokenMarketData:number[] = priceHistories[item.id] ? priceHistories[item.id].data : [];
|
||||||
const _currentValue = item.id == 'ecency' ? 1/150 : (coinData.currentPrice || 0);
|
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
|
//calculate percentage change
|
||||||
//TODO: verify or find a way to get exact percent change. current change value slightly differs from coingecko wep app values
|
//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 { CoinBase, CoinData } from '../redux/reducers/walletReducer';
|
||||||
import { GlobalProps } from '../redux/reducers/accountReducer';
|
import { GlobalProps } from '../redux/reducers/accountReducer';
|
||||||
import { COIN_IDS } from '../constants/defaultCoins';
|
import { COIN_IDS } from '../constants/defaultCoins';
|
||||||
|
import { getEstimatedAmount } from './vote';
|
||||||
|
|
||||||
export const transferTypes = [
|
export const transferTypes = [
|
||||||
'curation_reward',
|
'curation_reward',
|
||||||
@ -259,10 +260,12 @@ export const fetchCoinsData = async (
|
|||||||
)
|
)
|
||||||
: Promise<{[key:string]:CoinData}> => {
|
: 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;
|
const walletData = {} as any;
|
||||||
|
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
return walletData;
|
return walletData;
|
||||||
}
|
}
|
||||||
@ -286,7 +289,8 @@ export const fetchCoinsData = async (
|
|||||||
estimateValue: (balance + savings) * ppHive,
|
estimateValue: (balance + savings) * ppHive,
|
||||||
savings:Math.round(savings * 1000) / 1000,
|
savings:Math.round(savings * 1000) / 1000,
|
||||||
vsCurrency:vsCurrency,
|
vsCurrency:vsCurrency,
|
||||||
currentPrice:ppHive
|
currentPrice:ppHive,
|
||||||
|
unclaimedBalance:'',
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -300,20 +304,33 @@ export const fetchCoinsData = async (
|
|||||||
estimateValue: (balance + savings) * ppHbd,
|
estimateValue: (balance + savings) * ppHbd,
|
||||||
savings:Math.round(savings * 1000) / 1000,
|
savings:Math.round(savings * 1000) / 1000,
|
||||||
vsCurrency:vsCurrency,
|
vsCurrency:vsCurrency,
|
||||||
currentPrice:ppHbd
|
currentPrice:ppHbd,
|
||||||
|
unclaimedBalance:'',
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COIN_IDS.HP:{
|
case COIN_IDS.HP:{
|
||||||
//TODO: set correct values
|
const _getBalance = (val:number, cur:string) => (val ? Math.round(val * 1000) / 1000 + cur : '');
|
||||||
const balance = parseToken(userdata.hbd_balance);
|
const balance = Math.round(
|
||||||
const savings = parseToken(userdata.savings_hbd_balance);
|
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] = {
|
coinData[coinBase.id] = {
|
||||||
balance: Math.round(balance * 1000) / 1000,
|
balance: Math.round(balance * 1000) / 1000,
|
||||||
estimateValue: (balance + savings) * ppHbd,
|
estimateValue: parseFloat(estimateValueStr),
|
||||||
savings:Math.round(savings * 1000) / 1000,
|
unclaimedBalance,
|
||||||
vsCurrency:vsCurrency,
|
vsCurrency:vsCurrency,
|
||||||
currentPrice:ppHbd
|
currentPrice:ppHbd,
|
||||||
|
savings:0,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -343,7 +360,7 @@ export const fetchCoinsData = async (
|
|||||||
walletData.savingBalanceHbd = parseToken(userdata.savings_hbd_balance);
|
walletData.savingBalanceHbd = parseToken(userdata.savings_hbd_balance);
|
||||||
|
|
||||||
|
|
||||||
const {base, quote, hivePerMVests} = globalProps
|
|
||||||
walletData.hivePerMVests = hivePerMVests;
|
walletData.hivePerMVests = hivePerMVests;
|
||||||
const pricePerHive = base / quote;
|
const pricePerHive = base / quote;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user