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