mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-11-14 02:42:35 +01:00
small changes
This commit is contained in:
parent
a7bcb819b1
commit
652764d17b
2 changed files with 11 additions and 5 deletions
|
@ -101,17 +101,20 @@ mkGameValidator game bsZero' bsOne' dat red ctx =
|
|||
traceIfFalse "not signed by first player" (txSignedBy info (gFirst game)) &&
|
||||
traceIfFalse "commit mismatch" (checkNonce bs nonce c) &&
|
||||
traceIfFalse "missed deadline" (to (gRevealDeadline game) `contains` txInfoValidRange info) &&
|
||||
traceIfFalse "wrong stake" (lovelaces (txOutValue ownInput) == (2 * gStake game))
|
||||
traceIfFalse "wrong stake" (lovelaces (txOutValue ownInput) == (2 * gStake game)) &&
|
||||
traceIfFalse "NFT must go to first player" nftToFirst
|
||||
|
||||
(GameDatum _ Nothing, ClaimFirst) ->
|
||||
traceIfFalse "not signed by first player" (txSignedBy info (gFirst game)) &&
|
||||
traceIfFalse "too early" (from (1 + gPlayDeadline game) `contains` txInfoValidRange info) &&
|
||||
traceIfFalse "first player's stake missing" (lovelaces (txOutValue ownInput) == gStake game)
|
||||
traceIfFalse "first player's stake missing" (lovelaces (txOutValue ownInput) == gStake game) &&
|
||||
traceIfFalse "NFT must go to first player" nftToFirst
|
||||
|
||||
(GameDatum _ (Just _), ClaimSecond) ->
|
||||
traceIfFalse "not signed by second player" (txSignedBy info (gSecond game)) &&
|
||||
traceIfFalse "to early" (from (1 + gRevealDeadline game) `contains` txInfoValidRange info) &&
|
||||
traceIfFalse "wrong stake" (lovelaces (txOutValue ownInput) == (2 * gStake game))
|
||||
traceIfFalse "too early" (from (1 + gRevealDeadline game) `contains` txInfoValidRange info) &&
|
||||
traceIfFalse "wrong stake" (lovelaces (txOutValue ownInput) == (2 * gStake game)) &&
|
||||
traceIfFalse "NFT must go to first player" nftToFirst
|
||||
|
||||
_ -> False
|
||||
where
|
||||
|
@ -141,6 +144,9 @@ mkGameValidator game bsZero' bsOne' dat red ctx =
|
|||
Zero -> bsZero'
|
||||
One -> bsOne'
|
||||
|
||||
nftToFirst :: Bool
|
||||
nftToFirst = assetClassValueOf (valuePaidTo info $ gFirst game) (gToken game) == 1
|
||||
|
||||
data Gaming
|
||||
instance Scripts.ScriptType Gaming where
|
||||
type instance DatumType Gaming = GameDatum
|
||||
|
|
|
@ -199,7 +199,7 @@ firstGame fp = do
|
|||
v = lovelaceValueOf (fpStake fp)
|
||||
c = fpChoice fp
|
||||
bs = sha2_256 $ fpNonce fp `concatenate` if c == Zero then bsZero else bsOne
|
||||
void $ mapError @w @s @SMContractError (pack . show) $ runInitialise client (GameDatum bs Nothing) v
|
||||
void $ mapError' $ runInitialise client (GameDatum bs Nothing) v
|
||||
logInfo @String $ "made first move: " ++ show (fpChoice fp)
|
||||
|
||||
void $ awaitSlot $ 1 + fpPlayDeadline fp
|
||||
|
|
Loading…
Reference in a new issue