Skip to content

Commit

Permalink
feat: disable undelegate for erc20 votes if already delegating to self
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekhmet committed Jan 24, 2025
1 parent 56d4e22 commit 7556bf9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions apps/ui/src/components/SpaceDelegates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import removeMarkdown from 'remove-markdown';
import { getDelegationNetwork } from '@/helpers/delegation';
import { getGenericExplorerUrl } from '@/helpers/explorer';
import { getNames } from '@/helpers/stamp';
import { _n, _p, _vp, shorten } from '@/helpers/utils';
import { _n, _p, _vp, compareAddresses, shorten } from '@/helpers/utils';
import { getNetwork, supportsNullCurrent } from '@/networks';
import { SNAPSHOT_URLS } from '@/networks/offchain';
import { RequiredProperty, Space, SpaceMetadataDelegation } from '@/types';
Expand All @@ -24,6 +24,7 @@ const delegatee = ref<{
balance: number | null;
share: number;
name: string | null;
canUndelegate: boolean;
} | null>(null);
const sortBy = ref(
'delegatedVotes-desc' as
Expand Down Expand Up @@ -102,7 +103,8 @@ async function fetchDelegateRegistryDelegatee() {
id: delegation.delegate,
balance,
share: apiDelegate ? balance / Number(apiDelegate.delegatedVotes) : 1,
name: names[delegation.delegate]
name: names[delegation.delegate],
canUndelegate: true
};
} else {
delegatee.value = null;
Expand Down Expand Up @@ -136,7 +138,11 @@ async function fetchGovernorSubgraphDelegatee() {
share: apiDelegate
? Number(delegateeData.balance) / Number(apiDelegate.delegatedVotesRaw)
: 1,
name: names[delegateeData.address]
name: names[delegateeData.address],
canUndelegate: !compareAddresses(
delegateeData.address,
web3.value.account
)
};
} else {
delegatee.value = null;
Expand Down Expand Up @@ -318,7 +324,10 @@ watchEffect(() => setTitle(`Delegates - ${props.space.name}`));
<div class="text-[17px]" v-text="_p(delegatee.share)" />
</div>
</AppLink>
<div class="flex items-center justify-center">
<div
v-if="delegatee.canUndelegate"
class="flex items-center justify-center"
>
<UiDropdown>
<template #button>
<UiButton class="!p-0 !border-0 !h-[auto] !bg-transparent">
Expand Down

0 comments on commit 7556bf9

Please sign in to comment.