{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}

module Gen.Cardano.Api.Typed
  ( genAddressByron
  , genAddressInEra
  , genAddressShelley
  , genCertificate
  , genCostModel
  , genMaybePraosNonce
  , genPraosNonce
  , genProtocolParameters
  , genValueNestedRep
  , genValueNestedBundle
  , genByronKeyWitness
  , genShelleyKeyWitness

  , genTxId
  , genTxIn
  , genTxOutTxContext
  , genTxOutUTxOContext
  , genUTxO

    -- * Scripts
  , genReferenceScript
  , genScript
  , genSimpleScript
  , genPlutusScript
  , genScriptInAnyLang
  , genScriptInEra
  , genScriptHash
  , genScriptData
  , genScriptValidity

  , genAssetName
  , genAssetId
  , genEpochNo
  , genExecutionUnitPrices
  , genExecutionUnits
  , genHashScriptData
  , genKESPeriod
  , genNat
  , genNetworkId
  , genNetworkMagic
  , genOperationalCertificate
  , genOperationalCertificateIssueCounter
  , genOperationalCertificateWithCounter
  , genPaymentCredential
  , genPolicyId
  , genQuantity
  , genRationalInt64
  , genSeed
  , genShelleyBootstrapWitness
  , genShelleyHash
  , genShelleyWitness
  , genShelleyWitnessSigningKey
  , genSignedQuantity
  , genSigningKey
  , genSlotNo
  , genStakeAddress
  , genStakeAddressReference
  , genStakeCredential
  , genTtl
  , genTx
  , genTxAuxScripts
  , genTxBody
  , genTxBodyContent
  , genTxCertificates
  , genTxFee
  , genTxIndex
  , genTxInsCollateral
  , genTxInsReference
  , genTxMetadataInEra
  , genTxMintValue
  , genLovelace
  , genValue
  , genValueDefault
  , genVerificationKey
  , genVerificationKeyHash
  , genUpdateProposal
  , genProtocolParametersUpdate
  , genScriptDataSupportedInAlonzoEra
  , genTxOutDatumHashTxContext
  , genTxOutDatumHashUTxOContext
  , genTxOutValue
  , genTxReturnCollateral
  , genTxScriptValidity
  , genTxTotalCollateral
  , genTxUpdateProposal
  , genTxValidityLowerBound
  , genTxValidityRange
  , genTxValidityUpperBound
  , genTxWithdrawals
  , genUnsignedQuantity
  , genValueForMinting
  , genValueForTxOut
  , genWitnesses
  , genWitnessNetworkIdOrByronAddress

  , genRational
  ) where

import           Cardano.Api hiding (txIns)
import qualified Cardano.Api as Api
import           Cardano.Api.Byron (KeyWitness (ByronKeyWitness),
                   WitnessNetworkIdOrByronAddress (..))
import           Cardano.Api.Shelley (Hash (ScriptDataHash), KESPeriod (KESPeriod),
                   OperationalCertificateIssueCounter (OperationalCertificateIssueCounter),
                   PlutusScript (PlutusScriptSerialised), ProtocolParameters (ProtocolParameters),
                   ReferenceScript (..), ReferenceTxInsScriptsInlineDatumsSupportedInEra (..),
                   StakeCredential (StakeCredentialByKey), StakePoolKey,
                   refInsScriptsAndInlineDatsSupportedInEra)

import           Cardano.Prelude

import           Control.Monad.Fail (fail)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Short as SBS
import           Data.Coerce
import           Data.String
import qualified Data.Text as Text

import qualified Cardano.Binary as CBOR
import qualified Cardano.Crypto.Hash as Crypto
import qualified Cardano.Crypto.Seed as Crypto
import qualified Cardano.Ledger.Shelley.TxBody as Ledger (EraIndependentTxBody)
import qualified PlutusCore as Plutus

import           Hedgehog (Gen, Range)
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range

import qualified Cardano.Crypto.Hash.Class as CRYPTO
import           Cardano.Ledger.Alonzo.Language (Language (..))
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import           Cardano.Ledger.SafeHash (unsafeMakeSafeHash)

import           Gen.Cardano.Api.Metadata (genTxMetadata)
import           Test.Cardano.Chain.UTxO.Gen (genVKWitness)
import           Test.Cardano.Crypto.Gen (genProtocolMagicId)

{- HLINT ignore "Reduce duplication" -}

genAddressByron :: Gen (Address ByronAddr)
genAddressByron :: Gen (Address ByronAddr)
genAddressByron = NetworkId -> VerificationKey ByronKey -> Address ByronAddr
makeByronAddress (NetworkId -> VerificationKey ByronKey -> Address ByronAddr)
-> GenT Identity NetworkId
-> GenT Identity (VerificationKey ByronKey -> Address ByronAddr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity NetworkId
genNetworkId
                                   GenT Identity (VerificationKey ByronKey -> Address ByronAddr)
-> GenT Identity (VerificationKey ByronKey)
-> Gen (Address ByronAddr)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AsType ByronKey -> GenT Identity (VerificationKey ByronKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType ByronKey
AsByronKey

genAddressShelley :: Gen (Address ShelleyAddr)
genAddressShelley :: Gen (Address ShelleyAddr)
genAddressShelley = NetworkId
-> PaymentCredential
-> StakeAddressReference
-> Address ShelleyAddr
makeShelleyAddress (NetworkId
 -> PaymentCredential
 -> StakeAddressReference
 -> Address ShelleyAddr)
-> GenT Identity NetworkId
-> GenT
     Identity
     (PaymentCredential -> StakeAddressReference -> Address ShelleyAddr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity NetworkId
genNetworkId
                                       GenT
  Identity
  (PaymentCredential -> StakeAddressReference -> Address ShelleyAddr)
-> GenT Identity PaymentCredential
-> GenT Identity (StakeAddressReference -> Address ShelleyAddr)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity PaymentCredential
genPaymentCredential
                                       GenT Identity (StakeAddressReference -> Address ShelleyAddr)
-> GenT Identity StakeAddressReference -> Gen (Address ShelleyAddr)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity StakeAddressReference
genStakeAddressReference

genAddressInEra :: CardanoEra era -> Gen (AddressInEra era)
genAddressInEra :: CardanoEra era -> Gen (AddressInEra era)
genAddressInEra CardanoEra era
era =
  case CardanoEra era -> CardanoEraStyle era
forall era. CardanoEra era -> CardanoEraStyle era
cardanoEraStyle CardanoEra era
era of
    CardanoEraStyle era
LegacyByronEra ->
      Address ByronAddr -> AddressInEra era
forall era. Address ByronAddr -> AddressInEra era
byronAddressInEra (Address ByronAddr -> AddressInEra era)
-> Gen (Address ByronAddr) -> Gen (AddressInEra era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Address ByronAddr)
genAddressByron

    ShelleyBasedEra ShelleyBasedEra era
_ ->
      [Gen (AddressInEra era)] -> Gen (AddressInEra era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ Address ByronAddr -> AddressInEra era
forall era. Address ByronAddr -> AddressInEra era
byronAddressInEra   (Address ByronAddr -> AddressInEra era)
-> Gen (Address ByronAddr) -> Gen (AddressInEra era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Address ByronAddr)
genAddressByron
        , Address ShelleyAddr -> AddressInEra era
forall era.
IsShelleyBasedEra era =>
Address ShelleyAddr -> AddressInEra era
shelleyAddressInEra (Address ShelleyAddr -> AddressInEra era)
-> Gen (Address ShelleyAddr) -> Gen (AddressInEra era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Address ShelleyAddr)
genAddressShelley
        ]

genKESPeriod :: Gen KESPeriod
genKESPeriod :: Gen KESPeriod
genKESPeriod = Word -> KESPeriod
KESPeriod (Word -> KESPeriod) -> GenT Identity Word -> Gen KESPeriod
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Word -> GenT Identity Word
forall (m :: * -> *). MonadGen m => Range Word -> m Word
Gen.word Range Word
forall a. (Bounded a, Num a) => Range a
Range.constantBounded

genLovelace :: Gen Lovelace
genLovelace :: Gen Lovelace
genLovelace = Integer -> Lovelace
Lovelace (Integer -> Lovelace) -> GenT Identity Integer -> Gen Lovelace
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Integer -> GenT Identity Integer
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Integer -> Integer -> Range Integer
forall a. Integral a => a -> a -> Range a
Range.linear Integer
0 Integer
5000)


----------------------------------------------------------------------------
-- SimpleScript generators
--

genScript :: ScriptLanguage lang -> Gen (Script lang)
genScript :: ScriptLanguage lang -> Gen (Script lang)
genScript (SimpleScriptLanguage SimpleScriptVersion lang
lang) =
    SimpleScriptVersion lang -> SimpleScript lang -> Script lang
forall lang.
SimpleScriptVersion lang -> SimpleScript lang -> Script lang
SimpleScript SimpleScriptVersion lang
lang (SimpleScript lang -> Script lang)
-> GenT Identity (SimpleScript lang) -> Gen (Script lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SimpleScriptVersion lang -> GenT Identity (SimpleScript lang)
forall lang. SimpleScriptVersion lang -> Gen (SimpleScript lang)
genSimpleScript SimpleScriptVersion lang
lang
genScript (PlutusScriptLanguage PlutusScriptVersion lang
lang) =
    PlutusScriptVersion lang -> PlutusScript lang -> Script lang
forall lang.
PlutusScriptVersion lang -> PlutusScript lang -> Script lang
PlutusScript PlutusScriptVersion lang
lang (PlutusScript lang -> Script lang)
-> GenT Identity (PlutusScript lang) -> Gen (Script lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PlutusScriptVersion lang -> GenT Identity (PlutusScript lang)
forall lang. PlutusScriptVersion lang -> Gen (PlutusScript lang)
genPlutusScript PlutusScriptVersion lang
lang

genSimpleScript :: SimpleScriptVersion lang -> Gen (SimpleScript lang)
genSimpleScript :: SimpleScriptVersion lang -> Gen (SimpleScript lang)
genSimpleScript SimpleScriptVersion lang
lang =
    Gen (SimpleScript lang)
genTerm
  where
    genTerm :: Gen (SimpleScript lang)
genTerm = ([Gen (SimpleScript lang)] -> Gen (SimpleScript lang))
-> [Gen (SimpleScript lang)]
-> [Gen (SimpleScript lang)]
-> Gen (SimpleScript lang)
forall (m :: * -> *) a.
MonadGen m =>
([m a] -> m a) -> [m a] -> [m a] -> m a
Gen.recursive [Gen (SimpleScript lang)] -> Gen (SimpleScript lang)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice [Gen (SimpleScript lang)]
nonRecursive [Gen (SimpleScript lang)]
recursive

    -- Non-recursive generators
    nonRecursive :: [Gen (SimpleScript lang)]
nonRecursive =
         (Hash PaymentKey -> SimpleScript lang
forall lang. Hash PaymentKey -> SimpleScript lang
RequireSignature (Hash PaymentKey -> SimpleScript lang)
-> (VerificationKey PaymentKey -> Hash PaymentKey)
-> VerificationKey PaymentKey
-> SimpleScript lang
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. VerificationKey PaymentKey -> Hash PaymentKey
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash (VerificationKey PaymentKey -> SimpleScript lang)
-> GenT Identity (VerificationKey PaymentKey)
-> Gen (SimpleScript lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
             AsType PaymentKey -> GenT Identity (VerificationKey PaymentKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType PaymentKey
AsPaymentKey)

      Gen (SimpleScript lang)
-> [Gen (SimpleScript lang)] -> [Gen (SimpleScript lang)]
forall a. a -> [a] -> [a]
: [ TimeLocksSupported lang -> SlotNo -> SimpleScript lang
forall lang. TimeLocksSupported lang -> SlotNo -> SimpleScript lang
RequireTimeBefore TimeLocksSupported lang
supported (SlotNo -> SimpleScript lang)
-> GenT Identity SlotNo -> Gen (SimpleScript lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity SlotNo
genSlotNo
        | TimeLocksSupported lang
supported <- Maybe (TimeLocksSupported lang) -> [TimeLocksSupported lang]
forall a. Maybe a -> [a]
maybeToList (SimpleScriptVersion lang -> Maybe (TimeLocksSupported lang)
forall lang.
SimpleScriptVersion lang -> Maybe (TimeLocksSupported lang)
timeLocksSupported SimpleScriptVersion lang
lang) ]

     [Gen (SimpleScript lang)]
-> [Gen (SimpleScript lang)] -> [Gen (SimpleScript lang)]
forall a. [a] -> [a] -> [a]
++ [ TimeLocksSupported lang -> SlotNo -> SimpleScript lang
forall lang. TimeLocksSupported lang -> SlotNo -> SimpleScript lang
RequireTimeAfter TimeLocksSupported lang
supported (SlotNo -> SimpleScript lang)
-> GenT Identity SlotNo -> Gen (SimpleScript lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity SlotNo
genSlotNo
        | TimeLocksSupported lang
supported <- Maybe (TimeLocksSupported lang) -> [TimeLocksSupported lang]
forall a. Maybe a -> [a]
maybeToList (SimpleScriptVersion lang -> Maybe (TimeLocksSupported lang)
forall lang.
SimpleScriptVersion lang -> Maybe (TimeLocksSupported lang)
timeLocksSupported SimpleScriptVersion lang
lang) ]

    -- Recursive generators
    recursive :: [Gen (SimpleScript lang)]
recursive =
      [ [SimpleScript lang] -> SimpleScript lang
forall lang. [SimpleScript lang] -> SimpleScript lang
RequireAllOf ([SimpleScript lang] -> SimpleScript lang)
-> GenT Identity [SimpleScript lang] -> Gen (SimpleScript lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int
-> Gen (SimpleScript lang) -> GenT Identity [SimpleScript lang]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
10) Gen (SimpleScript lang)
genTerm

      , [SimpleScript lang] -> SimpleScript lang
forall lang. [SimpleScript lang] -> SimpleScript lang
RequireAnyOf ([SimpleScript lang] -> SimpleScript lang)
-> GenT Identity [SimpleScript lang] -> Gen (SimpleScript lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int
-> Gen (SimpleScript lang) -> GenT Identity [SimpleScript lang]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
10) Gen (SimpleScript lang)
genTerm

      , do [SimpleScript lang]
ts <- Range Int
-> Gen (SimpleScript lang) -> GenT Identity [SimpleScript lang]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
10) Gen (SimpleScript lang)
genTerm
           Int
m  <- Range Int -> GenT Identity Int
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 ([SimpleScript lang] -> Int
forall a. HasLength a => a -> Int
length [SimpleScript lang]
ts))
           SimpleScript lang -> Gen (SimpleScript lang)
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> [SimpleScript lang] -> SimpleScript lang
forall lang. Int -> [SimpleScript lang] -> SimpleScript lang
RequireMOf Int
m [SimpleScript lang]
ts)
      ]

genPlutusScript :: PlutusScriptVersion lang -> Gen (PlutusScript lang)
genPlutusScript :: PlutusScriptVersion lang -> Gen (PlutusScript lang)
genPlutusScript PlutusScriptVersion lang
_ =
    -- We make no attempt to create a valid script
    ShortByteString -> PlutusScript lang
forall lang. ShortByteString -> PlutusScript lang
PlutusScriptSerialised (ShortByteString -> PlutusScript lang)
-> (ByteString -> ShortByteString)
-> ByteString
-> PlutusScript lang
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ByteString -> ShortByteString
SBS.toShort (ByteString -> PlutusScript lang)
-> GenT Identity ByteString -> Gen (PlutusScript lang)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity ByteString
forall (m :: * -> *). MonadGen m => Range Int -> m ByteString
Gen.bytes (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
32)

genScriptData :: Gen ScriptData
genScriptData :: Gen ScriptData
genScriptData =
    ([Gen ScriptData] -> Gen ScriptData)
-> [Gen ScriptData] -> [Gen ScriptData] -> Gen ScriptData
forall (m :: * -> *) a.
MonadGen m =>
([m a] -> m a) -> [m a] -> [m a] -> m a
Gen.recursive
      [Gen ScriptData] -> Gen ScriptData
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ Integer -> ScriptData
ScriptDataNumber (Integer -> ScriptData) -> GenT Identity Integer -> Gen ScriptData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity Integer
genInteger
        , ByteString -> ScriptData
ScriptDataBytes  (ByteString -> ScriptData)
-> GenT Identity ByteString -> Gen ScriptData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity ByteString
genByteString
        ]
        -- The Gen.recursive combinator calls these with the size halved
        [ Integer -> [ScriptData] -> ScriptData
ScriptDataConstructor (Integer -> [ScriptData] -> ScriptData)
-> GenT Identity Integer
-> GenT Identity ([ScriptData] -> ScriptData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity Integer
genInteger
                                GenT Identity ([ScriptData] -> ScriptData)
-> GenT Identity [ScriptData] -> Gen ScriptData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity [ScriptData]
genScriptDataList
        , [ScriptData] -> ScriptData
ScriptDataList ([ScriptData] -> ScriptData)
-> GenT Identity [ScriptData] -> Gen ScriptData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity [ScriptData]
genScriptDataList
        , [(ScriptData, ScriptData)] -> ScriptData
ScriptDataMap  ([(ScriptData, ScriptData)] -> ScriptData)
-> GenT Identity [(ScriptData, ScriptData)] -> Gen ScriptData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity [(ScriptData, ScriptData)]
genScriptDataMap
        ]
  where
    genInteger :: Gen Integer
    genInteger :: GenT Identity Integer
genInteger = Range Integer -> GenT Identity Integer
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral
                  (Integer -> Integer -> Range Integer
forall a. Integral a => a -> a -> Range a
Range.linear
                    Integer
0 -- TODO: Alonzo should be -> (-fromIntegral (maxBound :: Word64) :: Integer)
                      -- Wrapping bug needs to be fixed in Plutus library
                    (Word64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64
forall a. Bounded a => a
maxBound :: Word64) :: Integer))

    genByteString :: Gen ByteString
    genByteString :: GenT Identity ByteString
genByteString = [Word8] -> ByteString
BS.pack ([Word8] -> ByteString)
-> GenT Identity [Word8] -> GenT Identity ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity Word8 -> GenT Identity [Word8]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
64)
                                         (Range Word8 -> GenT Identity Word8
forall (m :: * -> *). MonadGen m => Range Word8 -> m Word8
Gen.word8 Range Word8
forall a. (Bounded a, Num a) => Range a
Range.constantBounded)

    genScriptDataList :: Gen [ScriptData]
    genScriptDataList :: GenT Identity [ScriptData]
genScriptDataList =
      (Size -> GenT Identity [ScriptData]) -> GenT Identity [ScriptData]
forall (m :: * -> *) a. MonadGen m => (Size -> m a) -> m a
Gen.sized ((Size -> GenT Identity [ScriptData])
 -> GenT Identity [ScriptData])
-> (Size -> GenT Identity [ScriptData])
-> GenT Identity [ScriptData]
forall a b. (a -> b) -> a -> b
$ \Size
sz ->
        Range Int -> Gen ScriptData -> GenT Identity [ScriptData]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 (Size -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Size
sz)) Gen ScriptData
genScriptData

    genScriptDataMap  :: Gen [(ScriptData, ScriptData)]
    genScriptDataMap :: GenT Identity [(ScriptData, ScriptData)]
genScriptDataMap =
      (Size -> GenT Identity [(ScriptData, ScriptData)])
-> GenT Identity [(ScriptData, ScriptData)]
forall (m :: * -> *) a. MonadGen m => (Size -> m a) -> m a
Gen.sized ((Size -> GenT Identity [(ScriptData, ScriptData)])
 -> GenT Identity [(ScriptData, ScriptData)])
-> (Size -> GenT Identity [(ScriptData, ScriptData)])
-> GenT Identity [(ScriptData, ScriptData)]
forall a b. (a -> b) -> a -> b
$ \Size
sz ->
        Range Int
-> GenT Identity (ScriptData, ScriptData)
-> GenT Identity [(ScriptData, ScriptData)]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 (Size -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Size
sz)) (GenT Identity (ScriptData, ScriptData)
 -> GenT Identity [(ScriptData, ScriptData)])
-> GenT Identity (ScriptData, ScriptData)
-> GenT Identity [(ScriptData, ScriptData)]
forall a b. (a -> b) -> a -> b
$
          (,) (ScriptData -> ScriptData -> (ScriptData, ScriptData))
-> Gen ScriptData
-> GenT Identity (ScriptData -> (ScriptData, ScriptData))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptData
genScriptData GenT Identity (ScriptData -> (ScriptData, ScriptData))
-> Gen ScriptData -> GenT Identity (ScriptData, ScriptData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen ScriptData
genScriptData


-- ----------------------------------------------------------------------------
-- Script generators for any language, or any language valid in a specific era
--

genScriptInAnyLang :: Gen ScriptInAnyLang
genScriptInAnyLang :: Gen ScriptInAnyLang
genScriptInAnyLang =
    [Gen ScriptInAnyLang] -> Gen ScriptInAnyLang
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
      [ ScriptLanguage lang -> Script lang -> ScriptInAnyLang
forall lang. ScriptLanguage lang -> Script lang -> ScriptInAnyLang
ScriptInAnyLang ScriptLanguage lang
lang (Script lang -> ScriptInAnyLang)
-> GenT Identity (Script lang) -> Gen ScriptInAnyLang
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptLanguage lang -> GenT Identity (Script lang)
forall lang. ScriptLanguage lang -> Gen (Script lang)
genScript ScriptLanguage lang
lang
      | AnyScriptLanguage ScriptLanguage lang
lang <- [AnyScriptLanguage
forall a. Bounded a => a
minBound..AnyScriptLanguage
forall a. Bounded a => a
maxBound] ]

genScriptInEra :: CardanoEra era -> Gen (ScriptInEra era)
genScriptInEra :: CardanoEra era -> Gen (ScriptInEra era)
genScriptInEra CardanoEra era
era =
    [Gen (ScriptInEra era)] -> Gen (ScriptInEra era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
      [ ScriptLanguageInEra lang era -> Script lang -> ScriptInEra era
forall lang era.
ScriptLanguageInEra lang era -> Script lang -> ScriptInEra era
ScriptInEra ScriptLanguageInEra lang era
langInEra (Script lang -> ScriptInEra era)
-> GenT Identity (Script lang) -> Gen (ScriptInEra era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptLanguage lang -> GenT Identity (Script lang)
forall lang. ScriptLanguage lang -> Gen (Script lang)
genScript ScriptLanguage lang
lang
      | AnyScriptLanguage ScriptLanguage lang
lang <- [AnyScriptLanguage
forall a. Bounded a => a
minBound..AnyScriptLanguage
forall a. Bounded a => a
maxBound]
      , Just ScriptLanguageInEra lang era
langInEra <- [CardanoEra era
-> ScriptLanguage lang -> Maybe (ScriptLanguageInEra lang era)
forall era lang.
CardanoEra era
-> ScriptLanguage lang -> Maybe (ScriptLanguageInEra lang era)
scriptLanguageSupportedInEra CardanoEra era
era ScriptLanguage lang
lang] ]

genScriptHash :: Gen ScriptHash
genScriptHash :: Gen ScriptHash
genScriptHash = do
    ScriptInAnyLang ScriptLanguage lang
_ Script lang
script <- Gen ScriptInAnyLang
genScriptInAnyLang
    ScriptHash -> Gen ScriptHash
forall (m :: * -> *) a. Monad m => a -> m a
return (Script lang -> ScriptHash
forall lang. Script lang -> ScriptHash
hashScript Script lang
script)


----------------------------------------------------------------------------
-- Multi-asset generators
--

genAssetName :: Gen AssetName
genAssetName :: Gen AssetName
genAssetName =
  [(Int, Gen AssetName)] -> Gen AssetName
forall (m :: * -> *) a. MonadGen m => [(Int, m a)] -> m a
Gen.frequency
    -- mostly from a small number of choices, so we get plenty of repetition
    [ (Int
9, [AssetName] -> Gen AssetName
forall (m :: * -> *) a. MonadGen m => [a] -> m a
Gen.element [AssetName
"", AssetName
"a", AssetName
"b", AssetName
"c"])
    , (Int
1, ByteString -> AssetName
AssetName (ByteString -> AssetName)
-> GenT Identity ByteString -> Gen AssetName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity ByteString
forall (m :: * -> *). MonadGen m => Range Int -> m ByteString
Gen.bytes (Int -> Range Int
forall a. a -> Range a
Range.singleton  Int
32))
    , (Int
1, ByteString -> AssetName
AssetName (ByteString -> AssetName)
-> GenT Identity ByteString -> Gen AssetName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity ByteString
forall (m :: * -> *). MonadGen m => Range Int -> m ByteString
Gen.bytes (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
1 Int
31))
    ]

genPolicyId :: Gen PolicyId
genPolicyId :: Gen PolicyId
genPolicyId =
  [(Int, Gen PolicyId)] -> Gen PolicyId
forall (m :: * -> *) a. MonadGen m => [(Int, m a)] -> m a
Gen.frequency
      -- mostly from a small number of choices, so we get plenty of repetition
    [ (Int
9, [PolicyId] -> Gen PolicyId
forall (m :: * -> *) a. MonadGen m => [a] -> m a
Gen.element [ String -> PolicyId
forall a. IsString a => String -> a
fromString (Char
x Char -> String -> String
forall a. a -> [a] -> [a]
: Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
55 Char
'0') | Char
x <- [Char
'a'..Char
'c'] ])

       -- and some from the full range of the type
    , (Int
1, ScriptHash -> PolicyId
PolicyId (ScriptHash -> PolicyId) -> Gen ScriptHash -> Gen PolicyId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
genScriptHash)
    ]

genAssetId :: Gen AssetId
genAssetId :: Gen AssetId
genAssetId = [Gen AssetId] -> Gen AssetId
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice [ PolicyId -> AssetName -> AssetId
AssetId (PolicyId -> AssetName -> AssetId)
-> Gen PolicyId -> GenT Identity (AssetName -> AssetId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen PolicyId
genPolicyId GenT Identity (AssetName -> AssetId)
-> Gen AssetName -> Gen AssetId
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen AssetName
genAssetName
                        , AssetId -> Gen AssetId
forall (m :: * -> *) a. Monad m => a -> m a
return AssetId
AdaAssetId
                        ]

genQuantity :: Range Integer -> Gen Quantity
genQuantity :: Range Integer -> Gen Quantity
genQuantity Range Integer
range = Integer -> Quantity
forall a. Num a => Integer -> a
fromInteger (Integer -> Quantity) -> GenT Identity Integer -> Gen Quantity
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Integer -> GenT Identity Integer
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral Range Integer
range

-- | Generate a positive or negative quantity.
genSignedQuantity :: Gen Quantity
genSignedQuantity :: Gen Quantity
genSignedQuantity = Range Integer -> Gen Quantity
genQuantity (Integer -> Integer -> Integer -> Range Integer
forall a. a -> a -> a -> Range a
Range.constantFrom Integer
0 (-Integer
2) Integer
2)

genUnsignedQuantity :: Gen Quantity
genUnsignedQuantity :: Gen Quantity
genUnsignedQuantity = Range Integer -> Gen Quantity
genQuantity (Integer -> Integer -> Range Integer
forall a. a -> a -> Range a
Range.constant Integer
0 Integer
2)

genValue :: Gen AssetId -> Gen Quantity -> Gen Value
genValue :: Gen AssetId -> Gen Quantity -> Gen Value
genValue Gen AssetId
genAId Gen Quantity
genQuant =
  [(AssetId, Quantity)] -> Value
valueFromList ([(AssetId, Quantity)] -> Value)
-> GenT Identity [(AssetId, Quantity)] -> Gen Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Range Int
-> GenT Identity (AssetId, Quantity)
-> GenT Identity [(AssetId, Quantity)]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
10)
             ((,) (AssetId -> Quantity -> (AssetId, Quantity))
-> Gen AssetId -> GenT Identity (Quantity -> (AssetId, Quantity))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AssetId
genAId GenT Identity (Quantity -> (AssetId, Quantity))
-> Gen Quantity -> GenT Identity (AssetId, Quantity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Quantity
genQuant)

-- | Generate a 'Value' with any asset ID and a positive or negative quantity.
genValueDefault :: Gen Value
genValueDefault :: Gen Value
genValueDefault = Gen AssetId -> Gen Quantity -> Gen Value
genValue Gen AssetId
genAssetId Gen Quantity
genSignedQuantity

-- | Generate a 'Value' suitable for minting, i.e. non-ADA asset ID and a
-- positive or negative quantity.
genValueForMinting :: Gen Value
genValueForMinting :: Gen Value
genValueForMinting = Gen AssetId -> Gen Quantity -> Gen Value
genValue Gen AssetId
genAssetIdNoAda Gen Quantity
genSignedQuantity
  where
    genAssetIdNoAda :: Gen AssetId
    genAssetIdNoAda :: Gen AssetId
genAssetIdNoAda = PolicyId -> AssetName -> AssetId
AssetId (PolicyId -> AssetName -> AssetId)
-> Gen PolicyId -> GenT Identity (AssetName -> AssetId)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen PolicyId
genPolicyId GenT Identity (AssetName -> AssetId)
-> Gen AssetName -> Gen AssetId
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen AssetName
genAssetName

-- | Generate a 'Value' suitable for usage in a transaction output, i.e. any
-- asset ID and a positive quantity.
genValueForTxOut :: Gen Value
genValueForTxOut :: Gen Value
genValueForTxOut = Gen AssetId -> Gen Quantity -> Gen Value
genValue Gen AssetId
genAssetId Gen Quantity
genUnsignedQuantity


-- Note that we expect to sometimes generate duplicate policy id keys since we
-- pick 90% of policy ids from a set of just three.
genValueNestedRep :: Gen ValueNestedRep
genValueNestedRep :: Gen ValueNestedRep
genValueNestedRep =
  [ValueNestedBundle] -> ValueNestedRep
ValueNestedRep ([ValueNestedBundle] -> ValueNestedRep)
-> GenT Identity [ValueNestedBundle] -> Gen ValueNestedRep
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int
-> GenT Identity ValueNestedBundle
-> GenT Identity [ValueNestedBundle]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
5) GenT Identity ValueNestedBundle
genValueNestedBundle

genValueNestedBundle :: Gen ValueNestedBundle
genValueNestedBundle :: GenT Identity ValueNestedBundle
genValueNestedBundle =
  [GenT Identity ValueNestedBundle]
-> GenT Identity ValueNestedBundle
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
    [ Quantity -> ValueNestedBundle
ValueNestedBundleAda (Quantity -> ValueNestedBundle)
-> Gen Quantity -> GenT Identity ValueNestedBundle
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Quantity
genSignedQuantity
    , PolicyId -> Map AssetName Quantity -> ValueNestedBundle
ValueNestedBundle (PolicyId -> Map AssetName Quantity -> ValueNestedBundle)
-> Gen PolicyId
-> GenT Identity (Map AssetName Quantity -> ValueNestedBundle)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen PolicyId
genPolicyId
                        GenT Identity (Map AssetName Quantity -> ValueNestedBundle)
-> GenT Identity (Map AssetName Quantity)
-> GenT Identity ValueNestedBundle
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Range Int
-> GenT Identity (AssetName, Quantity)
-> GenT Identity (Map AssetName Quantity)
forall (m :: * -> *) k v.
(MonadGen m, Ord k) =>
Range Int -> m (k, v) -> m (Map k v)
Gen.map (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
5)
                                    ((,) (AssetName -> Quantity -> (AssetName, Quantity))
-> Gen AssetName
-> GenT Identity (Quantity -> (AssetName, Quantity))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AssetName
genAssetName GenT Identity (Quantity -> (AssetName, Quantity))
-> Gen Quantity -> GenT Identity (AssetName, Quantity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Quantity
genSignedQuantity)
    ]

genNetworkId :: Gen NetworkId
genNetworkId :: GenT Identity NetworkId
genNetworkId =
  [GenT Identity NetworkId] -> GenT Identity NetworkId
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
    [ NetworkId -> GenT Identity NetworkId
forall (f :: * -> *) a. Applicative f => a -> f a
pure NetworkId
Mainnet
    , NetworkMagic -> NetworkId
Testnet (NetworkMagic -> NetworkId)
-> GenT Identity NetworkMagic -> GenT Identity NetworkId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity NetworkMagic
genNetworkMagic
    ]

genNetworkMagic :: Gen NetworkMagic
genNetworkMagic :: GenT Identity NetworkMagic
genNetworkMagic = Word32 -> NetworkMagic
NetworkMagic (Word32 -> NetworkMagic)
-> GenT Identity Word32 -> GenT Identity NetworkMagic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Word32 -> GenT Identity Word32
forall (m :: * -> *). MonadGen m => Range Word32 -> m Word32
Gen.word32 Range Word32
forall a. (Bounded a, Num a) => Range a
Range.constantBounded

genOperationalCertificate :: Gen OperationalCertificate
genOperationalCertificate :: Gen OperationalCertificate
genOperationalCertificate = (OperationalCertificate, OperationalCertificateIssueCounter)
-> OperationalCertificate
forall a b. (a, b) -> a
fst ((OperationalCertificate, OperationalCertificateIssueCounter)
 -> OperationalCertificate)
-> GenT
     Identity
     (OperationalCertificate, OperationalCertificateIssueCounter)
-> Gen OperationalCertificate
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT
  Identity
  (OperationalCertificate, OperationalCertificateIssueCounter)
genOperationalCertificateWithCounter

genOperationalCertificateIssueCounter :: Gen OperationalCertificateIssueCounter
genOperationalCertificateIssueCounter :: Gen OperationalCertificateIssueCounter
genOperationalCertificateIssueCounter = (OperationalCertificate, OperationalCertificateIssueCounter)
-> OperationalCertificateIssueCounter
forall a b. (a, b) -> b
snd ((OperationalCertificate, OperationalCertificateIssueCounter)
 -> OperationalCertificateIssueCounter)
-> GenT
     Identity
     (OperationalCertificate, OperationalCertificateIssueCounter)
-> Gen OperationalCertificateIssueCounter
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT
  Identity
  (OperationalCertificate, OperationalCertificateIssueCounter)
genOperationalCertificateWithCounter

genOperationalCertificateWithCounter :: Gen (OperationalCertificate, OperationalCertificateIssueCounter)
genOperationalCertificateWithCounter :: GenT
  Identity
  (OperationalCertificate, OperationalCertificateIssueCounter)
genOperationalCertificateWithCounter = do
    VerificationKey KesKey
kesVKey <- AsType KesKey -> Gen (VerificationKey KesKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType KesKey
AsKesKey
    Either
  (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
stkPoolOrGenDelExtSign <- GenT Identity (SigningKey StakePoolKey)
-> GenT Identity (SigningKey GenesisDelegateExtendedKey)
-> GenT
     Identity
     (Either
        (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey))
forall (m :: * -> *) a b.
MonadGen m =>
m a -> m b -> m (Either a b)
Gen.either (AsType StakePoolKey -> GenT Identity (SigningKey StakePoolKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType StakePoolKey
AsStakePoolKey) (AsType GenesisDelegateExtendedKey
-> GenT Identity (SigningKey GenesisDelegateExtendedKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType GenesisDelegateExtendedKey
AsGenesisDelegateExtendedKey)
    KESPeriod
kesP <- Gen KESPeriod
genKESPeriod
    Word64
c <- Range Word64 -> GenT Identity Word64
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Range Word64 -> GenT Identity Word64)
-> Range Word64 -> GenT Identity Word64
forall a b. (a -> b) -> a -> b
$ Word64 -> Word64 -> Range Word64
forall a. Integral a => a -> a -> Range a
Range.linear Word64
0 Word64
1000
    let stakePoolVer :: VerificationKey StakePoolKey
stakePoolVer = (SigningKey StakePoolKey -> VerificationKey StakePoolKey)
-> (SigningKey GenesisDelegateExtendedKey
    -> VerificationKey StakePoolKey)
-> Either
     (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
-> VerificationKey StakePoolKey
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either SigningKey StakePoolKey -> VerificationKey StakePoolKey
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
convert (VerificationKey GenesisDelegateExtendedKey
 -> VerificationKey StakePoolKey)
-> (SigningKey GenesisDelegateExtendedKey
    -> VerificationKey GenesisDelegateExtendedKey)
-> SigningKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SigningKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey) Either
  (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
stkPoolOrGenDelExtSign
        iCounter :: OperationalCertificateIssueCounter
iCounter = Word64
-> VerificationKey StakePoolKey
-> OperationalCertificateIssueCounter
OperationalCertificateIssueCounter Word64
c VerificationKey StakePoolKey
stakePoolVer

    case VerificationKey KesKey
-> Either
     (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
-> KESPeriod
-> OperationalCertificateIssueCounter
-> Either
     OperationalCertIssueError
     (OperationalCertificate, OperationalCertificateIssueCounter)
issueOperationalCertificate VerificationKey KesKey
kesVKey Either
  (SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
stkPoolOrGenDelExtSign KESPeriod
kesP OperationalCertificateIssueCounter
iCounter of
      -- This case should be impossible as we clearly derive the verification
      -- key from the generated signing key.
      Left OperationalCertIssueError
err -> String
-> GenT
     Identity
     (OperationalCertificate, OperationalCertificateIssueCounter)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
 -> GenT
      Identity
      (OperationalCertificate, OperationalCertificateIssueCounter))
-> String
-> GenT
     Identity
     (OperationalCertificate, OperationalCertificateIssueCounter)
forall a b. (a -> b) -> a -> b
$ OperationalCertIssueError -> String
forall e. Error e => e -> String
displayError OperationalCertIssueError
err
      Right (OperationalCertificate, OperationalCertificateIssueCounter)
pair -> (OperationalCertificate, OperationalCertificateIssueCounter)
-> GenT
     Identity
     (OperationalCertificate, OperationalCertificateIssueCounter)
forall (m :: * -> *) a. Monad m => a -> m a
return (OperationalCertificate, OperationalCertificateIssueCounter)
pair
  where
    convert :: VerificationKey GenesisDelegateExtendedKey
            -> VerificationKey StakePoolKey
    convert :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
convert = (VerificationKey GenesisDelegateKey -> VerificationKey StakePoolKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey GenesisDelegateKey
                                   -> VerificationKey StakePoolKey)
            (VerificationKey GenesisDelegateKey
 -> VerificationKey StakePoolKey)
-> (VerificationKey GenesisDelegateExtendedKey
    -> VerificationKey GenesisDelegateKey)
-> VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey GenesisDelegateExtendedKey
                                   -> VerificationKey GenesisDelegateKey)


-- TODO: Generate payment credential via script
genPaymentCredential :: Gen PaymentCredential
genPaymentCredential :: GenT Identity PaymentCredential
genPaymentCredential = do
  VerificationKey PaymentKey
vKey <- AsType PaymentKey -> GenT Identity (VerificationKey PaymentKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType PaymentKey
AsPaymentKey
  PaymentCredential -> GenT Identity PaymentCredential
forall (m :: * -> *) a. Monad m => a -> m a
return (PaymentCredential -> GenT Identity PaymentCredential)
-> (Hash PaymentKey -> PaymentCredential)
-> Hash PaymentKey
-> GenT Identity PaymentCredential
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Hash PaymentKey -> PaymentCredential
PaymentCredentialByKey (Hash PaymentKey -> GenT Identity PaymentCredential)
-> Hash PaymentKey -> GenT Identity PaymentCredential
forall a b. (a -> b) -> a -> b
$ VerificationKey PaymentKey -> Hash PaymentKey
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash VerificationKey PaymentKey
vKey

genSigningKey :: Key keyrole => AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey :: AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType keyrole
roletoken = do
    Seed
seed <- Int -> Gen Seed
genSeed (Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
seedSize)
    let sk :: SigningKey keyrole
sk = AsType keyrole -> Seed -> SigningKey keyrole
forall keyrole.
Key keyrole =>
AsType keyrole -> Seed -> SigningKey keyrole
deterministicSigningKey AsType keyrole
roletoken Seed
seed
    SigningKey keyrole -> Gen (SigningKey keyrole)
forall (m :: * -> *) a. Monad m => a -> m a
return SigningKey keyrole
sk
  where
    seedSize :: Word
    seedSize :: Word
seedSize = AsType keyrole -> Word
forall keyrole. Key keyrole => AsType keyrole -> Word
deterministicSigningKeySeedSize AsType keyrole
roletoken

genStakeAddress :: Gen StakeAddress
genStakeAddress :: Gen StakeAddress
genStakeAddress = NetworkId -> StakeCredential -> StakeAddress
makeStakeAddress (NetworkId -> StakeCredential -> StakeAddress)
-> GenT Identity NetworkId
-> GenT Identity (StakeCredential -> StakeAddress)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity NetworkId
genNetworkId GenT Identity (StakeCredential -> StakeAddress)
-> GenT Identity StakeCredential -> Gen StakeAddress
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity StakeCredential
genStakeCredential

-- TODO: Generate StakeAddressReference via pointer
genStakeAddressReference :: Gen StakeAddressReference
genStakeAddressReference :: GenT Identity StakeAddressReference
genStakeAddressReference =
  [GenT Identity StakeAddressReference]
-> GenT Identity StakeAddressReference
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
    [ StakeCredential -> StakeAddressReference
StakeAddressByValue (StakeCredential -> StakeAddressReference)
-> GenT Identity StakeCredential
-> GenT Identity StakeAddressReference
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity StakeCredential
genStakeCredential
    , StakeAddressReference -> GenT Identity StakeAddressReference
forall (m :: * -> *) a. Monad m => a -> m a
return StakeAddressReference
NoStakeAddress
    ]

-- TODO: Generate StakeCredential via script
genStakeCredential :: Gen StakeCredential
genStakeCredential :: GenT Identity StakeCredential
genStakeCredential = do
  VerificationKey StakeKey
vKey <- AsType StakeKey -> Gen (VerificationKey StakeKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType StakeKey
AsStakeKey
  StakeCredential -> GenT Identity StakeCredential
forall (m :: * -> *) a. Monad m => a -> m a
return (StakeCredential -> GenT Identity StakeCredential)
-> (Hash StakeKey -> StakeCredential)
-> Hash StakeKey
-> GenT Identity StakeCredential
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Hash StakeKey -> StakeCredential
StakeCredentialByKey (Hash StakeKey -> GenT Identity StakeCredential)
-> Hash StakeKey -> GenT Identity StakeCredential
forall a b. (a -> b) -> a -> b
$ VerificationKey StakeKey -> Hash StakeKey
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash VerificationKey StakeKey
vKey

genShelleyHash :: Gen (Crypto.Hash Crypto.Blake2b_256 Ledger.EraIndependentTxBody)
genShelleyHash :: Gen (Hash Blake2b_256 EraIndependentTxBody)
genShelleyHash = Hash Blake2b_256 EraIndependentTxBody
-> Gen (Hash Blake2b_256 EraIndependentTxBody)
forall (m :: * -> *) a. Monad m => a -> m a
return (Hash Blake2b_256 EraIndependentTxBody
 -> Gen (Hash Blake2b_256 EraIndependentTxBody))
-> (Hash Blake2b_256 () -> Hash Blake2b_256 EraIndependentTxBody)
-> Hash Blake2b_256 ()
-> Gen (Hash Blake2b_256 EraIndependentTxBody)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Hash Blake2b_256 () -> Hash Blake2b_256 EraIndependentTxBody
forall h a b. Hash h a -> Hash h b
Crypto.castHash (Hash Blake2b_256 ()
 -> Gen (Hash Blake2b_256 EraIndependentTxBody))
-> Hash Blake2b_256 ()
-> Gen (Hash Blake2b_256 EraIndependentTxBody)
forall a b. (a -> b) -> a -> b
$ (() -> ByteString) -> () -> Hash Blake2b_256 ()
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith () -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' ()

genSlotNo :: Gen SlotNo
genSlotNo :: GenT Identity SlotNo
genSlotNo = Word64 -> SlotNo
SlotNo (Word64 -> SlotNo) -> GenT Identity Word64 -> GenT Identity SlotNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Word64 -> GenT Identity Word64
forall (m :: * -> *). MonadGen m => Range Word64 -> m Word64
Gen.word64 Range Word64
forall a. (Bounded a, Num a) => Range a
Range.constantBounded

genTxIn :: Gen TxIn
genTxIn :: Gen TxIn
genTxIn = TxId -> TxIx -> TxIn
TxIn (TxId -> TxIx -> TxIn)
-> GenT Identity TxId -> GenT Identity (TxIx -> TxIn)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity TxId
genTxId GenT Identity (TxIx -> TxIn) -> GenT Identity TxIx -> Gen TxIn
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity TxIx
genTxIndex

genTxId :: Gen TxId
genTxId :: GenT Identity TxId
genTxId = Hash StandardCrypto EraIndependentTxBody -> TxId
Hash Blake2b_256 EraIndependentTxBody -> TxId
TxId (Hash Blake2b_256 EraIndependentTxBody -> TxId)
-> Gen (Hash Blake2b_256 EraIndependentTxBody)
-> GenT Identity TxId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Hash Blake2b_256 EraIndependentTxBody)
genShelleyHash

genTxIndex :: Gen TxIx
genTxIndex :: GenT Identity TxIx
genTxIndex = Word -> TxIx
TxIx (Word -> TxIx) -> (Word16 -> Word) -> Word16 -> TxIx
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Word16 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> TxIx) -> GenT Identity Word16 -> GenT Identity TxIx
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Word16 -> GenT Identity Word16
forall (m :: * -> *). MonadGen m => Range Word16 -> m Word16
Gen.word16 Range Word16
forall a. (Bounded a, Num a) => Range a
Range.constantBounded

genTxOutValue :: CardanoEra era -> Gen (TxOutValue era)
genTxOutValue :: CardanoEra era -> Gen (TxOutValue era)
genTxOutValue CardanoEra era
era =
  case CardanoEra era
-> Either
     (OnlyAdaSupportedInEra era) (MultiAssetSupportedInEra era)
forall era.
CardanoEra era
-> Either
     (OnlyAdaSupportedInEra era) (MultiAssetSupportedInEra era)
multiAssetSupportedInEra CardanoEra era
era of
    Left OnlyAdaSupportedInEra era
adaOnlyInEra     -> OnlyAdaSupportedInEra era -> Lovelace -> TxOutValue era
forall era. OnlyAdaSupportedInEra era -> Lovelace -> TxOutValue era
TxOutAdaOnly OnlyAdaSupportedInEra era
adaOnlyInEra (Lovelace -> TxOutValue era)
-> Gen Lovelace -> Gen (TxOutValue era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
genLovelace
    Right MultiAssetSupportedInEra era
multiAssetInEra -> MultiAssetSupportedInEra era -> Value -> TxOutValue era
forall era. MultiAssetSupportedInEra era -> Value -> TxOutValue era
TxOutValue MultiAssetSupportedInEra era
multiAssetInEra (Value -> TxOutValue era) -> Gen Value -> Gen (TxOutValue era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Value
genValueForTxOut

genTxOutTxContext :: CardanoEra era -> Gen (TxOut CtxTx era)
genTxOutTxContext :: CardanoEra era -> Gen (TxOut CtxTx era)
genTxOutTxContext CardanoEra era
era =
  AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut (AddressInEra era
 -> TxOutValue era
 -> TxOutDatum CtxTx era
 -> ReferenceScript era
 -> TxOut CtxTx era)
-> GenT Identity (AddressInEra era)
-> GenT
     Identity
     (TxOutValue era
      -> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity (AddressInEra era)
forall era. CardanoEra era -> Gen (AddressInEra era)
genAddressInEra CardanoEra era
era
        GenT
  Identity
  (TxOutValue era
   -> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> GenT Identity (TxOutValue era)
-> GenT
     Identity
     (TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxOutValue era)
forall era. CardanoEra era -> Gen (TxOutValue era)
genTxOutValue CardanoEra era
era
        GenT
  Identity
  (TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> GenT Identity (TxOutDatum CtxTx era)
-> GenT Identity (ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxOutDatum CtxTx era)
forall era. CardanoEra era -> Gen (TxOutDatum CtxTx era)
genTxOutDatumHashTxContext CardanoEra era
era
        GenT Identity (ReferenceScript era -> TxOut CtxTx era)
-> GenT Identity (ReferenceScript era) -> Gen (TxOut CtxTx era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (ReferenceScript era)
forall era. CardanoEra era -> Gen (ReferenceScript era)
genReferenceScript CardanoEra era
era

genTxOutUTxOContext :: CardanoEra era -> Gen (TxOut CtxUTxO era)
genTxOutUTxOContext :: CardanoEra era -> Gen (TxOut CtxUTxO era)
genTxOutUTxOContext CardanoEra era
era =
  AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut (AddressInEra era
 -> TxOutValue era
 -> TxOutDatum CtxUTxO era
 -> ReferenceScript era
 -> TxOut CtxUTxO era)
-> GenT Identity (AddressInEra era)
-> GenT
     Identity
     (TxOutValue era
      -> TxOutDatum CtxUTxO era
      -> ReferenceScript era
      -> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity (AddressInEra era)
forall era. CardanoEra era -> Gen (AddressInEra era)
genAddressInEra CardanoEra era
era
        GenT
  Identity
  (TxOutValue era
   -> TxOutDatum CtxUTxO era
   -> ReferenceScript era
   -> TxOut CtxUTxO era)
-> GenT Identity (TxOutValue era)
-> GenT
     Identity
     (TxOutDatum CtxUTxO era
      -> ReferenceScript era -> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxOutValue era)
forall era. CardanoEra era -> Gen (TxOutValue era)
genTxOutValue CardanoEra era
era
        GenT
  Identity
  (TxOutDatum CtxUTxO era
   -> ReferenceScript era -> TxOut CtxUTxO era)
-> GenT Identity (TxOutDatum CtxUTxO era)
-> GenT Identity (ReferenceScript era -> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxOutDatum CtxUTxO era)
forall era. CardanoEra era -> Gen (TxOutDatum CtxUTxO era)
genTxOutDatumHashUTxOContext CardanoEra era
era
        GenT Identity (ReferenceScript era -> TxOut CtxUTxO era)
-> GenT Identity (ReferenceScript era) -> Gen (TxOut CtxUTxO era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (ReferenceScript era)
forall era. CardanoEra era -> Gen (ReferenceScript era)
genReferenceScript CardanoEra era
era

genReferenceScript :: CardanoEra era -> Gen (ReferenceScript era)
genReferenceScript :: CardanoEra era -> Gen (ReferenceScript era)
genReferenceScript CardanoEra era
era =
  case CardanoEra era
-> Maybe (ReferenceTxInsScriptsInlineDatumsSupportedInEra era)
forall era.
CardanoEra era
-> Maybe (ReferenceTxInsScriptsInlineDatumsSupportedInEra era)
refInsScriptsAndInlineDatsSupportedInEra CardanoEra era
era of
    Maybe (ReferenceTxInsScriptsInlineDatumsSupportedInEra era)
Nothing -> ReferenceScript era -> Gen (ReferenceScript era)
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
    Just ReferenceTxInsScriptsInlineDatumsSupportedInEra era
supp -> ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> ScriptInAnyLang -> ReferenceScript era
forall era.
ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> ScriptInAnyLang -> ReferenceScript era
ReferenceScript ReferenceTxInsScriptsInlineDatumsSupportedInEra era
supp (ScriptInAnyLang -> ReferenceScript era)
-> Gen ScriptInAnyLang -> Gen (ReferenceScript era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptInAnyLang
genScriptInAnyLang

genUTxO :: CardanoEra era -> Gen (UTxO era)
genUTxO :: CardanoEra era -> Gen (UTxO era)
genUTxO CardanoEra era
era =
  Map TxIn (TxOut CtxUTxO era) -> UTxO era
forall era. Map TxIn (TxOut CtxUTxO era) -> UTxO era
UTxO (Map TxIn (TxOut CtxUTxO era) -> UTxO era)
-> GenT Identity (Map TxIn (TxOut CtxUTxO era)) -> Gen (UTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int
-> GenT Identity (TxIn, TxOut CtxUTxO era)
-> GenT Identity (Map TxIn (TxOut CtxUTxO era))
forall (m :: * -> *) k v.
(MonadGen m, Ord k) =>
Range Int -> m (k, v) -> m (Map k v)
Gen.map (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
5) ((,) (TxIn -> TxOut CtxUTxO era -> (TxIn, TxOut CtxUTxO era))
-> Gen TxIn
-> GenT Identity (TxOut CtxUTxO era -> (TxIn, TxOut CtxUTxO era))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TxIn
genTxIn GenT Identity (TxOut CtxUTxO era -> (TxIn, TxOut CtxUTxO era))
-> GenT Identity (TxOut CtxUTxO era)
-> GenT Identity (TxIn, TxOut CtxUTxO era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (TxOut CtxTx era -> TxOut CtxUTxO era
forall era. TxOut CtxTx era -> TxOut CtxUTxO era
toCtxUTxOTxOut (TxOut CtxTx era -> TxOut CtxUTxO era)
-> GenT Identity (TxOut CtxTx era)
-> GenT Identity (TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity (TxOut CtxTx era)
forall era. CardanoEra era -> Gen (TxOut CtxTx era)
genTxOutTxContext CardanoEra era
era))

genTtl :: Gen SlotNo
genTtl :: GenT Identity SlotNo
genTtl = GenT Identity SlotNo
genSlotNo

-- TODO: Accept a range for generating ttl.
genTxValidityLowerBound :: CardanoEra era -> Gen (TxValidityLowerBound era)
genTxValidityLowerBound :: CardanoEra era -> Gen (TxValidityLowerBound era)
genTxValidityLowerBound CardanoEra era
era =
  case CardanoEra era -> Maybe (ValidityLowerBoundSupportedInEra era)
forall era.
CardanoEra era -> Maybe (ValidityLowerBoundSupportedInEra era)
validityLowerBoundSupportedInEra CardanoEra era
era of
    Maybe (ValidityLowerBoundSupportedInEra era)
Nothing        -> TxValidityLowerBound era -> Gen (TxValidityLowerBound era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxValidityLowerBound era
forall era. TxValidityLowerBound era
TxValidityNoLowerBound
    Just ValidityLowerBoundSupportedInEra era
supported -> ValidityLowerBoundSupportedInEra era
-> SlotNo -> TxValidityLowerBound era
forall era.
ValidityLowerBoundSupportedInEra era
-> SlotNo -> TxValidityLowerBound era
TxValidityLowerBound ValidityLowerBoundSupportedInEra era
supported (SlotNo -> TxValidityLowerBound era)
-> GenT Identity SlotNo -> Gen (TxValidityLowerBound era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity SlotNo
genTtl

-- TODO: Accept a range for generating ttl.
genTxValidityUpperBound :: CardanoEra era -> Gen (TxValidityUpperBound era)
genTxValidityUpperBound :: CardanoEra era -> Gen (TxValidityUpperBound era)
genTxValidityUpperBound CardanoEra era
era =
  case (CardanoEra era -> Maybe (ValidityUpperBoundSupportedInEra era)
forall era.
CardanoEra era -> Maybe (ValidityUpperBoundSupportedInEra era)
validityUpperBoundSupportedInEra CardanoEra era
era,
       CardanoEra era -> Maybe (ValidityNoUpperBoundSupportedInEra era)
forall era.
CardanoEra era -> Maybe (ValidityNoUpperBoundSupportedInEra era)
validityNoUpperBoundSupportedInEra CardanoEra era
era) of
    (Just ValidityUpperBoundSupportedInEra era
supported, Maybe (ValidityNoUpperBoundSupportedInEra era)
_) ->
      ValidityUpperBoundSupportedInEra era
-> SlotNo -> TxValidityUpperBound era
forall era.
ValidityUpperBoundSupportedInEra era
-> SlotNo -> TxValidityUpperBound era
TxValidityUpperBound ValidityUpperBoundSupportedInEra era
supported (SlotNo -> TxValidityUpperBound era)
-> GenT Identity SlotNo -> Gen (TxValidityUpperBound era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity SlotNo
genTtl

    (Maybe (ValidityUpperBoundSupportedInEra era)
Nothing, Just ValidityNoUpperBoundSupportedInEra era
supported) ->
      TxValidityUpperBound era -> Gen (TxValidityUpperBound era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValidityNoUpperBoundSupportedInEra era -> TxValidityUpperBound era
forall era.
ValidityNoUpperBoundSupportedInEra era -> TxValidityUpperBound era
TxValidityNoUpperBound ValidityNoUpperBoundSupportedInEra era
supported)

    (Maybe (ValidityUpperBoundSupportedInEra era)
Nothing, Maybe (ValidityNoUpperBoundSupportedInEra era)
Nothing) ->
      Text -> Gen (TxValidityUpperBound era)
forall a. HasCallStack => Text -> a
panic Text
"genTxValidityUpperBound: unexpected era support combination"

genTxValidityRange
  :: CardanoEra era
  -> Gen (TxValidityLowerBound era, TxValidityUpperBound era)
genTxValidityRange :: CardanoEra era
-> Gen (TxValidityLowerBound era, TxValidityUpperBound era)
genTxValidityRange CardanoEra era
era =
  (,)
    (TxValidityLowerBound era
 -> TxValidityUpperBound era
 -> (TxValidityLowerBound era, TxValidityUpperBound era))
-> GenT Identity (TxValidityLowerBound era)
-> GenT
     Identity
     (TxValidityUpperBound era
      -> (TxValidityLowerBound era, TxValidityUpperBound era))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity (TxValidityLowerBound era)
forall era. CardanoEra era -> Gen (TxValidityLowerBound era)
genTxValidityLowerBound CardanoEra era
era
    GenT
  Identity
  (TxValidityUpperBound era
   -> (TxValidityLowerBound era, TxValidityUpperBound era))
-> GenT Identity (TxValidityUpperBound era)
-> Gen (TxValidityLowerBound era, TxValidityUpperBound era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxValidityUpperBound era)
forall era. CardanoEra era -> Gen (TxValidityUpperBound era)
genTxValidityUpperBound CardanoEra era
era

genTxMetadataInEra :: CardanoEra era -> Gen (TxMetadataInEra era)
genTxMetadataInEra :: CardanoEra era -> Gen (TxMetadataInEra era)
genTxMetadataInEra CardanoEra era
era =
  case CardanoEra era -> Maybe (TxMetadataSupportedInEra era)
forall era. CardanoEra era -> Maybe (TxMetadataSupportedInEra era)
txMetadataSupportedInEra CardanoEra era
era of
    Maybe (TxMetadataSupportedInEra era)
Nothing -> TxMetadataInEra era -> Gen (TxMetadataInEra era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMetadataInEra era
forall era. TxMetadataInEra era
TxMetadataNone
    Just TxMetadataSupportedInEra era
supported ->
      [Gen (TxMetadataInEra era)] -> Gen (TxMetadataInEra era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ TxMetadataInEra era -> Gen (TxMetadataInEra era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMetadataInEra era
forall era. TxMetadataInEra era
TxMetadataNone
        , TxMetadataSupportedInEra era -> TxMetadata -> TxMetadataInEra era
forall era.
TxMetadataSupportedInEra era -> TxMetadata -> TxMetadataInEra era
TxMetadataInEra TxMetadataSupportedInEra era
supported (TxMetadata -> TxMetadataInEra era)
-> GenT Identity TxMetadata -> Gen (TxMetadataInEra era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity TxMetadata
genTxMetadata
        ]

genTxAuxScripts :: CardanoEra era -> Gen (TxAuxScripts era)
genTxAuxScripts :: CardanoEra era -> Gen (TxAuxScripts era)
genTxAuxScripts CardanoEra era
era =
  case CardanoEra era -> Maybe (AuxScriptsSupportedInEra era)
forall era. CardanoEra era -> Maybe (AuxScriptsSupportedInEra era)
auxScriptsSupportedInEra CardanoEra era
era of
    Maybe (AuxScriptsSupportedInEra era)
Nothing -> TxAuxScripts era -> Gen (TxAuxScripts era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxAuxScripts era
forall era. TxAuxScripts era
TxAuxScriptsNone
    Just AuxScriptsSupportedInEra era
supported ->
      AuxScriptsSupportedInEra era
-> [ScriptInEra era] -> TxAuxScripts era
forall era.
AuxScriptsSupportedInEra era
-> [ScriptInEra era] -> TxAuxScripts era
TxAuxScripts AuxScriptsSupportedInEra era
supported ([ScriptInEra era] -> TxAuxScripts era)
-> GenT Identity [ScriptInEra era] -> Gen (TxAuxScripts era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Range Int
-> GenT Identity (ScriptInEra era)
-> GenT Identity [ScriptInEra era]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
3)
                 (CardanoEra era -> GenT Identity (ScriptInEra era)
forall era. CardanoEra era -> Gen (ScriptInEra era)
genScriptInEra CardanoEra era
era)

genTxWithdrawals :: CardanoEra era -> Gen (TxWithdrawals BuildTx era)
genTxWithdrawals :: CardanoEra era -> Gen (TxWithdrawals BuildTx era)
genTxWithdrawals CardanoEra era
era =
  case CardanoEra era -> Maybe (WithdrawalsSupportedInEra era)
forall era. CardanoEra era -> Maybe (WithdrawalsSupportedInEra era)
withdrawalsSupportedInEra CardanoEra era
era of
    Maybe (WithdrawalsSupportedInEra era)
Nothing -> TxWithdrawals BuildTx era -> Gen (TxWithdrawals BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxWithdrawals BuildTx era
forall build era. TxWithdrawals build era
TxWithdrawalsNone
    Just WithdrawalsSupportedInEra era
supported ->
      [Gen (TxWithdrawals BuildTx era)]
-> Gen (TxWithdrawals BuildTx era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ TxWithdrawals BuildTx era -> Gen (TxWithdrawals BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxWithdrawals BuildTx era
forall build era. TxWithdrawals build era
TxWithdrawalsNone
        , TxWithdrawals BuildTx era -> Gen (TxWithdrawals BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WithdrawalsSupportedInEra era
-> [(StakeAddress, Lovelace,
     BuildTxWith BuildTx (Witness WitCtxStake era))]
-> TxWithdrawals BuildTx era
forall era build.
WithdrawalsSupportedInEra era
-> [(StakeAddress, Lovelace,
     BuildTxWith build (Witness WitCtxStake era))]
-> TxWithdrawals build era
TxWithdrawals WithdrawalsSupportedInEra era
supported [(StakeAddress, Lovelace,
  BuildTxWith BuildTx (Witness WitCtxStake era))]
forall a. Monoid a => a
mempty)
          -- TODO: Generate withdrawals
        ]

genTxCertificates :: CardanoEra era -> Gen (TxCertificates BuildTx era)
genTxCertificates :: CardanoEra era -> Gen (TxCertificates BuildTx era)
genTxCertificates CardanoEra era
era =
  case CardanoEra era -> Maybe (CertificatesSupportedInEra era)
forall era.
CardanoEra era -> Maybe (CertificatesSupportedInEra era)
certificatesSupportedInEra CardanoEra era
era of
    Maybe (CertificatesSupportedInEra era)
Nothing -> TxCertificates BuildTx era -> Gen (TxCertificates BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxCertificates BuildTx era
forall build era. TxCertificates build era
TxCertificatesNone
    Just CertificatesSupportedInEra era
supported -> do
      [Certificate]
certs <- Range Int
-> GenT Identity Certificate -> GenT Identity [Certificate]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
3) GenT Identity Certificate
genCertificate
      [Gen (TxCertificates BuildTx era)]
-> Gen (TxCertificates BuildTx era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ TxCertificates BuildTx era -> Gen (TxCertificates BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxCertificates BuildTx era
forall build era. TxCertificates build era
TxCertificatesNone
        , TxCertificates BuildTx era -> Gen (TxCertificates BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CertificatesSupportedInEra era
-> [Certificate]
-> BuildTxWith
     BuildTx (Map StakeCredential (Witness WitCtxStake era))
-> TxCertificates BuildTx era
forall era build.
CertificatesSupportedInEra era
-> [Certificate]
-> BuildTxWith
     build (Map StakeCredential (Witness WitCtxStake era))
-> TxCertificates build era
TxCertificates CertificatesSupportedInEra era
supported [Certificate]
certs (BuildTxWith
   BuildTx (Map StakeCredential (Witness WitCtxStake era))
 -> TxCertificates BuildTx era)
-> BuildTxWith
     BuildTx (Map StakeCredential (Witness WitCtxStake era))
-> TxCertificates BuildTx era
forall a b. (a -> b) -> a -> b
$ Map StakeCredential (Witness WitCtxStake era)
-> BuildTxWith
     BuildTx (Map StakeCredential (Witness WitCtxStake era))
forall a. a -> BuildTxWith BuildTx a
BuildTxWith Map StakeCredential (Witness WitCtxStake era)
forall a. Monoid a => a
mempty)
          -- TODO: Generate certificates
        ]

-- TODO: Add remaining certificates
genCertificate :: Gen Certificate
genCertificate :: GenT Identity Certificate
genCertificate =
  [GenT Identity Certificate] -> GenT Identity Certificate
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
    [ StakeCredential -> Certificate
StakeAddressRegistrationCertificate (StakeCredential -> Certificate)
-> GenT Identity StakeCredential -> GenT Identity Certificate
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity StakeCredential
genStakeCredential
    , StakeCredential -> Certificate
StakeAddressDeregistrationCertificate (StakeCredential -> Certificate)
-> GenT Identity StakeCredential -> GenT Identity Certificate
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity StakeCredential
genStakeCredential
    ]

genTxUpdateProposal :: CardanoEra era -> Gen (TxUpdateProposal era)
genTxUpdateProposal :: CardanoEra era -> Gen (TxUpdateProposal era)
genTxUpdateProposal CardanoEra era
era =
  case CardanoEra era -> Maybe (UpdateProposalSupportedInEra era)
forall era.
CardanoEra era -> Maybe (UpdateProposalSupportedInEra era)
updateProposalSupportedInEra CardanoEra era
era of
    Maybe (UpdateProposalSupportedInEra era)
Nothing -> TxUpdateProposal era -> Gen (TxUpdateProposal era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxUpdateProposal era
forall era. TxUpdateProposal era
TxUpdateProposalNone
    Just UpdateProposalSupportedInEra era
supported ->
      [Gen (TxUpdateProposal era)] -> Gen (TxUpdateProposal era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ TxUpdateProposal era -> Gen (TxUpdateProposal era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxUpdateProposal era
forall era. TxUpdateProposal era
TxUpdateProposalNone
        , UpdateProposalSupportedInEra era
-> UpdateProposal -> TxUpdateProposal era
forall era.
UpdateProposalSupportedInEra era
-> UpdateProposal -> TxUpdateProposal era
TxUpdateProposal UpdateProposalSupportedInEra era
supported (UpdateProposal -> TxUpdateProposal era)
-> GenT Identity UpdateProposal -> Gen (TxUpdateProposal era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity UpdateProposal
genUpdateProposal
        ]

genTxMintValue :: CardanoEra era -> Gen (TxMintValue BuildTx era)
genTxMintValue :: CardanoEra era -> Gen (TxMintValue BuildTx era)
genTxMintValue CardanoEra era
era =
  case CardanoEra era
-> Either
     (OnlyAdaSupportedInEra era) (MultiAssetSupportedInEra era)
forall era.
CardanoEra era
-> Either
     (OnlyAdaSupportedInEra era) (MultiAssetSupportedInEra era)
multiAssetSupportedInEra CardanoEra era
era of
    Left OnlyAdaSupportedInEra era
_ -> TxMintValue BuildTx era -> Gen (TxMintValue BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMintValue BuildTx era
forall build era. TxMintValue build era
TxMintNone
    Right MultiAssetSupportedInEra era
supported ->
      [Gen (TxMintValue BuildTx era)] -> Gen (TxMintValue BuildTx era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
        [ TxMintValue BuildTx era -> Gen (TxMintValue BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMintValue BuildTx era
forall build era. TxMintValue build era
TxMintNone
        , MultiAssetSupportedInEra era
-> Value
-> BuildTxWith
     BuildTx (Map PolicyId (ScriptWitness WitCtxMint era))
-> TxMintValue BuildTx era
forall era build.
MultiAssetSupportedInEra era
-> Value
-> BuildTxWith build (Map PolicyId (ScriptWitness WitCtxMint era))
-> TxMintValue build era
TxMintValue MultiAssetSupportedInEra era
supported (Value
 -> BuildTxWith
      BuildTx (Map PolicyId (ScriptWitness WitCtxMint era))
 -> TxMintValue BuildTx era)
-> Gen Value
-> GenT
     Identity
     (BuildTxWith BuildTx (Map PolicyId (ScriptWitness WitCtxMint era))
      -> TxMintValue BuildTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Value
genValueForMinting GenT
  Identity
  (BuildTxWith BuildTx (Map PolicyId (ScriptWitness WitCtxMint era))
   -> TxMintValue BuildTx era)
-> GenT
     Identity
     (BuildTxWith BuildTx (Map PolicyId (ScriptWitness WitCtxMint era)))
-> Gen (TxMintValue BuildTx era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> BuildTxWith BuildTx (Map PolicyId (ScriptWitness WitCtxMint era))
-> GenT
     Identity
     (BuildTxWith BuildTx (Map PolicyId (ScriptWitness WitCtxMint era)))
forall (m :: * -> *) a. Monad m => a -> m a
return (Map PolicyId (ScriptWitness WitCtxMint era)
-> BuildTxWith
     BuildTx (Map PolicyId (ScriptWitness WitCtxMint era))
forall a. a -> BuildTxWith BuildTx a
BuildTxWith Map PolicyId (ScriptWitness WitCtxMint era)
forall a. Monoid a => a
mempty)
        ]

genTxBodyContent :: CardanoEra era -> Gen (TxBodyContent BuildTx era)
genTxBodyContent :: CardanoEra era -> Gen (TxBodyContent BuildTx era)
genTxBodyContent CardanoEra era
era = do
  [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
txIns <- (TxIn -> (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)))
-> [TxIn] -> [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (, Witness WitCtxTxIn era
-> BuildTxWith BuildTx (Witness WitCtxTxIn era)
forall a. a -> BuildTxWith BuildTx a
BuildTxWith (KeyWitnessInCtx WitCtxTxIn -> Witness WitCtxTxIn era
forall witctx era. KeyWitnessInCtx witctx -> Witness witctx era
KeyWitness KeyWitnessInCtx WitCtxTxIn
KeyWitnessForSpending)) ([TxIn] -> [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))])
-> GenT Identity [TxIn]
-> GenT
     Identity [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> Gen TxIn -> GenT Identity [TxIn]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
1 Int
10) Gen TxIn
genTxIn
  TxInsCollateral era
txInsCollateral <- CardanoEra era -> Gen (TxInsCollateral era)
forall era. CardanoEra era -> Gen (TxInsCollateral era)
genTxInsCollateral CardanoEra era
era
  TxInsReference BuildTx era
txInsReference <- CardanoEra era -> Gen (TxInsReference BuildTx era)
forall era. CardanoEra era -> Gen (TxInsReference BuildTx era)
genTxInsReference CardanoEra era
era
  [TxOut CtxTx era]
txOuts <- Range Int
-> GenT Identity (TxOut CtxTx era)
-> GenT Identity [TxOut CtxTx era]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
1 Int
10) (CardanoEra era -> GenT Identity (TxOut CtxTx era)
forall era. CardanoEra era -> Gen (TxOut CtxTx era)
genTxOutTxContext CardanoEra era
era)
  TxTotalCollateral era
txTotalCollateral <- CardanoEra era -> Gen (TxTotalCollateral era)
forall era. CardanoEra era -> Gen (TxTotalCollateral era)
genTxTotalCollateral CardanoEra era
era
  TxReturnCollateral CtxTx era
txReturnCollateral <- CardanoEra era -> Gen (TxReturnCollateral CtxTx era)
forall era. CardanoEra era -> Gen (TxReturnCollateral CtxTx era)
genTxReturnCollateral CardanoEra era
era
  TxFee era
txFee <- CardanoEra era -> Gen (TxFee era)
forall era. CardanoEra era -> Gen (TxFee era)
genTxFee CardanoEra era
era
  (TxValidityLowerBound era, TxValidityUpperBound era)
txValidityRange <- CardanoEra era
-> Gen (TxValidityLowerBound era, TxValidityUpperBound era)
forall era.
CardanoEra era
-> Gen (TxValidityLowerBound era, TxValidityUpperBound era)
genTxValidityRange CardanoEra era
era
  TxMetadataInEra era
txMetadata <- CardanoEra era -> Gen (TxMetadataInEra era)
forall era. CardanoEra era -> Gen (TxMetadataInEra era)
genTxMetadataInEra CardanoEra era
era
  TxAuxScripts era
txAuxScripts <- CardanoEra era -> Gen (TxAuxScripts era)
forall era. CardanoEra era -> Gen (TxAuxScripts era)
genTxAuxScripts CardanoEra era
era
  let txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits = TxExtraKeyWitnesses era
forall era. TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone --TODO: Alonzo era: Generate witness key hashes
  BuildTxWith BuildTx (Maybe ProtocolParameters)
txProtocolParams <- Maybe ProtocolParameters
-> BuildTxWith BuildTx (Maybe ProtocolParameters)
forall a. a -> BuildTxWith BuildTx a
BuildTxWith (Maybe ProtocolParameters
 -> BuildTxWith BuildTx (Maybe ProtocolParameters))
-> GenT Identity (Maybe ProtocolParameters)
-> GenT Identity (BuildTxWith BuildTx (Maybe ProtocolParameters))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity ProtocolParameters
-> GenT Identity (Maybe ProtocolParameters)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ProtocolParameters
genProtocolParameters
  TxWithdrawals BuildTx era
txWithdrawals <- CardanoEra era -> Gen (TxWithdrawals BuildTx era)
forall era. CardanoEra era -> Gen (TxWithdrawals BuildTx era)
genTxWithdrawals CardanoEra era
era
  TxCertificates BuildTx era
txCertificates <- CardanoEra era -> Gen (TxCertificates BuildTx era)
forall era. CardanoEra era -> Gen (TxCertificates BuildTx era)
genTxCertificates CardanoEra era
era
  TxUpdateProposal era
txUpdateProposal <- CardanoEra era -> Gen (TxUpdateProposal era)
forall era. CardanoEra era -> Gen (TxUpdateProposal era)
genTxUpdateProposal CardanoEra era
era
  TxMintValue BuildTx era
txMintValue <- CardanoEra era -> Gen (TxMintValue BuildTx era)
forall era. CardanoEra era -> Gen (TxMintValue BuildTx era)
genTxMintValue CardanoEra era
era
  TxScriptValidity era
txScriptValidity <- CardanoEra era -> Gen (TxScriptValidity era)
forall era. CardanoEra era -> Gen (TxScriptValidity era)
genTxScriptValidity CardanoEra era
era

  TxBodyContent BuildTx era -> Gen (TxBodyContent BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxBodyContent BuildTx era -> Gen (TxBodyContent BuildTx era))
-> TxBodyContent BuildTx era -> Gen (TxBodyContent BuildTx era)
forall a b. (a -> b) -> a -> b
$ TxBodyContent :: forall build era.
TxIns build era
-> TxInsCollateral era
-> TxInsReference build era
-> [TxOut CtxTx era]
-> TxTotalCollateral era
-> TxReturnCollateral CtxTx era
-> TxFee era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
-> TxMetadataInEra era
-> TxAuxScripts era
-> TxExtraKeyWitnesses era
-> BuildTxWith build (Maybe ProtocolParameters)
-> TxWithdrawals build era
-> TxCertificates build era
-> TxUpdateProposal era
-> TxMintValue build era
-> TxScriptValidity era
-> TxBodyContent build era
TxBodyContent
    { [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
txIns :: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
txIns :: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
Api.txIns
    , TxInsCollateral era
txInsCollateral :: TxInsCollateral era
txInsCollateral :: TxInsCollateral era
Api.txInsCollateral
    , TxInsReference BuildTx era
txInsReference :: TxInsReference BuildTx era
txInsReference :: TxInsReference BuildTx era
Api.txInsReference
    , [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
Api.txOuts
    , TxTotalCollateral era
txTotalCollateral :: TxTotalCollateral era
txTotalCollateral :: TxTotalCollateral era
Api.txTotalCollateral
    , TxReturnCollateral CtxTx era
txReturnCollateral :: TxReturnCollateral CtxTx era
txReturnCollateral :: TxReturnCollateral CtxTx era
Api.txReturnCollateral
    , TxFee era
txFee :: TxFee era
txFee :: TxFee era
Api.txFee
    , (TxValidityLowerBound era, TxValidityUpperBound era)
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
Api.txValidityRange
    , TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata :: TxMetadataInEra era
Api.txMetadata
    , TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts :: TxAuxScripts era
Api.txAuxScripts
    , TxExtraKeyWitnesses era
forall era. TxExtraKeyWitnesses era
txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits :: forall era. TxExtraKeyWitnesses era
Api.txExtraKeyWits
    , BuildTxWith BuildTx (Maybe ProtocolParameters)
txProtocolParams :: BuildTxWith BuildTx (Maybe ProtocolParameters)
txProtocolParams :: BuildTxWith BuildTx (Maybe ProtocolParameters)
Api.txProtocolParams
    , TxWithdrawals BuildTx era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals :: TxWithdrawals BuildTx era
Api.txWithdrawals
    , TxCertificates BuildTx era
txCertificates :: TxCertificates BuildTx era
txCertificates :: TxCertificates BuildTx era
Api.txCertificates
    , TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
Api.txUpdateProposal
    , TxMintValue BuildTx era
txMintValue :: TxMintValue BuildTx era
txMintValue :: TxMintValue BuildTx era
Api.txMintValue
    , TxScriptValidity era
txScriptValidity :: TxScriptValidity era
txScriptValidity :: TxScriptValidity era
Api.txScriptValidity
    }

genTxInsCollateral :: CardanoEra era -> Gen (TxInsCollateral era)
genTxInsCollateral :: CardanoEra era -> Gen (TxInsCollateral era)
genTxInsCollateral CardanoEra era
era =
    case CardanoEra era -> Maybe (CollateralSupportedInEra era)
forall era. CardanoEra era -> Maybe (CollateralSupportedInEra era)
collateralSupportedInEra CardanoEra era
era of
      Maybe (CollateralSupportedInEra era)
Nothing        -> TxInsCollateral era -> Gen (TxInsCollateral era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxInsCollateral era
forall era. TxInsCollateral era
TxInsCollateralNone
      Just CollateralSupportedInEra era
supported -> [Gen (TxInsCollateral era)] -> Gen (TxInsCollateral era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
                          [ TxInsCollateral era -> Gen (TxInsCollateral era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxInsCollateral era
forall era. TxInsCollateral era
TxInsCollateralNone
                          , CollateralSupportedInEra era -> [TxIn] -> TxInsCollateral era
forall era.
CollateralSupportedInEra era -> [TxIn] -> TxInsCollateral era
TxInsCollateral CollateralSupportedInEra era
supported ([TxIn] -> TxInsCollateral era)
-> GenT Identity [TxIn] -> Gen (TxInsCollateral era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> Gen TxIn -> GenT Identity [TxIn]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
10) Gen TxIn
genTxIn
                          ]
genTxInsReference :: CardanoEra era -> Gen (TxInsReference BuildTx era)
genTxInsReference :: CardanoEra era -> Gen (TxInsReference BuildTx era)
genTxInsReference CardanoEra era
era =
    case CardanoEra era
-> Maybe (ReferenceTxInsScriptsInlineDatumsSupportedInEra era)
forall era.
CardanoEra era
-> Maybe (ReferenceTxInsScriptsInlineDatumsSupportedInEra era)
refInsScriptsAndInlineDatsSupportedInEra CardanoEra era
era of
      Maybe (ReferenceTxInsScriptsInlineDatumsSupportedInEra era)
Nothing        -> TxInsReference BuildTx era -> Gen (TxInsReference BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxInsReference BuildTx era
forall build era. TxInsReference build era
TxInsReferenceNone
      Just ReferenceTxInsScriptsInlineDatumsSupportedInEra era
supported -> [Gen (TxInsReference BuildTx era)]
-> Gen (TxInsReference BuildTx era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
                          [ TxInsReference BuildTx era -> Gen (TxInsReference BuildTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxInsReference BuildTx era
forall build era. TxInsReference build era
TxInsReferenceNone
                          , ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> [TxIn] -> TxInsReference BuildTx era
forall era build.
ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> [TxIn] -> TxInsReference build era
TxInsReference ReferenceTxInsScriptsInlineDatumsSupportedInEra era
supported ([TxIn] -> TxInsReference BuildTx era)
-> GenT Identity [TxIn] -> Gen (TxInsReference BuildTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> Gen TxIn -> GenT Identity [TxIn]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
10) Gen TxIn
genTxIn
                          ]


genTxReturnCollateral :: CardanoEra era -> Gen (TxReturnCollateral CtxTx era)
genTxReturnCollateral :: CardanoEra era -> Gen (TxReturnCollateral CtxTx era)
genTxReturnCollateral CardanoEra era
era =
  case CardanoEra era
-> Maybe (TxTotalAndReturnCollateralSupportedInEra era)
forall era.
CardanoEra era
-> Maybe (TxTotalAndReturnCollateralSupportedInEra era)
totalAndReturnCollateralSupportedInEra  CardanoEra era
era of
    Maybe (TxTotalAndReturnCollateralSupportedInEra era)
Nothing -> TxReturnCollateral CtxTx era -> Gen (TxReturnCollateral CtxTx era)
forall (m :: * -> *) a. Monad m => a -> m a
return TxReturnCollateral CtxTx era
forall ctx era. TxReturnCollateral ctx era
TxReturnCollateralNone
    Just TxTotalAndReturnCollateralSupportedInEra era
supp ->
      TxTotalAndReturnCollateralSupportedInEra era
-> TxOut CtxTx era -> TxReturnCollateral CtxTx era
forall era ctx.
TxTotalAndReturnCollateralSupportedInEra era
-> TxOut ctx era -> TxReturnCollateral ctx era
TxReturnCollateral TxTotalAndReturnCollateralSupportedInEra era
supp (TxOut CtxTx era -> TxReturnCollateral CtxTx era)
-> GenT Identity (TxOut CtxTx era)
-> Gen (TxReturnCollateral CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  CardanoEra era -> GenT Identity (TxOut CtxTx era)
forall era. CardanoEra era -> Gen (TxOut CtxTx era)
genTxOutTxContext CardanoEra era
era

genTxTotalCollateral :: CardanoEra era -> Gen (TxTotalCollateral era)
genTxTotalCollateral :: CardanoEra era -> Gen (TxTotalCollateral era)
genTxTotalCollateral CardanoEra era
era =
  case CardanoEra era
-> Maybe (TxTotalAndReturnCollateralSupportedInEra era)
forall era.
CardanoEra era
-> Maybe (TxTotalAndReturnCollateralSupportedInEra era)
totalAndReturnCollateralSupportedInEra  CardanoEra era
era of
    Maybe (TxTotalAndReturnCollateralSupportedInEra era)
Nothing -> TxTotalCollateral era -> Gen (TxTotalCollateral era)
forall (m :: * -> *) a. Monad m => a -> m a
return TxTotalCollateral era
forall era. TxTotalCollateral era
TxTotalCollateralNone
    Just TxTotalAndReturnCollateralSupportedInEra era
supp ->
      TxTotalAndReturnCollateralSupportedInEra era
-> Lovelace -> TxTotalCollateral era
forall era.
TxTotalAndReturnCollateralSupportedInEra era
-> Lovelace -> TxTotalCollateral era
TxTotalCollateral TxTotalAndReturnCollateralSupportedInEra era
supp (Lovelace -> TxTotalCollateral era)
-> Gen Lovelace -> Gen (TxTotalCollateral era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
genLovelace

genTxFee :: CardanoEra era -> Gen (TxFee era)
genTxFee :: CardanoEra era -> Gen (TxFee era)
genTxFee CardanoEra era
era =
  case CardanoEra era
-> Either (TxFeesImplicitInEra era) (TxFeesExplicitInEra era)
forall era.
CardanoEra era
-> Either (TxFeesImplicitInEra era) (TxFeesExplicitInEra era)
txFeesExplicitInEra CardanoEra era
era of
    Left  TxFeesImplicitInEra era
supported -> TxFee era -> Gen (TxFee era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxFeesImplicitInEra era -> TxFee era
forall era. TxFeesImplicitInEra era -> TxFee era
TxFeeImplicit TxFeesImplicitInEra era
supported)
    Right TxFeesExplicitInEra era
supported -> TxFeesExplicitInEra era -> Lovelace -> TxFee era
forall era. TxFeesExplicitInEra era -> Lovelace -> TxFee era
TxFeeExplicit TxFeesExplicitInEra era
supported (Lovelace -> TxFee era) -> Gen Lovelace -> Gen (TxFee era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
genLovelace

genTxBody :: IsCardanoEra era => CardanoEra era -> Gen (TxBody era)
genTxBody :: CardanoEra era -> Gen (TxBody era)
genTxBody CardanoEra era
era = do
  Either TxBodyError (TxBody era)
res <- TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
forall era.
IsCardanoEra era =>
TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
Api.createAndValidateTransactionBody (TxBodyContent BuildTx era -> Either TxBodyError (TxBody era))
-> GenT Identity (TxBodyContent BuildTx era)
-> GenT Identity (Either TxBodyError (TxBody era))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity (TxBodyContent BuildTx era)
forall era. CardanoEra era -> Gen (TxBodyContent BuildTx era)
genTxBodyContent CardanoEra era
era
  case Either TxBodyError (TxBody era)
res of
    Left TxBodyError
err -> String -> Gen (TxBody era)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (TxBodyError -> String
forall e. Error e => e -> String
displayError TxBodyError
err)
    Right TxBody era
txBody -> TxBody era -> Gen (TxBody era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxBody era
txBody

genTxScriptValidity :: CardanoEra era -> Gen (TxScriptValidity era)
genTxScriptValidity :: CardanoEra era -> Gen (TxScriptValidity era)
genTxScriptValidity CardanoEra era
era = case CardanoEra era -> Maybe (TxScriptValiditySupportedInEra era)
forall era.
CardanoEra era -> Maybe (TxScriptValiditySupportedInEra era)
txScriptValiditySupportedInCardanoEra CardanoEra era
era of
  Maybe (TxScriptValiditySupportedInEra era)
Nothing -> TxScriptValidity era -> Gen (TxScriptValidity era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxScriptValidity era
forall era. TxScriptValidity era
TxScriptValidityNone
  Just TxScriptValiditySupportedInEra era
witness -> TxScriptValiditySupportedInEra era
-> ScriptValidity -> TxScriptValidity era
forall era.
TxScriptValiditySupportedInEra era
-> ScriptValidity -> TxScriptValidity era
TxScriptValidity TxScriptValiditySupportedInEra era
witness (ScriptValidity -> TxScriptValidity era)
-> GenT Identity ScriptValidity -> Gen (TxScriptValidity era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity ScriptValidity
genScriptValidity

genScriptValidity :: Gen ScriptValidity
genScriptValidity :: GenT Identity ScriptValidity
genScriptValidity = [ScriptValidity] -> GenT Identity ScriptValidity
forall (m :: * -> *) a. MonadGen m => [a] -> m a
Gen.element [ScriptValidity
ScriptInvalid, ScriptValidity
ScriptValid]

genTx :: forall era. IsCardanoEra era => CardanoEra era -> Gen (Tx era)
genTx :: CardanoEra era -> Gen (Tx era)
genTx CardanoEra era
era =
  [KeyWitness era] -> TxBody era -> Tx era
forall era. [KeyWitness era] -> TxBody era -> Tx era
makeSignedTransaction
    ([KeyWitness era] -> TxBody era -> Tx era)
-> GenT Identity [KeyWitness era]
-> GenT Identity (TxBody era -> Tx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity [KeyWitness era]
forall era. CardanoEra era -> Gen [KeyWitness era]
genWitnesses CardanoEra era
era
    GenT Identity (TxBody era -> Tx era)
-> GenT Identity (TxBody era) -> Gen (Tx era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxBody era)
forall era. IsCardanoEra era => CardanoEra era -> Gen (TxBody era)
genTxBody CardanoEra era
era

genWitnesses :: CardanoEra era -> Gen [KeyWitness era]
genWitnesses :: CardanoEra era -> Gen [KeyWitness era]
genWitnesses CardanoEra era
era =
  case CardanoEra era -> CardanoEraStyle era
forall era. CardanoEra era -> CardanoEraStyle era
cardanoEraStyle CardanoEra era
era of
    CardanoEraStyle era
LegacyByronEra    -> Range Int
-> GenT Identity (KeyWitness ByronEra)
-> GenT Identity [KeyWitness ByronEra]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
1 Int
10) GenT Identity (KeyWitness ByronEra)
genByronKeyWitness
    ShelleyBasedEra ShelleyBasedEra era
_ -> do
      [KeyWitness era]
bsWits  <- Range Int -> GenT Identity (KeyWitness era) -> Gen [KeyWitness era]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
10)
                          (CardanoEra era -> GenT Identity (KeyWitness era)
forall era.
IsShelleyBasedEra era =>
CardanoEra era -> Gen (KeyWitness era)
genShelleyBootstrapWitness CardanoEra era
era)
      [KeyWitness era]
keyWits <- Range Int -> GenT Identity (KeyWitness era) -> Gen [KeyWitness era]
forall (m :: * -> *) a. MonadGen m => Range Int -> m a -> m [a]
Gen.list (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
0 Int
10)
                          (CardanoEra era -> GenT Identity (KeyWitness era)
forall era.
IsShelleyBasedEra era =>
CardanoEra era -> Gen (KeyWitness era)
genShelleyKeyWitness CardanoEra era
era)
      [KeyWitness era] -> Gen [KeyWitness era]
forall (m :: * -> *) a. Monad m => a -> m a
return ([KeyWitness era] -> Gen [KeyWitness era])
-> [KeyWitness era] -> Gen [KeyWitness era]
forall a b. (a -> b) -> a -> b
$ [KeyWitness era]
bsWits [KeyWitness era] -> [KeyWitness era] -> [KeyWitness era]
forall a. [a] -> [a] -> [a]
++ [KeyWitness era]
keyWits

genVerificationKey :: Key keyrole => AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey :: AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType keyrole
roletoken = SigningKey keyrole -> VerificationKey keyrole
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey (SigningKey keyrole -> VerificationKey keyrole)
-> GenT Identity (SigningKey keyrole)
-> Gen (VerificationKey keyrole)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType keyrole -> GenT Identity (SigningKey keyrole)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType keyrole
roletoken

genVerificationKeyHash :: Key keyrole => AsType keyrole -> Gen (Hash keyrole)
genVerificationKeyHash :: AsType keyrole -> Gen (Hash keyrole)
genVerificationKeyHash AsType keyrole
roletoken =
  VerificationKey keyrole -> Hash keyrole
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash (VerificationKey keyrole -> Hash keyrole)
-> GenT Identity (VerificationKey keyrole) -> Gen (Hash keyrole)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType keyrole -> GenT Identity (VerificationKey keyrole)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (VerificationKey keyrole)
genVerificationKey AsType keyrole
roletoken

genByronKeyWitness :: Gen (KeyWitness ByronEra)
genByronKeyWitness :: GenT Identity (KeyWitness ByronEra)
genByronKeyWitness = do
  ProtocolMagicId
pmId <- Gen ProtocolMagicId
genProtocolMagicId
  TxInWitness
txinWitness <- ProtocolMagicId -> Gen TxInWitness
genVKWitness ProtocolMagicId
pmId
  KeyWitness ByronEra -> GenT Identity (KeyWitness ByronEra)
forall (m :: * -> *) a. Monad m => a -> m a
return (KeyWitness ByronEra -> GenT Identity (KeyWitness ByronEra))
-> KeyWitness ByronEra -> GenT Identity (KeyWitness ByronEra)
forall a b. (a -> b) -> a -> b
$ TxInWitness -> KeyWitness ByronEra
ByronKeyWitness TxInWitness
txinWitness

genWitnessNetworkIdOrByronAddress :: Gen WitnessNetworkIdOrByronAddress
genWitnessNetworkIdOrByronAddress :: Gen WitnessNetworkIdOrByronAddress
genWitnessNetworkIdOrByronAddress =
  [Gen WitnessNetworkIdOrByronAddress]
-> Gen WitnessNetworkIdOrByronAddress
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
    [ NetworkId -> WitnessNetworkIdOrByronAddress
WitnessNetworkId (NetworkId -> WitnessNetworkIdOrByronAddress)
-> GenT Identity NetworkId -> Gen WitnessNetworkIdOrByronAddress
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity NetworkId
genNetworkId
    , Address ByronAddr -> WitnessNetworkIdOrByronAddress
WitnessByronAddress (Address ByronAddr -> WitnessNetworkIdOrByronAddress)
-> Gen (Address ByronAddr) -> Gen WitnessNetworkIdOrByronAddress
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Address ByronAddr)
genAddressByron
    ]

genShelleyBootstrapWitness
  :: IsShelleyBasedEra era
  => CardanoEra era
  -> Gen (KeyWitness era)
genShelleyBootstrapWitness :: CardanoEra era -> Gen (KeyWitness era)
genShelleyBootstrapWitness CardanoEra era
era =
 WitnessNetworkIdOrByronAddress
-> TxBody era -> SigningKey ByronKey -> KeyWitness era
forall era.
IsShelleyBasedEra era =>
WitnessNetworkIdOrByronAddress
-> TxBody era -> SigningKey ByronKey -> KeyWitness era
makeShelleyBootstrapWitness
   (WitnessNetworkIdOrByronAddress
 -> TxBody era -> SigningKey ByronKey -> KeyWitness era)
-> Gen WitnessNetworkIdOrByronAddress
-> GenT
     Identity (TxBody era -> SigningKey ByronKey -> KeyWitness era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen WitnessNetworkIdOrByronAddress
genWitnessNetworkIdOrByronAddress
   GenT Identity (TxBody era -> SigningKey ByronKey -> KeyWitness era)
-> GenT Identity (TxBody era)
-> GenT Identity (SigningKey ByronKey -> KeyWitness era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era -> GenT Identity (TxBody era)
forall era. IsCardanoEra era => CardanoEra era -> Gen (TxBody era)
genTxBody CardanoEra era
era
   GenT Identity (SigningKey ByronKey -> KeyWitness era)
-> GenT Identity (SigningKey ByronKey) -> Gen (KeyWitness era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AsType ByronKey -> GenT Identity (SigningKey ByronKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType ByronKey
AsByronKey

genShelleyKeyWitness
  :: IsShelleyBasedEra era
  => CardanoEra era
  -> Gen (KeyWitness era)
genShelleyKeyWitness :: CardanoEra era -> Gen (KeyWitness era)
genShelleyKeyWitness CardanoEra era
era =
  TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era
forall era.
IsShelleyBasedEra era =>
TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era
makeShelleyKeyWitness
    (TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era)
-> GenT Identity (TxBody era)
-> GenT Identity (ShelleyWitnessSigningKey -> KeyWitness era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> GenT Identity (TxBody era)
forall era. IsCardanoEra era => CardanoEra era -> Gen (TxBody era)
genTxBody CardanoEra era
era
    GenT Identity (ShelleyWitnessSigningKey -> KeyWitness era)
-> GenT Identity ShelleyWitnessSigningKey -> Gen (KeyWitness era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity ShelleyWitnessSigningKey
genShelleyWitnessSigningKey

genShelleyWitness
  :: IsShelleyBasedEra era
  => CardanoEra era
  -> Gen (KeyWitness era)
genShelleyWitness :: CardanoEra era -> Gen (KeyWitness era)
genShelleyWitness CardanoEra era
era =
  [Gen (KeyWitness era)] -> Gen (KeyWitness era)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
   [ CardanoEra era -> Gen (KeyWitness era)
forall era.
IsShelleyBasedEra era =>
CardanoEra era -> Gen (KeyWitness era)
genShelleyKeyWitness CardanoEra era
era
   , CardanoEra era -> Gen (KeyWitness era)
forall era.
IsShelleyBasedEra era =>
CardanoEra era -> Gen (KeyWitness era)
genShelleyBootstrapWitness CardanoEra era
era
   ]

genShelleyWitnessSigningKey :: Gen ShelleyWitnessSigningKey
genShelleyWitnessSigningKey :: GenT Identity ShelleyWitnessSigningKey
genShelleyWitnessSigningKey =
  [GenT Identity ShelleyWitnessSigningKey]
-> GenT Identity ShelleyWitnessSigningKey
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice [ SigningKey PaymentKey -> ShelleyWitnessSigningKey
WitnessPaymentKey (SigningKey PaymentKey -> ShelleyWitnessSigningKey)
-> GenT Identity (SigningKey PaymentKey)
-> GenT Identity ShelleyWitnessSigningKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  AsType PaymentKey -> GenT Identity (SigningKey PaymentKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType PaymentKey
AsPaymentKey
             , SigningKey PaymentExtendedKey -> ShelleyWitnessSigningKey
WitnessPaymentExtendedKey (SigningKey PaymentExtendedKey -> ShelleyWitnessSigningKey)
-> GenT Identity (SigningKey PaymentExtendedKey)
-> GenT Identity ShelleyWitnessSigningKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  AsType PaymentExtendedKey
-> GenT Identity (SigningKey PaymentExtendedKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType PaymentExtendedKey
AsPaymentExtendedKey
             , SigningKey StakeKey -> ShelleyWitnessSigningKey
WitnessStakeKey (SigningKey StakeKey -> ShelleyWitnessSigningKey)
-> GenT Identity (SigningKey StakeKey)
-> GenT Identity ShelleyWitnessSigningKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  AsType StakeKey -> GenT Identity (SigningKey StakeKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType StakeKey
AsStakeKey
             , SigningKey StakePoolKey -> ShelleyWitnessSigningKey
WitnessStakePoolKey (SigningKey StakePoolKey -> ShelleyWitnessSigningKey)
-> GenT Identity (SigningKey StakePoolKey)
-> GenT Identity ShelleyWitnessSigningKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  AsType StakePoolKey -> GenT Identity (SigningKey StakePoolKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType StakePoolKey
AsStakePoolKey
             , SigningKey GenesisDelegateKey -> ShelleyWitnessSigningKey
WitnessGenesisDelegateKey (SigningKey GenesisDelegateKey -> ShelleyWitnessSigningKey)
-> GenT Identity (SigningKey GenesisDelegateKey)
-> GenT Identity ShelleyWitnessSigningKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  AsType GenesisDelegateKey
-> GenT Identity (SigningKey GenesisDelegateKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType GenesisDelegateKey
AsGenesisDelegateKey
             , SigningKey GenesisUTxOKey -> ShelleyWitnessSigningKey
WitnessGenesisUTxOKey (SigningKey GenesisUTxOKey -> ShelleyWitnessSigningKey)
-> GenT Identity (SigningKey GenesisUTxOKey)
-> GenT Identity ShelleyWitnessSigningKey
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>  AsType GenesisUTxOKey -> GenT Identity (SigningKey GenesisUTxOKey)
forall keyrole.
Key keyrole =>
AsType keyrole -> Gen (SigningKey keyrole)
genSigningKey AsType GenesisUTxOKey
AsGenesisUTxOKey
             ]

genSeed :: Int -> Gen Crypto.Seed
genSeed :: Int -> Gen Seed
genSeed Int
n = ByteString -> Seed
Crypto.mkSeedFromBytes (ByteString -> Seed) -> GenT Identity ByteString -> Gen Seed
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity ByteString
forall (m :: * -> *). MonadGen m => Range Int -> m ByteString
Gen.bytes (Int -> Range Int
forall a. a -> Range a
Range.singleton Int
n)

genNat :: Gen Natural
genNat :: Gen Natural
genNat = Range Natural -> Gen Natural
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Natural -> Natural -> Range Natural
forall a. Integral a => a -> a -> Range a
Range.linear Natural
0 Natural
10)

genRational :: Gen Rational
genRational :: Gen Rational
genRational =
    (\Word64
d -> Ratio Word64 -> Rational
ratioToRational (Word64
1 Word64 -> Word64 -> Ratio Word64
forall a. Integral a => a -> a -> Ratio a
% Word64
d)) (Word64 -> Rational) -> GenT Identity Word64 -> Gen Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity Word64
genDenominator
  where
    genDenominator :: Gen Word64
    genDenominator :: GenT Identity Word64
genDenominator = Range Word64 -> GenT Identity Word64
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Word64 -> Word64 -> Range Word64
forall a. Integral a => a -> a -> Range a
Range.linear Word64
1 Word64
forall a. Bounded a => a
maxBound)

    ratioToRational :: Ratio Word64 -> Rational
    ratioToRational :: Ratio Word64 -> Rational
ratioToRational = Ratio Word64 -> Rational
forall a. Real a => a -> Rational
toRational

-- TODO: consolidate this back to just genRational once this is merged:
-- https://github.com/input-output-hk/cardano-ledger-specs/pull/2330
genRationalInt64 :: Gen Rational
genRationalInt64 :: Gen Rational
genRationalInt64 =
    (\Int64
d -> Ratio Int64 -> Rational
ratioToRational (Int64
1 Int64 -> Int64 -> Ratio Int64
forall a. Integral a => a -> a -> Ratio a
% Int64
d)) (Int64 -> Rational) -> GenT Identity Int64 -> Gen Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity Int64
genDenominator
  where
    genDenominator :: Gen Int64
    genDenominator :: GenT Identity Int64
genDenominator = Range Int64 -> GenT Identity Int64
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Int64 -> Int64 -> Range Int64
forall a. Integral a => a -> a -> Range a
Range.linear Int64
1 Int64
forall a. Bounded a => a
maxBound)

    ratioToRational :: Ratio Int64 -> Rational
    ratioToRational :: Ratio Int64 -> Rational
ratioToRational = Ratio Int64 -> Rational
forall a. Real a => a -> Rational
toRational

genEpochNo :: Gen EpochNo
genEpochNo :: Gen EpochNo
genEpochNo = Word64 -> EpochNo
EpochNo (Word64 -> EpochNo) -> GenT Identity Word64 -> Gen EpochNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Word64 -> GenT Identity Word64
forall (m :: * -> *). MonadGen m => Range Word64 -> m Word64
Gen.word64 (Word64 -> Word64 -> Range Word64
forall a. Integral a => a -> a -> Range a
Range.linear Word64
0 Word64
10)

genPraosNonce :: Gen PraosNonce
genPraosNonce :: Gen PraosNonce
genPraosNonce = ByteString -> PraosNonce
makePraosNonce (ByteString -> PraosNonce)
-> GenT Identity ByteString -> Gen PraosNonce
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity ByteString
forall (m :: * -> *). MonadGen m => Range Int -> m ByteString
Gen.bytes (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
32)

genMaybePraosNonce :: Gen (Maybe PraosNonce)
genMaybePraosNonce :: Gen (Maybe PraosNonce)
genMaybePraosNonce = Gen PraosNonce -> Gen (Maybe PraosNonce)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen PraosNonce
genPraosNonce

genProtocolParameters :: Gen ProtocolParameters
genProtocolParameters :: GenT Identity ProtocolParameters
genProtocolParameters =
  (Natural, Natural)
-> Maybe Rational
-> Maybe PraosNonce
-> Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Maybe Lovelace
-> Lovelace
-> Lovelace
-> Lovelace
-> EpochNo
-> Natural
-> Rational
-> Rational
-> Rational
-> Maybe Lovelace
-> Map AnyPlutusScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Lovelace
-> ProtocolParameters
ProtocolParameters
    ((Natural, Natural)
 -> Maybe Rational
 -> Maybe PraosNonce
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Natural
 -> Maybe Lovelace
 -> Lovelace
 -> Lovelace
 -> Lovelace
 -> EpochNo
 -> Natural
 -> Rational
 -> Rational
 -> Rational
 -> Maybe Lovelace
 -> Map AnyPlutusScriptVersion CostModel
 -> Maybe ExecutionUnitPrices
 -> Maybe ExecutionUnits
 -> Maybe ExecutionUnits
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Lovelace
 -> ProtocolParameters)
-> GenT Identity (Natural, Natural)
-> GenT
     Identity
     (Maybe Rational
      -> Maybe PraosNonce
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (Natural -> Natural -> (Natural, Natural))
-> Gen Natural -> GenT Identity (Natural -> (Natural, Natural))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Natural
genNat GenT Identity (Natural -> (Natural, Natural))
-> Gen Natural -> GenT Identity (Natural, Natural)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat)
    GenT
  Identity
  (Maybe Rational
   -> Maybe PraosNonce
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe Rational)
-> GenT
     Identity
     (Maybe PraosNonce
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Rational -> GenT Identity (Maybe Rational)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Rational
genRational
    GenT
  Identity
  (Maybe PraosNonce
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen (Maybe PraosNonce)
-> GenT
     Identity
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe PraosNonce)
genMaybePraosNonce
    GenT
  Identity
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Natural
-> GenT
     Identity
     (Natural
      -> Natural
      -> Natural
      -> Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat
    GenT
  Identity
  (Natural
   -> Natural
   -> Natural
   -> Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Natural
-> GenT
     Identity
     (Natural
      -> Natural
      -> Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat
    GenT
  Identity
  (Natural
   -> Natural
   -> Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Natural
-> GenT
     Identity
     (Natural
      -> Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat
    GenT
  Identity
  (Natural
   -> Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Natural
-> GenT
     Identity
     (Natural
      -> Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat
    GenT
  Identity
  (Natural
   -> Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Natural
-> GenT
     Identity
     (Maybe Lovelace
      -> Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat
    GenT
  Identity
  (Maybe Lovelace
   -> Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe Lovelace)
-> GenT
     Identity
     (Lovelace
      -> Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
    GenT
  Identity
  (Lovelace
   -> Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Lovelace
-> GenT
     Identity
     (Lovelace
      -> Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Lovelace
genLovelace
    GenT
  Identity
  (Lovelace
   -> Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Lovelace
-> GenT
     Identity
     (Lovelace
      -> EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Lovelace
genLovelace
    GenT
  Identity
  (Lovelace
   -> EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Lovelace
-> GenT
     Identity
     (EpochNo
      -> Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Lovelace
genLovelace
    GenT
  Identity
  (EpochNo
   -> Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen EpochNo
-> GenT
     Identity
     (Natural
      -> Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen EpochNo
genEpochNo
    GenT
  Identity
  (Natural
   -> Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Natural
-> GenT
     Identity
     (Rational
      -> Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat
    GenT
  Identity
  (Rational
   -> Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Rational
-> GenT
     Identity
     (Rational
      -> Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Rational
genRationalInt64
    GenT
  Identity
  (Rational
   -> Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Rational
-> GenT
     Identity
     (Rational
      -> Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Rational
genRational
    GenT
  Identity
  (Rational
   -> Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> Gen Rational
-> GenT
     Identity
     (Maybe Lovelace
      -> Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Rational
genRational
    GenT
  Identity
  (Maybe Lovelace
   -> Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe Lovelace)
-> GenT
     Identity
     (Map AnyPlutusScriptVersion CostModel
      -> Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
    GenT
  Identity
  (Map AnyPlutusScriptVersion CostModel
   -> Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Map AnyPlutusScriptVersion CostModel)
-> GenT
     Identity
     (Maybe ExecutionUnitPrices
      -> Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Map AnyPlutusScriptVersion CostModel
-> GenT Identity (Map AnyPlutusScriptVersion CostModel)
forall (m :: * -> *) a. Monad m => a -> m a
return Map AnyPlutusScriptVersion CostModel
forall a. Monoid a => a
mempty
    --TODO: Babbage figure out how to deal with
    -- asymmetric cost model JSON instances
    GenT
  Identity
  (Maybe ExecutionUnitPrices
   -> Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe ExecutionUnitPrices)
-> GenT
     Identity
     (Maybe ExecutionUnits
      -> Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity ExecutionUnitPrices
-> GenT Identity (Maybe ExecutionUnitPrices)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ExecutionUnitPrices
genExecutionUnitPrices
    GenT
  Identity
  (Maybe ExecutionUnits
   -> Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe ExecutionUnits)
-> GenT
     Identity
     (Maybe ExecutionUnits
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity ExecutionUnits
-> GenT Identity (Maybe ExecutionUnits)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ExecutionUnits
genExecutionUnits
    GenT
  Identity
  (Maybe ExecutionUnits
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe ExecutionUnits)
-> GenT
     Identity
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> GenT Identity ExecutionUnits
-> GenT Identity (Maybe ExecutionUnits)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ExecutionUnits
genExecutionUnits
    GenT
  Identity
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> ProtocolParameters)
-> GenT Identity (Maybe Natural)
-> GenT
     Identity
     (Maybe Natural
      -> Maybe Natural -> Maybe Lovelace -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
    GenT
  Identity
  (Maybe Natural
   -> Maybe Natural -> Maybe Lovelace -> ProtocolParameters)
-> GenT Identity (Maybe Natural)
-> GenT
     Identity (Maybe Natural -> Maybe Lovelace -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
    GenT
  Identity (Maybe Natural -> Maybe Lovelace -> ProtocolParameters)
-> GenT Identity (Maybe Natural)
-> GenT Identity (Maybe Lovelace -> ProtocolParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
    GenT Identity (Maybe Lovelace -> ProtocolParameters)
-> GenT Identity (Maybe Lovelace)
-> GenT Identity ProtocolParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace

genProtocolParametersUpdate :: Gen ProtocolParametersUpdate
genProtocolParametersUpdate :: Gen ProtocolParametersUpdate
genProtocolParametersUpdate = do
  Maybe (Natural, Natural)
protocolUpdateProtocolVersion     <- GenT Identity (Natural, Natural)
-> GenT Identity (Maybe (Natural, Natural))
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe ((,) (Natural -> Natural -> (Natural, Natural))
-> Gen Natural -> GenT Identity (Natural -> (Natural, Natural))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Natural
genNat GenT Identity (Natural -> (Natural, Natural))
-> Gen Natural -> GenT Identity (Natural, Natural)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Natural
genNat)
  Maybe Rational
protocolUpdateDecentralization    <- Gen Rational -> GenT Identity (Maybe Rational)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Rational
genRational
  Maybe (Maybe PraosNonce)
protocolUpdateExtraPraosEntropy   <- Gen (Maybe PraosNonce) -> GenT Identity (Maybe (Maybe PraosNonce))
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen (Maybe PraosNonce)
genMaybePraosNonce
  Maybe Natural
protocolUpdateMaxBlockHeaderSize  <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Natural
protocolUpdateMaxBlockBodySize    <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Natural
protocolUpdateMaxTxSize           <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Natural
protocolUpdateTxFeeFixed          <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Natural
protocolUpdateTxFeePerByte        <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Lovelace
protocolUpdateMinUTxOValue        <- Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
  Maybe Lovelace
protocolUpdateStakeAddressDeposit <- Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
  Maybe Lovelace
protocolUpdateStakePoolDeposit    <- Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
  Maybe Lovelace
protocolUpdateMinPoolCost         <- Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
  Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch  <- Gen EpochNo -> GenT Identity (Maybe EpochNo)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen EpochNo
genEpochNo
  Maybe Natural
protocolUpdateStakePoolTargetNum  <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Rational
protocolUpdatePoolPledgeInfluence <- Gen Rational -> GenT Identity (Maybe Rational)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Rational
genRationalInt64
  Maybe Rational
protocolUpdateMonetaryExpansion   <- Gen Rational -> GenT Identity (Maybe Rational)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Rational
genRational
  Maybe Rational
protocolUpdateTreasuryCut         <- Gen Rational -> GenT Identity (Maybe Rational)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Rational
genRational
  Maybe Lovelace
protocolUpdateUTxOCostPerWord     <- Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
  let protocolUpdateCostModels :: Map AnyPlutusScriptVersion CostModel
protocolUpdateCostModels = Map AnyPlutusScriptVersion CostModel
forall a. Monoid a => a
mempty -- genCostModels
  --TODO: Babbage figure out how to deal with
  -- asymmetric cost model JSON instances
  Maybe ExecutionUnitPrices
protocolUpdatePrices              <- GenT Identity ExecutionUnitPrices
-> GenT Identity (Maybe ExecutionUnitPrices)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ExecutionUnitPrices
genExecutionUnitPrices
  Maybe ExecutionUnits
protocolUpdateMaxTxExUnits        <- GenT Identity ExecutionUnits
-> GenT Identity (Maybe ExecutionUnits)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ExecutionUnits
genExecutionUnits
  Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits     <- GenT Identity ExecutionUnits
-> GenT Identity (Maybe ExecutionUnits)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe GenT Identity ExecutionUnits
genExecutionUnits
  Maybe Natural
protocolUpdateMaxValueSize        <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Natural
protocolUpdateCollateralPercent   <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Natural
protocolUpdateMaxCollateralInputs <- Gen Natural -> GenT Identity (Maybe Natural)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Natural
genNat
  Maybe Lovelace
protocolUpdateUTxOCostPerByte     <- Gen Lovelace -> GenT Identity (Maybe Lovelace)
forall (m :: * -> *) a. MonadGen m => m a -> m (Maybe a)
Gen.maybe Gen Lovelace
genLovelace
  ProtocolParametersUpdate -> Gen ProtocolParametersUpdate
forall (f :: * -> *) a. Applicative f => a -> f a
pure ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe PraosNonce)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> Maybe Lovelace
-> Map AnyPlutusScriptVersion CostModel
-> Maybe ExecutionUnitPrices
-> Maybe ExecutionUnits
-> Maybe ExecutionUnits
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Lovelace
-> ProtocolParametersUpdate
ProtocolParametersUpdate{Maybe Natural
Maybe (Maybe PraosNonce)
Maybe Rational
Maybe (Natural, Natural)
Maybe ExecutionUnitPrices
Maybe Lovelace
Maybe ExecutionUnits
Maybe EpochNo
Map AnyPlutusScriptVersion CostModel
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateExtraPraosEntropy :: Maybe (Maybe PraosNonce)
protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateMinUTxOValue :: Maybe Lovelace
protocolUpdateStakeAddressDeposit :: Maybe Lovelace
protocolUpdateStakePoolDeposit :: Maybe Lovelace
protocolUpdateMinPoolCost :: Maybe Lovelace
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateUTxOCostPerWord :: Maybe Lovelace
protocolUpdateCostModels :: Map AnyPlutusScriptVersion CostModel
protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateUTxOCostPerByte :: Maybe Lovelace
protocolUpdateUTxOCostPerByte :: Maybe Lovelace
protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdateCostModels :: Map AnyPlutusScriptVersion CostModel
protocolUpdateUTxOCostPerWord :: Maybe Lovelace
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdateMinPoolCost :: Maybe Lovelace
protocolUpdateStakePoolDeposit :: Maybe Lovelace
protocolUpdateStakeAddressDeposit :: Maybe Lovelace
protocolUpdateMinUTxOValue :: Maybe Lovelace
protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateExtraPraosEntropy :: Maybe (Maybe PraosNonce)
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
..}


genUpdateProposal :: Gen UpdateProposal
genUpdateProposal :: GenT Identity UpdateProposal
genUpdateProposal =
  Map (Hash GenesisKey) ProtocolParametersUpdate
-> EpochNo -> UpdateProposal
UpdateProposal
    (Map (Hash GenesisKey) ProtocolParametersUpdate
 -> EpochNo -> UpdateProposal)
-> GenT Identity (Map (Hash GenesisKey) ProtocolParametersUpdate)
-> GenT Identity (EpochNo -> UpdateProposal)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int
-> GenT Identity (Hash GenesisKey, ProtocolParametersUpdate)
-> GenT Identity (Map (Hash GenesisKey) ProtocolParametersUpdate)
forall (m :: * -> *) k v.
(MonadGen m, Ord k) =>
Range Int -> m (k, v) -> m (Map k v)
Gen.map (Int -> Int -> Range Int
forall a. a -> a -> Range a
Range.constant Int
1 Int
3)
                ((,) (Hash GenesisKey
 -> ProtocolParametersUpdate
 -> (Hash GenesisKey, ProtocolParametersUpdate))
-> GenT Identity (Hash GenesisKey)
-> GenT
     Identity
     (ProtocolParametersUpdate
      -> (Hash GenesisKey, ProtocolParametersUpdate))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType GenesisKey -> GenT Identity (Hash GenesisKey)
forall keyrole. Key keyrole => AsType keyrole -> Gen (Hash keyrole)
genVerificationKeyHash AsType GenesisKey
AsGenesisKey
                     GenT
  Identity
  (ProtocolParametersUpdate
   -> (Hash GenesisKey, ProtocolParametersUpdate))
-> Gen ProtocolParametersUpdate
-> GenT Identity (Hash GenesisKey, ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen ProtocolParametersUpdate
genProtocolParametersUpdate)
    GenT Identity (EpochNo -> UpdateProposal)
-> Gen EpochNo -> GenT Identity UpdateProposal
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen EpochNo
genEpochNo

genCostModel :: Gen CostModel
genCostModel :: Gen CostModel
genCostModel = case Maybe CostModelParams
Plutus.defaultCostModelParams of
  Maybe CostModelParams
Nothing -> Text -> Gen CostModel
forall a. HasCallStack => Text -> a
panic Text
"Plutus defaultCostModelParams is broken."
  Just CostModelParams
dcm -> do
      Either CostModelApplyError CostModel
eCostModel <- Language -> CostModelParams -> Either CostModelApplyError CostModel
Alonzo.mkCostModel (Language
 -> CostModelParams -> Either CostModelApplyError CostModel)
-> GenT Identity Language
-> GenT
     Identity (CostModelParams -> Either CostModelApplyError CostModel)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity Language
genPlutusLanguage
                                       GenT
  Identity (CostModelParams -> Either CostModelApplyError CostModel)
-> GenT Identity CostModelParams
-> GenT Identity (Either CostModelApplyError CostModel)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Integer -> GenT Identity Integer)
-> CostModelParams -> GenT Identity CostModelParams
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (GenT Identity Integer -> Integer -> GenT Identity Integer
forall a b. a -> b -> a
const (GenT Identity Integer -> Integer -> GenT Identity Integer)
-> GenT Identity Integer -> Integer -> GenT Identity Integer
forall a b. (a -> b) -> a -> b
$ Range Integer -> GenT Identity Integer
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Integer -> Integer -> Range Integer
forall a. Integral a => a -> a -> Range a
Range.linear Integer
0 Integer
5000)) CostModelParams
dcm
      case Either CostModelApplyError CostModel
eCostModel of
        Left CostModelApplyError
err -> Text -> Gen CostModel
forall a. HasCallStack => Text -> a
panic (Text -> Gen CostModel) -> Text -> Gen CostModel
forall a b. (a -> b) -> a -> b
$ String -> Text
Text.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ String
"genCostModel: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> CostModelApplyError -> String
forall a b. (Show a, ConvertText String b) => a -> b
show CostModelApplyError
err
        Right CostModel
cModel -> CostModel -> Gen CostModel
forall (m :: * -> *) a. Monad m => a -> m a
return (CostModel -> Gen CostModel)
-> (CostModelParams -> CostModel)
-> CostModelParams
-> Gen CostModel
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. CostModelParams -> CostModel
CostModel (CostModelParams -> Gen CostModel)
-> CostModelParams -> Gen CostModel
forall a b. (a -> b) -> a -> b
$ CostModel -> CostModelParams
Alonzo.getCostModelParams CostModel
cModel

genPlutusLanguage :: Gen Language
genPlutusLanguage :: GenT Identity Language
genPlutusLanguage = [Language] -> GenT Identity Language
forall (m :: * -> *) a. MonadGen m => [a] -> m a
Gen.element [Language
PlutusV1, Language
PlutusV2]

_genCostModels :: Gen (Map AnyPlutusScriptVersion CostModel)
_genCostModels :: GenT Identity (Map AnyPlutusScriptVersion CostModel)
_genCostModels =
    Range Int
-> GenT Identity (AnyPlutusScriptVersion, CostModel)
-> GenT Identity (Map AnyPlutusScriptVersion CostModel)
forall (m :: * -> *) k v.
(MonadGen m, Ord k) =>
Range Int -> m (k, v) -> m (Map k v)
Gen.map (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 ([AnyPlutusScriptVersion] -> Int
forall a. HasLength a => a -> Int
length [AnyPlutusScriptVersion]
plutusScriptVersions))
            ((,) (AnyPlutusScriptVersion
 -> CostModel -> (AnyPlutusScriptVersion, CostModel))
-> GenT Identity AnyPlutusScriptVersion
-> GenT Identity (CostModel -> (AnyPlutusScriptVersion, CostModel))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [AnyPlutusScriptVersion] -> GenT Identity AnyPlutusScriptVersion
forall (m :: * -> *) a. MonadGen m => [a] -> m a
Gen.element [AnyPlutusScriptVersion]
plutusScriptVersions
                 GenT Identity (CostModel -> (AnyPlutusScriptVersion, CostModel))
-> Gen CostModel
-> GenT Identity (AnyPlutusScriptVersion, CostModel)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen CostModel
genCostModel)
  where
    plutusScriptVersions :: [AnyPlutusScriptVersion]
    plutusScriptVersions :: [AnyPlutusScriptVersion]
plutusScriptVersions = [AnyPlutusScriptVersion
forall a. Bounded a => a
minBound..AnyPlutusScriptVersion
forall a. Bounded a => a
maxBound]

genExecutionUnits :: Gen ExecutionUnits
genExecutionUnits :: GenT Identity ExecutionUnits
genExecutionUnits = Natural -> Natural -> ExecutionUnits
ExecutionUnits (Natural -> Natural -> ExecutionUnits)
-> Gen Natural -> GenT Identity (Natural -> ExecutionUnits)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Natural -> Gen Natural
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Natural -> Natural -> Range Natural
forall a. a -> a -> Range a
Range.constant Natural
0 Natural
1000)
                                   GenT Identity (Natural -> ExecutionUnits)
-> Gen Natural -> GenT Identity ExecutionUnits
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Range Natural -> Gen Natural
forall (m :: * -> *) a. (MonadGen m, Integral a) => Range a -> m a
Gen.integral (Natural -> Natural -> Range Natural
forall a. a -> a -> Range a
Range.constant Natural
0 Natural
1000)

genExecutionUnitPrices :: Gen ExecutionUnitPrices
genExecutionUnitPrices :: GenT Identity ExecutionUnitPrices
genExecutionUnitPrices = Rational -> Rational -> ExecutionUnitPrices
ExecutionUnitPrices (Rational -> Rational -> ExecutionUnitPrices)
-> Gen Rational -> GenT Identity (Rational -> ExecutionUnitPrices)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Rational
genRational GenT Identity (Rational -> ExecutionUnitPrices)
-> Gen Rational -> GenT Identity ExecutionUnitPrices
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Rational
genRational

genTxOutDatumHashTxContext :: CardanoEra era -> Gen (TxOutDatum CtxTx era)
genTxOutDatumHashTxContext :: CardanoEra era -> Gen (TxOutDatum CtxTx era)
genTxOutDatumHashTxContext CardanoEra era
era = case CardanoEra era
era of
    CardanoEra era
ByronEra   -> TxOutDatum CtxTx era -> Gen (TxOutDatum CtxTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
ShelleyEra -> TxOutDatum CtxTx era -> Gen (TxOutDatum CtxTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
AllegraEra -> TxOutDatum CtxTx era -> Gen (TxOutDatum CtxTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
MaryEra    -> TxOutDatum CtxTx era -> Gen (TxOutDatum CtxTx era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
AlonzoEra  -> [GenT Identity (TxOutDatum CtxTx AlonzoEra)]
-> GenT Identity (TxOutDatum CtxTx AlonzoEra)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
                    [ TxOutDatum CtxTx AlonzoEra
-> GenT Identity (TxOutDatum CtxTx AlonzoEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxTx AlonzoEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
                    , ScriptDataSupportedInEra AlonzoEra
-> Hash ScriptData -> TxOutDatum CtxTx AlonzoEra
forall era ctx.
ScriptDataSupportedInEra era
-> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash ScriptDataSupportedInEra AlonzoEra
ScriptDataInAlonzoEra (Hash ScriptData -> TxOutDatum CtxTx AlonzoEra)
-> GenT Identity (Hash ScriptData)
-> GenT Identity (TxOutDatum CtxTx AlonzoEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity (Hash ScriptData)
genHashScriptData
                    , ScriptDataSupportedInEra AlonzoEra
-> ScriptData -> TxOutDatum CtxTx AlonzoEra
forall era.
ScriptDataSupportedInEra era -> ScriptData -> TxOutDatum CtxTx era
TxOutDatumInTx ScriptDataSupportedInEra AlonzoEra
ScriptDataInAlonzoEra (ScriptData -> TxOutDatum CtxTx AlonzoEra)
-> Gen ScriptData -> GenT Identity (TxOutDatum CtxTx AlonzoEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptData
genScriptData
                    ]
    CardanoEra era
BabbageEra -> [GenT Identity (TxOutDatum CtxTx BabbageEra)]
-> GenT Identity (TxOutDatum CtxTx BabbageEra)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
                    [ TxOutDatum CtxTx BabbageEra
-> GenT Identity (TxOutDatum CtxTx BabbageEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxTx BabbageEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
                    , ScriptDataSupportedInEra BabbageEra
-> Hash ScriptData -> TxOutDatum CtxTx BabbageEra
forall era ctx.
ScriptDataSupportedInEra era
-> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash ScriptDataSupportedInEra BabbageEra
ScriptDataInBabbageEra (Hash ScriptData -> TxOutDatum CtxTx BabbageEra)
-> GenT Identity (Hash ScriptData)
-> GenT Identity (TxOutDatum CtxTx BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity (Hash ScriptData)
genHashScriptData
                    , ScriptDataSupportedInEra BabbageEra
-> ScriptData -> TxOutDatum CtxTx BabbageEra
forall era.
ScriptDataSupportedInEra era -> ScriptData -> TxOutDatum CtxTx era
TxOutDatumInTx ScriptDataSupportedInEra BabbageEra
ScriptDataInBabbageEra (ScriptData -> TxOutDatum CtxTx BabbageEra)
-> Gen ScriptData -> GenT Identity (TxOutDatum CtxTx BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptData
genScriptData
                    , ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
-> ScriptData -> TxOutDatum CtxTx BabbageEra
forall era ctx.
ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> ScriptData -> TxOutDatum ctx era
TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptData -> TxOutDatum CtxTx BabbageEra)
-> Gen ScriptData -> GenT Identity (TxOutDatum CtxTx BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptData
genScriptData
                    ]

genTxOutDatumHashUTxOContext :: CardanoEra era -> Gen (TxOutDatum CtxUTxO era)
genTxOutDatumHashUTxOContext :: CardanoEra era -> Gen (TxOutDatum CtxUTxO era)
genTxOutDatumHashUTxOContext CardanoEra era
era = case CardanoEra era
era of
    CardanoEra era
ByronEra   -> TxOutDatum CtxUTxO era -> Gen (TxOutDatum CtxUTxO era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
ShelleyEra -> TxOutDatum CtxUTxO era -> Gen (TxOutDatum CtxUTxO era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
AllegraEra -> TxOutDatum CtxUTxO era -> Gen (TxOutDatum CtxUTxO era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
MaryEra    -> TxOutDatum CtxUTxO era -> Gen (TxOutDatum CtxUTxO era)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
    CardanoEra era
AlonzoEra  -> [GenT Identity (TxOutDatum CtxUTxO AlonzoEra)]
-> GenT Identity (TxOutDatum CtxUTxO AlonzoEra)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
                    [ TxOutDatum CtxUTxO AlonzoEra
-> GenT Identity (TxOutDatum CtxUTxO AlonzoEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxUTxO AlonzoEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
                    , ScriptDataSupportedInEra AlonzoEra
-> Hash ScriptData -> TxOutDatum CtxUTxO AlonzoEra
forall era ctx.
ScriptDataSupportedInEra era
-> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash ScriptDataSupportedInEra AlonzoEra
ScriptDataInAlonzoEra (Hash ScriptData -> TxOutDatum CtxUTxO AlonzoEra)
-> GenT Identity (Hash ScriptData)
-> GenT Identity (TxOutDatum CtxUTxO AlonzoEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity (Hash ScriptData)
genHashScriptData
                    ]
    CardanoEra era
BabbageEra -> [GenT Identity (TxOutDatum CtxUTxO BabbageEra)]
-> GenT Identity (TxOutDatum CtxUTxO BabbageEra)
forall (m :: * -> *) a. MonadGen m => [m a] -> m a
Gen.choice
                    [ TxOutDatum CtxUTxO BabbageEra
-> GenT Identity (TxOutDatum CtxUTxO BabbageEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatum CtxUTxO BabbageEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
                    , ScriptDataSupportedInEra BabbageEra
-> Hash ScriptData -> TxOutDatum CtxUTxO BabbageEra
forall era ctx.
ScriptDataSupportedInEra era
-> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash ScriptDataSupportedInEra BabbageEra
ScriptDataInBabbageEra (Hash ScriptData -> TxOutDatum CtxUTxO BabbageEra)
-> GenT Identity (Hash ScriptData)
-> GenT Identity (TxOutDatum CtxUTxO BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenT Identity (Hash ScriptData)
genHashScriptData
                    , ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
-> ScriptData -> TxOutDatum CtxUTxO BabbageEra
forall era ctx.
ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> ScriptData -> TxOutDatum ctx era
TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptData -> TxOutDatum CtxUTxO BabbageEra)
-> Gen ScriptData -> GenT Identity (TxOutDatum CtxUTxO BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptData
genScriptData
                    ]

mkDummyHash :: forall h a. CRYPTO.HashAlgorithm h => Int -> CRYPTO.Hash h a
mkDummyHash :: Int -> Hash h a
mkDummyHash = Hash h Int -> Hash h a
coerce (Hash h Int -> Hash h a) -> (Int -> Hash h Int) -> Int -> Hash h a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Int -> Encoding) -> Int -> Hash h Int
forall h a. HashAlgorithm h => (a -> Encoding) -> a -> Hash h a
CRYPTO.hashWithSerialiser @h Int -> Encoding
forall a. ToCBOR a => a -> Encoding
CBOR.toCBOR

genHashScriptData :: Gen (Cardano.Api.Hash ScriptData)
genHashScriptData :: GenT Identity (Hash ScriptData)
genHashScriptData = DataHash StandardCrypto -> Hash ScriptData
ScriptDataHash (DataHash StandardCrypto -> Hash ScriptData)
-> (Int -> DataHash StandardCrypto) -> Int -> Hash ScriptData
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Hash Blake2b_256 EraIndependentData -> DataHash StandardCrypto
forall crypto index.
Hash (HASH crypto) index -> SafeHash crypto index
unsafeMakeSafeHash (Hash Blake2b_256 EraIndependentData -> DataHash StandardCrypto)
-> (Int -> Hash Blake2b_256 EraIndependentData)
-> Int
-> DataHash StandardCrypto
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Int -> Hash Blake2b_256 EraIndependentData
forall h a. HashAlgorithm h => Int -> Hash h a
mkDummyHash (Int -> Hash ScriptData)
-> GenT Identity Int -> GenT Identity (Hash ScriptData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Range Int -> GenT Identity Int
forall (m :: * -> *). MonadGen m => Range Int -> m Int
Gen.int (Int -> Int -> Range Int
forall a. Integral a => a -> a -> Range a
Range.linear Int
0 Int
10)

genScriptDataSupportedInAlonzoEra :: Gen (ScriptDataSupportedInEra AlonzoEra)
genScriptDataSupportedInAlonzoEra :: Gen (ScriptDataSupportedInEra AlonzoEra)
genScriptDataSupportedInAlonzoEra = ScriptDataSupportedInEra AlonzoEra
-> Gen (ScriptDataSupportedInEra AlonzoEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScriptDataSupportedInEra AlonzoEra
ScriptDataInAlonzoEra