The homework for Week 2 involves implementing validators for two Plutus contracts. Details are here.
Spoiler alert! This probably gives away the answer to Week 2's first homework problem:
-- ...
module Week02.Homework1 where
-- ...
-- This should validate if and only if the two Booleans in the redeemer are equal!
mkValidator :: () -> (Bool, Bool) -> ScriptContext -> Bool
mkValidator _ r _ = traceIfFalse "Invalid redeemer" $ fst r == snd r
data Typed
instance Scripts.ValidatorTypes Typed where
type instance DatumType Typed = ()
type instance RedeemerType Typed = (Bool, Bool)
typedValidator :: Scripts.TypedValidator Typed
typedValidator = Scripts.mkTypedValidator @Typed
$$(PlutusTx.compile [|| mkValidator ||])
$$(PlutusTx.compile [|| wrap ||])
where
wrap = Scripts.wrapValidator @() @(Bool, Bool)
validator :: Validator
validator = Scripts.validatorScript typedValidator
--
-- HERE!
--
-- This appears superfluous
--
valHash :: Ledger.ValidatorHash
valHash = undefined -- FIX ME!
--valHash = Scripts.validatorHash typedValidator
scrAddress :: Ledger.Address
scrAddress = scriptAddress validator
-- ...
mkSchemaDefinitions ''GiftSchema
mkKnownCurrencies []
As marked superfluous above...
My Plutus Playground simulations execute correctly whether this line is defined or not:
valHash = undefined -- FIX ME!
This is also true of the same function definition in the second homework assignment for Week 2.