ensure the proposal is in executable state while minting GATs

This commit is contained in:
fanghr 2022-04-21 22:08:37 +08:00
parent 0f2be417a7
commit 8ec958646c

View file

@ -43,7 +43,7 @@ import Agora.AuthorityToken (
import Agora.Proposal ( import Agora.Proposal (
PProposalDatum, PProposalDatum,
PProposalId, PProposalId,
PProposalStatus (PFinished, PLocked), PProposalStatus (PFinished, PExecutable),
PProposalThresholds, PProposalThresholds,
PProposalVotes (PProposalVotes), PProposalVotes (PProposalVotes),
PResultTag (PResultTag), PResultTag (PResultTag),
@ -409,11 +409,11 @@ governorValidator params =
pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"] pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"]
inputProposalDatum' inputProposalDatum'
let isInputLocked = pmatch (pfromData inputProposalDatum.status) $ \case let isExecutable = pmatch (pfromData inputProposalDatum.status) $ \case
PLocked _ -> pconstant False PExecutable _ -> pconstant True
_ -> pconstant False _ -> pconstant False
passert "Proposal must be in locked state in order to execute effects" $ isInputLocked passert "Proposal must be in executable state in order to execute effects" $ isExecutable
let fields = let fields =
pdcons @"id" # inputProposalDatum.id pdcons @"id" # inputProposalDatum.id
@ -439,7 +439,8 @@ governorValidator params =
noVotes = plookup' # pnoResultTag # votes noVotes = plookup' # pnoResultTag # votes
biggerVotes = pif (yesVotes #< noVotes) noVotes yesVotes biggerVotes = pif (yesVotes #< noVotes) noVotes yesVotes
passert "Number of votes doesn't meet the minimum requirement" $ minimumVotes #< biggerVotes passert "Number of votes doesn't meet the minimum requirement" $
minimumVotes #< biggerVotes
let finalResultTag = pif (yesVotes #< noVotes) pnoResultTag pyesResultTag let finalResultTag = pif (yesVotes #< noVotes) pnoResultTag pyesResultTag