I want to use a custom type for one of my policy parameters, which will be applied by a tool like Lucid.
Example of param:
data CoinParams = CoinParams {
policyOwner :: PubKeyHash,
tokenName :: TokenName
}
My policy will then look like this:
policy :: CoinParams -> () -> ScriptContext -> Bool
policy ... = ...
Before compilation I wrap the policy:
vvv
wrappedPolicy :: BuiltinData -> BuiltinData -> BuiltinData -> ()
wrappedPolicy params = wrapPolicy (policy $ unsafeFromBuiltinData params)
^^ ^^^ ^^
But this won't work because there is no UnsafeFromData CoinParams
instance(required to use unsafeFromBuiltInData
). I'm struggling to understand how to implement the instance because I'm not sure how to 'destructure' BuiltinData to map it to my custom type. Could anyone assist? Thanks