From 987f76b7d429bbf01f01af35a1478ea383593f4f Mon Sep 17 00:00:00 2001 From: alisa Date: Thu, 27 Apr 2023 15:34:39 +0800 Subject: [PATCH] feat: add node Info and application version --- src/components/CardParameter.vue | 14 +++++++------- src/components/TableParameter.vue | 26 ++++++++++++++++++++++++++ src/modules/[chain]/index.vue | 2 -- src/modules/[chain]/indexStore.ts | 1 - src/modules/[chain]/params/index.vue | 9 +++++---- src/stores/useBlockchain.ts | 2 -- src/stores/useParamsStore.ts | 23 ++++++++++++++++++++--- 7 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 src/components/TableParameter.vue diff --git a/src/components/CardParameter.vue b/src/components/CardParameter.vue index e66877b8..20078378 100644 --- a/src/components/CardParameter.vue +++ b/src/components/CardParameter.vue @@ -10,13 +10,13 @@ const props = defineProps({ \ No newline at end of file diff --git a/src/components/TableParameter.vue b/src/components/TableParameter.vue new file mode 100644 index 00000000..3433a101 --- /dev/null +++ b/src/components/TableParameter.vue @@ -0,0 +1,26 @@ + + \ No newline at end of file diff --git a/src/modules/[chain]/index.vue b/src/modules/[chain]/index.vue index 6da7cd57..6bcdbaab 100644 --- a/src/modules/[chain]/index.vue +++ b/src/modules/[chain]/index.vue @@ -25,9 +25,7 @@ const format = useFormatter(); const ticker = computed(() => store.coinInfo.tickers[store.tickerIndex]); blockchain.$subscribe((m, s) => { - console.log('index:', m); if (!Array.isArray(m.events) && ['chainName', 'endpoint'].includes(m.events.key)) { - console.log(m.events.key); store.loadDashboard(); } }); diff --git a/src/modules/[chain]/indexStore.ts b/src/modules/[chain]/indexStore.ts index 31d6adb7..9a9357ec 100644 --- a/src/modules/[chain]/indexStore.ts +++ b/src/modules/[chain]/indexStore.ts @@ -176,7 +176,6 @@ export const useIndexModule = defineStore('module-index', { }, actions: { async loadDashboard() { - console.log('initial dashboard') this.$reset() this.initCoingecko() useMintStore().fetchInflation() diff --git a/src/modules/[chain]/params/index.vue b/src/modules/[chain]/params/index.vue index abc38e75..13b36e7e 100644 --- a/src/modules/[chain]/params/index.vue +++ b/src/modules/[chain]/params/index.vue @@ -2,6 +2,8 @@ import { useParamStore } from '@/stores'; import { ref, onMounted } from 'vue' import CardParameter from '@/components/CardParameter.vue' +import TableParameter from '@/components/TableParameter.vue' +import { sort } from 'semver'; const store = useParamStore() const chain = ref(store.chain) onMounted(() => { @@ -22,13 +24,10 @@ onMounted(() => { - - - + - @@ -36,7 +35,9 @@ onMounted(() => { + + diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 283b181b..67159285 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -36,7 +36,6 @@ export const useBlockchain = defineStore("blockchain", { const router = useRouter() const routes = router?.getRoutes()||[] - console.log(routes) if(this.current && routes) { currNavItem = [{ title: this.current?.prettyName || this.chainName || '', @@ -115,7 +114,6 @@ export const useBlockchain = defineStore("blockchain", { }, setCurrent(name: string) { this.chainName = name - console.log('set current', name) }, } diff --git a/src/stores/useParamsStore.ts b/src/stores/useParamsStore.ts index abd510fe..05da9ba2 100644 --- a/src/stores/useParamsStore.ts +++ b/src/stores/useParamsStore.ts @@ -44,6 +44,14 @@ export const useParamStore = defineStore("paramstore", { title: 'Governance Parameters', items: [] as Array, }, + appVersion: { + title: 'Application Version', + items: {}, + }, + nodeVersion: { + title: 'Node Information', + items: {}, + }, }), getters: { blockchain() { @@ -58,6 +66,7 @@ export const useParamStore = defineStore("paramstore", { this.handleSlashingParams() this.handleDistributionParams() this.handleGovernanceParams() + this.handleAbciInfo() }, async handleBaseBlockLatest() { try { @@ -65,7 +74,6 @@ export const useParamStore = defineStore("paramstore", { const height = this.chain.items.findIndex(x => x.subtitle === 'height') this.chain.title = `Chain ID: ${res.block.header.chain_id}` this.chain.items[height].value = res.block.header.height - console.log(res, 999) // if (timeIn(res.block.header.time, 3, 'm')) { // this.syncing = true // } else { @@ -111,7 +119,6 @@ export const useParamStore = defineStore("paramstore", { const res = await this.getSlashingParams() this.slashing.items = Object.entries(res.params).map(([key, value]) => ({ subtitle:key, value: value })) - console.log('Slashing', res) }, async handleDistributionParams(){ const res = await this.getDistributionParams() @@ -124,13 +131,20 @@ export const useParamStore = defineStore("paramstore", { return } Promise.all([this.getGovParamsVoting(),this.getGovParamsDeposit(),this.getGovParamsTally()]).then((resArr) => { - console.log(resArr, 'resArrr') const govParams = {...resArr[0]?.voting_params,...resArr[1]?.deposit_params,...resArr[2]?.tally_params} this.gov.items = Object.entries(govParams).map(([key, value]) => ({ subtitle:key, value: value })) }) }, + async handleAbciInfo(){ + const res = await this.fetchAbciInfo() + this.appVersion.items = Object.entries(res.application_version).map(([key, value]) => ({ subtitle:key, + value: value })) + this.nodeVersion.items = Object.entries(res.default_node_info).map(([key, value]) => ({ subtitle:key, + value: value })) + console.log('handleAbciInfo', res) + }, async getBaseTendermintBlockLatest() { return await this.blockchain.rpc.getBaseBlockLatest() }, @@ -168,6 +182,9 @@ export const useParamStore = defineStore("paramstore", { async getGovParamsTally() { return await this.blockchain.rpc.getGovParamsTally() }, + async fetchAbciInfo() { + return this.blockchain.rpc.getBaseNodeInfo() + } }