Skip to content

Commit

Permalink
fix: always allow admins and moderators to propose (#1007)
Browse files Browse the repository at this point in the history
* fix: always allow admins and moderators to propose

* fix: add controller to list of team addresses

* fix: remove controller

* fix: allow authors to bypass proposal validation
  • Loading branch information
wa0x6e authored Dec 1, 2024
1 parent 3e6b096 commit 84094bc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion apps/ui/src/stores/votingPowers.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<Map<string, VotingPowerItem>>(new Map());

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 84094bc

Please sign in to comment.