{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableSuperClasses #-} {-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Mary.ImpTest ( MaryEraImp, module Test.Cardano.Ledger.Allegra.ImpTest, mkTokenMintingTx, ) where import Cardano.Ledger.Allegra.Scripts import Cardano.Ledger.Mary (MaryEra) import Cardano.Ledger.Mary.Core import Cardano.Ledger.Mary.Value import Lens.Micro ((&), (.~)) import Test.Cardano.Ledger.Allegra.ImpTest import Test.Cardano.Ledger.Imp.Common import Test.Cardano.Ledger.Mary.Arbitrary () import Test.Cardano.Ledger.Mary.TreeDiff () instance ShelleyEraImp MaryEra where impSatisfyNativeScript :: Set (KeyHash 'Witness) -> TxBody MaryEra -> NativeScript MaryEra -> ImpTestM MaryEra (Maybe (Map (KeyHash 'Witness) (KeyPair 'Witness))) impSatisfyNativeScript = forall era. (AllegraEraScript era, AllegraEraTxBody era) => Set (KeyHash 'Witness) -> TxBody era -> NativeScript era -> ImpTestM era (Maybe (Map (KeyHash 'Witness) (KeyPair 'Witness))) impAllegraSatisfyNativeScript fixupTx :: HasCallStack => Tx MaryEra -> ImpTestM MaryEra (Tx MaryEra) fixupTx = forall era. (ShelleyEraImp era, HasCallStack) => Tx era -> ImpTestM era (Tx era) shelleyFixupTx class ( ShelleyEraImp era , MaryEraTxBody era , NativeScript era ~ Timelock era , Value era ~ MaryValue ) => MaryEraImp era instance MaryEraImp MaryEra mkTokenMintingTx :: MaryEraImp era => ScriptHash -> ImpTestM era (Tx era) mkTokenMintingTx :: forall era. MaryEraImp era => ScriptHash -> ImpTestM era (Tx era) mkTokenMintingTx ScriptHash sh = do AssetName name <- forall a (m :: * -> *). (Arbitrary a, MonadGen m) => m a arbitrary Integer count <- forall (g :: * -> *) a. (MonadGen g, Random a) => (a, a) -> g a choose (Integer 1, Integer 10) let policyId :: PolicyID policyId = ScriptHash -> PolicyID PolicyID ScriptHash sh let ma :: MultiAsset ma = [(PolicyID, AssetName, Integer)] -> MultiAsset multiAssetFromList [(PolicyID policyId, AssetName name, Integer count)] Addr addr <- forall s (m :: * -> *) g. (HasKeyPairs s, MonadState s m, HasStatefulGen g m) => m Addr freshKeyAddr_ forall (f :: * -> *) a. Applicative f => a -> f a pure forall a b. (a -> b) -> a -> b $ forall era. EraTx era => TxBody era -> Tx era mkBasicTx forall era. EraTxBody era => TxBody era mkBasicTxBody forall a b. a -> (a -> b) -> b & forall era. EraTx era => Lens' (Tx era) (TxBody era) bodyTxL forall b c a. (b -> c) -> (a -> b) -> a -> c . forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset mintTxBodyL forall s t a b. ASetter s t a b -> b -> s -> t .~ MultiAsset ma forall a b. a -> (a -> b) -> b & forall era. EraTx era => Lens' (Tx era) (TxBody era) bodyTxL forall b c a. (b -> c) -> (a -> b) -> a -> c . forall era. EraTxBody era => Lens' (TxBody era) (StrictSeq (TxOut era)) outputsTxBodyL forall s t a b. ASetter s t a b -> b -> s -> t .~ [forall era. (EraTxOut era, HasCallStack) => Addr -> Value era -> TxOut era mkBasicTxOut Addr addr (Coin -> MultiAsset -> MaryValue MaryValue forall a. Monoid a => a mempty MultiAsset ma)]