diff --git a/apps/ui/src/stores/votingPowers.ts b/apps/ui/src/stores/votingPowers.ts index 974a8702b..613796c49 100644 --- a/apps/ui/src/stores/votingPowers.ts +++ b/apps/ui/src/stores/votingPowers.ts @@ -1,5 +1,6 @@ import { utils } from '@snapshot-labs/sx'; import { defineStore } from 'pinia'; +import { compareAddresses } from '@/helpers/utils'; import { getNetwork } from '@/networks'; import { VotingPower, VotingPowerStatus } from '@/networks/types'; import { Proposal, Space } from '@/types'; @@ -34,6 +35,16 @@ function isSpace(item: SpaceDetails | Proposal): item is Space { return 'proposal_threshold' in item; } +function isSpaceMember(space: Space, account: string): boolean { + return [ + ...(space.additionalRawData?.admins || []), + ...(space.additionalRawData?.moderators || []), + ...(space.additionalRawData?.members || []) + ] + .filter(Boolean) + .some(member => compareAddresses(member, account)); +} + export const useVotingPowersStore = defineStore('votingPowers', () => { const votingPowers = reactive>(new Map()); @@ -103,7 +114,9 @@ export const useVotingPowersStore = defineStore('votingPowers', () => { if (isSpace(item) && proposeVp) { const totalProposeVp = proposeVp.reduce((acc, b) => acc + b.value, 0n); - vpItem.canPropose = totalProposeVp >= BigInt(item.proposal_threshold); + vpItem.canPropose = + totalProposeVp >= BigInt(item.proposal_threshold) || + isSpaceMember(space as Space, account); } else { vpItem.canVote = vpItem.totalVotingPower > 0n; }