I am trying to make a minting policy that fails after a certain deadline.
I have tried something like this
{-# INLINABLE mkTokenPolicy #-}
mkTokenPolicy :: TxOutRef -> TokenName -> Integer -> () -> ScriptContext -> Bool
mkTokenPolicy oref tn amt () ctx = traceIfFalse "Deadline reached" checkDeadline && --getinng error that oef isnt even used
traceIfFalse "wrong amount minted" checkMintedAmount
where
info :: TxInfo
info = scriptContextTxInfo ctx
checkDeadline:: Bool
checkDeadline = ivTo (from mDeadline) > ivTo (txInfoValidRange info)
where
mDeadline :: POSIXTime
mDeadline = 1680120281000
checkMintedAmount :: Bool
checkMintedAmount = case flattenValue (txInfoMint info) of
[(_, tn', amt')] -> tn' == tn && amt' == amt
_ -> False
and have also tried something like this
{-# INLINABLE mkTokenPolicy #-}
mkTokenPolicy :: TxOutRef -> TokenName -> Integer -> () -> ScriptContext -> Bool
mkTokenPolicy oref tn amt () ctx = traceIfFalse "Deadline reached" checkDeadline && --getinng error that oef isnt even used
traceIfFalse "wrong amount minted" checkMintedAmount
where
info :: TxInfo
info = scriptContextTxInfo ctx
checkDeadline:: Bool
checkDeadline = to mDeadline `contains` txInfoValidRange info
where
mDeadline :: POSIXTime
mDeadline = 1680120281000
checkMintedAmount :: Bool
checkMintedAmount = case flattenValue (txInfoMint info) of
[(_, tn', amt')] -> tn' == tn && amt' == amt
_ -> False
However, no matter what I seem to do, checkDeadline always returns False. Does anyone have any thoughts on how I can fix this?