From a8077bca569c7270f4f9d99e9a0211c583400e5c Mon Sep 17 00:00:00 2001 From: Kirill Klimenko Date: Tue, 12 Dec 2023 01:20:13 +0100 Subject: [PATCH] Fix #1299 #1300 #1201 #1301 #1302 #1303 --- app/daos/[daoAddress]/treasury/page.tsx | 5 +++-- src/components/Proposals/ProposalSummary.tsx | 4 ++-- .../ProposalVotes/context/VoteContext.tsx | 8 +++++++- src/components/ui/modals/DelegateModal.tsx | 4 ++-- .../loaders/governance/useERC20LinearStrategy.ts | 14 +++++++++----- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/daos/[daoAddress]/treasury/page.tsx b/app/daos/[daoAddress]/treasury/page.tsx index c71b665889..12450364bc 100644 --- a/app/daos/[daoAddress]/treasury/page.tsx +++ b/app/daos/[daoAddress]/treasury/page.tsx @@ -10,16 +10,17 @@ import { ModalType } from '../../../../src/components/ui/modals/ModalProvider'; import { useFractalModal } from '../../../../src/components/ui/modals/useFractalModal'; import PageHeader from '../../../../src/components/ui/page/Header/PageHeader'; import ClientOnly from '../../../../src/components/ui/utils/ClientOnly'; +import useSubmitProposal from '../../../../src/hooks/DAO/proposal/useSubmitProposal'; import { useFractal } from '../../../../src/providers/App/AppProvider'; export default function Treasury() { const { - readOnly: { user }, node: { daoName, daoAddress }, } = useFractal(); const { t } = useTranslation('treasury'); const treasuryTotal = useTreasuryTotalBN(); - const showButton = user.votingWeight.gt(0) && !treasuryTotal.isZero(); + const { canUserCreateProposal } = useSubmitProposal(); + const showButton = canUserCreateProposal && !treasuryTotal.isZero(); return ( diff --git a/src/components/Proposals/ProposalSummary.tsx b/src/components/Proposals/ProposalSummary.tsx index 6d20e845a1..152184c4e0 100644 --- a/src/components/Proposals/ProposalSummary.tsx +++ b/src/components/Proposals/ProposalSummary.tsx @@ -18,7 +18,7 @@ import { InfoRow } from './MultisigProposalDetails/TxDetails'; export default function ProposalSummary({ proposal: { startBlock, - votesSummary: { yes, no, abstain, quorum }, + votesSummary: { yes, no, abstain }, deadlineMs, proposer, transactionHash, @@ -73,7 +73,7 @@ export default function ProposalSummary({ const noVotesPercentage = getVotesPercentage(no); const strategyQuorum = votesToken && isERC20 - ? quorum.div(votesToken.totalSupply.div(100)).toNumber() + ? votingStrategy.quorumPercentage!.value.toNumber() : isERC721 ? votingStrategy.quorumThreshold!.value.toNumber() : 1; diff --git a/src/components/Proposals/ProposalVotes/context/VoteContext.tsx b/src/components/Proposals/ProposalVotes/context/VoteContext.tsx index 81766b1f3d..6dced8c80b 100644 --- a/src/components/Proposals/ProposalVotes/context/VoteContext.tsx +++ b/src/components/Proposals/ProposalVotes/context/VoteContext.tsx @@ -52,6 +52,7 @@ export function VoteContextProvider({ readOnly: { user, dao }, node: { safe }, governance: { type }, + governanceContracts: { ozLinearVotingContract }, } = useFractal(); const { loadVotingWeight } = useSnapshotProposal(proposal as SnapshotProposal); const { remainingTokenIds, getUserERC721VotingTokens } = useUserERC721VotingTokens( @@ -91,7 +92,10 @@ export function VoteContextProvider({ const votingWeightData = await loadVotingWeight(); newCanVote = votingWeightData.votingWeight >= 1; } else if (type === GovernanceType.AZORIUS_ERC20) { - newCanVote = user.votingWeight.gt(0) && !hasVoted; + newCanVote = + ( + await ozLinearVotingContract!.asSigner.getProposalVotingSupply(proposal.proposalId) + )?.gt(0) && !hasVoted; } else if (type === GovernanceType.AZORIUS_ERC721) { if (refetchUserTokens) { await getUserERC721VotingTokens(); @@ -119,6 +123,8 @@ export function VoteContextProvider({ getUserERC721VotingTokens, isSnapshotProposal, loadVotingWeight, + ozLinearVotingContract, + proposal?.proposalId, ] ); useEffect(() => { diff --git a/src/components/ui/modals/DelegateModal.tsx b/src/components/ui/modals/DelegateModal.tsx index 4d4b75b79d..8af73316eb 100644 --- a/src/components/ui/modals/DelegateModal.tsx +++ b/src/components/ui/modals/DelegateModal.tsx @@ -199,7 +199,7 @@ export function DelegateModal({ close }: { close: Function }) { !!errors.address || contractCallPending || !values.address || - azoriusGovernance.votesToken?.balance?.isZero() + values.address === azoriusGovernance.votesToken?.delegatee } > {t('buttonDelegate')} @@ -213,7 +213,7 @@ export function DelegateModal({ close }: { close: Function }) { !!errors.address || contractCallPending || !values.address || - decentGovernance.lockedVotesToken.balance?.isZero() + values.address === decentGovernance.lockedVotesToken.delegatee } > {t('buttonLockedDelegate')} diff --git a/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts b/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts index 561df07000..7476c9a408 100644 --- a/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts +++ b/src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts @@ -28,11 +28,15 @@ export const useERC20LinearStrategy = () => { if (!ozLinearVotingContract || !azoriusContract) { return {}; } - const [votingPeriodBlocks, quorumPercentage, timeLockPeriod] = await Promise.all([ - ozLinearVotingContract.asSigner.votingPeriod(), - ozLinearVotingContract.asSigner.quorumNumerator(), - azoriusContract.asSigner.timelockPeriod(), - ]); + const [votingPeriodBlocks, quorumNumerator, quorumDenominator, timeLockPeriod] = + await Promise.all([ + ozLinearVotingContract.asSigner.votingPeriod(), + ozLinearVotingContract.asSigner.quorumNumerator(), + ozLinearVotingContract.asSigner.QUORUM_DENOMINATOR(), + azoriusContract.asSigner.timelockPeriod(), + ]); + + const quorumPercentage = quorumNumerator.mul(100).div(quorumDenominator); const votingPeriodValue = await blocksToSeconds(votingPeriodBlocks, provider); const timeLockPeriodValue = await blocksToSeconds(timeLockPeriod, provider);