Merge branch 'master' into emiflake/stake

This commit is contained in:
Emily Martins 2022-02-18 21:26:51 +01:00
commit 2a6ed6d19e
7 changed files with 51 additions and 4 deletions

View file

@ -103,15 +103,15 @@ stakePolicy _stake =
ctx <- pletFields @'["txInfo", "purpose"] ctx'
PMinting ownSymbol <- pmatch $ pfromData ctx.purpose
-- TODO: add this to 'valueCorrect'
let stValue = psingletonValue # (pfield @"_0" # ownSymbol) # pconstant "ST" # 1
passert "A UTXO must exist with the correct output" $
anyOutput @(StakeDatum gt) # pfromData ctx.txInfo
# ( plam $ \value stakeDatum' -> P.do
stakeDatum <- pletFields @'["owner", "stakedAmount"] stakeDatum'
let expectedValue = paddValue # (discreteValue # stakeDatum.stakedAmount) # stValue
let ownerSignsTransaction = ptxSignedBy # ctx.txInfo # stakeDatum.owner
let valueCorrect = pdata value #== pdata (paddValue # (discreteValue # stakeDatum.stakedAmount) # stValue)
let valueCorrect = pdata value #== pdata expectedValue
ownerSignsTransaction #&& valueCorrect
)