Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Dec 14, 2023
2 parents 519d70e + e3569c5 commit 25ea1ef
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
5 changes: 3 additions & 2 deletions app/daos/[daoAddress]/treasury/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ClientOnly>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Proposals/ProposalSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -119,6 +123,8 @@ export function VoteContextProvider({
getUserERC721VotingTokens,
isSnapshotProposal,
loadVotingWeight,
ozLinearVotingContract,
proposal?.proposalId,
]
);
useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/modals/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')}
Expand All @@ -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')}
Expand Down
14 changes: 9 additions & 5 deletions src/hooks/DAO/loaders/governance/useERC20LinearStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 25ea1ef

Please sign in to comment.