diff --git a/src/libs/fetch.js b/src/libs/fetch.js index b1795c4c..4db1e1f6 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -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)) } diff --git a/src/libs/utils.js b/src/libs/utils.js index 7683f065..1cad7347 100644 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -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 } diff --git a/src/views/Summary.vue b/src/views/Summary.vue index ce31f50a..3a249a94 100644 --- a/src/views/Summary.vue +++ b/src/views/Summary.vue @@ -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 + }, }, }