mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-20 03:42:10 +03:00
Merge pull request #2421 from ecency/nt/estm-fallback
update estm value fetch
This commit is contained in:
commit
3f7bce6725
@ -30,17 +30,12 @@ export const convertQuoteItem = (rawData:any, currencyRate:number) => {
|
|||||||
} as QuoteItem
|
} as QuoteItem
|
||||||
}
|
}
|
||||||
|
|
||||||
export const convertLatestQuotes = (rawData: any, estmPrice:number, currencyRate:number) => {
|
export const convertLatestQuotes = (rawData: any, currencyRate:number) => {
|
||||||
return {
|
return {
|
||||||
[COIN_IDS.HIVE]:convertQuoteItem(rawData.hive.quotes.usd, currencyRate),
|
[COIN_IDS.HIVE]:convertQuoteItem(rawData.hive.quotes.usd, currencyRate),
|
||||||
[COIN_IDS.HP]:convertQuoteItem(rawData.hive.quotes.usd, currencyRate),
|
[COIN_IDS.HP]:convertQuoteItem(rawData.hive.quotes.usd, currencyRate),
|
||||||
[COIN_IDS.HBD]:convertQuoteItem(rawData.hbd.quotes.usd, currencyRate),
|
[COIN_IDS.HBD]:convertQuoteItem(rawData.hbd.quotes.usd, currencyRate),
|
||||||
[COIN_IDS.ECENCY]:convertQuoteItem({
|
[COIN_IDS.ECENCY]:convertQuoteItem(rawData.estm.quotes.usd, currencyRate)
|
||||||
price:estmPrice,
|
|
||||||
percent_change:0,
|
|
||||||
last_updated:new Date().toISOString()
|
|
||||||
}, currencyRate)
|
|
||||||
|
|
||||||
} as LatestQuotes;
|
} as LatestQuotes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ import { CommentHistoryItem, LatestMarketPrices, ReceivedVestingShare, Referral,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export const getCurrencyRate = (currency) =>
|
export const getCurrencyRate = (currency) =>
|
||||||
api
|
ecencyApi
|
||||||
.get(`/market-data/currency-rate/${currency}/hbd?fixed=1`)
|
.get(`/private-api/market-data/${currency}/hbd?fixed=1`)
|
||||||
.then((resp) => resp.data)
|
.then((resp) => resp.data)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
bugsnagInstance.notify(err);
|
bugsnagInstance.notify(err);
|
||||||
@ -31,14 +31,14 @@ export const getLatestQuotes = async (currencyRate: number): Promise<LatestMarke
|
|||||||
try {
|
try {
|
||||||
console.log('using currency rate', currencyRate);
|
console.log('using currency rate', currencyRate);
|
||||||
const res = await ecencyApi.get(`/private-api/market-data/latest`);
|
const res = await ecencyApi.get(`/private-api/market-data/latest`);
|
||||||
const estmRes = await getCurrencyTokenRate('usd', 'estm')
|
|
||||||
|
|
||||||
if (!res.data || !estmRes) {
|
if (!res.data) {
|
||||||
throw new Error("No quote data returned");
|
throw new Error("No quote data returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = convertLatestQuotes(res.data, estmRes, currencyRate);
|
const data = convertLatestQuotes(res.data, currencyRate);
|
||||||
console.log('parsed quotes data', data);
|
console.log('parsed quotes data', data, currencyRate);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
bugsnagInstance.notify(error);
|
bugsnagInstance.notify(error);
|
||||||
@ -49,8 +49,8 @@ export const getLatestQuotes = async (currencyRate: number): Promise<LatestMarke
|
|||||||
|
|
||||||
|
|
||||||
export const getCurrencyTokenRate = (currency, token) =>
|
export const getCurrencyTokenRate = (currency, token) =>
|
||||||
api
|
ecencyApi
|
||||||
.get(`/market-data/currency-rate/${currency}/${token}`)
|
.get(`/private-api/market-data/${currency}/${token}`)
|
||||||
.then((resp) => resp.data)
|
.then((resp) => resp.data)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
bugsnagInstance.notify(err);
|
bugsnagInstance.notify(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user