{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Test.Cardano.Ledger.Generic.Scriptic where
import Cardano.Ledger.Allegra.Scripts (
pattern RequireTimeExpire,
pattern RequireTimeStart,
)
import Cardano.Ledger.Core
import Cardano.Ledger.Mary.Value (AssetName (..), MultiAsset (..), PolicyID (..))
import Cardano.Ledger.Plutus.Language (Language (..))
import Cardano.Ledger.Shelley.Scripts (
pattern RequireAllOf,
pattern RequireAnyOf,
pattern RequireMOf,
pattern RequireSignature,
)
import Cardano.Slotting.Slot (SlotNo (..))
import qualified Data.Map.Strict as Map
import qualified Data.Sequence.Strict as Seq (fromList)
import Numeric.Natural (Natural)
import Test.Cardano.Ledger.Alonzo.Arbitrary (alwaysFails, alwaysSucceeds)
import Test.Cardano.Ledger.Generic.Indexed (theKeyHash)
import Test.Cardano.Ledger.Generic.Proof
theSlot :: Int -> SlotNo
theSlot :: Int -> SlotNo
theSlot Int
n = Word64 -> SlotNo
SlotNo (Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n)
class (EraScript era, Show (Script era)) => Scriptic era where
always :: Natural -> Proof era -> Script era
alwaysAlt :: Natural -> Proof era -> Script era
never :: Natural -> Proof era -> Script era
require :: KeyHash 'Witness -> Proof era -> NativeScript era
allOf :: [Proof era -> NativeScript era] -> Proof era -> NativeScript era
anyOf :: [Proof era -> NativeScript era] -> Proof era -> NativeScript era
mOf :: Int -> [Proof era -> NativeScript era] -> Proof era -> NativeScript era
class Scriptic era => PostShelley era where
before :: Int -> Proof era -> NativeScript era
after :: Int -> Proof era -> NativeScript era
class HasTokens era where
forge :: Integer -> Script era -> MultiAsset
instance Scriptic ShelleyEra where
never :: Natural -> Proof ShelleyEra -> Script ShelleyEra
never Natural
_ Proof ShelleyEra
Shelley = StrictSeq (NativeScript ShelleyEra) -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf StrictSeq (NativeScript ShelleyEra)
StrictSeq (MultiSig ShelleyEra)
forall a. Monoid a => a
mempty
always :: Natural -> Proof ShelleyEra -> Script ShelleyEra
always Natural
_ Proof ShelleyEra
Shelley = StrictSeq (NativeScript ShelleyEra) -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf StrictSeq (NativeScript ShelleyEra)
StrictSeq (MultiSig ShelleyEra)
forall a. Monoid a => a
mempty
alwaysAlt :: Natural -> Proof ShelleyEra -> Script ShelleyEra
alwaysAlt Natural
_ Proof ShelleyEra
Shelley = StrictSeq (NativeScript ShelleyEra) -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf StrictSeq (NativeScript ShelleyEra)
StrictSeq (MultiSig ShelleyEra)
forall a. Monoid a => a
mempty
require :: KeyHash 'Witness -> Proof ShelleyEra -> NativeScript ShelleyEra
require KeyHash 'Witness
key Proof ShelleyEra
Shelley = KeyHash 'Witness -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
KeyHash 'Witness -> NativeScript era
RequireSignature KeyHash 'Witness
key
allOf :: [Proof ShelleyEra -> NativeScript ShelleyEra]
-> Proof ShelleyEra -> NativeScript ShelleyEra
allOf [Proof ShelleyEra -> NativeScript ShelleyEra]
xs Proof ShelleyEra
Shelley = StrictSeq (NativeScript ShelleyEra) -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf ([MultiSig ShelleyEra] -> StrictSeq (MultiSig ShelleyEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof ShelleyEra -> MultiSig ShelleyEra) -> MultiSig ShelleyEra)
-> [Proof ShelleyEra -> MultiSig ShelleyEra]
-> [MultiSig ShelleyEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof ShelleyEra -> MultiSig ShelleyEra)
-> Proof ShelleyEra -> MultiSig ShelleyEra
forall a b. (a -> b) -> a -> b
$ Proof ShelleyEra
Shelley) [Proof ShelleyEra -> NativeScript ShelleyEra]
[Proof ShelleyEra -> MultiSig ShelleyEra]
xs))
anyOf :: [Proof ShelleyEra -> NativeScript ShelleyEra]
-> Proof ShelleyEra -> NativeScript ShelleyEra
anyOf [Proof ShelleyEra -> NativeScript ShelleyEra]
xs Proof ShelleyEra
Shelley = StrictSeq (NativeScript ShelleyEra) -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf ([MultiSig ShelleyEra] -> StrictSeq (MultiSig ShelleyEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof ShelleyEra -> MultiSig ShelleyEra) -> MultiSig ShelleyEra)
-> [Proof ShelleyEra -> MultiSig ShelleyEra]
-> [MultiSig ShelleyEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof ShelleyEra -> MultiSig ShelleyEra)
-> Proof ShelleyEra -> MultiSig ShelleyEra
forall a b. (a -> b) -> a -> b
$ Proof ShelleyEra
Shelley) [Proof ShelleyEra -> NativeScript ShelleyEra]
[Proof ShelleyEra -> MultiSig ShelleyEra]
xs))
mOf :: Int
-> [Proof ShelleyEra -> NativeScript ShelleyEra]
-> Proof ShelleyEra
-> NativeScript ShelleyEra
mOf Int
n [Proof ShelleyEra -> NativeScript ShelleyEra]
xs Proof ShelleyEra
Shelley = Int
-> StrictSeq (NativeScript ShelleyEra) -> NativeScript ShelleyEra
forall era.
ShelleyEraScript era =>
Int -> StrictSeq (NativeScript era) -> NativeScript era
RequireMOf Int
n ([MultiSig ShelleyEra] -> StrictSeq (MultiSig ShelleyEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof ShelleyEra -> MultiSig ShelleyEra) -> MultiSig ShelleyEra)
-> [Proof ShelleyEra -> MultiSig ShelleyEra]
-> [MultiSig ShelleyEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof ShelleyEra -> MultiSig ShelleyEra)
-> Proof ShelleyEra -> MultiSig ShelleyEra
forall a b. (a -> b) -> a -> b
$ Proof ShelleyEra
Shelley) [Proof ShelleyEra -> NativeScript ShelleyEra]
[Proof ShelleyEra -> MultiSig ShelleyEra]
xs))
instance Scriptic AllegraEra where
never :: Natural -> Proof AllegraEra -> Script AllegraEra
never Natural
_ Proof AllegraEra
Allegra = StrictSeq (NativeScript AllegraEra) -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf StrictSeq (Timelock AllegraEra)
StrictSeq (NativeScript AllegraEra)
forall a. Monoid a => a
mempty
always :: Natural -> Proof AllegraEra -> Script AllegraEra
always Natural
_ Proof AllegraEra
Allegra = StrictSeq (NativeScript AllegraEra) -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf StrictSeq (Timelock AllegraEra)
StrictSeq (NativeScript AllegraEra)
forall a. Monoid a => a
mempty
alwaysAlt :: Natural -> Proof AllegraEra -> Script AllegraEra
alwaysAlt Natural
_ Proof AllegraEra
Allegra = StrictSeq (NativeScript AllegraEra) -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf StrictSeq (Timelock AllegraEra)
StrictSeq (NativeScript AllegraEra)
forall a. Monoid a => a
mempty
require :: KeyHash 'Witness -> Proof AllegraEra -> NativeScript AllegraEra
require KeyHash 'Witness
key Proof AllegraEra
Allegra = KeyHash 'Witness -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
KeyHash 'Witness -> NativeScript era
RequireSignature KeyHash 'Witness
key
allOf :: [Proof AllegraEra -> NativeScript AllegraEra]
-> Proof AllegraEra -> NativeScript AllegraEra
allOf [Proof AllegraEra -> NativeScript AllegraEra]
xs Proof AllegraEra
proof = StrictSeq (NativeScript AllegraEra) -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf ([Timelock AllegraEra] -> StrictSeq (Timelock AllegraEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof AllegraEra -> Timelock AllegraEra) -> Timelock AllegraEra)
-> [Proof AllegraEra -> Timelock AllegraEra]
-> [Timelock AllegraEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof AllegraEra -> Timelock AllegraEra)
-> Proof AllegraEra -> Timelock AllegraEra
forall a b. (a -> b) -> a -> b
$ Proof AllegraEra
proof) [Proof AllegraEra -> Timelock AllegraEra]
[Proof AllegraEra -> NativeScript AllegraEra]
xs))
anyOf :: [Proof AllegraEra -> NativeScript AllegraEra]
-> Proof AllegraEra -> NativeScript AllegraEra
anyOf [Proof AllegraEra -> NativeScript AllegraEra]
xs Proof AllegraEra
proof = StrictSeq (NativeScript AllegraEra) -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf ([Timelock AllegraEra] -> StrictSeq (Timelock AllegraEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof AllegraEra -> Timelock AllegraEra) -> Timelock AllegraEra)
-> [Proof AllegraEra -> Timelock AllegraEra]
-> [Timelock AllegraEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof AllegraEra -> Timelock AllegraEra)
-> Proof AllegraEra -> Timelock AllegraEra
forall a b. (a -> b) -> a -> b
$ Proof AllegraEra
proof) [Proof AllegraEra -> Timelock AllegraEra]
[Proof AllegraEra -> NativeScript AllegraEra]
xs))
mOf :: Int
-> [Proof AllegraEra -> NativeScript AllegraEra]
-> Proof AllegraEra
-> NativeScript AllegraEra
mOf Int
n [Proof AllegraEra -> NativeScript AllegraEra]
xs Proof AllegraEra
proof = Int
-> StrictSeq (NativeScript AllegraEra) -> NativeScript AllegraEra
forall era.
ShelleyEraScript era =>
Int -> StrictSeq (NativeScript era) -> NativeScript era
RequireMOf Int
n ([Timelock AllegraEra] -> StrictSeq (Timelock AllegraEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof AllegraEra -> Timelock AllegraEra) -> Timelock AllegraEra)
-> [Proof AllegraEra -> Timelock AllegraEra]
-> [Timelock AllegraEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof AllegraEra -> Timelock AllegraEra)
-> Proof AllegraEra -> Timelock AllegraEra
forall a b. (a -> b) -> a -> b
$ Proof AllegraEra
proof) [Proof AllegraEra -> Timelock AllegraEra]
[Proof AllegraEra -> NativeScript AllegraEra]
xs))
instance PostShelley AllegraEra where
before :: Int -> Proof AllegraEra -> NativeScript AllegraEra
before Int
n Proof AllegraEra
Allegra = SlotNo -> NativeScript AllegraEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeStart (Int -> SlotNo
theSlot Int
n)
after :: Int -> Proof AllegraEra -> NativeScript AllegraEra
after Int
n Proof AllegraEra
Allegra = SlotNo -> NativeScript AllegraEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeExpire (Int -> SlotNo
theSlot Int
n)
instance Scriptic MaryEra where
never :: Natural -> Proof MaryEra -> Script MaryEra
never Natural
_ Proof MaryEra
Mary = StrictSeq (NativeScript MaryEra) -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf StrictSeq (Timelock MaryEra)
StrictSeq (NativeScript MaryEra)
forall a. Monoid a => a
mempty
always :: Natural -> Proof MaryEra -> Script MaryEra
always Natural
_ Proof MaryEra
Mary = StrictSeq (NativeScript MaryEra) -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf StrictSeq (Timelock MaryEra)
StrictSeq (NativeScript MaryEra)
forall a. Monoid a => a
mempty
alwaysAlt :: Natural -> Proof MaryEra -> Script MaryEra
alwaysAlt Natural
_ Proof MaryEra
Mary = StrictSeq (NativeScript MaryEra) -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf StrictSeq (Timelock MaryEra)
StrictSeq (NativeScript MaryEra)
forall a. Monoid a => a
mempty
require :: KeyHash 'Witness -> Proof MaryEra -> NativeScript MaryEra
require KeyHash 'Witness
key Proof MaryEra
Mary = KeyHash 'Witness -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
KeyHash 'Witness -> NativeScript era
RequireSignature KeyHash 'Witness
key
allOf :: [Proof MaryEra -> NativeScript MaryEra]
-> Proof MaryEra -> NativeScript MaryEra
allOf [Proof MaryEra -> NativeScript MaryEra]
xs Proof MaryEra
proof = StrictSeq (NativeScript MaryEra) -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf ([Timelock MaryEra] -> StrictSeq (Timelock MaryEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof MaryEra -> Timelock MaryEra) -> Timelock MaryEra)
-> [Proof MaryEra -> Timelock MaryEra] -> [Timelock MaryEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof MaryEra -> Timelock MaryEra)
-> Proof MaryEra -> Timelock MaryEra
forall a b. (a -> b) -> a -> b
$ Proof MaryEra
proof) [Proof MaryEra -> Timelock MaryEra]
[Proof MaryEra -> NativeScript MaryEra]
xs))
anyOf :: [Proof MaryEra -> NativeScript MaryEra]
-> Proof MaryEra -> NativeScript MaryEra
anyOf [Proof MaryEra -> NativeScript MaryEra]
xs Proof MaryEra
proof = StrictSeq (NativeScript MaryEra) -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf ([Timelock MaryEra] -> StrictSeq (Timelock MaryEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof MaryEra -> Timelock MaryEra) -> Timelock MaryEra)
-> [Proof MaryEra -> Timelock MaryEra] -> [Timelock MaryEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof MaryEra -> Timelock MaryEra)
-> Proof MaryEra -> Timelock MaryEra
forall a b. (a -> b) -> a -> b
$ Proof MaryEra
proof) [Proof MaryEra -> Timelock MaryEra]
[Proof MaryEra -> NativeScript MaryEra]
xs))
mOf :: Int
-> [Proof MaryEra -> NativeScript MaryEra]
-> Proof MaryEra
-> NativeScript MaryEra
mOf Int
n [Proof MaryEra -> NativeScript MaryEra]
xs Proof MaryEra
proof = Int -> StrictSeq (NativeScript MaryEra) -> NativeScript MaryEra
forall era.
ShelleyEraScript era =>
Int -> StrictSeq (NativeScript era) -> NativeScript era
RequireMOf Int
n ([Timelock MaryEra] -> StrictSeq (Timelock MaryEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof MaryEra -> Timelock MaryEra) -> Timelock MaryEra)
-> [Proof MaryEra -> Timelock MaryEra] -> [Timelock MaryEra]
forall a b. (a -> b) -> [a] -> [b]
map ((Proof MaryEra -> Timelock MaryEra)
-> Proof MaryEra -> Timelock MaryEra
forall a b. (a -> b) -> a -> b
$ Proof MaryEra
proof) [Proof MaryEra -> Timelock MaryEra]
[Proof MaryEra -> NativeScript MaryEra]
xs))
instance PostShelley MaryEra where
before :: Int -> Proof MaryEra -> NativeScript MaryEra
before Int
n Proof MaryEra
Mary = SlotNo -> NativeScript MaryEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeStart (Int -> SlotNo
theSlot Int
n)
after :: Int -> Proof MaryEra -> NativeScript MaryEra
after Int
n Proof MaryEra
Mary = SlotNo -> NativeScript MaryEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeExpire (Int -> SlotNo
theSlot Int
n)
instance HasTokens MaryEra where
forge :: Integer -> Script MaryEra -> MultiAsset
forge Integer
n Script MaryEra
s = Map PolicyID (Map AssetName Integer) -> MultiAsset
MultiAsset (Map PolicyID (Map AssetName Integer) -> MultiAsset)
-> Map PolicyID (Map AssetName Integer) -> MultiAsset
forall a b. (a -> b) -> a -> b
$ PolicyID
-> Map AssetName Integer -> Map PolicyID (Map AssetName Integer)
forall k a. k -> a -> Map k a
Map.singleton PolicyID
pid (AssetName -> Integer -> Map AssetName Integer
forall k a. k -> a -> Map k a
Map.singleton AssetName
an Integer
n)
where
pid :: PolicyID
pid = ScriptHash -> PolicyID
PolicyID (forall era. EraScript era => Script era -> ScriptHash
hashScript @MaryEra Script MaryEra
s)
an :: AssetName
an = ShortByteString -> AssetName
AssetName ShortByteString
"an"
instance HasTokens AlonzoEra where
forge :: Integer -> Script AlonzoEra -> MultiAsset
forge Integer
n Script AlonzoEra
s = Map PolicyID (Map AssetName Integer) -> MultiAsset
MultiAsset (Map PolicyID (Map AssetName Integer) -> MultiAsset)
-> Map PolicyID (Map AssetName Integer) -> MultiAsset
forall a b. (a -> b) -> a -> b
$ PolicyID
-> Map AssetName Integer -> Map PolicyID (Map AssetName Integer)
forall k a. k -> a -> Map k a
Map.singleton PolicyID
pid (AssetName -> Integer -> Map AssetName Integer
forall k a. k -> a -> Map k a
Map.singleton AssetName
an Integer
n)
where
pid :: PolicyID
pid = ScriptHash -> PolicyID
PolicyID (forall era. EraScript era => Script era -> ScriptHash
hashScript @AlonzoEra Script AlonzoEra
s)
an :: AssetName
an = ShortByteString -> AssetName
AssetName ShortByteString
"an"
instance HasTokens BabbageEra where
forge :: Integer -> Script BabbageEra -> MultiAsset
forge Integer
n Script BabbageEra
s = Map PolicyID (Map AssetName Integer) -> MultiAsset
MultiAsset (Map PolicyID (Map AssetName Integer) -> MultiAsset)
-> Map PolicyID (Map AssetName Integer) -> MultiAsset
forall a b. (a -> b) -> a -> b
$ PolicyID
-> Map AssetName Integer -> Map PolicyID (Map AssetName Integer)
forall k a. k -> a -> Map k a
Map.singleton PolicyID
pid (AssetName -> Integer -> Map AssetName Integer
forall k a. k -> a -> Map k a
Map.singleton AssetName
an Integer
n)
where
pid :: PolicyID
pid = ScriptHash -> PolicyID
PolicyID (forall era. EraScript era => Script era -> ScriptHash
hashScript @BabbageEra Script BabbageEra
s)
an :: AssetName
an = ShortByteString -> AssetName
AssetName ShortByteString
"an"
instance HasTokens ConwayEra where
forge :: Integer -> Script ConwayEra -> MultiAsset
forge Integer
n Script ConwayEra
s = Map PolicyID (Map AssetName Integer) -> MultiAsset
MultiAsset (Map PolicyID (Map AssetName Integer) -> MultiAsset)
-> Map PolicyID (Map AssetName Integer) -> MultiAsset
forall a b. (a -> b) -> a -> b
$ PolicyID
-> Map AssetName Integer -> Map PolicyID (Map AssetName Integer)
forall k a. k -> a -> Map k a
Map.singleton PolicyID
pid (AssetName -> Integer -> Map AssetName Integer
forall k a. k -> a -> Map k a
Map.singleton AssetName
an Integer
n)
where
pid :: PolicyID
pid = ScriptHash -> PolicyID
PolicyID (forall era. EraScript era => Script era -> ScriptHash
hashScript @ConwayEra Script ConwayEra
s)
an :: AssetName
an = ShortByteString -> AssetName
AssetName ShortByteString
"an"
instance Scriptic AlonzoEra where
never :: Natural -> Proof AlonzoEra -> Script AlonzoEra
never Natural
n Proof AlonzoEra
Alonzo = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysFails @'PlutusV1 Natural
n
always :: Natural -> Proof AlonzoEra -> Script AlonzoEra
always Natural
n Proof AlonzoEra
Alonzo = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysSucceeds @'PlutusV1 Natural
n
alwaysAlt :: Natural -> Proof AlonzoEra -> Script AlonzoEra
alwaysAlt Natural
n Proof AlonzoEra
Alonzo = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysSucceeds @'PlutusV1 Natural
n
require :: KeyHash 'Witness -> Proof AlonzoEra -> NativeScript AlonzoEra
require KeyHash 'Witness
key Proof AlonzoEra
Alonzo = KeyHash 'Witness -> NativeScript AlonzoEra
forall era.
ShelleyEraScript era =>
KeyHash 'Witness -> NativeScript era
RequireSignature KeyHash 'Witness
key
allOf :: [Proof AlonzoEra -> NativeScript AlonzoEra]
-> Proof AlonzoEra -> NativeScript AlonzoEra
allOf [Proof AlonzoEra -> NativeScript AlonzoEra]
xs Proof AlonzoEra
proof = StrictSeq (NativeScript AlonzoEra) -> NativeScript AlonzoEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf ([Timelock AlonzoEra] -> StrictSeq (Timelock AlonzoEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof AlonzoEra -> Timelock AlonzoEra)
-> Proof AlonzoEra -> Timelock AlonzoEra
forall a b. (a -> b) -> a -> b
$ Proof AlonzoEra
proof) ((Proof AlonzoEra -> Timelock AlonzoEra) -> Timelock AlonzoEra)
-> [Proof AlonzoEra -> Timelock AlonzoEra] -> [Timelock AlonzoEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof AlonzoEra -> Timelock AlonzoEra]
[Proof AlonzoEra -> NativeScript AlonzoEra]
xs))
anyOf :: [Proof AlonzoEra -> NativeScript AlonzoEra]
-> Proof AlonzoEra -> NativeScript AlonzoEra
anyOf [Proof AlonzoEra -> NativeScript AlonzoEra]
xs Proof AlonzoEra
proof = StrictSeq (NativeScript AlonzoEra) -> NativeScript AlonzoEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf ([Timelock AlonzoEra] -> StrictSeq (Timelock AlonzoEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof AlonzoEra -> Timelock AlonzoEra)
-> Proof AlonzoEra -> Timelock AlonzoEra
forall a b. (a -> b) -> a -> b
$ Proof AlonzoEra
proof) ((Proof AlonzoEra -> Timelock AlonzoEra) -> Timelock AlonzoEra)
-> [Proof AlonzoEra -> Timelock AlonzoEra] -> [Timelock AlonzoEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof AlonzoEra -> Timelock AlonzoEra]
[Proof AlonzoEra -> NativeScript AlonzoEra]
xs))
mOf :: Int
-> [Proof AlonzoEra -> NativeScript AlonzoEra]
-> Proof AlonzoEra
-> NativeScript AlonzoEra
mOf Int
n [Proof AlonzoEra -> NativeScript AlonzoEra]
xs Proof AlonzoEra
proof = Int -> StrictSeq (NativeScript AlonzoEra) -> NativeScript AlonzoEra
forall era.
ShelleyEraScript era =>
Int -> StrictSeq (NativeScript era) -> NativeScript era
RequireMOf Int
n ([Timelock AlonzoEra] -> StrictSeq (Timelock AlonzoEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof AlonzoEra -> Timelock AlonzoEra)
-> Proof AlonzoEra -> Timelock AlonzoEra
forall a b. (a -> b) -> a -> b
$ Proof AlonzoEra
proof) ((Proof AlonzoEra -> Timelock AlonzoEra) -> Timelock AlonzoEra)
-> [Proof AlonzoEra -> Timelock AlonzoEra] -> [Timelock AlonzoEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof AlonzoEra -> Timelock AlonzoEra]
[Proof AlonzoEra -> NativeScript AlonzoEra]
xs))
instance PostShelley AlonzoEra where
before :: Int -> Proof AlonzoEra -> NativeScript AlonzoEra
before Int
n Proof AlonzoEra
Alonzo = SlotNo -> NativeScript AlonzoEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeStart (Int -> SlotNo
theSlot Int
n)
after :: Int -> Proof AlonzoEra -> NativeScript AlonzoEra
after Int
n Proof AlonzoEra
Alonzo = SlotNo -> NativeScript AlonzoEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeExpire (Int -> SlotNo
theSlot Int
n)
instance Scriptic BabbageEra where
never :: Natural -> Proof BabbageEra -> Script BabbageEra
never Natural
n Proof BabbageEra
Babbage = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysFails @'PlutusV1 Natural
n
always :: Natural -> Proof BabbageEra -> Script BabbageEra
always Natural
n Proof BabbageEra
Babbage = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysSucceeds @'PlutusV1 Natural
n
alwaysAlt :: Natural -> Proof BabbageEra -> Script BabbageEra
alwaysAlt Natural
n Proof BabbageEra
Babbage = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysSucceeds @'PlutusV2 Natural
n
require :: KeyHash 'Witness -> Proof BabbageEra -> NativeScript BabbageEra
require KeyHash 'Witness
key Proof BabbageEra
Babbage = KeyHash 'Witness -> NativeScript BabbageEra
forall era.
ShelleyEraScript era =>
KeyHash 'Witness -> NativeScript era
RequireSignature KeyHash 'Witness
key
allOf :: [Proof BabbageEra -> NativeScript BabbageEra]
-> Proof BabbageEra -> NativeScript BabbageEra
allOf [Proof BabbageEra -> NativeScript BabbageEra]
xs Proof BabbageEra
proof = StrictSeq (NativeScript BabbageEra) -> NativeScript BabbageEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf ([Timelock BabbageEra] -> StrictSeq (Timelock BabbageEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof BabbageEra -> Timelock BabbageEra)
-> Proof BabbageEra -> Timelock BabbageEra
forall a b. (a -> b) -> a -> b
$ Proof BabbageEra
proof) ((Proof BabbageEra -> Timelock BabbageEra) -> Timelock BabbageEra)
-> [Proof BabbageEra -> Timelock BabbageEra]
-> [Timelock BabbageEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof BabbageEra -> Timelock BabbageEra]
[Proof BabbageEra -> NativeScript BabbageEra]
xs))
anyOf :: [Proof BabbageEra -> NativeScript BabbageEra]
-> Proof BabbageEra -> NativeScript BabbageEra
anyOf [Proof BabbageEra -> NativeScript BabbageEra]
xs Proof BabbageEra
proof = StrictSeq (NativeScript BabbageEra) -> NativeScript BabbageEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf ([Timelock BabbageEra] -> StrictSeq (Timelock BabbageEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof BabbageEra -> Timelock BabbageEra)
-> Proof BabbageEra -> Timelock BabbageEra
forall a b. (a -> b) -> a -> b
$ Proof BabbageEra
proof) ((Proof BabbageEra -> Timelock BabbageEra) -> Timelock BabbageEra)
-> [Proof BabbageEra -> Timelock BabbageEra]
-> [Timelock BabbageEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof BabbageEra -> Timelock BabbageEra]
[Proof BabbageEra -> NativeScript BabbageEra]
xs))
mOf :: Int
-> [Proof BabbageEra -> NativeScript BabbageEra]
-> Proof BabbageEra
-> NativeScript BabbageEra
mOf Int
n [Proof BabbageEra -> NativeScript BabbageEra]
xs Proof BabbageEra
proof = Int
-> StrictSeq (NativeScript BabbageEra) -> NativeScript BabbageEra
forall era.
ShelleyEraScript era =>
Int -> StrictSeq (NativeScript era) -> NativeScript era
RequireMOf Int
n ([Timelock BabbageEra] -> StrictSeq (Timelock BabbageEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof BabbageEra -> Timelock BabbageEra)
-> Proof BabbageEra -> Timelock BabbageEra
forall a b. (a -> b) -> a -> b
$ Proof BabbageEra
proof) ((Proof BabbageEra -> Timelock BabbageEra) -> Timelock BabbageEra)
-> [Proof BabbageEra -> Timelock BabbageEra]
-> [Timelock BabbageEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof BabbageEra -> Timelock BabbageEra]
[Proof BabbageEra -> NativeScript BabbageEra]
xs))
instance PostShelley BabbageEra where
before :: Int -> Proof BabbageEra -> NativeScript BabbageEra
before Int
n Proof BabbageEra
Babbage = SlotNo -> NativeScript BabbageEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeStart (Int -> SlotNo
theSlot Int
n)
after :: Int -> Proof BabbageEra -> NativeScript BabbageEra
after Int
n Proof BabbageEra
Babbage = SlotNo -> NativeScript BabbageEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeExpire (Int -> SlotNo
theSlot Int
n)
instance Scriptic ConwayEra where
never :: Natural -> Proof ConwayEra -> Script ConwayEra
never Natural
n Proof ConwayEra
Conway = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysFails @'PlutusV1 Natural
n
always :: Natural -> Proof ConwayEra -> Script ConwayEra
always Natural
n Proof ConwayEra
Conway = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysSucceeds @'PlutusV1 Natural
n
alwaysAlt :: Natural -> Proof ConwayEra -> Script ConwayEra
alwaysAlt Natural
n Proof ConwayEra
Conway = forall (l :: Language) era.
(HasCallStack, EraPlutusTxInfo l era) =>
Natural -> Script era
alwaysSucceeds @'PlutusV2 Natural
n
require :: KeyHash 'Witness -> Proof ConwayEra -> NativeScript ConwayEra
require KeyHash 'Witness
key Proof ConwayEra
Conway = KeyHash 'Witness -> NativeScript ConwayEra
forall era.
ShelleyEraScript era =>
KeyHash 'Witness -> NativeScript era
RequireSignature KeyHash 'Witness
key
allOf :: [Proof ConwayEra -> NativeScript ConwayEra]
-> Proof ConwayEra -> NativeScript ConwayEra
allOf [Proof ConwayEra -> NativeScript ConwayEra]
xs Proof ConwayEra
proof = StrictSeq (NativeScript ConwayEra) -> NativeScript ConwayEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAllOf ([Timelock ConwayEra] -> StrictSeq (Timelock ConwayEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof ConwayEra -> Timelock ConwayEra)
-> Proof ConwayEra -> Timelock ConwayEra
forall a b. (a -> b) -> a -> b
$ Proof ConwayEra
proof) ((Proof ConwayEra -> Timelock ConwayEra) -> Timelock ConwayEra)
-> [Proof ConwayEra -> Timelock ConwayEra] -> [Timelock ConwayEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof ConwayEra -> Timelock ConwayEra]
[Proof ConwayEra -> NativeScript ConwayEra]
xs))
anyOf :: [Proof ConwayEra -> NativeScript ConwayEra]
-> Proof ConwayEra -> NativeScript ConwayEra
anyOf [Proof ConwayEra -> NativeScript ConwayEra]
xs Proof ConwayEra
proof = StrictSeq (NativeScript ConwayEra) -> NativeScript ConwayEra
forall era.
ShelleyEraScript era =>
StrictSeq (NativeScript era) -> NativeScript era
RequireAnyOf ([Timelock ConwayEra] -> StrictSeq (Timelock ConwayEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof ConwayEra -> Timelock ConwayEra)
-> Proof ConwayEra -> Timelock ConwayEra
forall a b. (a -> b) -> a -> b
$ Proof ConwayEra
proof) ((Proof ConwayEra -> Timelock ConwayEra) -> Timelock ConwayEra)
-> [Proof ConwayEra -> Timelock ConwayEra] -> [Timelock ConwayEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof ConwayEra -> Timelock ConwayEra]
[Proof ConwayEra -> NativeScript ConwayEra]
xs))
mOf :: Int
-> [Proof ConwayEra -> NativeScript ConwayEra]
-> Proof ConwayEra
-> NativeScript ConwayEra
mOf Int
n [Proof ConwayEra -> NativeScript ConwayEra]
xs Proof ConwayEra
proof = Int -> StrictSeq (NativeScript ConwayEra) -> NativeScript ConwayEra
forall era.
ShelleyEraScript era =>
Int -> StrictSeq (NativeScript era) -> NativeScript era
RequireMOf Int
n ([Timelock ConwayEra] -> StrictSeq (Timelock ConwayEra)
forall a. [a] -> StrictSeq a
Seq.fromList (((Proof ConwayEra -> Timelock ConwayEra)
-> Proof ConwayEra -> Timelock ConwayEra
forall a b. (a -> b) -> a -> b
$ Proof ConwayEra
proof) ((Proof ConwayEra -> Timelock ConwayEra) -> Timelock ConwayEra)
-> [Proof ConwayEra -> Timelock ConwayEra] -> [Timelock ConwayEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Proof ConwayEra -> Timelock ConwayEra]
[Proof ConwayEra -> NativeScript ConwayEra]
xs))
instance PostShelley ConwayEra where
before :: Int -> Proof ConwayEra -> NativeScript ConwayEra
before Int
n Proof ConwayEra
Conway = SlotNo -> NativeScript ConwayEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeStart (Int -> SlotNo
theSlot Int
n)
after :: Int -> Proof ConwayEra -> NativeScript ConwayEra
after Int
n Proof ConwayEra
Conway = SlotNo -> NativeScript ConwayEra
forall era. AllegraEraScript era => SlotNo -> NativeScript era
RequireTimeExpire (Int -> SlotNo
theSlot Int
n)
matchkey :: Scriptic era => Int -> Proof era -> NativeScript era
matchkey :: forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
n Proof era
era = KeyHash 'Witness -> Proof era -> NativeScript era
forall era.
Scriptic era =>
KeyHash 'Witness -> Proof era -> NativeScript era
require (Int -> KeyHash 'Witness
forall (kr :: KeyRole). Int -> KeyHash kr
theKeyHash Int
n) Proof era
era
test21 :: Scriptic era => Proof era -> Script era
test21 :: forall era. Scriptic era => Proof era -> Script era
test21 Proof era
wit = NativeScript era -> Script era
forall era. EraScript era => NativeScript era -> Script era
fromNativeScript (NativeScript era -> Script era) -> NativeScript era -> Script era
forall a b. (a -> b) -> a -> b
$ [Proof era -> NativeScript era] -> Proof era -> NativeScript era
forall era.
Scriptic era =>
[Proof era -> NativeScript era] -> Proof era -> NativeScript era
allOf [Int -> Proof era -> NativeScript era
forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
1, [Proof era -> NativeScript era] -> Proof era -> NativeScript era
forall era.
Scriptic era =>
[Proof era -> NativeScript era] -> Proof era -> NativeScript era
anyOf [Int -> Proof era -> NativeScript era
forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
2, Int -> Proof era -> NativeScript era
forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
3]] Proof era
wit
test22 :: PostShelley era => Proof era -> Script era
test22 :: forall era. PostShelley era => Proof era -> Script era
test22 Proof era
wit = NativeScript era -> Script era
forall era. EraScript era => NativeScript era -> Script era
fromNativeScript (NativeScript era -> Script era) -> NativeScript era -> Script era
forall a b. (a -> b) -> a -> b
$ Int
-> [Proof era -> NativeScript era] -> Proof era -> NativeScript era
forall era.
Scriptic era =>
Int
-> [Proof era -> NativeScript era] -> Proof era -> NativeScript era
mOf Int
2 [Int -> Proof era -> NativeScript era
forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
1, Int -> Proof era -> NativeScript era
forall era. PostShelley era => Int -> Proof era -> NativeScript era
before Int
100, [Proof era -> NativeScript era] -> Proof era -> NativeScript era
forall era.
Scriptic era =>
[Proof era -> NativeScript era] -> Proof era -> NativeScript era
anyOf [Int -> Proof era -> NativeScript era
forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
2, Int -> Proof era -> NativeScript era
forall era. Scriptic era => Int -> Proof era -> NativeScript era
matchkey Int
3]] Proof era
wit