remove price cache

This commit is contained in:
liangping 2022-10-28 12:11:46 +08:00
parent b684059eb0
commit 676e19ed1d

View File

@ -10,7 +10,7 @@ import { sha256 } from '@cosmjs/crypto'
import { toHex } from '@cosmjs/encoding'
let chains = {}
const coingecko = {}
let configs = require.context('../../chains/mainnet', false, /\.json$/)
if (isTestnet()) {
configs = require.context('../../chains/testnet', false, /\.json$/)
@ -21,6 +21,9 @@ configs.keys().forEach(k => {
const c = configs(k)
c.chain_name = String(c.chain_name).toLowerCase()
update[c.chain_name] = c
c.assets.forEach(x => {
if (x.coingecko_id && x.coingecko_id !== '') coingecko[x.coingecko_id] = String(x.symbol).toUpperCase()
})
})
chains = update
@ -83,9 +86,24 @@ export default {
},
actions: {
async getQuotes(context) {
fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => {
context.commit('setQuotes', data)
// fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => {
// context.commit('setQuotes', data)
// console.log(data)
// })
console.log(coingecko)
const keys = Object.keys(coingecko)
if (keys.length > 0) {
const currencies = 'usd,cny,eur,jpy,krw,sgd,hkd'
fetch(`https://api.coingecko.com/api/v3/simple/price?vs_currencies=${currencies}&ids=${keys.join(',')}`).then(data => data.json()).then(data => {
// use symbol as key instead of coingecko id
const quotes = {}
Object.keys(data).forEach(k => {
quotes[coingecko[k]] = data[k]
})
context.commit('setQuotes', quotes)
console.log(quotes)
})
}
},
async getAllIBCDenoms(context, _this) {