From 004d4a81c03b8065f48da87bb4f254516de5a515 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Tue, 6 Jun 2023 13:58:56 +0800 Subject: [PATCH] feat: add showName function --- src/modules/[chain]/consensus/index.vue | 48 +++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/modules/[chain]/consensus/index.vue b/src/modules/[chain]/consensus/index.vue index e06488ef..5c413d01 100644 --- a/src/modules/[chain]/consensus/index.vue +++ b/src/modules/[chain]/consensus/index.vue @@ -31,7 +31,8 @@ let positions = ref([]); onMounted(() => { stakingStore.init(); rpc.value = - 'https://rpc-osmosis-ia.cosmosia.notional.ventures/consensus_state'; + 'https://rpc-osmosis-ia.cosmosia.notional.ventures:443/consensus_state'; + // 'https://rpc-osmosis-ia.cosmosia.notional.ventures/consensus_state'; // rpcList.value[0].address + '/consensus_state'; fetchPosition(); console.log(stakingStore.rpc, 'stakingStore', validators); @@ -46,11 +47,25 @@ const newTime = computed(() => { return format.toDay(updatetime.value || '', 'time'); }); +function showName(i, text) { + if (text === 'nil-Vote') { + if (positions[i]) { + const val = validators.value.find((x) => x.hex === positions[i].address); + return val?.description?.moniker || i; + } + return i; + } + const txt = text.substring(text.indexOf(':') + 1, text.indexOf(' ')); + const sig = text.split(' '); + const val = validators.value.find((x) => x.hex.startsWith(txt)); + return `${val?.description?.moniker || txt} - ${sig[2]}`; +} function onChange() { httpstatus.value = 200; httpStatusText.value = ''; roundState = {}; } + async function fetchPosition() { let dumpurl = rpc.value.replace('consensus_state', 'dump_consensus_state'); try { @@ -90,8 +105,8 @@ async function update() { return data.json(); }) .then((res) => { - console.log(5555, 999, res); roundState = res.result.round_state; + console.log(5555, 999, res, roundState); const raw = roundState['height/round/step']?.split('/'); // eslint-disable-next-line prefer-destructuring height.value = raw[0]; @@ -101,7 +116,7 @@ async function update() { step.value = raw[2]; // find the highest onboard rate - roundState.height_vote_set.forEach((element) => { + roundState?.height_vote_set?.forEach((element) => { const rates = Number( element.prevotes_bit_array.substring( element.prevotes_bit_array.length - 4 @@ -225,6 +240,33 @@ async function update() { Updated at {{ newTime || '' }} +
+
Round: {{ item.round }}
+
{{ item.prevotes_bit_array }}
+ +
+ + {{ showName(i, pre) }} +
+ +