I'll use this answer to log my journey as I try things out.
Tentative Solution/Answer
Looks like P.show
can't be used in a validator based on https://discord.com/channels/826816523368005654/826829805387120690/892870961353879592
I'll wait for more confirmation before accepting this. I hope that's not the case.
Attempt 1
I've also tried using trace
with
mkValidator dat _ ctx = do
trace $ printf "deadline %s" (P.show $ deadline dat)
False
but that also results in an error:
• Couldn't match expected type ‘Bool’ with actual type ‘a0 -> b0’
• In a stmt of a 'do' block:
trace $ printf "deadline %s" (P.show $ deadline dat)
In the expression:
do trace $ printf "deadline %s" (P.show $ deadline dat)
False
In an equation for ‘mkValidator’:
mkValidator dat _ ctx
= do trace $ printf "deadline %s" (P.show $ deadline dat)
False
Attempt 2
Looks like using do
in a validator is a fools errand. Now I'm trying to add debug info to the trace message.
mkValidator :: VestingDatum -> () -> ScriptContext -> Bool
mkValidator dat _ ctx = traceIfFalse (P.show $ deadline dat) False
but it turns out that P.show
doesn't return the correct type (it returns [P.Char]
when a BuiltinString
is required). Trying to coerce [P.Char]
to a BuiltinString
using stringToBuiltinString
from https://playground.plutus.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Builtins-Class.html#v:stringToBuiltinString results in a very large error that looks like linker problems:
GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable GHC.CString.unpackAppendCString# No unfolding Context: Compiling expr: GHC.CString.unpackAppendCString# Context: Compiling expr: GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime4 Context: Compiling expr: GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime4 (GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime3 (case GHC.Show.$w$cshowsPrec4 0# (x `cast` (Plutus.V1.Ledger.Time.N:POSIXTime[0] :: GHC.Types.Coercible Plutus.V1.Ledger.Time.POSIXTime GHC.Integer.Type.Integer)) Plutus.V1.Ledger.Time.$fShowPOSIXTime5 of { (# ww3 [Occ=Once], ww4 [Occ=Once] #) -> GHC.Types.: @ GHC.Types.Char ww3 ww4 })) Context: Compiling expr: \ (x [Occ=Once] :: Plutus.V1.Ledger.Time.POSIXTime) -> GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime4 (GHC.CString.unpackAppendCString# Plutus.V1.Ledger.Time.$fShowPOSIXTime3 (case GHC.Show.$w$cshowsPrec4 0# (x `cast` (Plutus.V1.Ledger.Time.N:POSIXTime[0] :: GHC.Types.Coercible Plutus.V1.Ledger.Time.POSIXTime GHC.Integer.Type.Integer)) Plutus.V1.Ledger.Time.$fShowPOSIXTime5 of { (# ww3 [Occ=Once], ww4 [Occ=Once] #) -> GHC.Types.: @ GHC.Types.Char ww3 ww4 })) Context: Compiling definition of: Plutus.V1.Ledger.Time.$fShowPOSIXTime_$cshow Context: Compiling expr: Plutus.V1.Ledger.Time.$fShowPOSIXTime_$cshow Context: Compiling expr: Plutus.V1.Ledger.Time.$fShowPOSIXTime_$cshow (case dat of { Main.VestingDatum _ [Occ=Dead] _ [Occ=Dead] ds_dLa0 [Occ=Once] -> ds_dLa0 }) Context: Compiling expr: