imp: disable delegate for top 1/3 validators
This commit is contained in:
parent
c5b88d73c2
commit
b5bdf6ec12
@ -90,9 +90,28 @@ const change24Color = (key?: Key) => {
|
|||||||
if (v < 0) return 'text-error';
|
if (v < 0) return 'text-error';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const calculateRank = function (position: number) {
|
||||||
|
let sum = 0;
|
||||||
|
for (let i = 0; i < position; i++) {
|
||||||
|
sum += Number(staking.validators[i]?.delegator_shares);
|
||||||
|
}
|
||||||
|
const percent = sum / staking.totalPower;
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case tab.value === 'active' && percent < 0.33:
|
||||||
|
return 'error';
|
||||||
|
case tab.value === 'active' && percent < 0.67:
|
||||||
|
return 'warning';
|
||||||
|
default:
|
||||||
|
return 'primary';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const list = computed(() => {
|
const list = computed(() => {
|
||||||
return tab.value === 'active' ? staking.validators : unbondList.value;
|
if (tab.value === 'active') {
|
||||||
// return staking.validators
|
return staking.validators.map((x, i) => ({v: x, rank: calculateRank(i)}));
|
||||||
|
}
|
||||||
|
return unbondList.value.map((x, i) => ({v: x, rank: 'primary'}));
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadAvatars = () => {
|
const loadAvatars = () => {
|
||||||
@ -137,22 +156,6 @@ const logo = (identity?: string) => {
|
|||||||
? url
|
? url
|
||||||
: `https://s3.amazonaws.com/keybase_processed_uploads/${url}`;
|
: `https://s3.amazonaws.com/keybase_processed_uploads/${url}`;
|
||||||
};
|
};
|
||||||
const rank = function (position: number) {
|
|
||||||
let sum = 0;
|
|
||||||
for (let i = 0; i < position; i++) {
|
|
||||||
sum += Number(staking.validators[i]?.delegator_shares);
|
|
||||||
}
|
|
||||||
const percent = sum / staking.totalPower;
|
|
||||||
|
|
||||||
switch (true) {
|
|
||||||
case tab.value === 'active' && percent < 0.33:
|
|
||||||
return 'error';
|
|
||||||
case tab.value === 'active' && percent < 0.67:
|
|
||||||
return 'warning';
|
|
||||||
default:
|
|
||||||
return 'primary';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchChange();
|
fetchChange();
|
||||||
loadAvatars();
|
loadAvatars();
|
||||||
@ -200,7 +203,7 @@ loadAvatars();
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr
|
<tr
|
||||||
v-for="(v, i) in list"
|
v-for="({v, rank}, i) in list"
|
||||||
:key="v.operator_address"
|
:key="v.operator_address"
|
||||||
class="hover:bg-gray-100 dark:hover:bg-[#384059]"
|
class="hover:bg-gray-100 dark:hover:bg-[#384059]"
|
||||||
>
|
>
|
||||||
@ -208,11 +211,11 @@ loadAvatars();
|
|||||||
<td>
|
<td>
|
||||||
<div
|
<div
|
||||||
class="text-xs truncate relative px-2 py-1 rounded-full w-fit"
|
class="text-xs truncate relative px-2 py-1 rounded-full w-fit"
|
||||||
:class="`text-${rank(i)}`"
|
:class="`text-${rank}`"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="inset-x-0 inset-y-0 opacity-10 absolute"
|
class="inset-x-0 inset-y-0 opacity-10 absolute"
|
||||||
:class="`bg-${rank(i)}`"
|
:class="`bg-${rank}`"
|
||||||
></span>
|
></span>
|
||||||
{{ i + 1 }}
|
{{ i + 1 }}
|
||||||
</div>
|
</div>
|
||||||
@ -321,7 +324,7 @@ loadAvatars();
|
|||||||
Jailed
|
Jailed
|
||||||
</div>
|
</div>
|
||||||
<label
|
<label
|
||||||
v-else
|
v-else-if="rank !== 'error'"
|
||||||
for="delegate"
|
for="delegate"
|
||||||
class="btn btn-xs btn-primary rounded-sm capitalize"
|
class="btn btn-xs btn-primary rounded-sm capitalize"
|
||||||
@click="
|
@click="
|
||||||
|
Loading…
Reference in New Issue
Block a user