fix misleading assert messages && add some comments
This commit is contained in:
parent
8a408f3ab0
commit
ee6ae128de
3 changed files with 10 additions and 8 deletions
|
|
@ -374,6 +374,10 @@ voteOnProposal params =
|
||||||
stakeOutput =
|
stakeOutput =
|
||||||
stakeInput
|
stakeInput
|
||||||
{ txOutDatumHash = Just $ toDatumHash stakeOutputDatum
|
{ txOutDatumHash = Just $ toDatumHash stakeOutputDatum
|
||||||
|
-- We won't include the minimum Ada in the output value
|
||||||
|
-- due to how we check the output value in the stake validator.
|
||||||
|
-- The implementation is correct though, it should work in a
|
||||||
|
-- real on-chain environment.
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -199,14 +199,14 @@ proposalValidator proposal =
|
||||||
PProposalVotes voteMap <- tcmatch proposalF.votes
|
PProposalVotes voteMap <- tcmatch proposalF.votes
|
||||||
voteFor <- tclet $ pfromData $ pfield @"resultTag" # r
|
voteFor <- tclet $ pfromData $ pfield @"resultTag" # r
|
||||||
|
|
||||||
tcassert "Invalid vote option" $
|
tcassert "Vote option should be valid" $
|
||||||
pisJust #$ plookup # voteFor # voteMap
|
pisJust #$ plookup # voteFor # voteMap
|
||||||
|
|
||||||
-- Find the input stake, the amount of new votes should be the 'stakedAmount'.
|
-- Find the input stake, the amount of new votes should be the 'stakedAmount'.
|
||||||
let stakeInput =
|
let stakeInput =
|
||||||
pfield @"resolved"
|
pfield @"resolved"
|
||||||
#$ mustBePJust
|
#$ mustBePJust
|
||||||
# "Stake input not found"
|
# "Stake input should be present"
|
||||||
#$ pfind
|
#$ pfind
|
||||||
# plam
|
# plam
|
||||||
( \(pfromData . (pfield @"value" #) . (pfield @"resolved" #) -> value) ->
|
( \(pfromData . (pfield @"value" #) . (pfield @"resolved" #) -> value) ->
|
||||||
|
|
@ -220,7 +220,7 @@ proposalValidator proposal =
|
||||||
stakeInF <- tcont $ pletFields @'["stakedAmount", "lockedBy", "owner"] stakeIn
|
stakeInF <- tcont $ pletFields @'["stakedAmount", "lockedBy", "owner"] stakeIn
|
||||||
|
|
||||||
-- Ensure that no lock with the current proposal id has been put on the stake.
|
-- Ensure that no lock with the current proposal id has been put on the stake.
|
||||||
tcassert "Cannot vote on the a proposal using the same stake twice" $
|
tcassert "Same stake shouldn't vote on the same propsoal twice" $
|
||||||
pnot #$ pany
|
pnot #$ pany
|
||||||
# plam
|
# plam
|
||||||
( \((pfield @"proposalTag" #) . pfromData -> pid) ->
|
( \((pfield @"proposalTag" #) . pfromData -> pid) ->
|
||||||
|
|
@ -231,7 +231,7 @@ proposalValidator proposal =
|
||||||
-- TODO: maybe we can move this outside of the pmatch block.
|
-- TODO: maybe we can move this outside of the pmatch block.
|
||||||
-- Filter out own output with own address and PST.
|
-- Filter out own output with own address and PST.
|
||||||
let ownOutput =
|
let ownOutput =
|
||||||
mustBePJust # "Own output not found" #$ pfind
|
mustBePJust # "Own output should be present" #$ pfind
|
||||||
# plam
|
# plam
|
||||||
( \input -> unTermCont $ do
|
( \input -> unTermCont $ do
|
||||||
inputF <- tcont $ pletFields @'["address", "value"] input
|
inputF <- tcont $ pletFields @'["address", "value"] input
|
||||||
|
|
@ -268,14 +268,14 @@ proposalValidator proposal =
|
||||||
.& #startingTime .= proposalF.startingTime
|
.& #startingTime .= proposalF.startingTime
|
||||||
)
|
)
|
||||||
|
|
||||||
tcassert "Invalid output proposal" $ proposalOut #== expectedProposalOut
|
tcassert "Output proposal should be valid" $ proposalOut #== expectedProposalOut
|
||||||
|
|
||||||
-- We validate the output stake datum here as well: We need the vote option
|
-- We validate the output stake datum here as well: We need the vote option
|
||||||
-- to create a valid 'ProposalLock', however the vote option is encoded
|
-- to create a valid 'ProposalLock', however the vote option is encoded
|
||||||
-- in the proposal redeemer, which is invisible for the stake validator.
|
-- in the proposal redeemer, which is invisible for the stake validator.
|
||||||
|
|
||||||
let stakeOutput =
|
let stakeOutput =
|
||||||
mustBePJust # "Stake output not found"
|
mustBePJust # "Stake output should be present"
|
||||||
#$ pfind
|
#$ pfind
|
||||||
# plam
|
# plam
|
||||||
( \(pfromData . (pfield @"value" #) -> value) ->
|
( \(pfromData . (pfield @"value" #) -> value) ->
|
||||||
|
|
|
||||||
|
|
@ -327,8 +327,6 @@ stakeValidator stake =
|
||||||
$ \value address newStakeDatum' ->
|
$ \value address newStakeDatum' ->
|
||||||
let isScriptAddress = pdata address #== ownAddress
|
let isScriptAddress = pdata address #== ownAddress
|
||||||
correctOutputDatum = pdata newStakeDatum' #== expectedDatum
|
correctOutputDatum = pdata newStakeDatum' #== expectedDatum
|
||||||
-- TODO: Is this correct? I think We only need to ensure
|
|
||||||
-- correct amount of GT/SST in the continuing output.
|
|
||||||
valueCorrect = pdata continuingValue #== pdata value
|
valueCorrect = pdata continuingValue #== pdata value
|
||||||
in pif
|
in pif
|
||||||
isScriptAddress
|
isScriptAddress
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue