I have Homework1 of week 5, and it works in the repl (meaning, the test gives the expected result). However, when I try the script in the playground (and remove the test - I don't think that makes a big difference, though, and I removed the line module ...
), it's stuck on slot 1, at the bottom:
("txSignatures",Array []),("txValidRange",Object (fromList [("ivFrom",Array [Object (fromList [("tag",String "NegInf")]),Bool True]),("ivTo",Array [Object (fromList [("tag",String "PosInf")]),Bool True])]))])),("unBalancedTxUtxoIndex",Array []),("unBalancedTxValidityTimeRange",Object (fromList [("ivFrom",Array [Object (fromList [("tag",String "NegInf")]),Bool True]),("ivTo",Array [Object (fromList [("contents",Number 1.596059152999e12),("tag",String "Finite")]),Bool True])]))]))])),("mkTxLogTxConstraints",Object (fromList [("txConstraints",Array [Object (fromList [("contents",Array [String "aea02b83a8e055c06b768c2fcbf1101422b78405892b5027144ddb3b",String "d87980",Object (fromList [("unTokenName",String "ABC")]),Number 5.0]),("tag",String "MustMintValue")]),Object (fromList [("contents",Object (fromList [("ivFrom",Array [Object (fromList [("tag",String "NegInf")]),Bool True]),("ivTo",Array [Object (fromList [("contents",Number 1.596059152999e12),("tag",String "Finite")]),Bool True])])),("tag",String "MustValidateIn")])]),("txOwnInputs",Array []),("txOwnOutputs",Array [])]))])
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
Handled request: Iteration 3 request ID 1
Response: "{\"contents\":1596059092999,\"tag\":\"CurrentTime
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
Current requests (1): Iteration 4 request ID 1
Request: "{\"contents\":{\"unBalancedTxRequiredSignatories\
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
Handled request: Iteration 4 request ID 1
Response: "{\"contents\":{\"contents\":{\"contents\":{\"cont
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
Current requests (0):
, Slot 1: 00000000-0000-4000-8000-000000000000 {Wallet W872c}:
Contract instance stopped with error: "WalletError (ValidationError (ScriptFailure (EvaluationError [\"PT5\"] \"CekEvaluationFailure\")))" ]
I don't really understand why the script fails in the playground, while it works perfectly fine in the repl. How to try out the same script in the repl?
Thanks!
== EDIT 15/02/2022
The important lines (I think):
mkPolicy :: PaymentPubKeyHash -> POSIXTime -> () -> ScriptContext -> Bool
mkPolicy pkh deadline () ctx =
txSignedBy txInfo (unPaymentPubKeyHash pkh) &&
to deadline `contains` txInfoValidRange txInfo
where txInfo :: TxInfo
txInfo = scriptContextTxInfo ctx
policy :: PaymentPubKeyHash -> POSIXTime -> Scripts.MintingPolicy
policy pkh deadline = mkMintingPolicyScript $
$$(PlutusTx.compile [|| mintingPolicyScript ||])
`PlutusTx.applyCode`
PlutusTx.liftCode pkh
`PlutusTx.applyCode`
PlutusTx.liftCode deadline
where
mintingPolicyScript :: PaymentPubKeyHash -> POSIXTime -> Scripts.WrappedMintingPolicyType
mintingPolicyScript = \pkh' deadline' -> Scripts.wrapMintingPolicy $ mkPolicy pkh' deadline'
curSymbol :: PaymentPubKeyHash -> POSIXTime -> CurrencySymbol
curSymbol = \pkh' deadline' -> scriptCurrencySymbol (policy pkh' deadline')