forked from LaconicNetwork/cosmos-explorer
merge
This commit is contained in:
@@ -97,7 +97,8 @@ const format = useFormatter();
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'blocks'
|
||||
i18n: 'blocks',
|
||||
order: 5
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
@@ -47,7 +47,8 @@ const changeTab = (val: '2' | '3' | '4') => {
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'governance'
|
||||
i18n: 'governance',
|
||||
order: 2
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
@@ -70,7 +70,8 @@ function color(v: string) {
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'ibc'
|
||||
i18n: 'ibc',
|
||||
order: 8
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
@@ -14,6 +14,7 @@ import ProposalListItem from '@/components/ProposalListItem.vue';
|
||||
const blockchain = useBlockchain();
|
||||
const store = useIndexModule();
|
||||
const walletStore = useWalletStore()
|
||||
const format = useFormatter()
|
||||
|
||||
const coinInfo = computed(() => {
|
||||
return store.coinInfo;
|
||||
@@ -21,9 +22,9 @@ const coinInfo = computed(() => {
|
||||
|
||||
onMounted(() => {
|
||||
store.loadDashboard();
|
||||
walletStore.loadMyAsset()
|
||||
});
|
||||
|
||||
const format = useFormatter();
|
||||
const ticker = computed(() => store.coinInfo.tickers[store.tickerIndex]);
|
||||
|
||||
blockchain.$subscribe((m, s) => {
|
||||
@@ -32,6 +33,7 @@ blockchain.$subscribe((m, s) => {
|
||||
['chainName', 'endpoint'].includes(m.events.key)
|
||||
) {
|
||||
store.loadDashboard();
|
||||
walletStore.loadMyAsset()
|
||||
}
|
||||
});
|
||||
function shortName(name: string, id: string) {
|
||||
@@ -65,7 +67,20 @@ const comLinks = [
|
||||
];
|
||||
|
||||
// wallet box
|
||||
|
||||
const change = computed(() => {
|
||||
const token = walletStore.balanceOfStakingToken
|
||||
return token? format.priceChanges(token.denom) : 0
|
||||
})
|
||||
const color= computed(() => {
|
||||
switch(true) {
|
||||
case change.value > 0:
|
||||
return "text-green-600"
|
||||
case change.value === 0:
|
||||
return "text-grey-500"
|
||||
case change.value < 0:
|
||||
return "text-red-600"
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -226,10 +241,18 @@ const comLinks = [
|
||||
<span v-if="walletStore.currentAddress" class="float-right font-light text-sm">More</span>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 auto-cols-auto gap-4 px-4 pb-8 py-4">
|
||||
<div class="bg-base-100">1</div>
|
||||
<div class="bg-base-100">2</div>
|
||||
<div class="bg-base-100">1</div>
|
||||
<div class="bg-base-100">2</div>
|
||||
<div class="bg-base-100">{{ format.formatToken(walletStore.balanceOfStakingToken) }}
|
||||
<br><span :class="color">{{ format.showChanges(change) }}<small>%</small></span>{{ format.tokenValue(walletStore.balanceOfStakingToken) }}</div>
|
||||
<div class="bg-base-100">{{ format.formatToken(walletStore.stakingAmount) }}
|
||||
<br> {{ format.tokenValue(walletStore.stakingAmount) }}</div>
|
||||
<div class="bg-base-100">{{ format.formatToken(walletStore.rewardAmount) }}</div>
|
||||
<div class="bg-base-100">{{ format.formatToken(walletStore.unbondingAmount) }}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div v-for="v in walletStore.delegations">
|
||||
{{ v }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -244,7 +267,8 @@ const comLinks = [
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'dashboard'
|
||||
i18n: 'dashboard',
|
||||
order: 1,
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
@@ -55,7 +55,8 @@ onMounted(() => {
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'parameters'
|
||||
i18n: 'parameters',
|
||||
order: 10
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
@@ -16,43 +16,68 @@ const tab = ref('active');
|
||||
const unbondList = ref([] as Validator[]);
|
||||
const base = useBaseStore();
|
||||
onMounted(() => {
|
||||
fetchChange(0);
|
||||
staking.fetchInacitveValdiators().then((x) => {
|
||||
unbondList.value = x;
|
||||
});
|
||||
});
|
||||
|
||||
function fetchChange(offset: number) {
|
||||
const base = useBaseStore();
|
||||
const diff = 86400000 / base.blocktime;
|
||||
// base.fetchAbciInfo().then(h => {
|
||||
// // console.log('block:', h)
|
||||
// base.fetchValidatorByHeight(h.lastBlockHeight, offset).then(x => {
|
||||
// x.validators.forEach(v => {
|
||||
// if(v.pubkey) latest.value[pubkeyToAddress(v.pubkey.algorithm, v.pubkey.data)] = Number(v.votingPower)
|
||||
// })
|
||||
// })
|
||||
// const height = Number(h.lastBlockHeight) - diff
|
||||
// base.fetchValidatorByHeight(height > 0 ? height : 1, offset).then(old => {
|
||||
// old.validators.forEach(v => {
|
||||
// if(v.pubkey) yesterday.value[pubkeyToAddress(v.pubkey.algorithm, v.pubkey.data)] = Number(v.votingPower)
|
||||
// })
|
||||
// // console.log(Object.keys(yesterday.value).map(x => x.toUpperCase()))
|
||||
// })
|
||||
// })
|
||||
async function fetchChange() {
|
||||
console.log('fetch changes')
|
||||
let page = 0
|
||||
|
||||
let height = Number(base.latest?.block?.header?.height || 0)
|
||||
if (height > 14400) {
|
||||
height -= 14400
|
||||
} else {
|
||||
height = 1
|
||||
}
|
||||
// voting power in 24h ago
|
||||
while(page < staking.validators.length && height > 0) {
|
||||
await base.fetchValidatorByHeight(height, page).then(x => {
|
||||
x.validators.forEach(v => {
|
||||
yesterday.value[v.pub_key.key] = Number(v.voting_power)
|
||||
})
|
||||
})
|
||||
page += 100
|
||||
}
|
||||
|
||||
page = 0
|
||||
// voting power for now
|
||||
while(page < staking.validators.length) {
|
||||
await base.fetchLatestValidators(page).then(x => {
|
||||
x.validators.forEach(v => {
|
||||
latest.value[v.pub_key.key] = Number(v.voting_power)
|
||||
})
|
||||
})
|
||||
page += 100
|
||||
}
|
||||
}
|
||||
|
||||
fetchChange();
|
||||
|
||||
const changes = computed(() => {
|
||||
const changes = {} as Record<string, number>
|
||||
Object.keys(latest.value).forEach(k => {
|
||||
const l = latest.value[k] || 0
|
||||
const y = yesterday.value[k] || 0
|
||||
changes[k] = l - y
|
||||
})
|
||||
return changes
|
||||
})
|
||||
|
||||
const change24 = (key: Key) => {
|
||||
const txt = key.key;
|
||||
const n: number = latest.value[txt];
|
||||
const o: number = yesterday.value[txt];
|
||||
return n > 0 && o > 0 ? n - o : 0;
|
||||
// const n: number = latest.value[txt];
|
||||
// const o: number = yesterday.value[txt];
|
||||
// // console.log( txt, n, o)
|
||||
// return n > 0 && o > 0 ? n - o : 0;
|
||||
return changes.value[txt]
|
||||
};
|
||||
|
||||
const change24Text = (key?: Key) => {
|
||||
if (!key) return '';
|
||||
const v = change24(key);
|
||||
return v !== 0 ? format.numberAndSign(v) : '';
|
||||
return v !== 0 ? format.showChanges(v) : '';
|
||||
};
|
||||
|
||||
const change24Color = (key?: Key) => {
|
||||
@@ -308,7 +333,8 @@ const rank = function (position: number) {
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'staking'
|
||||
i18n: 'staking',
|
||||
order: 3
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
@@ -162,7 +162,8 @@ watchEffect(() => {
|
||||
<route>
|
||||
{
|
||||
meta: {
|
||||
i18n: 'uptime'
|
||||
i18n: 'uptime',
|
||||
order: 8
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
Reference in New Issue
Block a user