From c3a10f8bbdae383749a9c0ad05ddc41a5e3d1015 Mon Sep 17 00:00:00 2001 From: fanghr Date: Thu, 28 Apr 2022 17:31:34 +0800 Subject: [PATCH] move `pgetNextProposalId` from `Proposal` module to `Governor` module --- agora/Agora/Governor.hs | 10 +++++++--- agora/Agora/Proposal.hs | 9 --------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/agora/Agora/Governor.hs b/agora/Agora/Governor.hs index 1d4fcf9..ea34a5d 100644 --- a/agora/Agora/Governor.hs +++ b/agora/Agora/Governor.hs @@ -27,6 +27,7 @@ module Agora.Governor ( -- * Utilities gstAssetClass, gatSymbol, + pgetNextProposalId ) where -------------------------------------------------------------------------------- @@ -44,7 +45,7 @@ import Agora.AuthorityToken ( ) import Agora.Proposal ( PProposalDatum (..), - PProposalId, + PProposalId(..), PProposalStatus (PFinished), PProposalThresholds, PResultTag, @@ -52,7 +53,6 @@ import Agora.Proposal ( ProposalId, ProposalStatus (Draft, Locked), ProposalThresholds, - pnextProposalId, proposalDatumValid, proposalPolicy, proposalValidator, @@ -392,7 +392,7 @@ governorValidator gov = case redeemer of PCreateProposal _ -> P.do - let expectedNextProposalId = pnextProposalId # oldParams.nextProposalId + let expectedNextProposalId = pgetNextProposalId # oldParams.nextProposalId expectedNewDatum = pcon $ PGovernorDatum $ @@ -789,3 +789,7 @@ gatSymbol gov = mintingPolicySymbol policy where at = AuthorityToken $ gstAssetClass gov policy = mkMintingPolicy $ authorityTokenPolicy at + +-- | Get next proposal id. +pgetNextProposalId :: Term s (PProposalId :--> PProposalId) +pgetNextProposalId = phoistAcyclic $ plam $ \(pto -> pid) -> pcon $ PProposalId $ pid + 1 diff --git a/agora/Agora/Proposal.hs b/agora/Agora/Proposal.hs index db97f7a..f57e5e4 100644 --- a/agora/Agora/Proposal.hs +++ b/agora/Agora/Proposal.hs @@ -30,9 +30,6 @@ module Agora.Proposal ( -- * Plutarch helpers proposalDatumValid, - - -- * Utils - pnextProposalId, ) where import GHC.Generics qualified as GHC @@ -437,9 +434,3 @@ proposalDatumValid proposal = , ptraceIfFalse "Proposal has fewer cosigners than the limit" $ plength # (pfromData datum.cosigners) #<= pconstant proposal.maximumCosigners , ptraceIfFalse "Proposal votes and effects are compatible with each other" $ pkeysEqual # datum.effects # pto (pfromData datum.votes) ] - --------------------------------------------------------------------------------- - --- | Get next proposal id. -pnextProposalId :: Term s (PProposalId :--> PProposalId) -pnextProposalId = phoistAcyclic $ plam $ \(pto -> pid) -> pcon $ PProposalId $ pid + 1