ensure votes changed in VotingReady while calling UnlockStakes
This commit is contained in:
parent
431092fb1c
commit
0d0e122bd2
1 changed files with 37 additions and 31 deletions
|
|
@ -549,40 +549,41 @@ proposalValidator =
|
||||||
|
|
||||||
PUnlockStake _ -> spendStakes $ \sctxF -> do
|
PUnlockStake _ -> spendStakes $ \sctxF -> do
|
||||||
let expectedVotes =
|
let expectedVotes =
|
||||||
pfoldl
|
pdata $
|
||||||
# plam
|
pfoldl
|
||||||
( \votes stake -> unTermCont $ do
|
# plam
|
||||||
stakeF <-
|
( \votes stake -> unTermCont $ do
|
||||||
pletFieldsC
|
stakeF <-
|
||||||
@'["stakedAmount", "lockedBy"]
|
pletFieldsC
|
||||||
stake
|
@'["stakedAmount", "lockedBy"]
|
||||||
|
stake
|
||||||
|
|
||||||
stakeRoles <-
|
stakeRoles <-
|
||||||
pletC $
|
pletC $
|
||||||
pgetStakeRoles
|
pgetStakeRoles
|
||||||
# proposalInputDatumF.proposalId
|
# proposalInputDatumF.proposalId
|
||||||
# stakeF.lockedBy
|
# stakeF.lockedBy
|
||||||
|
|
||||||
pguardC "Stake input should be relevant" $
|
pguardC "Stake input should be relevant" $
|
||||||
pnot #$ pisIrrelevant # stakeRoles
|
pnot #$ pisIrrelevant # stakeRoles
|
||||||
|
|
||||||
let canRetractVotes =
|
let canRetractVotes =
|
||||||
pisVoter # stakeRoles
|
pisVoter # stakeRoles
|
||||||
|
|
||||||
voteCount =
|
voteCount =
|
||||||
pto $
|
pto $
|
||||||
pfromData stakeF.stakedAmount
|
pfromData stakeF.stakedAmount
|
||||||
|
|
||||||
newVotes =
|
newVotes =
|
||||||
pretractVotes
|
pretractVotes
|
||||||
# (pextractVoteOption # stakeRoles)
|
# (pextractVoteOption # stakeRoles)
|
||||||
# voteCount
|
# voteCount
|
||||||
# votes
|
# votes
|
||||||
|
|
||||||
pure $ pif canRetractVotes newVotes votes
|
pure $ pif canRetractVotes newVotes votes
|
||||||
)
|
)
|
||||||
# proposalInputDatumF.votes
|
# proposalInputDatumF.votes
|
||||||
# sctxF.inputStakes
|
# sctxF.inputStakes
|
||||||
|
|
||||||
inVotingPeriod =
|
inVotingPeriod =
|
||||||
pisWithin # getTimingRelation PVotingPeriod
|
pisWithin # getTimingRelation PVotingPeriod
|
||||||
|
|
@ -611,14 +612,19 @@ proposalValidator =
|
||||||
.& #thresholds
|
.& #thresholds
|
||||||
.= proposalInputDatumF.thresholds
|
.= proposalInputDatumF.thresholds
|
||||||
.& #votes
|
.& #votes
|
||||||
.= pdata expectedVotes
|
.= expectedVotes
|
||||||
.& #timingConfig
|
.& #timingConfig
|
||||||
.= proposalInputDatumF.timingConfig
|
.= proposalInputDatumF.timingConfig
|
||||||
.& #startingTime
|
.& #startingTime
|
||||||
.= proposalInputDatumF.startingTime
|
.= proposalInputDatumF.startingTime
|
||||||
)
|
)
|
||||||
in ptraceIfFalse "Update votes" $
|
in foldl1
|
||||||
expectedProposalOut #== proposalOutputDatum
|
(#&&)
|
||||||
|
[ ptraceIfFalse "Votes changed" $
|
||||||
|
pnot #$ expectedVotes #== proposalInputDatumF.votes
|
||||||
|
, ptraceIfFalse "Proposal update correct" $
|
||||||
|
expectedProposalOut #== proposalOutputDatum
|
||||||
|
]
|
||||||
)
|
)
|
||||||
-- No change to the proposal is allowed.
|
-- No change to the proposal is allowed.
|
||||||
( ptraceIfFalse "Proposal unchanged" $
|
( ptraceIfFalse "Proposal unchanged" $
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue