fix winner outcome selection logic and timing
This commit is contained in:
parent
042c18a382
commit
4c97341acf
5 changed files with 113 additions and 58 deletions
|
|
@ -52,6 +52,7 @@ import Agora.Proposal (
|
|||
Proposal (..),
|
||||
ProposalStatus (Draft, Locked),
|
||||
pemptyVotesFor,
|
||||
pneutralOption,
|
||||
proposalDatumValid,
|
||||
pwinner,
|
||||
)
|
||||
|
|
@ -114,13 +115,11 @@ import Plutarch.Api.V1.AssetClass (
|
|||
passetClass,
|
||||
passetClassValueOf,
|
||||
)
|
||||
import Plutarch.Extra.Comonad (pextract)
|
||||
import Plutarch.Extra.Map (
|
||||
pkeys,
|
||||
plookup,
|
||||
plookup',
|
||||
)
|
||||
import Plutarch.Extra.TermCont (pmatchC)
|
||||
import Plutarch.SafeMoney (PDiscrete (..), pvalueDiscrete')
|
||||
import Plutarch.TryFrom ()
|
||||
|
||||
|
|
@ -605,15 +604,9 @@ governorValidator gov =
|
|||
-- TODO: anything else to check here?
|
||||
|
||||
-- Find the highest votes and the corresponding tag.
|
||||
winner <- tclet $ mustBePJust # "No winning outcome" #$ pwinner # proposalInputDatumF.votes
|
||||
|
||||
PDiscrete minimumVotes' <- pmatchC $ pfromData $ pfield @"execute" # proposalInputDatumF.thresholds
|
||||
let highestVote = pfromData $ psndBuiltin # winner
|
||||
minimumVotes = pextract # minimumVotes'
|
||||
|
||||
tcassert "Higgest vote doesn't meet the minimum requirement" $ minimumVotes #<= highestVote
|
||||
|
||||
let finalResultTag = pfromData $ pfstBuiltin # winner
|
||||
let quorum = pto $ pto $ pfromData $ pfield @"execute" # proposalInputDatumF.thresholds
|
||||
neutralOption = pneutralOption # proposalInputDatumF.effects
|
||||
finalResultTag = pwinner # proposalInputDatumF.votes # quorum # neutralOption
|
||||
|
||||
-- The effects of the winner outcome.
|
||||
effectGroup <- tclet $ plookup' # finalResultTag #$ proposalInputDatumF.effects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue