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 be05643f13
commit 8da0a1b016
No known key found for this signature in database
GPG key ID: 35CD9A71CD5D5870

View file

@ -43,7 +43,7 @@ import Agora.AuthorityToken (
import Agora.Proposal (
PProposalDatum,
PProposalId,
PProposalStatus (PFinished, PLocked),
PProposalStatus (PFinished, PExecutable),
PProposalThresholds,
PProposalVotes (PProposalVotes),
PResultTag (PResultTag),
@ -409,11 +409,11 @@ governorValidator params =
pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"]
inputProposalDatum'
let isInputLocked = pmatch (pfromData inputProposalDatum.status) $ \case
PLocked _ -> pconstant False
let isExecutable = pmatch (pfromData inputProposalDatum.status) $ \case
PExecutable _ -> pconstant True
_ -> 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 =
pdcons @"id" # inputProposalDatum.id
@ -439,7 +439,8 @@ governorValidator params =
noVotes = plookup' # pnoResultTag # votes
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