diff --git a/src/libs/data/data.js b/src/libs/data/data.js index ff302180..3dd64ff8 100644 --- a/src/libs/data/data.js +++ b/src/libs/data/data.js @@ -20,9 +20,20 @@ export function formatToken(token) { return `${(token.amount / 1000000).toFixed()} ${denom}` } +const COUNT_ABBRS = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'] + +export function formatNumber(count, withAbbr = false, decimals = 2) { + const i = count === 0 ? count : Math.floor(Math.log(count) / Math.log(1000)) + let result = parseFloat((count / (1000 ** i)).toFixed(decimals)) + if (withAbbr) { + result += `${COUNT_ABBRS[i]}` + } + return result +} + export function tokenFormatter(tokens) { if (Array.isArray(tokens)) { - return tokens.map(t => formatToken(t)) + return tokens.map(t => formatToken(t)).join() } return formatToken(tokens) } diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 5baccee3..87f99907 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -1,5 +1,6 @@ import fetch from 'node-fetch' import store from '@/store' +import compareVersions from 'compare-versions' import { Proposal, ProposalTally, Proposer, StakingPool, Votes, Deposit, Validator, StakingParameters, Block, ValidatorDistribution, StakingDelegation, @@ -41,6 +42,13 @@ const chainAPI = class ChainFetch { return this.get(`/staking/delegators/${delegatorAddr}/delegations/${validatorAddr}`).then(data => StakingDelegation.create(commonProcess(data))) } + async getBankTotal(denom) { + if (compareVersions(this.config.sdk_version, '0.40') < 0) { + return this.get(`/supply/total/${denom}`).then(data => ({ amount: commonProcess(data), denom })) + } + return this.get(`/bank/total/${denom}`).then(data => commonProcess(data)) + } + async getStakingPool() { return this.get('/staking/pool').then(data => new StakingPool().init(commonProcess(data))) } @@ -61,6 +69,30 @@ const chainAPI = class ChainFetch { return this.get(`/staking/validators/${address}`).then(data => new Validator().init(commonProcess(data))) } + async getSlashingParameters() { + return this.get('/slashing/parameters').then(data => commonProcess(data)) + } + + async getMintParameters() { + return this.get('/minting/parameters').then(data => commonProcess(data)) + } + + async getDistributionParameters() { + return this.get('/distribution/parameters').then(data => commonProcess(data)) + } + + async getGovernanceParameterDeposit() { + return this.get('/gov/parameters/deposit').then(data => commonProcess(data)) + } + + async getGovernanceParameterTallying() { + return this.get('/gov/parameters/tallying').then(data => commonProcess(data)) + } + + async getGovernanceParameterVoting() { + return this.get('/gov/parameters/voting').then(data => commonProcess(data)) + } + async getGovernanceTally(pid, total) { return this.get(`/gov/proposals/${pid}/tally`).then(data => new ProposalTally().init(commonProcess(data), total)) } diff --git a/src/router/index.js b/src/router/index.js index fa0f881d..f8a27683 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -31,7 +31,7 @@ const router = new VueRouter({ path: '/:chain/info', name: 'info', alias: '/:chain', - component: () => import('@/views/Info.vue'), + component: () => import('@/views/Summary.vue'), meta: { pageTitle: 'Home', breadcrumb: [ diff --git a/src/views/Info.vue b/src/views/Info.vue deleted file mode 100644 index 6724617f..00000000 --- a/src/views/Info.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - - - diff --git a/src/views/Summary.vue b/src/views/Summary.vue new file mode 100644 index 00000000..f8c623c7 --- /dev/null +++ b/src/views/Summary.vue @@ -0,0 +1,160 @@ + + + + + diff --git a/src/views/SummaryParmetersComponent.vue b/src/views/SummaryParmetersComponent.vue new file mode 100644 index 00000000..7eeebe79 --- /dev/null +++ b/src/views/SummaryParmetersComponent.vue @@ -0,0 +1,77 @@ + + +