require PtryFrom PData (PAsData datum) in makeEffect
This commit is contained in:
parent
19f5481ef2
commit
9dc4a87ab3
4 changed files with 9 additions and 9 deletions
|
|
@ -23,7 +23,7 @@ import Plutus.V1.Ledger.Value (CurrencySymbol)
|
|||
-}
|
||||
makeEffect ::
|
||||
forall (datum :: PType).
|
||||
(PIsData datum, PTryFrom PData datum) =>
|
||||
(PIsData datum, PTryFrom PData (PAsData datum)) =>
|
||||
CurrencySymbol ->
|
||||
(forall (s :: S). Term s PCurrencySymbol -> Term s datum -> Term s PTxOutRef -> Term s (PAsData PTxInfo) -> Term s POpaque) ->
|
||||
ClosedTerm PValidator
|
||||
|
|
@ -35,7 +35,7 @@ makeEffect gatCs' f =
|
|||
-- convert input datum, PData, into desierable type
|
||||
-- the way this conversion is performed should be defined
|
||||
-- by PTryFrom for each datum in effect script.
|
||||
(datum', _) <- tctryFrom @datum datum
|
||||
(pfromData -> datum', _) <- tctryFrom datum
|
||||
|
||||
-- ensure purpose is Spending.
|
||||
PSpending txOutRef <- tcmatch $ pfromData ctx.purpose
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ instance PUnsafeLiftDecl PMutateGovernorDatum where type PLifted PMutateGovernor
|
|||
deriving via (DerivePConstantViaData MutateGovernorDatum PMutateGovernorDatum) instance (PConstantDecl MutateGovernorDatum)
|
||||
|
||||
-- TODO: Derive this.
|
||||
instance PTryFrom PData PMutateGovernorDatum where
|
||||
type PTryFromExcess PData PMutateGovernorDatum = Const ()
|
||||
instance PTryFrom PData (PAsData PMutateGovernorDatum) where
|
||||
type PTryFromExcess PData (PAsData PMutateGovernorDatum) = Const ()
|
||||
ptryFrom' d k =
|
||||
k (punsafeCoerce d, ())
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ import Plutus.V1.Ledger.Value (CurrencySymbol)
|
|||
newtype PNoOp (s :: S) = PNoOp (Term s PUnit)
|
||||
deriving (PlutusType, PIsData) via (DerivePNewtype PNoOp PUnit)
|
||||
|
||||
instance PTryFrom PData PNoOp where
|
||||
type PTryFromExcess PData PNoOp = Const ()
|
||||
instance PTryFrom PData (PAsData PNoOp) where
|
||||
type PTryFromExcess PData (PAsData PNoOp) = Const ()
|
||||
ptryFrom' _ cont =
|
||||
-- JUSTIFICATION:
|
||||
-- We don't care anything about data.
|
||||
-- It should always be reduced to Unit.
|
||||
cont (pcon $ PNoOp (pconstant ()), ())
|
||||
cont (pdata $ pcon $ PNoOp (pconstant ()), ())
|
||||
|
||||
-- | Dummy effect which can only burn its GAT.
|
||||
noOpValidator :: CurrencySymbol -> ClosedTerm PValidator
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ deriving via
|
|||
instance
|
||||
(PConstantDecl TreasuryWithdrawalDatum)
|
||||
|
||||
instance PTryFrom PData PTreasuryWithdrawalDatum where
|
||||
type PTryFromExcess PData PTreasuryWithdrawalDatum = Const ()
|
||||
instance PTryFrom PData (PAsData PTreasuryWithdrawalDatum) where
|
||||
type PTryFromExcess PData (PAsData PTreasuryWithdrawalDatum) = Const ()
|
||||
ptryFrom' opq cont =
|
||||
-- TODO: This should not use 'punsafeCoerce'.
|
||||
-- Blocked by 'PCredential', and 'PTuple'.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue