forked from cerc-io/cosmos-explorer
Fix inflation for evmos
This commit is contained in:
parent
4d80a0589d
commit
c9b8cf8066
@ -132,10 +132,13 @@ export default class ChainFetch {
|
||||
}
|
||||
|
||||
async getMintingInflation() {
|
||||
if (this.config.chain_name === 'evmos') {
|
||||
return this.get('/evmos/inflation/v1/inflation_rate').then(data => Number(data.inflation_rate / 100 || 0))
|
||||
}
|
||||
if (this.isModuleLoaded('minting')) {
|
||||
return this.get('/minting/inflation').then(data => Number(commonProcess(data)))
|
||||
}
|
||||
return null
|
||||
return 0
|
||||
}
|
||||
|
||||
async getStakingParameters() {
|
||||
@ -185,6 +188,24 @@ export default class ChainFetch {
|
||||
}
|
||||
|
||||
async getMintParameters() {
|
||||
if (this.config.chain_name === 'evmos') {
|
||||
const result = await this.get('/evmos/inflation/v1/params').then(data => data.params)
|
||||
await this.get('/evmos/inflation/v1/period').then(data => {
|
||||
Object.entries(data).forEach(x => {
|
||||
const k = x[0]
|
||||
const v = x[1]
|
||||
result[k] = v
|
||||
})
|
||||
})
|
||||
await this.get('/evmos/inflation/v1/total_supply').then(data => {
|
||||
Object.entries(data).forEach(x => {
|
||||
const k = x[0]
|
||||
const v = x[1]
|
||||
result[k] = v
|
||||
})
|
||||
})
|
||||
return result
|
||||
}
|
||||
if (this.isModuleLoaded('minting')) {
|
||||
return this.get('/minting/parameters').then(data => commonProcess(data))
|
||||
}
|
||||
|
@ -325,6 +325,8 @@ export function isToken(value) {
|
||||
let is = false
|
||||
if (Array.isArray(value)) {
|
||||
is = value.findIndex(x => Object.keys(x).includes('denom')) > -1
|
||||
} else {
|
||||
is = Object.keys(value).includes('denom')
|
||||
}
|
||||
return is
|
||||
}
|
||||
|
@ -224,16 +224,32 @@ export default {
|
||||
if (typeof data[k] === 'boolean') {
|
||||
return { title: data[k], subtitle: k }
|
||||
}
|
||||
const d = Number(data[k])
|
||||
if (d < 1.01) {
|
||||
return { title: `${percent(d)}%`, subtitle: k }
|
||||
}
|
||||
if (d > 1000000000) {
|
||||
return { title: `${toDuration(d / 1000000)}`, subtitle: k }
|
||||
}
|
||||
return { title: data[k], subtitle: k }
|
||||
return { title: this.convert(data[k]), subtitle: k }
|
||||
})
|
||||
},
|
||||
convert(v) {
|
||||
if (typeof v === 'object') {
|
||||
const v2 = {}
|
||||
Object.entries(v).forEach(e => {
|
||||
const k = e[0]
|
||||
const x = e[1]
|
||||
v2[k] = this.convert(x)
|
||||
})
|
||||
return v2
|
||||
}
|
||||
const d = parseFloat(v)
|
||||
if (d === 0) return 0
|
||||
if (d < 1.01) {
|
||||
return `${percent(d)}%`
|
||||
}
|
||||
if (d > 1000000000) {
|
||||
return `${toDuration(d / 1000000)}`
|
||||
}
|
||||
if (d > 0) {
|
||||
return d.toFixed()
|
||||
}
|
||||
return v
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user