{-# LANGUAGE ConstraintKinds       #-}
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveAnyClass        #-}
{-# LANGUAGE DerivingStrategies    #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE GADTs                 #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns        #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE PatternSynonyms       #-}
{-# LANGUAGE Rank2Types            #-}
{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeApplications      #-}
{-# LANGUAGE TypeOperators         #-}
{-# OPTIONS_GHC -Wno-overlapping-patterns #-}
module Wallet.Emulator.MultiAgent where

import Cardano.Api qualified as C
import Cardano.Api.Shelley qualified as C
import Cardano.Node.Emulator.Generators (alwaysSucceedPolicy, alwaysSucceedPolicyId, signAll)
import Cardano.Node.Emulator.Internal.Node.Chain qualified as Chain
import Cardano.Node.Emulator.Internal.Node.Params (Params (..))
import Control.Lens (AReview, Getter, Lens', Prism', anon, at, folded, makeLenses, prism', reversed, review, to, view,
                     (&), (.~), (^..))
import Control.Monad.Freer (Eff, Member, Members, interpret, send, subsume, type (~>))
import Control.Monad.Freer.Error (Error)
import Control.Monad.Freer.Extras.Log (LogMessage, LogMsg, LogObserve, handleObserveLog, mapLog)
import Control.Monad.Freer.Extras.Modify (handleZoomedState, raiseEnd, writeIntoState)
import Control.Monad.Freer.State (State)
import Data.Aeson (FromJSON, ToJSON)
import Data.Foldable (fold)
import Data.Map (Map)
import Data.Map qualified as Map
import Data.Maybe (fromMaybe, isNothing)
import Data.Text qualified as T
import GHC.Generics (Generic)
import Ledger.Address (PaymentPubKeyHash, pubKeyHashAddress)
import Ledger.AddressMap qualified as AM
import Ledger.Blockchain (Blockchain)
import Ledger.Index (minAdaTxOut)
import Ledger.Index qualified as Index
import Ledger.Scripts (MintingPolicy (getMintingPolicy))
import Ledger.Slot (Slot)
import Ledger.Tx.CardanoAPI (ToCardanoError, pattern CardanoEmulatorEraTx)
import Ledger.Tx.CardanoAPI.Internal qualified as C (toCardanoPlutusScript, toCardanoValidityRange, zeroExecutionUnits)
import Ledger.Tx.CardanoAPI.Internal qualified as CardanoAPI (toCardanoAddressInEra, toCardanoTxOutValue)
import Ledger.Tx.Internal (TxOut (TxOut), emptyTxBodyContent, txOutValue)
import Ledger.Tx.Internal qualified as Tx (TxOut (getTxOut))
import Ledger.Value.CardanoAPI (lovelaceToValue)
import Ledger.Value.CardanoAPI qualified as CardanoAPI
import Plutus.ChainIndex.ChainIndexError qualified as ChainIndex (ChainIndexError)
import Plutus.ChainIndex.ChainIndexLog qualified as ChainIndex (ChainIndexLog)
import Plutus.ChainIndex.Effects qualified as ChainIndex (ChainIndexControlEffect, ChainIndexQueryEffect)
import Plutus.ChainIndex.Emulator.Handlers qualified as ChainIndex (handleControl, handleQuery)
import Plutus.Trace.Emulator.Types (ContractInstanceLog, EmulatedWalletEffects, EmulatedWalletEffects', UserThreadMsg)
import Plutus.Trace.Scheduler qualified as Scheduler
import Plutus.V1.Ledger.Scripts qualified as Script
import PlutusTx (toData)
import Prettyprinter (Pretty (pretty), colon, (<+>))
import Wallet.API qualified as WAPI
import Wallet.Emulator.LogMessages (RequestHandlerLogMsg, TxBalanceMsg)
import Wallet.Emulator.NodeClient qualified as NC
import Wallet.Emulator.Wallet (Wallet)
import Wallet.Emulator.Wallet qualified as Wallet

-- | An event with a timestamp measured in emulator time
--   (currently: 'Slot')
data EmulatorTimeEvent e =
    EmulatorTimeEvent
        { EmulatorTimeEvent e -> Slot
_eteEmulatorTime :: Slot
        , EmulatorTimeEvent e -> e
_eteEvent        :: e
        }
    deriving stock (EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool
(EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool)
-> (EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool)
-> Eq (EmulatorTimeEvent e)
forall e.
Eq e =>
EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool
$c/= :: forall e.
Eq e =>
EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool
== :: EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool
$c== :: forall e.
Eq e =>
EmulatorTimeEvent e -> EmulatorTimeEvent e -> Bool
Eq, Int -> EmulatorTimeEvent e -> ShowS
[EmulatorTimeEvent e] -> ShowS
EmulatorTimeEvent e -> String
(Int -> EmulatorTimeEvent e -> ShowS)
-> (EmulatorTimeEvent e -> String)
-> ([EmulatorTimeEvent e] -> ShowS)
-> Show (EmulatorTimeEvent e)
forall e. Show e => Int -> EmulatorTimeEvent e -> ShowS
forall e. Show e => [EmulatorTimeEvent e] -> ShowS
forall e. Show e => EmulatorTimeEvent e -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmulatorTimeEvent e] -> ShowS
$cshowList :: forall e. Show e => [EmulatorTimeEvent e] -> ShowS
show :: EmulatorTimeEvent e -> String
$cshow :: forall e. Show e => EmulatorTimeEvent e -> String
showsPrec :: Int -> EmulatorTimeEvent e -> ShowS
$cshowsPrec :: forall e. Show e => Int -> EmulatorTimeEvent e -> ShowS
Show, (forall x. EmulatorTimeEvent e -> Rep (EmulatorTimeEvent e) x)
-> (forall x. Rep (EmulatorTimeEvent e) x -> EmulatorTimeEvent e)
-> Generic (EmulatorTimeEvent e)
forall x. Rep (EmulatorTimeEvent e) x -> EmulatorTimeEvent e
forall x. EmulatorTimeEvent e -> Rep (EmulatorTimeEvent e) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall e x. Rep (EmulatorTimeEvent e) x -> EmulatorTimeEvent e
forall e x. EmulatorTimeEvent e -> Rep (EmulatorTimeEvent e) x
$cto :: forall e x. Rep (EmulatorTimeEvent e) x -> EmulatorTimeEvent e
$cfrom :: forall e x. EmulatorTimeEvent e -> Rep (EmulatorTimeEvent e) x
Generic, a -> EmulatorTimeEvent b -> EmulatorTimeEvent a
(a -> b) -> EmulatorTimeEvent a -> EmulatorTimeEvent b
(forall a b.
 (a -> b) -> EmulatorTimeEvent a -> EmulatorTimeEvent b)
-> (forall a b. a -> EmulatorTimeEvent b -> EmulatorTimeEvent a)
-> Functor EmulatorTimeEvent
forall a b. a -> EmulatorTimeEvent b -> EmulatorTimeEvent a
forall a b. (a -> b) -> EmulatorTimeEvent a -> EmulatorTimeEvent b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> EmulatorTimeEvent b -> EmulatorTimeEvent a
$c<$ :: forall a b. a -> EmulatorTimeEvent b -> EmulatorTimeEvent a
fmap :: (a -> b) -> EmulatorTimeEvent a -> EmulatorTimeEvent b
$cfmap :: forall a b. (a -> b) -> EmulatorTimeEvent a -> EmulatorTimeEvent b
Functor, EmulatorTimeEvent a -> Bool
(a -> m) -> EmulatorTimeEvent a -> m
(a -> b -> b) -> b -> EmulatorTimeEvent a -> b
(forall m. Monoid m => EmulatorTimeEvent m -> m)
-> (forall m a. Monoid m => (a -> m) -> EmulatorTimeEvent a -> m)
-> (forall m a. Monoid m => (a -> m) -> EmulatorTimeEvent a -> m)
-> (forall a b. (a -> b -> b) -> b -> EmulatorTimeEvent a -> b)
-> (forall a b. (a -> b -> b) -> b -> EmulatorTimeEvent a -> b)
-> (forall b a. (b -> a -> b) -> b -> EmulatorTimeEvent a -> b)
-> (forall b a. (b -> a -> b) -> b -> EmulatorTimeEvent a -> b)
-> (forall a. (a -> a -> a) -> EmulatorTimeEvent a -> a)
-> (forall a. (a -> a -> a) -> EmulatorTimeEvent a -> a)
-> (forall a. EmulatorTimeEvent a -> [a])
-> (forall a. EmulatorTimeEvent a -> Bool)
-> (forall a. EmulatorTimeEvent a -> Int)
-> (forall a. Eq a => a -> EmulatorTimeEvent a -> Bool)
-> (forall a. Ord a => EmulatorTimeEvent a -> a)
-> (forall a. Ord a => EmulatorTimeEvent a -> a)
-> (forall a. Num a => EmulatorTimeEvent a -> a)
-> (forall a. Num a => EmulatorTimeEvent a -> a)
-> Foldable EmulatorTimeEvent
forall a. Eq a => a -> EmulatorTimeEvent a -> Bool
forall a. Num a => EmulatorTimeEvent a -> a
forall a. Ord a => EmulatorTimeEvent a -> a
forall m. Monoid m => EmulatorTimeEvent m -> m
forall a. EmulatorTimeEvent a -> Bool
forall a. EmulatorTimeEvent a -> Int
forall a. EmulatorTimeEvent a -> [a]
forall a. (a -> a -> a) -> EmulatorTimeEvent a -> a
forall m a. Monoid m => (a -> m) -> EmulatorTimeEvent a -> m
forall b a. (b -> a -> b) -> b -> EmulatorTimeEvent a -> b
forall a b. (a -> b -> b) -> b -> EmulatorTimeEvent a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: EmulatorTimeEvent a -> a
$cproduct :: forall a. Num a => EmulatorTimeEvent a -> a
sum :: EmulatorTimeEvent a -> a
$csum :: forall a. Num a => EmulatorTimeEvent a -> a
minimum :: EmulatorTimeEvent a -> a
$cminimum :: forall a. Ord a => EmulatorTimeEvent a -> a
maximum :: EmulatorTimeEvent a -> a
$cmaximum :: forall a. Ord a => EmulatorTimeEvent a -> a
elem :: a -> EmulatorTimeEvent a -> Bool
$celem :: forall a. Eq a => a -> EmulatorTimeEvent a -> Bool
length :: EmulatorTimeEvent a -> Int
$clength :: forall a. EmulatorTimeEvent a -> Int
null :: EmulatorTimeEvent a -> Bool
$cnull :: forall a. EmulatorTimeEvent a -> Bool
toList :: EmulatorTimeEvent a -> [a]
$ctoList :: forall a. EmulatorTimeEvent a -> [a]
foldl1 :: (a -> a -> a) -> EmulatorTimeEvent a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> EmulatorTimeEvent a -> a
foldr1 :: (a -> a -> a) -> EmulatorTimeEvent a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> EmulatorTimeEvent a -> a
foldl' :: (b -> a -> b) -> b -> EmulatorTimeEvent a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> EmulatorTimeEvent a -> b
foldl :: (b -> a -> b) -> b -> EmulatorTimeEvent a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> EmulatorTimeEvent a -> b
foldr' :: (a -> b -> b) -> b -> EmulatorTimeEvent a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> EmulatorTimeEvent a -> b
foldr :: (a -> b -> b) -> b -> EmulatorTimeEvent a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> EmulatorTimeEvent a -> b
foldMap' :: (a -> m) -> EmulatorTimeEvent a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> EmulatorTimeEvent a -> m
foldMap :: (a -> m) -> EmulatorTimeEvent a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> EmulatorTimeEvent a -> m
fold :: EmulatorTimeEvent m -> m
$cfold :: forall m. Monoid m => EmulatorTimeEvent m -> m
Foldable, Functor EmulatorTimeEvent
Foldable EmulatorTimeEvent
Functor EmulatorTimeEvent
-> Foldable EmulatorTimeEvent
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> EmulatorTimeEvent a -> f (EmulatorTimeEvent b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    EmulatorTimeEvent (f a) -> f (EmulatorTimeEvent a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> EmulatorTimeEvent a -> m (EmulatorTimeEvent b))
-> (forall (m :: * -> *) a.
    Monad m =>
    EmulatorTimeEvent (m a) -> m (EmulatorTimeEvent a))
-> Traversable EmulatorTimeEvent
(a -> f b) -> EmulatorTimeEvent a -> f (EmulatorTimeEvent b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
EmulatorTimeEvent (m a) -> m (EmulatorTimeEvent a)
forall (f :: * -> *) a.
Applicative f =>
EmulatorTimeEvent (f a) -> f (EmulatorTimeEvent a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> EmulatorTimeEvent a -> m (EmulatorTimeEvent b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> EmulatorTimeEvent a -> f (EmulatorTimeEvent b)
sequence :: EmulatorTimeEvent (m a) -> m (EmulatorTimeEvent a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
EmulatorTimeEvent (m a) -> m (EmulatorTimeEvent a)
mapM :: (a -> m b) -> EmulatorTimeEvent a -> m (EmulatorTimeEvent b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> EmulatorTimeEvent a -> m (EmulatorTimeEvent b)
sequenceA :: EmulatorTimeEvent (f a) -> f (EmulatorTimeEvent a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
EmulatorTimeEvent (f a) -> f (EmulatorTimeEvent a)
traverse :: (a -> f b) -> EmulatorTimeEvent a -> f (EmulatorTimeEvent b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> EmulatorTimeEvent a -> f (EmulatorTimeEvent b)
$cp2Traversable :: Foldable EmulatorTimeEvent
$cp1Traversable :: Functor EmulatorTimeEvent
Traversable)
    deriving anyclass ([EmulatorTimeEvent e] -> Encoding
[EmulatorTimeEvent e] -> Value
EmulatorTimeEvent e -> Encoding
EmulatorTimeEvent e -> Value
(EmulatorTimeEvent e -> Value)
-> (EmulatorTimeEvent e -> Encoding)
-> ([EmulatorTimeEvent e] -> Value)
-> ([EmulatorTimeEvent e] -> Encoding)
-> ToJSON (EmulatorTimeEvent e)
forall e. ToJSON e => [EmulatorTimeEvent e] -> Encoding
forall e. ToJSON e => [EmulatorTimeEvent e] -> Value
forall e. ToJSON e => EmulatorTimeEvent e -> Encoding
forall e. ToJSON e => EmulatorTimeEvent e -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [EmulatorTimeEvent e] -> Encoding
$ctoEncodingList :: forall e. ToJSON e => [EmulatorTimeEvent e] -> Encoding
toJSONList :: [EmulatorTimeEvent e] -> Value
$ctoJSONList :: forall e. ToJSON e => [EmulatorTimeEvent e] -> Value
toEncoding :: EmulatorTimeEvent e -> Encoding
$ctoEncoding :: forall e. ToJSON e => EmulatorTimeEvent e -> Encoding
toJSON :: EmulatorTimeEvent e -> Value
$ctoJSON :: forall e. ToJSON e => EmulatorTimeEvent e -> Value
ToJSON, Value -> Parser [EmulatorTimeEvent e]
Value -> Parser (EmulatorTimeEvent e)
(Value -> Parser (EmulatorTimeEvent e))
-> (Value -> Parser [EmulatorTimeEvent e])
-> FromJSON (EmulatorTimeEvent e)
forall e. FromJSON e => Value -> Parser [EmulatorTimeEvent e]
forall e. FromJSON e => Value -> Parser (EmulatorTimeEvent e)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [EmulatorTimeEvent e]
$cparseJSONList :: forall e. FromJSON e => Value -> Parser [EmulatorTimeEvent e]
parseJSON :: Value -> Parser (EmulatorTimeEvent e)
$cparseJSON :: forall e. FromJSON e => Value -> Parser (EmulatorTimeEvent e)
FromJSON)

makeLenses ''EmulatorTimeEvent

instance Pretty e => Pretty (EmulatorTimeEvent e) where
    pretty :: EmulatorTimeEvent e -> Doc ann
pretty EmulatorTimeEvent{Slot
_eteEmulatorTime :: Slot
_eteEmulatorTime :: forall e. EmulatorTimeEvent e -> Slot
_eteEmulatorTime, e
_eteEvent :: e
_eteEvent :: forall e. EmulatorTimeEvent e -> e
_eteEvent} =
        Slot -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Slot
_eteEmulatorTime Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> e -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty e
_eteEvent

emulatorTimeEvent :: Slot -> Prism' (EmulatorTimeEvent e) e
emulatorTimeEvent :: Slot -> Prism' (EmulatorTimeEvent e) e
emulatorTimeEvent Slot
t = (e -> EmulatorTimeEvent e)
-> (EmulatorTimeEvent e -> Maybe e)
-> Prism' (EmulatorTimeEvent e) e
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Slot -> e -> EmulatorTimeEvent e
forall e. Slot -> e -> EmulatorTimeEvent e
EmulatorTimeEvent Slot
t) (\case { EmulatorTimeEvent Slot
s e
e | Slot
s Slot -> Slot -> Bool
forall a. Eq a => a -> a -> Bool
== Slot
t -> e -> Maybe e
forall a. a -> Maybe a
Just e
e; EmulatorTimeEvent e
_ -> Maybe e
forall a. Maybe a
Nothing})

-- | Events produced by the blockchain emulator.
data EmulatorEvent' =
    ChainEvent Chain.ChainEvent
    | ClientEvent Wallet NC.NodeClientEvent
    | WalletEvent Wallet Wallet.WalletEvent
    | ChainIndexEvent Wallet ChainIndex.ChainIndexLog
    | SchedulerEvent Scheduler.SchedulerLog
    | InstanceEvent ContractInstanceLog
    | UserThreadEvent UserThreadMsg
    deriving stock (EmulatorEvent' -> EmulatorEvent' -> Bool
(EmulatorEvent' -> EmulatorEvent' -> Bool)
-> (EmulatorEvent' -> EmulatorEvent' -> Bool) -> Eq EmulatorEvent'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmulatorEvent' -> EmulatorEvent' -> Bool
$c/= :: EmulatorEvent' -> EmulatorEvent' -> Bool
== :: EmulatorEvent' -> EmulatorEvent' -> Bool
$c== :: EmulatorEvent' -> EmulatorEvent' -> Bool
Eq, Int -> EmulatorEvent' -> ShowS
[EmulatorEvent'] -> ShowS
EmulatorEvent' -> String
(Int -> EmulatorEvent' -> ShowS)
-> (EmulatorEvent' -> String)
-> ([EmulatorEvent'] -> ShowS)
-> Show EmulatorEvent'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmulatorEvent'] -> ShowS
$cshowList :: [EmulatorEvent'] -> ShowS
show :: EmulatorEvent' -> String
$cshow :: EmulatorEvent' -> String
showsPrec :: Int -> EmulatorEvent' -> ShowS
$cshowsPrec :: Int -> EmulatorEvent' -> ShowS
Show, (forall x. EmulatorEvent' -> Rep EmulatorEvent' x)
-> (forall x. Rep EmulatorEvent' x -> EmulatorEvent')
-> Generic EmulatorEvent'
forall x. Rep EmulatorEvent' x -> EmulatorEvent'
forall x. EmulatorEvent' -> Rep EmulatorEvent' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmulatorEvent' x -> EmulatorEvent'
$cfrom :: forall x. EmulatorEvent' -> Rep EmulatorEvent' x
Generic)
    deriving anyclass ([EmulatorEvent'] -> Encoding
[EmulatorEvent'] -> Value
EmulatorEvent' -> Encoding
EmulatorEvent' -> Value
(EmulatorEvent' -> Value)
-> (EmulatorEvent' -> Encoding)
-> ([EmulatorEvent'] -> Value)
-> ([EmulatorEvent'] -> Encoding)
-> ToJSON EmulatorEvent'
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [EmulatorEvent'] -> Encoding
$ctoEncodingList :: [EmulatorEvent'] -> Encoding
toJSONList :: [EmulatorEvent'] -> Value
$ctoJSONList :: [EmulatorEvent'] -> Value
toEncoding :: EmulatorEvent' -> Encoding
$ctoEncoding :: EmulatorEvent' -> Encoding
toJSON :: EmulatorEvent' -> Value
$ctoJSON :: EmulatorEvent' -> Value
ToJSON, Value -> Parser [EmulatorEvent']
Value -> Parser EmulatorEvent'
(Value -> Parser EmulatorEvent')
-> (Value -> Parser [EmulatorEvent']) -> FromJSON EmulatorEvent'
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [EmulatorEvent']
$cparseJSONList :: Value -> Parser [EmulatorEvent']
parseJSON :: Value -> Parser EmulatorEvent'
$cparseJSON :: Value -> Parser EmulatorEvent'
FromJSON)

instance Pretty EmulatorEvent' where
    pretty :: EmulatorEvent' -> Doc ann
pretty = \case
        ClientEvent Wallet
w NodeClientEvent
e     -> Wallet -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Wallet
w Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> NodeClientEvent -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty NodeClientEvent
e
        ChainEvent ChainEvent
e        -> ChainEvent -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty ChainEvent
e
        WalletEvent Wallet
w WalletEvent
e     -> Wallet -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Wallet
w Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> WalletEvent -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty WalletEvent
e
        ChainIndexEvent Wallet
w ChainIndexLog
e -> Wallet -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Wallet
w Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ChainIndexLog -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty ChainIndexLog
e
        SchedulerEvent SchedulerLog
e    -> SchedulerLog -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty SchedulerLog
e
        InstanceEvent ContractInstanceLog
e     -> ContractInstanceLog -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty ContractInstanceLog
e
        UserThreadEvent UserThreadMsg
e   -> UserThreadMsg -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty UserThreadMsg
e

type EmulatorEvent = EmulatorTimeEvent EmulatorEvent'

chainEvent :: Prism' EmulatorEvent' Chain.ChainEvent
chainEvent :: p ChainEvent (f ChainEvent) -> p EmulatorEvent' (f EmulatorEvent')
chainEvent = (ChainEvent -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe ChainEvent)
-> Prism EmulatorEvent' EmulatorEvent' ChainEvent ChainEvent
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ChainEvent -> EmulatorEvent'
ChainEvent (\case { ChainEvent ChainEvent
c -> ChainEvent -> Maybe ChainEvent
forall a. a -> Maybe a
Just ChainEvent
c; EmulatorEvent'
_ -> Maybe ChainEvent
forall a. Maybe a
Nothing })

walletClientEvent :: Wallet -> Prism' EmulatorEvent' NC.NodeClientEvent
walletClientEvent :: Wallet -> Prism' EmulatorEvent' NodeClientEvent
walletClientEvent Wallet
w = (NodeClientEvent -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe NodeClientEvent)
-> Prism' EmulatorEvent' NodeClientEvent
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Wallet -> NodeClientEvent -> EmulatorEvent'
ClientEvent Wallet
w) (\case { ClientEvent Wallet
w' NodeClientEvent
c | Wallet
w Wallet -> Wallet -> Bool
forall a. Eq a => a -> a -> Bool
== Wallet
w' -> NodeClientEvent -> Maybe NodeClientEvent
forall a. a -> Maybe a
Just NodeClientEvent
c; EmulatorEvent'
_ -> Maybe NodeClientEvent
forall a. Maybe a
Nothing })

walletEvent :: Wallet -> Prism' EmulatorEvent' Wallet.WalletEvent
walletEvent :: Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
w = (WalletEvent -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe WalletEvent)
-> Prism' EmulatorEvent' WalletEvent
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Wallet -> WalletEvent -> EmulatorEvent'
WalletEvent Wallet
w) (\case { WalletEvent Wallet
w' WalletEvent
c | Wallet
w Wallet -> Wallet -> Bool
forall a. Eq a => a -> a -> Bool
== Wallet
w' -> WalletEvent -> Maybe WalletEvent
forall a. a -> Maybe a
Just WalletEvent
c; EmulatorEvent'
_ -> Maybe WalletEvent
forall a. Maybe a
Nothing })

walletEvent' :: Prism' EmulatorEvent' (Wallet, Wallet.WalletEvent)
walletEvent' :: p (Wallet, WalletEvent) (f (Wallet, WalletEvent))
-> p EmulatorEvent' (f EmulatorEvent')
walletEvent' = ((Wallet, WalletEvent) -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe (Wallet, WalletEvent))
-> Prism
     EmulatorEvent'
     EmulatorEvent'
     (Wallet, WalletEvent)
     (Wallet, WalletEvent)
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ((Wallet -> WalletEvent -> EmulatorEvent')
-> (Wallet, WalletEvent) -> EmulatorEvent'
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Wallet -> WalletEvent -> EmulatorEvent'
WalletEvent) (\case { WalletEvent Wallet
w WalletEvent
c -> (Wallet, WalletEvent) -> Maybe (Wallet, WalletEvent)
forall a. a -> Maybe a
Just (Wallet
w, WalletEvent
c); EmulatorEvent'
_ -> Maybe (Wallet, WalletEvent)
forall a. Maybe a
Nothing })

chainIndexEvent :: Wallet -> Prism' EmulatorEvent' ChainIndex.ChainIndexLog
chainIndexEvent :: Wallet -> Prism' EmulatorEvent' ChainIndexLog
chainIndexEvent Wallet
w = (ChainIndexLog -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe ChainIndexLog)
-> Prism' EmulatorEvent' ChainIndexLog
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Wallet -> ChainIndexLog -> EmulatorEvent'
ChainIndexEvent Wallet
w) (\case { ChainIndexEvent Wallet
w' ChainIndexLog
c | Wallet
w Wallet -> Wallet -> Bool
forall a. Eq a => a -> a -> Bool
== Wallet
w' -> ChainIndexLog -> Maybe ChainIndexLog
forall a. a -> Maybe a
Just ChainIndexLog
c; EmulatorEvent'
_ -> Maybe ChainIndexLog
forall a. Maybe a
Nothing })

schedulerEvent :: Prism' EmulatorEvent' Scheduler.SchedulerLog
schedulerEvent :: p SchedulerLog (f SchedulerLog)
-> p EmulatorEvent' (f EmulatorEvent')
schedulerEvent = (SchedulerLog -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe SchedulerLog)
-> Prism EmulatorEvent' EmulatorEvent' SchedulerLog SchedulerLog
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' SchedulerLog -> EmulatorEvent'
SchedulerEvent (\case { SchedulerEvent SchedulerLog
e -> SchedulerLog -> Maybe SchedulerLog
forall a. a -> Maybe a
Just SchedulerLog
e; EmulatorEvent'
_ -> Maybe SchedulerLog
forall a. Maybe a
Nothing })

instanceEvent :: Prism' EmulatorEvent' ContractInstanceLog
instanceEvent :: p ContractInstanceLog (f ContractInstanceLog)
-> p EmulatorEvent' (f EmulatorEvent')
instanceEvent = (ContractInstanceLog -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe ContractInstanceLog)
-> Prism
     EmulatorEvent'
     EmulatorEvent'
     ContractInstanceLog
     ContractInstanceLog
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ContractInstanceLog -> EmulatorEvent'
InstanceEvent (\case { InstanceEvent ContractInstanceLog
e -> ContractInstanceLog -> Maybe ContractInstanceLog
forall a. a -> Maybe a
Just ContractInstanceLog
e; EmulatorEvent'
_ -> Maybe ContractInstanceLog
forall a. Maybe a
Nothing })

userThreadEvent :: Prism' EmulatorEvent' UserThreadMsg
userThreadEvent :: p UserThreadMsg (f UserThreadMsg)
-> p EmulatorEvent' (f EmulatorEvent')
userThreadEvent = (UserThreadMsg -> EmulatorEvent')
-> (EmulatorEvent' -> Maybe UserThreadMsg)
-> Prism EmulatorEvent' EmulatorEvent' UserThreadMsg UserThreadMsg
forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' UserThreadMsg -> EmulatorEvent'
UserThreadEvent (\case { UserThreadEvent UserThreadMsg
e -> UserThreadMsg -> Maybe UserThreadMsg
forall a. a -> Maybe a
Just UserThreadMsg
e ; EmulatorEvent'
_ -> Maybe UserThreadMsg
forall a. Maybe a
Nothing })

type EmulatedWalletControlEffects =
        '[ NC.NodeClientControlEffect
         , ChainIndex.ChainIndexControlEffect
         , Wallet.SigningProcessControlEffect
         , LogObserve (LogMessage T.Text)
         , LogMsg T.Text
        ]

{- Note [Control effects]

Plutus contracts interact with the outside world through a number of different
effects. These effects are captured in 'EmulatedWalletEffects'. They are
supposed to be a realistic representation of the capabilities that contracts
will have in the real world, when the system is released.

In the tests we often want to simulate events that happened "outside of the
contract". For example: A new block is added to the chain, or a user takes the
transaction and emails it to another person to sign, before sending it to the
node. These kinds of events cannot be expressed in 'EmulatedWalletEffects',
because it would make the emulated wallet effects unrealistic - Plutus
contracts in the real world will not have the power to decide when a new block
gets added to the chain, or to control who adds their signature to a
transaction.

But in the emulated world of our unit tests we, the contract authors, would very
much like to have this power. That is why there is a second list of emulator
effects: 'EmulatedWalletControlEffects' are the of effects that only make sense
in the emulator, but not in the real world. With 'EmulatedWalletControlEffects'
we can control the blockchain and the lines of communication between the
emulated components.

By being clear about which of our (ie. the contract authors) actions
require the full power of 'EmulatedWalletControlEffects', we can be more
confident that our contracts will run in the real world, and not just in the
test environment. That is why there are two similar but different constructors
for 'MultiAgentEffect': 'WalletAction' is used for things that we will be able
to do in the real world, and 'WalletControlAction' is for everything else.

-}

-- | The type of actions in the emulator.
data MultiAgentEffect r where
    -- | A direct action performed by a wallet. Usually represents a "user action", as it is
    -- triggered externally.
    WalletAction :: Wallet -> Eff EmulatedWalletEffects r -> MultiAgentEffect r

data MultiAgentControlEffect r where
    -- | An action affecting the emulated parts of a wallet (only available in emulator - see note [Control effects].)
    WalletControlAction :: Wallet -> Eff EmulatedWalletControlEffects r -> MultiAgentControlEffect r

-- | Run an action in the context of a wallet (ie. agent)
walletAction
    :: (Member MultiAgentEffect effs)
    => Wallet
    -> Eff EmulatedWalletEffects r
    -> Eff effs r
walletAction :: Wallet -> Eff EmulatedWalletEffects r -> Eff effs r
walletAction Wallet
wallet Eff EmulatedWalletEffects r
act = MultiAgentEffect r -> Eff effs r
forall (eff :: * -> *) (effs :: [* -> *]) a.
Member eff effs =>
eff a -> Eff effs a
send (Wallet -> Eff EmulatedWalletEffects r -> MultiAgentEffect r
forall r.
Wallet -> Eff EmulatedWalletEffects r -> MultiAgentEffect r
WalletAction Wallet
wallet Eff EmulatedWalletEffects r
act)

handleMultiAgentEffects ::
    forall effs.
    Member MultiAgentEffect effs
    => Wallet
    -> Eff (EmulatedWalletEffects' effs)
    ~> Eff effs
handleMultiAgentEffects :: Wallet -> Eff (EmulatedWalletEffects' effs) ~> Eff effs
handleMultiAgentEffects Wallet
wallet =
    (LogMsg Text ~> Eff effs) -> Eff (LogMsg Text : effs) ~> Eff effs
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet -> LogMsg Text ~> Eff effs
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @(LogMsg T.Text) Wallet
wallet)
        (Eff (LogMsg Text : effs) x -> Eff effs x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff (LogMsg Text : effs) x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff effs x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LogMsg TxBalanceMsg ~> Eff (LogMsg Text : effs))
-> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs)
   ~> Eff (LogMsg Text : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet -> LogMsg TxBalanceMsg ~> Eff (LogMsg Text : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @(LogMsg TxBalanceMsg) Wallet
wallet)
        (Eff (LogMsg TxBalanceMsg : LogMsg Text : effs) x
 -> Eff (LogMsg Text : effs) x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs) x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff (LogMsg Text : effs) x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LogMsg RequestHandlerLogMsg
 ~> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs))
-> Eff
     (LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : effs)
   ~> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet
-> LogMsg RequestHandlerLogMsg
   ~> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @(LogMsg RequestHandlerLogMsg) Wallet
wallet)
        (Eff
   (LogMsg RequestHandlerLogMsg
      : LogMsg TxBalanceMsg : LogMsg Text : effs)
   x
 -> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs) x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff
         (LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : effs)
         x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff (LogMsg TxBalanceMsg : LogMsg Text : effs) x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LogObserve (LogMessage Text)
 ~> Eff
      (LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : effs))
-> Eff
     (LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : effs)
   ~> Eff
        (LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet
-> LogObserve (LogMessage Text)
   ~> Eff
        (LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @(LogObserve (LogMessage T.Text)) Wallet
wallet)
        (Eff
   (LogObserve (LogMessage Text)
      : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
      : effs)
   x
 -> Eff
      (LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : effs)
      x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff
         (LogObserve (LogMessage Text)
            : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
            : effs)
         x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff
     (LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : effs)
     x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ChainIndexQueryEffect
 ~> Eff
      (LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : effs))
-> Eff
     (ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : effs)
   ~> Eff
        (LogObserve (LogMessage Text)
           : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet
-> ChainIndexQueryEffect
   ~> Eff
        (LogObserve (LogMessage Text)
           : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
           : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @ChainIndex.ChainIndexQueryEffect Wallet
wallet)
        (Eff
   (ChainIndexQueryEffect
      : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
      : LogMsg TxBalanceMsg : LogMsg Text : effs)
   x
 -> Eff
      (LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : effs)
      x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff
         (ChainIndexQueryEffect
            : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : effs)
         x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff
     (LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : effs)
     x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NodeClientEffect
 ~> Eff
      (ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : effs))
-> Eff
     (NodeClientEffect
        : ChainIndexQueryEffect : LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : effs)
   ~> Eff
        (ChainIndexQueryEffect
           : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet
-> NodeClientEffect
   ~> Eff
        (ChainIndexQueryEffect
           : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @WAPI.NodeClientEffect Wallet
wallet)
        (Eff
   (NodeClientEffect
      : ChainIndexQueryEffect : LogObserve (LogMessage Text)
      : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
      : effs)
   x
 -> Eff
      (ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : effs)
      x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff
         (NodeClientEffect
            : ChainIndexQueryEffect : LogObserve (LogMessage Text)
            : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
            : effs)
         x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff
     (ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : effs)
     x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Error WalletAPIError
 ~> Eff
      (NodeClientEffect
         : ChainIndexQueryEffect : LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : effs))
-> Eff
     (Error WalletAPIError
        : NodeClientEffect : ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : effs)
   ~> Eff
        (NodeClientEffect
           : ChainIndexQueryEffect : LogObserve (LogMessage Text)
           : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet
-> Error WalletAPIError
   ~> Eff
        (NodeClientEffect
           : ChainIndexQueryEffect : LogObserve (LogMessage Text)
           : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
           : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @(Error WAPI.WalletAPIError) Wallet
wallet)
        (Eff
   (Error WalletAPIError
      : NodeClientEffect : ChainIndexQueryEffect
      : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
      : LogMsg TxBalanceMsg : LogMsg Text : effs)
   x
 -> Eff
      (NodeClientEffect
         : ChainIndexQueryEffect : LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : effs)
      x)
-> (Eff (EmulatedWalletEffects' effs) x
    -> Eff
         (Error WalletAPIError
            : NodeClientEffect : ChainIndexQueryEffect
            : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : effs)
         x)
-> Eff (EmulatedWalletEffects' effs) x
-> Eff
     (NodeClientEffect
        : ChainIndexQueryEffect : LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : effs)
     x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WalletEffect
 ~> Eff
      (Error WalletAPIError
         : NodeClientEffect : ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : effs))
-> Eff (EmulatedWalletEffects' effs)
   ~> Eff
        (Error WalletAPIError
           : NodeClientEffect : ChainIndexQueryEffect
           : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Wallet
-> WalletEffect
   ~> Eff
        (Error WalletAPIError
           : NodeClientEffect : ChainIndexQueryEffect
           : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : effs)
forall (f :: * -> *) (effs :: [* -> *]).
(Member f EmulatedWalletEffects, Member MultiAgentEffect effs) =>
Wallet -> f ~> Eff effs
raiseWallet @WAPI.WalletEffect Wallet
wallet)

raiseWallet :: forall f effs.
    ( Member f EmulatedWalletEffects
    , Member MultiAgentEffect effs
    )
    => Wallet
    -> f
    ~> Eff effs
raiseWallet :: Wallet -> f ~> Eff effs
raiseWallet Wallet
wllt = Wallet -> Eff EmulatedWalletEffects x -> Eff effs x
forall (effs :: [* -> *]) r.
Member MultiAgentEffect effs =>
Wallet -> Eff EmulatedWalletEffects r -> Eff effs r
walletAction Wallet
wllt (Eff EmulatedWalletEffects x -> Eff effs x)
-> (f x -> Eff EmulatedWalletEffects x) -> f x -> Eff effs x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f x -> Eff EmulatedWalletEffects x
forall (eff :: * -> *) (effs :: [* -> *]) a.
Member eff effs =>
eff a -> Eff effs a
send

-- | Run a control action in the context of a wallet
walletControlAction
    :: (Member MultiAgentControlEffect effs)
    => Wallet
    -> Eff EmulatedWalletControlEffects r
    -> Eff effs r
walletControlAction :: Wallet -> Eff EmulatedWalletControlEffects r -> Eff effs r
walletControlAction Wallet
wallet = MultiAgentControlEffect r -> Eff effs r
forall (eff :: * -> *) (effs :: [* -> *]) a.
Member eff effs =>
eff a -> Eff effs a
send (MultiAgentControlEffect r -> Eff effs r)
-> (Eff EmulatedWalletControlEffects r
    -> MultiAgentControlEffect r)
-> Eff EmulatedWalletControlEffects r
-> Eff effs r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Wallet
-> Eff EmulatedWalletControlEffects r -> MultiAgentControlEffect r
forall r.
Wallet
-> Eff EmulatedWalletControlEffects r -> MultiAgentControlEffect r
WalletControlAction Wallet
wallet

-- | The state of the emulator itself.
data EmulatorState = EmulatorState {
    EmulatorState -> ChainState
_chainState   :: Chain.ChainState, -- ^ Mockchain
    EmulatorState -> Map Wallet WalletState
_walletStates :: Map Wallet Wallet.WalletState, -- ^ The state of each agent.
    EmulatorState -> [LogMessage EmulatorEvent]
_emulatorLog  :: [LogMessage EmulatorEvent] -- ^ The emulator log messages, with the newest last.
    } deriving (Int -> EmulatorState -> ShowS
[EmulatorState] -> ShowS
EmulatorState -> String
(Int -> EmulatorState -> ShowS)
-> (EmulatorState -> String)
-> ([EmulatorState] -> ShowS)
-> Show EmulatorState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmulatorState] -> ShowS
$cshowList :: [EmulatorState] -> ShowS
show :: EmulatorState -> String
$cshow :: EmulatorState -> String
showsPrec :: Int -> EmulatorState -> ShowS
$cshowsPrec :: Int -> EmulatorState -> ShowS
Show)

makeLenses ''EmulatorState

walletState :: Wallet -> Lens' EmulatorState Wallet.WalletState
walletState :: Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet = (Map Wallet WalletState -> f (Map Wallet WalletState))
-> EmulatorState -> f EmulatorState
Lens' EmulatorState (Map Wallet WalletState)
walletStates ((Map Wallet WalletState -> f (Map Wallet WalletState))
 -> EmulatorState -> f EmulatorState)
-> ((WalletState -> f WalletState)
    -> Map Wallet WalletState -> f (Map Wallet WalletState))
-> (WalletState -> f WalletState)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map Wallet WalletState)
-> Lens'
     (Map Wallet WalletState) (Maybe (IxValue (Map Wallet WalletState)))
forall m. At m => Index m -> Lens' m (Maybe (IxValue m))
at Index (Map Wallet WalletState)
Wallet
wallet ((Maybe WalletState -> f (Maybe WalletState))
 -> Map Wallet WalletState -> f (Map Wallet WalletState))
-> ((WalletState -> f WalletState)
    -> Maybe WalletState -> f (Maybe WalletState))
-> (WalletState -> f WalletState)
-> Map Wallet WalletState
-> f (Map Wallet WalletState)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WalletState
-> (WalletState -> Bool) -> Iso' (Maybe WalletState) WalletState
forall a. a -> (a -> Bool) -> Iso' (Maybe a) a
anon WalletState
emptyState (Bool -> WalletState -> Bool
forall a b. a -> b -> a
const Bool
False) where
    emptyState :: WalletState
emptyState = WalletState -> Maybe WalletState -> WalletState
forall a. a -> Maybe a -> a
fromMaybe (String -> WalletState
forall a. HasCallStack => String -> a
error (String -> WalletState) -> String -> WalletState
forall a b. (a -> b) -> a -> b
$ String
"walletState: not a known wallet: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Wallet -> String
forall a. Show a => a -> String
show Wallet
wallet) (Wallet -> Maybe WalletState
Wallet.emptyWalletState Wallet
wallet)

-- | Get the blockchain as a list of blocks, starting with the oldest (genesis)
--   block.
chainOldestFirst :: Lens' EmulatorState Blockchain
chainOldestFirst :: (Blockchain -> f Blockchain) -> EmulatorState -> f EmulatorState
chainOldestFirst = (ChainState -> f ChainState) -> EmulatorState -> f EmulatorState
Lens' EmulatorState ChainState
chainState ((ChainState -> f ChainState) -> EmulatorState -> f EmulatorState)
-> ((Blockchain -> f Blockchain) -> ChainState -> f ChainState)
-> (Blockchain -> f Blockchain)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Blockchain -> f Blockchain) -> ChainState -> f ChainState
Lens' ChainState Blockchain
Chain.chainNewestFirst ((Blockchain -> f Blockchain) -> ChainState -> f ChainState)
-> ((Blockchain -> f Blockchain) -> Blockchain -> f Blockchain)
-> (Blockchain -> f Blockchain)
-> ChainState
-> f ChainState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Blockchain -> f Blockchain) -> Blockchain -> f Blockchain
forall a. Reversing a => Iso' a a
reversed

chainUtxo :: Getter EmulatorState AM.AddressMap
chainUtxo :: (AddressMap -> f AddressMap) -> EmulatorState -> f EmulatorState
chainUtxo = (ChainState -> f ChainState) -> EmulatorState -> f EmulatorState
Lens' EmulatorState ChainState
chainState ((ChainState -> f ChainState) -> EmulatorState -> f EmulatorState)
-> ((AddressMap -> f AddressMap) -> ChainState -> f ChainState)
-> (AddressMap -> f AddressMap)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Blockchain -> f Blockchain) -> ChainState -> f ChainState
Lens' ChainState Blockchain
Chain.chainNewestFirst ((Blockchain -> f Blockchain) -> ChainState -> f ChainState)
-> ((AddressMap -> f AddressMap) -> Blockchain -> f Blockchain)
-> (AddressMap -> f AddressMap)
-> ChainState
-> f ChainState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Blockchain -> AddressMap)
-> (AddressMap -> f AddressMap) -> Blockchain -> f Blockchain
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to Blockchain -> AddressMap
AM.fromChain

-- | Get a map with the total value of each wallet's "own funds".
fundsDistribution :: EmulatorState -> Map Wallet C.Value
fundsDistribution :: EmulatorState -> Map Wallet Value
fundsDistribution EmulatorState
st =
    let fullState :: AddressMap
fullState = Getting AddressMap EmulatorState AddressMap
-> EmulatorState -> AddressMap
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting AddressMap EmulatorState AddressMap
Getter EmulatorState AddressMap
chainUtxo EmulatorState
st
        wallets :: [Wallet]
wallets = EmulatorState
st EmulatorState
-> Getting (Endo [Wallet]) EmulatorState Wallet -> [Wallet]
forall s a. s -> Getting (Endo [a]) s a -> [a]
^.. (Map Wallet WalletState
 -> Const (Endo [Wallet]) (Map Wallet WalletState))
-> EmulatorState -> Const (Endo [Wallet]) EmulatorState
Lens' EmulatorState (Map Wallet WalletState)
walletStates ((Map Wallet WalletState
  -> Const (Endo [Wallet]) (Map Wallet WalletState))
 -> EmulatorState -> Const (Endo [Wallet]) EmulatorState)
-> ((Wallet -> Const (Endo [Wallet]) Wallet)
    -> Map Wallet WalletState
    -> Const (Endo [Wallet]) (Map Wallet WalletState))
-> Getting (Endo [Wallet]) EmulatorState Wallet
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Map Wallet WalletState -> [Wallet])
-> Optic'
     (->) (Const (Endo [Wallet])) (Map Wallet WalletState) [Wallet]
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to Map Wallet WalletState -> [Wallet]
forall k a. Map k a -> [k]
Map.keys Optic'
  (->) (Const (Endo [Wallet])) (Map Wallet WalletState) [Wallet]
-> ((Wallet -> Const (Endo [Wallet]) Wallet)
    -> [Wallet] -> Const (Endo [Wallet]) [Wallet])
-> (Wallet -> Const (Endo [Wallet]) Wallet)
-> Map Wallet WalletState
-> Const (Endo [Wallet]) (Map Wallet WalletState)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Wallet -> Const (Endo [Wallet]) Wallet)
-> [Wallet] -> Const (Endo [Wallet]) [Wallet]
forall (f :: * -> *) a. Foldable f => IndexedFold Int (f a) a
folded
        walletFunds :: [(Wallet, Value)]
walletFunds = ((Wallet -> (Wallet, Value)) -> [Wallet] -> [(Wallet, Value)])
-> [Wallet] -> (Wallet -> (Wallet, Value)) -> [(Wallet, Value)]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Wallet -> (Wallet, Value)) -> [Wallet] -> [(Wallet, Value)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Wallet]
wallets ((Wallet -> (Wallet, Value)) -> [(Wallet, Value)])
-> (Wallet -> (Wallet, Value)) -> [(Wallet, Value)]
forall a b. (a -> b) -> a -> b
$ \Wallet
w ->
            (Wallet
w, ((CardanoTx, TxOut) -> Value)
-> Map TxIn (CardanoTx, TxOut) -> Value
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (TxOut -> Value
txOutValue (TxOut -> Value)
-> ((CardanoTx, TxOut) -> TxOut) -> (CardanoTx, TxOut) -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CardanoTx, TxOut) -> TxOut
forall a b. (a, b) -> b
snd) (Map TxIn (CardanoTx, TxOut) -> Value)
-> Map TxIn (CardanoTx, TxOut) -> Value
forall a b. (a -> b) -> a -> b
$ Getting
  (Map TxIn (CardanoTx, TxOut))
  AddressMap
  (Map TxIn (CardanoTx, TxOut))
-> AddressMap -> Map TxIn (CardanoTx, TxOut)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view (CardanoAddress -> Lens' AddressMap (Map TxIn (CardanoTx, TxOut))
AM.fundsAt (Wallet -> CardanoAddress
Wallet.mockWalletAddress Wallet
w)) AddressMap
fullState)
    in [(Wallet, Value)] -> Map Wallet Value
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Wallet, Value)]
walletFunds

-- | Get the emulator log.
emLog :: EmulatorState -> [LogMessage EmulatorEvent]
emLog :: EmulatorState -> [LogMessage EmulatorEvent]
emLog = Getting
  [LogMessage EmulatorEvent] EmulatorState [LogMessage EmulatorEvent]
-> EmulatorState -> [LogMessage EmulatorEvent]
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  [LogMessage EmulatorEvent] EmulatorState [LogMessage EmulatorEvent]
Lens' EmulatorState [LogMessage EmulatorEvent]
emulatorLog

emptyEmulatorState :: EmulatorState
emptyEmulatorState :: EmulatorState
emptyEmulatorState = EmulatorState :: ChainState
-> Map Wallet WalletState
-> [LogMessage EmulatorEvent]
-> EmulatorState
EmulatorState {
    _chainState :: ChainState
_chainState = ChainState
Chain.emptyChainState,
    _walletStates :: Map Wallet WalletState
_walletStates = Map Wallet WalletState
forall a. Monoid a => a
mempty,
    _emulatorLog :: [LogMessage EmulatorEvent]
_emulatorLog = [LogMessage EmulatorEvent]
forall a. Monoid a => a
mempty
    }

-- | Initialise the emulator state with a blockchain.
emulatorState :: Blockchain -> EmulatorState
emulatorState :: Blockchain -> EmulatorState
emulatorState Blockchain
bc = EmulatorState
emptyEmulatorState
    EmulatorState -> (EmulatorState -> EmulatorState) -> EmulatorState
forall a b. a -> (a -> b) -> b
& (ChainState -> Identity ChainState)
-> EmulatorState -> Identity EmulatorState
Lens' EmulatorState ChainState
chainState ((ChainState -> Identity ChainState)
 -> EmulatorState -> Identity EmulatorState)
-> ChainState -> EmulatorState -> EmulatorState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Blockchain -> ChainState
Chain.fromBlockchain Blockchain
bc

-- | Initialise the emulator state with a pool of pending transactions.
emulatorStatePool :: Chain.TxPool -> EmulatorState
emulatorStatePool :: TxPool -> EmulatorState
emulatorStatePool TxPool
tp = EmulatorState
emptyEmulatorState
    EmulatorState -> (EmulatorState -> EmulatorState) -> EmulatorState
forall a b. a -> (a -> b) -> b
& (ChainState -> Identity ChainState)
-> EmulatorState -> Identity EmulatorState
Lens' EmulatorState ChainState
chainState ((ChainState -> Identity ChainState)
 -> EmulatorState -> Identity EmulatorState)
-> ((TxPool -> Identity TxPool)
    -> ChainState -> Identity ChainState)
-> (TxPool -> Identity TxPool)
-> EmulatorState
-> Identity EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TxPool -> Identity TxPool) -> ChainState -> Identity ChainState
Lens' ChainState TxPool
Chain.txPool ((TxPool -> Identity TxPool)
 -> EmulatorState -> Identity EmulatorState)
-> TxPool -> EmulatorState -> EmulatorState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxPool
tp

{- Note [Creating wallets with multiple outputs]

Every transaction needs a collateral input, which is a wallet output that gets spent
when the transaction fails to validate on chain (phase 2 validation). This output is required
to be an Ada-only output. To make sure we always have an Ada-only output available during emulation,
we create 10 Ada-only outputs per wallet here.
-}

-- | Initialise the emulator state with a single pending transaction that
--   creates the initial distribution of funds to public key addresses.
emulatorStateInitialDist :: Params -> Map PaymentPubKeyHash C.Value -> Either ToCardanoError EmulatorState
emulatorStateInitialDist :: Params
-> Map PaymentPubKeyHash Value
-> Either ToCardanoError EmulatorState
emulatorStateInitialDist Params
params Map PaymentPubKeyHash Value
mp = do
    Lovelace
minAdaEmptyTxOut <- Either ToCardanoError Lovelace
mMinAdaTxOut
    [[TxOut]]
outs <- ((PaymentPubKeyHash, Value) -> Either ToCardanoError [TxOut])
-> [(PaymentPubKeyHash, Value)] -> Either ToCardanoError [[TxOut]]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Lovelace
-> (PaymentPubKeyHash, Value) -> Either ToCardanoError [TxOut]
mkOutputs Lovelace
minAdaEmptyTxOut) (Map PaymentPubKeyHash Value -> [(PaymentPubKeyHash, Value)]
forall k a. Map k a -> [(k, a)]
Map.toList Map PaymentPubKeyHash Value
mp)
    (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
validityRange <- SlotRange
-> Either
     ToCardanoError
     (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
C.toCardanoValidityRange SlotRange
WAPI.defaultSlotRange
    ScriptWitness WitCtxMint BabbageEra
mintWitness <- (ToCardanoError
 -> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra))
-> (ScriptWitness WitCtxMint BabbageEra
    -> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra))
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
forall a. HasCallStack => String -> a
error (String
 -> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra))
-> (ToCardanoError -> String)
-> ToCardanoError
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ToCardanoError -> String
forall a. Show a => a -> String
show) ScriptWitness WitCtxMint BabbageEra
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
 -> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra))
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
forall a b. (a -> b) -> a -> b
$ ScriptLanguageInEra PlutusScriptV2 BabbageEra
-> PlutusScriptVersion PlutusScriptV2
-> PlutusScriptOrReferenceInput PlutusScriptV2
-> ScriptDatum WitCtxMint
-> ScriptRedeemer
-> ExecutionUnits
-> ScriptWitness WitCtxMint BabbageEra
forall lang era witctx.
ScriptLanguageInEra lang era
-> PlutusScriptVersion lang
-> PlutusScriptOrReferenceInput lang
-> ScriptDatum witctx
-> ScriptRedeemer
-> ExecutionUnits
-> ScriptWitness witctx era
C.PlutusScriptWitness ScriptLanguageInEra PlutusScriptV2 BabbageEra
C.PlutusScriptV2InBabbage PlutusScriptVersion PlutusScriptV2
C.PlutusScriptV2
                           (PlutusScriptOrReferenceInput PlutusScriptV2
 -> ScriptDatum WitCtxMint
 -> ScriptRedeemer
 -> ExecutionUnits
 -> ScriptWitness WitCtxMint BabbageEra)
-> Either
     ToCardanoError (PlutusScriptOrReferenceInput PlutusScriptV2)
-> Either
     ToCardanoError
     (ScriptDatum WitCtxMint
      -> ScriptRedeemer
      -> ExecutionUnits
      -> ScriptWitness WitCtxMint BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PlutusScript PlutusScriptV2
-> PlutusScriptOrReferenceInput PlutusScriptV2
forall lang. PlutusScript lang -> PlutusScriptOrReferenceInput lang
C.PScript (PlutusScript PlutusScriptV2
 -> PlutusScriptOrReferenceInput PlutusScriptV2)
-> Either ToCardanoError (PlutusScript PlutusScriptV2)
-> Either
     ToCardanoError (PlutusScriptOrReferenceInput PlutusScriptV2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType (PlutusScript PlutusScriptV2)
-> Script -> Either ToCardanoError (PlutusScript PlutusScriptV2)
forall plutusScript.
SerialiseAsRawBytes plutusScript =>
AsType plutusScript -> Script -> Either ToCardanoError plutusScript
C.toCardanoPlutusScript
                                                  (AsType PlutusScriptV2 -> AsType (PlutusScript PlutusScriptV2)
forall lang. AsType lang -> AsType (PlutusScript lang)
C.AsPlutusScript AsType PlutusScriptV2
C.AsPlutusScriptV2)
                                                  (MintingPolicy -> Script
getMintingPolicy MintingPolicy
alwaysSucceedPolicy))
                           Either
  ToCardanoError
  (ScriptDatum WitCtxMint
   -> ScriptRedeemer
   -> ExecutionUnits
   -> ScriptWitness WitCtxMint BabbageEra)
-> Either ToCardanoError (ScriptDatum WitCtxMint)
-> Either
     ToCardanoError
     (ScriptRedeemer
      -> ExecutionUnits -> ScriptWitness WitCtxMint BabbageEra)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ScriptDatum WitCtxMint
-> Either ToCardanoError (ScriptDatum WitCtxMint)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScriptDatum WitCtxMint
C.NoScriptDatumForMint
                           Either
  ToCardanoError
  (ScriptRedeemer
   -> ExecutionUnits -> ScriptWitness WitCtxMint BabbageEra)
-> Either ToCardanoError ScriptRedeemer
-> Either
     ToCardanoError
     (ExecutionUnits -> ScriptWitness WitCtxMint BabbageEra)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ScriptRedeemer -> Either ToCardanoError ScriptRedeemer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Data -> ScriptRedeemer
C.fromPlutusData (Data -> ScriptRedeemer) -> Data -> ScriptRedeemer
forall a b. (a -> b) -> a -> b
$ Redeemer -> Data
forall a. ToData a => a -> Data
toData Redeemer
Script.unitRedeemer)
                           Either
  ToCardanoError
  (ExecutionUnits -> ScriptWitness WitCtxMint BabbageEra)
-> Either ToCardanoError ExecutionUnits
-> Either ToCardanoError (ScriptWitness WitCtxMint BabbageEra)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ExecutionUnits -> Either ToCardanoError ExecutionUnits
forall (f :: * -> *) a. Applicative f => a -> f a
pure ExecutionUnits
C.zeroExecutionUnits
    let
        txBodyContent :: TxBodyContent BuildTx BabbageEra
txBodyContent = TxBodyContent BuildTx BabbageEra
emptyTxBodyContent
           { txIns :: TxIns BuildTx BabbageEra
C.txIns = [ (TxIn
Index.genesisTxIn, Witness WitCtxTxIn BabbageEra
-> BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra)
forall a. a -> BuildTxWith BuildTx a
C.BuildTxWith (KeyWitnessInCtx WitCtxTxIn -> Witness WitCtxTxIn BabbageEra
forall witctx era. KeyWitnessInCtx witctx -> Witness witctx era
C.KeyWitness KeyWitnessInCtx WitCtxTxIn
C.KeyWitnessForSpending)) ]
           , txInsCollateral :: TxInsCollateral BabbageEra
C.txInsCollateral = CollateralSupportedInEra BabbageEra
-> [TxIn] -> TxInsCollateral BabbageEra
forall era.
CollateralSupportedInEra era -> [TxIn] -> TxInsCollateral era
C.TxInsCollateral CollateralSupportedInEra BabbageEra
C.CollateralInBabbageEra [TxIn
Index.genesisTxIn]
           , txMintValue :: TxMintValue BuildTx BabbageEra
C.txMintValue = MultiAssetSupportedInEra BabbageEra
-> Value
-> BuildTxWith
     BuildTx (Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
-> TxMintValue BuildTx BabbageEra
forall era build.
MultiAssetSupportedInEra era
-> Value
-> BuildTxWith build (Map PolicyId (ScriptWitness WitCtxMint era))
-> TxMintValue build era
C.TxMintValue MultiAssetSupportedInEra BabbageEra
C.MultiAssetInBabbageEra (Map PaymentPubKeyHash Value -> Value
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold (Map PaymentPubKeyHash Value -> Value)
-> Map PaymentPubKeyHash Value -> Value
forall a b. (a -> b) -> a -> b
$ (Value -> Value)
-> Map PaymentPubKeyHash Value -> Map PaymentPubKeyHash Value
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map Value -> Value
CardanoAPI.noAdaValue Map PaymentPubKeyHash Value
mp)
                              (Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
-> BuildTxWith
     BuildTx (Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
forall a. a -> BuildTxWith BuildTx a
C.BuildTxWith (PolicyId
-> ScriptWitness WitCtxMint BabbageEra
-> Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
forall k a. k -> a -> Map k a
Map.singleton PolicyId
alwaysSucceedPolicyId ScriptWitness WitCtxMint BabbageEra
mintWitness))
           , txOuts :: [TxOut CtxTx BabbageEra]
C.txOuts = TxOut -> TxOut CtxTx BabbageEra
Tx.getTxOut (TxOut -> TxOut CtxTx BabbageEra)
-> [TxOut] -> [TxOut CtxTx BabbageEra]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [[TxOut]] -> [TxOut]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[TxOut]]
outs
           , txValidityRange :: (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
C.txValidityRange = (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
validityRange
           }
    TxBody BabbageEra
txBody <- (TxBodyError -> Either ToCardanoError (TxBody BabbageEra))
-> (TxBody BabbageEra -> Either ToCardanoError (TxBody BabbageEra))
-> Either TxBodyError (TxBody BabbageEra)
-> Either ToCardanoError (TxBody BabbageEra)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> Either ToCardanoError (TxBody BabbageEra)
forall a. HasCallStack => String -> a
error (String -> Either ToCardanoError (TxBody BabbageEra))
-> (TxBodyError -> String)
-> TxBodyError
-> Either ToCardanoError (TxBody BabbageEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
"emulatorStateInitialDist: Can't create TxBody: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<>) ShowS -> (TxBodyError -> String) -> TxBodyError -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxBodyError -> String
forall a. Show a => a -> String
show) TxBody BabbageEra -> Either ToCardanoError (TxBody BabbageEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either TxBodyError (TxBody BabbageEra)
 -> Either ToCardanoError (TxBody BabbageEra))
-> Either TxBodyError (TxBody BabbageEra)
-> Either ToCardanoError (TxBody BabbageEra)
forall a b. (a -> b) -> a -> b
$ TxBodyContent BuildTx BabbageEra
-> Either TxBodyError (TxBody BabbageEra)
forall era.
IsCardanoEra era =>
TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
C.makeTransactionBody TxBodyContent BuildTx BabbageEra
txBodyContent
    let cTx :: CardanoTx
cTx = CardanoTx -> CardanoTx
signAll (CardanoTx -> CardanoTx) -> CardanoTx -> CardanoTx
forall a b. (a -> b) -> a -> b
$ Tx BabbageEra -> CardanoTx
CardanoEmulatorEraTx (Tx BabbageEra -> CardanoTx) -> Tx BabbageEra -> CardanoTx
forall a b. (a -> b) -> a -> b
$ TxBody BabbageEra -> [KeyWitness BabbageEra] -> Tx BabbageEra
forall era. TxBody era -> [KeyWitness era] -> Tx era
C.Tx TxBody BabbageEra
txBody []
    EmulatorState -> Either ToCardanoError EmulatorState
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EmulatorState -> Either ToCardanoError EmulatorState)
-> EmulatorState -> Either ToCardanoError EmulatorState
forall a b. (a -> b) -> a -> b
$ TxPool -> EmulatorState
emulatorStatePool [CardanoTx
cTx]
    where
        -- we start with an empty TxOut and we adjust it to be sure that the contained Adas fit the size
        -- of the TxOut
        mMinAdaTxOut :: Either ToCardanoError Lovelace
mMinAdaTxOut = do
          let k :: PaymentPubKeyHash
k = (PaymentPubKeyHash, Value) -> PaymentPubKeyHash
forall a b. (a, b) -> a
fst ((PaymentPubKeyHash, Value) -> PaymentPubKeyHash)
-> (PaymentPubKeyHash, Value) -> PaymentPubKeyHash
forall a b. (a -> b) -> a -> b
$ [(PaymentPubKeyHash, Value)] -> (PaymentPubKeyHash, Value)
forall a. [a] -> a
head ([(PaymentPubKeyHash, Value)] -> (PaymentPubKeyHash, Value))
-> [(PaymentPubKeyHash, Value)] -> (PaymentPubKeyHash, Value)
forall a b. (a -> b) -> a -> b
$ Map PaymentPubKeyHash Value -> [(PaymentPubKeyHash, Value)]
forall k a. Map k a -> [(k, a)]
Map.toList Map PaymentPubKeyHash Value
mp
          TxOut
emptyTxOut <- PaymentPubKeyHash -> Value -> Either ToCardanoError TxOut
mkOutput PaymentPubKeyHash
k Value
forall a. Monoid a => a
mempty
          Lovelace -> Either ToCardanoError Lovelace
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Lovelace -> Either ToCardanoError Lovelace)
-> Lovelace -> Either ToCardanoError Lovelace
forall a b. (a -> b) -> a -> b
$ PParams (BabbageEra StandardCrypto) -> TxOut -> Lovelace
minAdaTxOut (Params -> PParams (BabbageEra StandardCrypto)
emulatorPParams Params
params) TxOut
emptyTxOut
        -- See [Creating wallets with multiple outputs]
        mkOutputs :: Lovelace
-> (PaymentPubKeyHash, Value) -> Either ToCardanoError [TxOut]
mkOutputs Lovelace
minAda (PaymentPubKeyHash
key, Value
vl) = (Value -> Either ToCardanoError TxOut)
-> [Value] -> Either ToCardanoError [TxOut]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (PaymentPubKeyHash -> Value -> Either ToCardanoError TxOut
mkOutput PaymentPubKeyHash
key) (Value -> Lovelace -> [Value]
splitInto10 Value
vl Lovelace
minAda)
        splitInto10 :: Value -> Lovelace -> [Value]
splitInto10 Value
vl Lovelace
minAda = if Lovelace
count Lovelace -> Lovelace -> Bool
forall a. Ord a => a -> a -> Bool
<= Lovelace
1
            then [Value
vl]
            else Int -> Value -> [Value]
forall a. Int -> a -> [a]
replicate (Lovelace -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Lovelace
count) (Lovelace -> Value
lovelaceToValue (Lovelace
ada Lovelace -> Lovelace -> Lovelace
forall a. Integral a => a -> a -> a
`div` Lovelace
count)) [Value] -> [Value] -> [Value]
forall a. [a] -> [a] -> [a]
++ [Value]
remainder
            where
                ada :: Lovelace
ada = case Value -> Maybe Lovelace
C.valueToLovelace Value
vl of
                    Just Lovelace
lovelace -> Lovelace
lovelace
                    Maybe Lovelace
Nothing       -> Value -> Lovelace
C.selectLovelace Value
vl Lovelace -> Lovelace -> Lovelace
forall a. Num a => a -> a -> a
- Lovelace
minAda
                -- Make sure we don't make the outputs too small
                count :: Lovelace
count = Lovelace -> Lovelace -> Lovelace
forall a. Ord a => a -> a -> a
min Lovelace
10 (Lovelace -> Lovelace) -> Lovelace -> Lovelace
forall a b. (a -> b) -> a -> b
$ Lovelace
ada Lovelace -> Lovelace -> Lovelace
forall a. Integral a => a -> a -> a
`div` Lovelace
minAda
                remainder :: [Value]
remainder = [ Value
vl Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> Lovelace -> Value
lovelaceToValue (-Lovelace
ada) | Maybe Lovelace -> Bool
forall a. Maybe a -> Bool
isNothing (Value -> Maybe Lovelace
C.valueToLovelace Value
vl) ]
        mkOutput :: PaymentPubKeyHash -> Value -> Either ToCardanoError TxOut
mkOutput PaymentPubKeyHash
key Value
vl = do
            CardanoAddress
addr <- NetworkId -> Address -> Either ToCardanoError CardanoAddress
CardanoAPI.toCardanoAddressInEra (Params -> NetworkId
pNetworkId Params
params) (PaymentPubKeyHash -> Maybe StakingCredential -> Address
pubKeyHashAddress PaymentPubKeyHash
key Maybe StakingCredential
forall a. Maybe a
Nothing)
            TxOut -> Either ToCardanoError TxOut
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxOut -> Either ToCardanoError TxOut)
-> TxOut -> Either ToCardanoError TxOut
forall a b. (a -> b) -> a -> b
$ TxOut CtxTx BabbageEra -> TxOut
TxOut (TxOut CtxTx BabbageEra -> TxOut)
-> TxOut CtxTx BabbageEra -> TxOut
forall a b. (a -> b) -> a -> b
$ CardanoAddress
-> TxOutValue BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxTx BabbageEra
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
C.TxOut CardanoAddress
addr (Value -> TxOutValue BabbageEra
CardanoAPI.toCardanoTxOutValue Value
vl) TxOutDatum CtxTx BabbageEra
forall ctx era. TxOutDatum ctx era
C.TxOutDatumNone ReferenceScript BabbageEra
forall era. ReferenceScript era
C.ReferenceScriptNone

type MultiAgentEffs =
    '[ State EmulatorState
     , LogMsg EmulatorEvent'
     , Error WAPI.WalletAPIError
     , Error ChainIndex.ChainIndexError
     , Chain.ChainEffect
     , Chain.ChainControlEffect
     ]

handleMultiAgentControl
    :: forall effs. Members MultiAgentEffs effs
    => Eff (MultiAgentControlEffect ': effs) ~> Eff effs
handleMultiAgentControl :: Eff (MultiAgentControlEffect : effs) ~> Eff effs
handleMultiAgentControl = (MultiAgentControlEffect ~> Eff effs)
-> Eff (MultiAgentControlEffect : effs) ~> Eff effs
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((MultiAgentControlEffect ~> Eff effs)
 -> Eff (MultiAgentControlEffect : effs) ~> Eff effs)
-> (MultiAgentControlEffect ~> Eff effs)
-> Eff (MultiAgentControlEffect : effs) ~> Eff effs
forall a b. (a -> b) -> a -> b
$ \case
    WalletControlAction wallet act -> do
        let
            p1 :: AReview EmulatorEvent' Wallet.WalletEvent
            p1 :: AReview EmulatorEvent' WalletEvent
p1 = Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
wallet
            p2 :: AReview EmulatorEvent' NC.NodeClientEvent
            p2 :: AReview EmulatorEvent' NodeClientEvent
p2 = Wallet -> Prism' EmulatorEvent' NodeClientEvent
walletClientEvent Wallet
wallet
            p3 :: AReview EmulatorEvent' ChainIndex.ChainIndexLog
            p3 :: AReview EmulatorEvent' ChainIndexLog
p3 = Wallet -> Prism' EmulatorEvent' ChainIndexLog
chainIndexEvent Wallet
wallet
            p4 :: AReview EmulatorEvent' T.Text
            p4 :: AReview EmulatorEvent' Text
p4 =  Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
wallet AReview EmulatorEvent' WalletEvent
-> (Tagged Text (Identity Text)
    -> Tagged WalletEvent (Identity WalletEvent))
-> AReview EmulatorEvent' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tagged Text (Identity Text)
-> Tagged WalletEvent (Identity WalletEvent)
Prism' WalletEvent Text
Wallet._GenericLog
        Eff EmulatedWalletControlEffects x
act
            Eff EmulatedWalletControlEffects x
-> (Eff EmulatedWalletControlEffects x
    -> Eff
         (NodeClientControlEffect
            : ChainIndexControlEffect : SigningProcessControlEffect
            : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (NodeClientControlEffect
        : ChainIndexControlEffect : SigningProcessControlEffect
        : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff EmulatedWalletControlEffects x
-> Eff
     (NodeClientControlEffect
        : ChainIndexControlEffect : SigningProcessControlEffect
        : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall (effs :: [* -> *]) (as :: [* -> *]).
CanWeakenEnd as effs =>
Eff as ~> Eff effs
raiseEnd
            Eff
  (NodeClientControlEffect
     : ChainIndexControlEffect : SigningProcessControlEffect
     : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (NodeClientControlEffect
         : ChainIndexControlEffect : SigningProcessControlEffect
         : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (ChainIndexControlEffect
            : SigningProcessControlEffect : LogObserve (LogMessage Text)
            : LogMsg Text : State WalletState : LogMsg WalletEvent
            : State NodeClientState : LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (ChainIndexControlEffect
        : SigningProcessControlEffect : LogObserve (LogMessage Text)
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff
  (NodeClientControlEffect
     : ChainIndexControlEffect : SigningProcessControlEffect
     : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> Eff
     (ChainIndexControlEffect
        : SigningProcessControlEffect : LogObserve (LogMessage Text)
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall (effs :: [* -> *]).
Members NodeClientEffs effs =>
Eff (NodeClientControlEffect : effs) ~> Eff effs
NC.handleNodeControl
            Eff
  (ChainIndexControlEffect
     : SigningProcessControlEffect : LogObserve (LogMessage Text)
     : LogMsg Text : State WalletState : LogMsg WalletEvent
     : State NodeClientState : LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (ChainIndexControlEffect
         : SigningProcessControlEffect : LogObserve (LogMessage Text)
         : LogMsg Text : State WalletState : LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (SigningProcessControlEffect
            : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (SigningProcessControlEffect
        : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (ChainIndexControlEffect
 ~> Eff
      (SigningProcessControlEffect
         : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (ChainIndexControlEffect
        : SigningProcessControlEffect : LogObserve (LogMessage Text)
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (SigningProcessControlEffect
           : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
           : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret forall (effs :: [* -> *]).
(Member (State ChainIndexEmulatorState) effs,
 Member (Error ChainIndexError) effs,
 Member (LogMsg ChainIndexLog) effs) =>
ChainIndexControlEffect ~> Eff effs
ChainIndexControlEffect
~> Eff
     (SigningProcessControlEffect
        : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
ChainIndex.handleControl
            Eff
  (SigningProcessControlEffect
     : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (SigningProcessControlEffect
         : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogObserve (LogMessage Text)
            : LogMsg Text : State WalletState : LogMsg WalletEvent
            : State NodeClientState : LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogObserve (LogMessage Text)
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff
  (SigningProcessControlEffect
     : LogObserve (LogMessage Text) : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> Eff
     (LogObserve (LogMessage Text)
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall (effs :: [* -> *]).
Members SigningProcessEffs effs =>
Eff (SigningProcessControlEffect : effs) ~> Eff effs
Wallet.handleSigningProcessControl
            Eff
  (LogObserve (LogMessage Text)
     : LogMsg Text : State WalletState : LogMsg WalletEvent
     : State NodeClientState : LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogObserve (LogMessage Text)
         : LogMsg Text : State WalletState : LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (LogMsg Text
            : State WalletState : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff
  (LogObserve (LogMessage Text)
     : LogMsg Text : State WalletState : LogMsg WalletEvent
     : State NodeClientState : LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> Eff
     (LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall (effs :: [* -> *]).
Member (LogMsg Text) effs =>
Eff (LogObserve (LogMessage Text) : effs) ~> Eff effs
handleObserveLog
            Eff
  (LogMsg Text
     : State WalletState : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (LogMsg Text
         : State WalletState : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg Text
 ~> Eff
      (State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (State WalletState
           : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((Text -> EmulatorEvent')
-> LogMsg Text
   ~> Eff
        (State WalletState
           : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' Text -> Text -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' Text
p4))
            Eff
  (State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg WalletEvent
            : State NodeClientState : LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (State WalletState
 ~> Eff
      (LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg WalletEvent
           : State NodeClientState : LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState WalletState
-> State WalletState
   ~> Eff
        (LogMsg WalletEvent
           : State NodeClientState : LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet))
            Eff
  (LogMsg WalletEvent
     : State NodeClientState : LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg WalletEvent
 ~> Eff
      (State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((WalletEvent -> EmulatorEvent')
-> LogMsg WalletEvent
   ~> Eff
        (State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' WalletEvent -> WalletEvent -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' WalletEvent
p1))
            Eff
  (State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (State NodeClientState
 ~> Eff
      (LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState NodeClientState
-> State NodeClientState
   ~> Eff
        (LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet ((WalletState -> f WalletState)
 -> EmulatorState -> f EmulatorState)
-> ((NodeClientState -> f NodeClientState)
    -> WalletState -> f WalletState)
-> (NodeClientState -> f NodeClientState)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NodeClientState -> f NodeClientState)
-> WalletState -> f WalletState
Lens' WalletState NodeClientState
Wallet.nodeClient))
            Eff
  (LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg NodeClientEvent
 ~> Eff
      (State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((NodeClientEvent -> EmulatorEvent')
-> LogMsg NodeClientEvent
   ~> Eff
        (State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' NodeClientEvent
-> NodeClientEvent -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' NodeClientEvent
p2))
            Eff
  (State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (State ChainIndexEmulatorState
 ~> Eff
      (LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState ChainIndexEmulatorState
-> State ChainIndexEmulatorState
   ~> Eff
        (LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet ((WalletState -> f WalletState)
 -> EmulatorState -> f EmulatorState)
-> ((ChainIndexEmulatorState -> f ChainIndexEmulatorState)
    -> WalletState -> f WalletState)
-> (ChainIndexEmulatorState -> f ChainIndexEmulatorState)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ChainIndexEmulatorState -> f ChainIndexEmulatorState)
-> WalletState -> f WalletState
Lens' WalletState ChainIndexEmulatorState
Wallet.chainIndexEmulatorState))
            Eff
  (LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg ChainIndexLog
 ~> Eff
      (State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((ChainIndexLog -> EmulatorEvent')
-> LogMsg ChainIndexLog
   ~> Eff
        (State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' ChainIndexLog
-> ChainIndexLog -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' ChainIndexLog
p3))
            Eff
  (State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff (Writer [LogMessage EmulatorEvent] : effs) x)
-> Eff (Writer [LogMessage EmulatorEvent] : effs) x
forall a b. a -> (a -> b) -> b
& (State (Maybe SigningProcess)
 ~> Eff (Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff (Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState (Maybe SigningProcess)
-> State (Maybe SigningProcess)
   ~> Eff (Writer [LogMessage EmulatorEvent] : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet ((WalletState -> f WalletState)
 -> EmulatorState -> f EmulatorState)
-> ((Maybe SigningProcess -> f (Maybe SigningProcess))
    -> WalletState -> f WalletState)
-> (Maybe SigningProcess -> f (Maybe SigningProcess))
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe SigningProcess -> f (Maybe SigningProcess))
-> WalletState -> f WalletState
Lens' WalletState (Maybe SigningProcess)
Wallet.signingProcess))
            Eff (Writer [LogMessage EmulatorEvent] : effs) x
-> (Eff (Writer [LogMessage EmulatorEvent] : effs) x -> Eff effs x)
-> Eff effs x
forall a b. a -> (a -> b) -> b
& (Writer [LogMessage EmulatorEvent] ~> Eff effs)
-> Eff (Writer [LogMessage EmulatorEvent] : effs) ~> Eff effs
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Setter' EmulatorState [LogMessage EmulatorEvent]
-> Writer [LogMessage EmulatorEvent] ~> Eff effs
forall s1 s2 (effs :: [* -> *]).
(Monoid s1, Member (State s2) effs) =>
Setter' s2 s1 -> Writer s1 ~> Eff effs
writeIntoState Lens' EmulatorState [LogMessage EmulatorEvent]
Setter' EmulatorState [LogMessage EmulatorEvent]
emulatorLog)

handleMultiAgent
    :: forall effs. Members MultiAgentEffs effs
    => Eff (MultiAgentEffect ': effs) ~> Eff effs
handleMultiAgent :: Eff (MultiAgentEffect : effs) ~> Eff effs
handleMultiAgent = (MultiAgentEffect ~> Eff effs)
-> Eff (MultiAgentEffect : effs) ~> Eff effs
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((MultiAgentEffect ~> Eff effs)
 -> Eff (MultiAgentEffect : effs) ~> Eff effs)
-> (MultiAgentEffect ~> Eff effs)
-> Eff (MultiAgentEffect : effs) ~> Eff effs
forall a b. (a -> b) -> a -> b
$ \case
    -- TODO: catch, log, and rethrow wallet errors?
    WalletAction wallet act ->  do
        let
            p1 :: AReview EmulatorEvent' Wallet.WalletEvent
            p1 :: AReview EmulatorEvent' WalletEvent
p1 = Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
wallet
            p2 :: AReview EmulatorEvent' NC.NodeClientEvent
            p2 :: AReview EmulatorEvent' NodeClientEvent
p2 = Wallet -> Prism' EmulatorEvent' NodeClientEvent
walletClientEvent Wallet
wallet
            p3 :: AReview EmulatorEvent' ChainIndex.ChainIndexLog
            p3 :: AReview EmulatorEvent' ChainIndexLog
p3 = Wallet -> Prism' EmulatorEvent' ChainIndexLog
chainIndexEvent Wallet
wallet
            p4 :: AReview EmulatorEvent' T.Text
            p4 :: AReview EmulatorEvent' Text
p4 = Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
wallet AReview EmulatorEvent' WalletEvent
-> (Tagged Text (Identity Text)
    -> Tagged WalletEvent (Identity WalletEvent))
-> AReview EmulatorEvent' Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tagged Text (Identity Text)
-> Tagged WalletEvent (Identity WalletEvent)
Prism' WalletEvent Text
Wallet._GenericLog
            p5 :: AReview EmulatorEvent' RequestHandlerLogMsg
            p5 :: AReview EmulatorEvent' RequestHandlerLogMsg
p5 = Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
wallet AReview EmulatorEvent' WalletEvent
-> (Tagged RequestHandlerLogMsg (Identity RequestHandlerLogMsg)
    -> Tagged WalletEvent (Identity WalletEvent))
-> AReview EmulatorEvent' RequestHandlerLogMsg
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tagged RequestHandlerLogMsg (Identity RequestHandlerLogMsg)
-> Tagged WalletEvent (Identity WalletEvent)
Prism' WalletEvent RequestHandlerLogMsg
Wallet._RequestHandlerLog
            p6 :: AReview EmulatorEvent' TxBalanceMsg
            p6 :: AReview EmulatorEvent' TxBalanceMsg
p6 = Wallet -> Prism' EmulatorEvent' WalletEvent
walletEvent Wallet
wallet AReview EmulatorEvent' WalletEvent
-> (Tagged TxBalanceMsg (Identity TxBalanceMsg)
    -> Tagged WalletEvent (Identity WalletEvent))
-> AReview EmulatorEvent' TxBalanceMsg
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tagged TxBalanceMsg (Identity TxBalanceMsg)
-> Tagged WalletEvent (Identity WalletEvent)
Prism' WalletEvent TxBalanceMsg
Wallet._TxBalanceLog
        Eff EmulatedWalletEffects x
act
            Eff EmulatedWalletEffects x
-> (Eff EmulatedWalletEffects x
    -> Eff
         (WalletEffect
            : Error WalletAPIError : NodeClientEffect : ChainIndexQueryEffect
            : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (WalletEffect
        : Error WalletAPIError : NodeClientEffect : ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff EmulatedWalletEffects x
-> Eff
     (WalletEffect
        : Error WalletAPIError : NodeClientEffect : ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall (effs :: [* -> *]) (as :: [* -> *]).
CanWeakenEnd as effs =>
Eff as ~> Eff effs
raiseEnd
            Eff
  (WalletEffect
     : Error WalletAPIError : NodeClientEffect : ChainIndexQueryEffect
     : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
     : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (WalletEffect
         : Error WalletAPIError : NodeClientEffect : ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (Error WalletAPIError
            : NodeClientEffect : ChainIndexQueryEffect
            : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (Error WalletAPIError
        : NodeClientEffect : ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (WalletEffect
 ~> Eff
      (Error WalletAPIError
         : NodeClientEffect : ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (WalletEffect
        : Error WalletAPIError : NodeClientEffect : ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (Error WalletAPIError
           : NodeClientEffect : ChainIndexQueryEffect
           : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
           : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
           : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret forall (effs :: [* -> *]).
(Member (Error WalletAPIError) effs, Member NodeClientEffect effs,
 Member ChainIndexQueryEffect effs, Member (State WalletState) effs,
 Member (LogMsg TxBalanceMsg) effs) =>
WalletEffect ~> Eff effs
WalletEffect
~> Eff
     (Error WalletAPIError
        : NodeClientEffect : ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
Wallet.handleWallet
            Eff
  (Error WalletAPIError
     : NodeClientEffect : ChainIndexQueryEffect
     : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
     : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (Error WalletAPIError
         : NodeClientEffect : ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (NodeClientEffect
            : ChainIndexQueryEffect : LogObserve (LogMessage Text)
            : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
            : State WalletState : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (NodeClientEffect
        : ChainIndexQueryEffect : LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff
  (Error WalletAPIError
     : NodeClientEffect : ChainIndexQueryEffect
     : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
     : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> Eff
     (NodeClientEffect
        : ChainIndexQueryEffect : LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall (eff :: * -> *) (effs :: [* -> *]).
Member eff effs =>
Eff (eff : effs) ~> Eff effs
subsume
            Eff
  (NodeClientEffect
     : ChainIndexQueryEffect : LogObserve (LogMessage Text)
     : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
     : State WalletState : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (NodeClientEffect
         : ChainIndexQueryEffect : LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : State WalletState : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (ChainIndexQueryEffect
            : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff
  (NodeClientEffect
     : ChainIndexQueryEffect : LogObserve (LogMessage Text)
     : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
     : State WalletState : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> Eff
     (ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall (effs :: [* -> *]).
Members NodeClientEffs effs =>
Eff (NodeClientEffect : effs) ~> Eff effs
NC.handleNodeClient
            Eff
  (ChainIndexQueryEffect
     : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
     : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (ChainIndexQueryEffect
         : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogObserve (LogMessage Text)
            : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
            : State WalletState : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (ChainIndexQueryEffect
 ~> Eff
      (LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : State WalletState : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (ChainIndexQueryEffect
        : LogObserve (LogMessage Text) : LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogObserve (LogMessage Text)
           : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
           : State WalletState : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret forall (effs :: [* -> *]).
(Member (State ChainIndexEmulatorState) effs,
 Member (Error ChainIndexError) effs,
 Member (LogMsg ChainIndexLog) effs) =>
ChainIndexQueryEffect ~> Eff effs
ChainIndexQueryEffect
~> Eff
     (LogObserve (LogMessage Text)
        : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
ChainIndex.handleQuery
            Eff
  (LogObserve (LogMessage Text)
     : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
     : State WalletState : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (LogObserve (LogMessage Text)
         : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
         : State WalletState : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg RequestHandlerLogMsg
            : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& Eff
  (LogObserve (LogMessage Text)
     : LogMsg RequestHandlerLogMsg : LogMsg TxBalanceMsg : LogMsg Text
     : State WalletState : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> Eff
     (LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall (effs :: [* -> *]).
Member (LogMsg Text) effs =>
Eff (LogObserve (LogMessage Text) : effs) ~> Eff effs
handleObserveLog
            Eff
  (LogMsg RequestHandlerLogMsg
     : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (LogMsg RequestHandlerLogMsg
         : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg TxBalanceMsg
            : LogMsg Text : State WalletState : LogMsg WalletEvent
            : State NodeClientState : LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg TxBalanceMsg
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg RequestHandlerLogMsg
 ~> Eff
      (LogMsg TxBalanceMsg
         : LogMsg Text : State WalletState : LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (LogMsg RequestHandlerLogMsg
        : LogMsg TxBalanceMsg : LogMsg Text : State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg TxBalanceMsg
           : LogMsg Text : State WalletState : LogMsg WalletEvent
           : State NodeClientState : LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((RequestHandlerLogMsg -> EmulatorEvent')
-> LogMsg RequestHandlerLogMsg
   ~> Eff
        (LogMsg TxBalanceMsg
           : LogMsg Text : State WalletState : LogMsg WalletEvent
           : State NodeClientState : LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' RequestHandlerLogMsg
-> RequestHandlerLogMsg -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' RequestHandlerLogMsg
p5))
            Eff
  (LogMsg TxBalanceMsg
     : LogMsg Text : State WalletState : LogMsg WalletEvent
     : State NodeClientState : LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg TxBalanceMsg
         : LogMsg Text : State WalletState : LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (LogMsg Text
            : State WalletState : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg TxBalanceMsg
 ~> Eff
      (LogMsg Text
         : State WalletState : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg TxBalanceMsg
        : LogMsg Text : State WalletState : LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (LogMsg Text
           : State WalletState : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((TxBalanceMsg -> EmulatorEvent')
-> LogMsg TxBalanceMsg
   ~> Eff
        (LogMsg Text
           : State WalletState : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' TxBalanceMsg
-> TxBalanceMsg -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' TxBalanceMsg
p6))
            Eff
  (LogMsg Text
     : State WalletState : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (LogMsg Text
         : State WalletState : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (State WalletState
            : LogMsg WalletEvent : State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg Text
 ~> Eff
      (State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg Text
        : State WalletState : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (State WalletState
           : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((Text -> EmulatorEvent')
-> LogMsg Text
   ~> Eff
        (State WalletState
           : LogMsg WalletEvent : State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' Text -> Text -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' Text
p4))
            Eff
  (State WalletState
     : LogMsg WalletEvent : State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State WalletState
         : LogMsg WalletEvent : State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg WalletEvent
            : State NodeClientState : LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (State WalletState
 ~> Eff
      (LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (State WalletState
        : LogMsg WalletEvent : State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg WalletEvent
           : State NodeClientState : LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState WalletState
-> State WalletState
   ~> Eff
        (LogMsg WalletEvent
           : State NodeClientState : LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet))
            Eff
  (LogMsg WalletEvent
     : State NodeClientState : LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg WalletEvent
         : State NodeClientState : LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (State NodeClientState
            : LogMsg NodeClientEvent : State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg WalletEvent
 ~> Eff
      (State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg WalletEvent
        : State NodeClientState : LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((WalletEvent -> EmulatorEvent')
-> LogMsg WalletEvent
   ~> Eff
        (State NodeClientState
           : LogMsg NodeClientEvent : State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' WalletEvent -> WalletEvent -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' WalletEvent
p1))
            Eff
  (State NodeClientState
     : LogMsg NodeClientEvent : State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State NodeClientState
         : LogMsg NodeClientEvent : State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg NodeClientEvent
            : State ChainIndexEmulatorState : LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (State NodeClientState
 ~> Eff
      (LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (State NodeClientState
        : LogMsg NodeClientEvent : State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState NodeClientState
-> State NodeClientState
   ~> Eff
        (LogMsg NodeClientEvent
           : State ChainIndexEmulatorState : LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet ((WalletState -> f WalletState)
 -> EmulatorState -> f EmulatorState)
-> ((NodeClientState -> f NodeClientState)
    -> WalletState -> f WalletState)
-> (NodeClientState -> f NodeClientState)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NodeClientState -> f NodeClientState)
-> WalletState -> f WalletState
Lens' WalletState NodeClientState
Wallet.nodeClient))
            Eff
  (LogMsg NodeClientEvent
     : State ChainIndexEmulatorState : LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg NodeClientEvent
         : State ChainIndexEmulatorState : LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (State ChainIndexEmulatorState
            : LogMsg ChainIndexLog : State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg NodeClientEvent
 ~> Eff
      (State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg NodeClientEvent
        : State ChainIndexEmulatorState : LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((NodeClientEvent -> EmulatorEvent')
-> LogMsg NodeClientEvent
   ~> Eff
        (State ChainIndexEmulatorState
           : LogMsg ChainIndexLog : State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' NodeClientEvent
-> NodeClientEvent -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' NodeClientEvent
p2))
            Eff
  (State ChainIndexEmulatorState
     : LogMsg ChainIndexLog : State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State ChainIndexEmulatorState
         : LogMsg ChainIndexLog : State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff
         (LogMsg ChainIndexLog
            : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
            : effs)
         x)
-> Eff
     (LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
     x
forall a b. a -> (a -> b) -> b
& (State ChainIndexEmulatorState
 ~> Eff
      (LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs))
-> Eff
     (State ChainIndexEmulatorState
        : LogMsg ChainIndexLog : State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff
        (LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState ChainIndexEmulatorState
-> State ChainIndexEmulatorState
   ~> Eff
        (LogMsg ChainIndexLog
           : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
           : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet ((WalletState -> f WalletState)
 -> EmulatorState -> f EmulatorState)
-> ((ChainIndexEmulatorState -> f ChainIndexEmulatorState)
    -> WalletState -> f WalletState)
-> (ChainIndexEmulatorState -> f ChainIndexEmulatorState)
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ChainIndexEmulatorState -> f ChainIndexEmulatorState)
-> WalletState -> f WalletState
Lens' WalletState ChainIndexEmulatorState
Wallet.chainIndexEmulatorState))
            Eff
  (LogMsg ChainIndexLog
     : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
     : effs)
  x
-> (Eff
      (LogMsg ChainIndexLog
         : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
         : effs)
      x
    -> Eff
         (State (Maybe SigningProcess)
            : Writer [LogMessage EmulatorEvent] : effs)
         x)
-> Eff
     (State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
     x
forall a b. a -> (a -> b) -> b
& (LogMsg ChainIndexLog
 ~> Eff
      (State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (LogMsg ChainIndexLog
        : State (Maybe SigningProcess) : Writer [LogMessage EmulatorEvent]
        : effs)
   ~> Eff
        (State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret ((ChainIndexLog -> EmulatorEvent')
-> LogMsg ChainIndexLog
   ~> Eff
        (State (Maybe SigningProcess)
           : Writer [LogMessage EmulatorEvent] : effs)
forall a b (effs :: [* -> *]).
Member (LogMsg b) effs =>
(a -> b) -> LogMsg a ~> Eff effs
mapLog (AReview EmulatorEvent' ChainIndexLog
-> ChainIndexLog -> EmulatorEvent'
forall b (m :: * -> *) t. MonadReader b m => AReview t b -> m t
review AReview EmulatorEvent' ChainIndexLog
p3))
            Eff
  (State (Maybe SigningProcess)
     : Writer [LogMessage EmulatorEvent] : effs)
  x
-> (Eff
      (State (Maybe SigningProcess)
         : Writer [LogMessage EmulatorEvent] : effs)
      x
    -> Eff (Writer [LogMessage EmulatorEvent] : effs) x)
-> Eff (Writer [LogMessage EmulatorEvent] : effs) x
forall a b. a -> (a -> b) -> b
& (State (Maybe SigningProcess)
 ~> Eff (Writer [LogMessage EmulatorEvent] : effs))
-> Eff
     (State (Maybe SigningProcess)
        : Writer [LogMessage EmulatorEvent] : effs)
   ~> Eff (Writer [LogMessage EmulatorEvent] : effs)
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Lens' EmulatorState (Maybe SigningProcess)
-> State (Maybe SigningProcess)
   ~> Eff (Writer [LogMessage EmulatorEvent] : effs)
forall s2 (effs :: [* -> *]) s1.
Member (State s2) effs =>
Lens' s2 s1 -> State s1 ~> Eff effs
handleZoomedState (Wallet -> Lens' EmulatorState WalletState
walletState Wallet
wallet ((WalletState -> f WalletState)
 -> EmulatorState -> f EmulatorState)
-> ((Maybe SigningProcess -> f (Maybe SigningProcess))
    -> WalletState -> f WalletState)
-> (Maybe SigningProcess -> f (Maybe SigningProcess))
-> EmulatorState
-> f EmulatorState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe SigningProcess -> f (Maybe SigningProcess))
-> WalletState -> f WalletState
Lens' WalletState (Maybe SigningProcess)
Wallet.signingProcess))
            Eff (Writer [LogMessage EmulatorEvent] : effs) x
-> (Eff (Writer [LogMessage EmulatorEvent] : effs) x -> Eff effs x)
-> Eff effs x
forall a b. a -> (a -> b) -> b
& (Writer [LogMessage EmulatorEvent] ~> Eff effs)
-> Eff (Writer [LogMessage EmulatorEvent] : effs) ~> Eff effs
forall (eff :: * -> *) (effs :: [* -> *]).
(eff ~> Eff effs) -> Eff (eff : effs) ~> Eff effs
interpret (Setter' EmulatorState [LogMessage EmulatorEvent]
-> Writer [LogMessage EmulatorEvent] ~> Eff effs
forall s1 s2 (effs :: [* -> *]).
(Monoid s1, Member (State s2) effs) =>
Setter' s2 s1 -> Writer s1 ~> Eff effs
writeIntoState Lens' EmulatorState [LogMessage EmulatorEvent]
Setter' EmulatorState [LogMessage EmulatorEvent]
emulatorLog)