forked from cerc-io/cosmos-explorer
feat: add function
This commit is contained in:
parent
98f1696a5d
commit
31434f96f3
@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import fetch from 'cross-fetch'
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import {
|
import {
|
||||||
useBaseStore,
|
useBaseStore,
|
||||||
@ -10,14 +11,52 @@ import {
|
|||||||
const chainStore = useBlockchain();
|
const chainStore = useBlockchain();
|
||||||
const dashboard = useDashboard();
|
const dashboard = useDashboard();
|
||||||
const stakingStore = useStakingStore();
|
const stakingStore = useStakingStore();
|
||||||
const rpcList = ref(chainStore.current?.endpoints?.rpc || []);
|
const rpcList = ref(
|
||||||
const httpstatus = 300;
|
chainStore.current?.endpoints?.rpc || [{ address: '', provider: '' }]
|
||||||
const httpStatusText = 'error';
|
);
|
||||||
let rpc = ref('');
|
let rpc = ref('');
|
||||||
|
const validators = ref(stakingStore.validators);
|
||||||
|
|
||||||
|
let httpstatus = ref(200);
|
||||||
|
let httpStatusText = ref('');
|
||||||
|
let roundState = {};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
stakingStore.init();
|
stakingStore.init();
|
||||||
|
rpc.value = rpcList.value[0].address + '/consensus_state';
|
||||||
|
fetchPosition();
|
||||||
|
console.log(stakingStore.rpc, 'stakingStore', validators);
|
||||||
});
|
});
|
||||||
console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc);
|
console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc);
|
||||||
|
|
||||||
|
function onChange() {
|
||||||
|
httpstatus.value = 200;
|
||||||
|
httpStatusText.value = '';
|
||||||
|
roundState = {};
|
||||||
|
}
|
||||||
|
async function fetchPosition () {
|
||||||
|
const dumpurl = rpc.value.replace('consensus_state', 'dump_consensus_state');
|
||||||
|
console.log(dumpurl, 'dumpurl')
|
||||||
|
try {
|
||||||
|
const response = await fetch(dumpurl);
|
||||||
|
console.log(3333, 'data');
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error: ${response.status}`);
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
console.log(data, 'data');
|
||||||
|
} catch (error) {}
|
||||||
|
console.log(dumpurl, 'dumpurl');
|
||||||
|
// fetch(dumpurl)
|
||||||
|
// .then((data) => {
|
||||||
|
// httpstatus.value = data.status;
|
||||||
|
// httpStatusText.value = data.httpStatusText;
|
||||||
|
// return data.json();
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// positions = res.result.round_state.validators.validators;
|
||||||
|
// });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -41,14 +80,14 @@ console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc);
|
|||||||
{{ item?.address }}/consensus_state
|
{{ item?.address }}/consensus_state
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<button class="btn btn-primary">Monitor</button>
|
<button class="btn btn-primary" @click="onChange">Monitor</button>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="httpstatus !== 200" class="text-error mt-1">
|
<div v-if="httpstatus !== 200" class="text-error mt-1">
|
||||||
{{ httpstatus }}: {{ httpStatusText }}
|
{{ httpstatus }}: {{ httpStatusText }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- cards -->
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<div class="grid grid-cols-1 md:!grid-cols-4 auto-cols-auto gap-4 pb-4">
|
<div class="grid grid-cols-1 md:!grid-cols-4 auto-cols-auto gap-4 pb-4">
|
||||||
<div
|
<div
|
||||||
@ -117,7 +156,7 @@ console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- -->
|
<!-- update -->
|
||||||
<div class="bg-base-100 px-4 pt-3 pb-4 rounded shadow">
|
<div class="bg-base-100 px-4 pt-3 pb-4 rounded shadow">
|
||||||
<div class="flex flex-1 flex-col truncate">
|
<div class="flex flex-1 flex-col truncate">
|
||||||
<!-- format(updatetime) -->
|
<!-- format(updatetime) -->
|
||||||
@ -144,7 +183,7 @@ console.log(chainStore.current?.endpoints?.rpc, 9998888, chainStore.rpc);
|
|||||||
<h2 class="text-base font-semibold">Tips</h2>
|
<h2 class="text-base font-semibold">Tips</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="px-4 py-4">
|
<div class="px-4 py-4">
|
||||||
<ul style="list-style-type: disc;" class="pl-8">
|
<ul style="list-style-type: disc" class="pl-8">
|
||||||
<li>
|
<li>
|
||||||
This tool is useful for validators to monitor who is onboard during
|
This tool is useful for validators to monitor who is onboard during
|
||||||
an upgrade
|
an upgrade
|
||||||
|
@ -88,6 +88,7 @@ export const useStakingStore = defineStore('stakingStore', {
|
|||||||
(a, b) => Number(b.delegator_shares) - Number(a.delegator_shares)
|
(a, b) => Number(b.delegator_shares) - Number(a.delegator_shares)
|
||||||
)
|
)
|
||||||
if (status === 'BOND_STATUS_BONDED') {
|
if (status === 'BOND_STATUS_BONDED') {
|
||||||
|
console.log(proVals, 'proVals')
|
||||||
this.validators = proVals;
|
this.validators = proVals;
|
||||||
}
|
}
|
||||||
return proVals
|
return proVals
|
||||||
|
Loading…
Reference in New Issue
Block a user