small fixes for Treasury Withdrawal Effect

This commit is contained in:
Seungheon Oh 2022-04-15 08:43:47 -05:00
parent 81dccdb858
commit a3a76a2461
No known key found for this signature in database
GPG key ID: 9B0E12D357369B66

View file

@ -64,6 +64,7 @@ deriving via
instance
(PConstant TreasuryWithdrawalDatum)
-- These functions can be replaced with ones on Utils.hs once seungheonoh/util branch get merged.
findOwnInput :: Term s (PTxInfo :--> PTxOutRef :--> PTxInInfo)
findOwnInput = phoistAcyclic $
plam $ \txInfo spending' -> P.do
@ -95,7 +96,7 @@ treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $
pall # plam id #$ pmap
# plam (\out -> pelem # out # outputValues)
#$ receivers
outputNumberMatchesRecivers = plength # receivers #== plength # (pfromData txInfo.outputs)
outputNumberMatchesReceivers = plength # receivers #== plength # (pfromData txInfo.outputs)
outputIsNotPayingToEffect = P.do
input <- pletFields @'["address", "value"] $ findOwnAddress # pfromData txInfo' # txOutRef'
let correctMinimum = passetClassValueOf' (AssetClass ("", "")) # input.value #== 2000000
@ -108,9 +109,8 @@ treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $
# pfromData txInfo.outputs
correctMinimum #&& notPayingToEffect
passert "Transaction output does not match receivers" $
outputContentMatchesRecivers
#&& outputNumberMatchesRecivers
#&& outputIsNotPayingToEffect
passert "Transaction output does not match receivers" outputContentMatchesRecivers
passert "" outputNumberMatchesReceivers
passert "" outputIsNotPayingToEffect
popaque $ pconstant ()