{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

module Test.Cardano.Ledger.Mary.Examples.Consensus where

import Cardano.Ledger.Coin
import Cardano.Ledger.Crypto
import Cardano.Ledger.Genesis (NoGenesis (..))
import Cardano.Ledger.Mary (Mary)
import Cardano.Ledger.Mary.Core
import Cardano.Ledger.Mary.Value
import qualified Data.Map.Strict as Map (singleton)
import Data.Proxy
import Lens.Micro
import Test.Cardano.Ledger.Allegra.Examples.Consensus
import Test.Cardano.Ledger.MaryEraGen ()
import Test.Cardano.Ledger.Shelley.Examples.Consensus

-- | ShelleyLedgerExamples for Allegra era
ledgerExamplesMary :: ShelleyLedgerExamples Mary
ledgerExamplesMary :: ShelleyLedgerExamples Mary
ledgerExamplesMary =
  forall era.
(ShelleyBasedEra' era, EraSegWits era, EraGov era,
 PredicateFailure (EraRule "DELEGS" era)
 ~ ShelleyDelegsPredFailure era,
 PredicateFailure (EraRule "LEDGER" era)
 ~ ShelleyLedgerPredFailure era,
 Default (StashedAVVMAddresses era), ProtVerAtMost era 4) =>
(TxBody era -> KeyPairWits era -> TxWits era)
-> (ShelleyTx era -> Tx era)
-> Value era
-> TxBody era
-> TxAuxData era
-> TranslationContext era
-> ShelleyLedgerExamples era
defaultShelleyLedgerExamples
    (forall era.
(EraTx era,
 Signable
   (DSIGN (EraCrypto era))
   (Hash (HASH (EraCrypto era)) EraIndependentTxBody)) =>
Proxy era -> TxBody era -> KeyPairWits era -> ShelleyTxWits era
mkWitnessesPreAlonzo (forall {k} (t :: k). Proxy t
Proxy @Mary))
    forall a. a -> a
id
    (forall c. Crypto c => Int -> MaryValue c
exampleMultiAssetValue Int
1)
    ((forall era.
(AllegraEraTxBody era, ShelleyEraTxBody era) =>
Value era -> TxBody era
exampleAllegraTxBody (forall c. Crypto c => Int -> MaryValue c
exampleMultiAssetValue Int
1)) forall a b. a -> (a -> b) -> b
& forall era.
MaryEraTxBody era =>
Lens' (TxBody era) (MultiAsset (EraCrypto era))
mintTxBodyL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall c. Crypto c => Int -> MultiAsset c
exampleMultiAsset Int
1)
    forall era.
(AllegraEraScript era, NativeScript era ~ Timelock era) =>
AllegraTxAuxData era
exampleAllegraTxAuxData
    forall era. NoGenesis era
NoGenesis

exampleMultiAssetValue :: Crypto c => Int -> MaryValue c
exampleMultiAssetValue :: forall c. Crypto c => Int -> MaryValue c
exampleMultiAssetValue Int
x = forall c. Coin -> MultiAsset c -> MaryValue c
MaryValue (Integer -> Coin
Coin Integer
100) forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => Int -> MultiAsset c
exampleMultiAsset Int
x

exampleMultiAsset :: forall c. Crypto c => Int -> MultiAsset c
exampleMultiAsset :: forall c. Crypto c => Int -> MultiAsset c
exampleMultiAsset Int
x =
  forall c. Map (PolicyID c) (Map AssetName Integer) -> MultiAsset c
MultiAsset (forall k a. k -> a -> Map k a
Map.singleton PolicyID c
policyId forall a b. (a -> b) -> a -> b
$ forall k a. k -> a -> Map k a
Map.singleton AssetName
couttsCoin Integer
1000)
  where
    policyId :: PolicyID c
    policyId :: PolicyID c
policyId = forall c. ScriptHash c -> PolicyID c
PolicyID forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => Int -> ScriptHash c
mkScriptHash Int
x

    couttsCoin :: AssetName
    couttsCoin :: AssetName
couttsCoin = ShortByteString -> AssetName
AssetName ShortByteString
"couttsCoin"