-- | This modules provides a variety of options associated with a
-- 'Cooked.Skeleton.TxSkel'. These options mostly revolves around customizing
-- the default behavior of cooked-validators's transaction generation mechanism.
module Cooked.Skeleton.Option
  ( BalanceOutputPolicy (..),
    FeePolicy (..),
    BalancingPolicy (..),
    BalancingUtxos (..),
    CollateralUtxos (..),
    AnchorResolution (..),
    TxSkelOpts (..),
    txSkelOptModTxL,
    txSkelOptAutoSlotIncreaseL,
    txSkelOptBalancingPolicyL,
    txSkelOptBalanceOutputPolicyL,
    txSkelOptFeePolicyL,
    txSkelOptBalancingUtxosL,
    txSkelOptModParamsL,
    txSkelOptCollateralUtxosL,
    txSkelOptAnchorResolutionL,
    txSkelOptAddModTx,
    txSkelOptAddModParams,
  )
where

import Cardano.Api qualified as Cardano
import Cardano.Node.Emulator qualified as Emulator
import Cooked.Wallet
import Data.ByteString (ByteString)
import Data.Default
import Data.Map (Map)
import Data.Map qualified as Map
import Data.Set (Set)
import Optics.Core
import Optics.TH
import PlutusLedgerApi.V3 qualified as Api

-- | What fee policy to use in the transaction.
data FeePolicy
  = -- | Use automatic fee computation. If balancing is activated, an optimal
    -- fee will be computed based on the transaction and existing utxos in the
    -- balancing wallet. Otherwise, the maximum transaction fee will be applied.
    AutoFeeComputation
  | -- | Provide a fee to the transaction. If the autobalancing is activated, it
    -- will be attempted around this fee, which might lead to failure if it is
    -- too low, otherwise, this fee will be given to transaction generation.
    ManualFee Integer
  deriving (FeePolicy -> FeePolicy -> Bool
(FeePolicy -> FeePolicy -> Bool)
-> (FeePolicy -> FeePolicy -> Bool) -> Eq FeePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FeePolicy -> FeePolicy -> Bool
== :: FeePolicy -> FeePolicy -> Bool
$c/= :: FeePolicy -> FeePolicy -> Bool
/= :: FeePolicy -> FeePolicy -> Bool
Eq, Eq FeePolicy
Eq FeePolicy =>
(FeePolicy -> FeePolicy -> Ordering)
-> (FeePolicy -> FeePolicy -> Bool)
-> (FeePolicy -> FeePolicy -> Bool)
-> (FeePolicy -> FeePolicy -> Bool)
-> (FeePolicy -> FeePolicy -> Bool)
-> (FeePolicy -> FeePolicy -> FeePolicy)
-> (FeePolicy -> FeePolicy -> FeePolicy)
-> Ord FeePolicy
FeePolicy -> FeePolicy -> Bool
FeePolicy -> FeePolicy -> Ordering
FeePolicy -> FeePolicy -> FeePolicy
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FeePolicy -> FeePolicy -> Ordering
compare :: FeePolicy -> FeePolicy -> Ordering
$c< :: FeePolicy -> FeePolicy -> Bool
< :: FeePolicy -> FeePolicy -> Bool
$c<= :: FeePolicy -> FeePolicy -> Bool
<= :: FeePolicy -> FeePolicy -> Bool
$c> :: FeePolicy -> FeePolicy -> Bool
> :: FeePolicy -> FeePolicy -> Bool
$c>= :: FeePolicy -> FeePolicy -> Bool
>= :: FeePolicy -> FeePolicy -> Bool
$cmax :: FeePolicy -> FeePolicy -> FeePolicy
max :: FeePolicy -> FeePolicy -> FeePolicy
$cmin :: FeePolicy -> FeePolicy -> FeePolicy
min :: FeePolicy -> FeePolicy -> FeePolicy
Ord, Int -> FeePolicy -> ShowS
[FeePolicy] -> ShowS
FeePolicy -> String
(Int -> FeePolicy -> ShowS)
-> (FeePolicy -> String)
-> ([FeePolicy] -> ShowS)
-> Show FeePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FeePolicy -> ShowS
showsPrec :: Int -> FeePolicy -> ShowS
$cshow :: FeePolicy -> String
show :: FeePolicy -> String
$cshowList :: [FeePolicy] -> ShowS
showList :: [FeePolicy] -> ShowS
Show)

instance Default FeePolicy where
  def :: FeePolicy
def = FeePolicy
AutoFeeComputation

-- | Whether to adjust a potentially existing output to the balancing wallet
-- with the change during transaction balancing.
data BalanceOutputPolicy
  = -- | Try to adjust an existing public key output with the change. If no
    -- suitable output can be found, create a new change output.
    AdjustExistingOutput
  | -- | Do not change the existing outputs, always create a new change output.
    DontAdjustExistingOutput
  deriving (BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
(BalanceOutputPolicy -> BalanceOutputPolicy -> Bool)
-> (BalanceOutputPolicy -> BalanceOutputPolicy -> Bool)
-> Eq BalanceOutputPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
== :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
$c/= :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
/= :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
Eq, Eq BalanceOutputPolicy
Eq BalanceOutputPolicy =>
(BalanceOutputPolicy -> BalanceOutputPolicy -> Ordering)
-> (BalanceOutputPolicy -> BalanceOutputPolicy -> Bool)
-> (BalanceOutputPolicy -> BalanceOutputPolicy -> Bool)
-> (BalanceOutputPolicy -> BalanceOutputPolicy -> Bool)
-> (BalanceOutputPolicy -> BalanceOutputPolicy -> Bool)
-> (BalanceOutputPolicy
    -> BalanceOutputPolicy -> BalanceOutputPolicy)
-> (BalanceOutputPolicy
    -> BalanceOutputPolicy -> BalanceOutputPolicy)
-> Ord BalanceOutputPolicy
BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
BalanceOutputPolicy -> BalanceOutputPolicy -> Ordering
BalanceOutputPolicy -> BalanceOutputPolicy -> BalanceOutputPolicy
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BalanceOutputPolicy -> BalanceOutputPolicy -> Ordering
compare :: BalanceOutputPolicy -> BalanceOutputPolicy -> Ordering
$c< :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
< :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
$c<= :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
<= :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
$c> :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
> :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
$c>= :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
>= :: BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
$cmax :: BalanceOutputPolicy -> BalanceOutputPolicy -> BalanceOutputPolicy
max :: BalanceOutputPolicy -> BalanceOutputPolicy -> BalanceOutputPolicy
$cmin :: BalanceOutputPolicy -> BalanceOutputPolicy -> BalanceOutputPolicy
min :: BalanceOutputPolicy -> BalanceOutputPolicy -> BalanceOutputPolicy
Ord, Int -> BalanceOutputPolicy -> ShowS
[BalanceOutputPolicy] -> ShowS
BalanceOutputPolicy -> String
(Int -> BalanceOutputPolicy -> ShowS)
-> (BalanceOutputPolicy -> String)
-> ([BalanceOutputPolicy] -> ShowS)
-> Show BalanceOutputPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BalanceOutputPolicy -> ShowS
showsPrec :: Int -> BalanceOutputPolicy -> ShowS
$cshow :: BalanceOutputPolicy -> String
show :: BalanceOutputPolicy -> String
$cshowList :: [BalanceOutputPolicy] -> ShowS
showList :: [BalanceOutputPolicy] -> ShowS
Show)

instance Default BalanceOutputPolicy where
  def :: BalanceOutputPolicy
def = BalanceOutputPolicy
AdjustExistingOutput

-- | Which UTxOs to use when balancing. Note that utxos that are already known
-- by the skeleton being balanced (in the sense of
-- `Cooked.Skeleton.txSkelKnownTxOutRefs`, i.e. inputs and reference inputs)
-- will be filtered out during balancing.
data BalancingUtxos
  = -- | Use all UTxOs containing only a Value (no datum, no staking credential,
    -- and no reference script) belonging to the balancing wallet.
    BalancingUtxosFromBalancingWallet
  | -- | Use the provided UTxOs. UTxOs belonging to scripts will be filtered out
    BalancingUtxosFromSet (Set Api.TxOutRef)
  deriving (BalancingUtxos -> BalancingUtxos -> Bool
(BalancingUtxos -> BalancingUtxos -> Bool)
-> (BalancingUtxos -> BalancingUtxos -> Bool) -> Eq BalancingUtxos
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BalancingUtxos -> BalancingUtxos -> Bool
== :: BalancingUtxos -> BalancingUtxos -> Bool
$c/= :: BalancingUtxos -> BalancingUtxos -> Bool
/= :: BalancingUtxos -> BalancingUtxos -> Bool
Eq, Eq BalancingUtxos
Eq BalancingUtxos =>
(BalancingUtxos -> BalancingUtxos -> Ordering)
-> (BalancingUtxos -> BalancingUtxos -> Bool)
-> (BalancingUtxos -> BalancingUtxos -> Bool)
-> (BalancingUtxos -> BalancingUtxos -> Bool)
-> (BalancingUtxos -> BalancingUtxos -> Bool)
-> (BalancingUtxos -> BalancingUtxos -> BalancingUtxos)
-> (BalancingUtxos -> BalancingUtxos -> BalancingUtxos)
-> Ord BalancingUtxos
BalancingUtxos -> BalancingUtxos -> Bool
BalancingUtxos -> BalancingUtxos -> Ordering
BalancingUtxos -> BalancingUtxos -> BalancingUtxos
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BalancingUtxos -> BalancingUtxos -> Ordering
compare :: BalancingUtxos -> BalancingUtxos -> Ordering
$c< :: BalancingUtxos -> BalancingUtxos -> Bool
< :: BalancingUtxos -> BalancingUtxos -> Bool
$c<= :: BalancingUtxos -> BalancingUtxos -> Bool
<= :: BalancingUtxos -> BalancingUtxos -> Bool
$c> :: BalancingUtxos -> BalancingUtxos -> Bool
> :: BalancingUtxos -> BalancingUtxos -> Bool
$c>= :: BalancingUtxos -> BalancingUtxos -> Bool
>= :: BalancingUtxos -> BalancingUtxos -> Bool
$cmax :: BalancingUtxos -> BalancingUtxos -> BalancingUtxos
max :: BalancingUtxos -> BalancingUtxos -> BalancingUtxos
$cmin :: BalancingUtxos -> BalancingUtxos -> BalancingUtxos
min :: BalancingUtxos -> BalancingUtxos -> BalancingUtxos
Ord, Int -> BalancingUtxos -> ShowS
[BalancingUtxos] -> ShowS
BalancingUtxos -> String
(Int -> BalancingUtxos -> ShowS)
-> (BalancingUtxos -> String)
-> ([BalancingUtxos] -> ShowS)
-> Show BalancingUtxos
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BalancingUtxos -> ShowS
showsPrec :: Int -> BalancingUtxos -> ShowS
$cshow :: BalancingUtxos -> String
show :: BalancingUtxos -> String
$cshowList :: [BalancingUtxos] -> ShowS
showList :: [BalancingUtxos] -> ShowS
Show)

instance Default BalancingUtxos where
  def :: BalancingUtxos
def = BalancingUtxos
BalancingUtxosFromBalancingWallet

-- | Whether to balance the transaction or not, and which wallet to use to
-- provide outputs for balancing.
data BalancingPolicy
  = -- | Balance with the first signer of the list of signers
    BalanceWithFirstSigner
  | -- | Balance using a given wallet
    BalanceWith Wallet
  | -- | Do not perform balancing at all
    DoNotBalance
  deriving (BalancingPolicy -> BalancingPolicy -> Bool
(BalancingPolicy -> BalancingPolicy -> Bool)
-> (BalancingPolicy -> BalancingPolicy -> Bool)
-> Eq BalancingPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BalancingPolicy -> BalancingPolicy -> Bool
== :: BalancingPolicy -> BalancingPolicy -> Bool
$c/= :: BalancingPolicy -> BalancingPolicy -> Bool
/= :: BalancingPolicy -> BalancingPolicy -> Bool
Eq, Eq BalancingPolicy
Eq BalancingPolicy =>
(BalancingPolicy -> BalancingPolicy -> Ordering)
-> (BalancingPolicy -> BalancingPolicy -> Bool)
-> (BalancingPolicy -> BalancingPolicy -> Bool)
-> (BalancingPolicy -> BalancingPolicy -> Bool)
-> (BalancingPolicy -> BalancingPolicy -> Bool)
-> (BalancingPolicy -> BalancingPolicy -> BalancingPolicy)
-> (BalancingPolicy -> BalancingPolicy -> BalancingPolicy)
-> Ord BalancingPolicy
BalancingPolicy -> BalancingPolicy -> Bool
BalancingPolicy -> BalancingPolicy -> Ordering
BalancingPolicy -> BalancingPolicy -> BalancingPolicy
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BalancingPolicy -> BalancingPolicy -> Ordering
compare :: BalancingPolicy -> BalancingPolicy -> Ordering
$c< :: BalancingPolicy -> BalancingPolicy -> Bool
< :: BalancingPolicy -> BalancingPolicy -> Bool
$c<= :: BalancingPolicy -> BalancingPolicy -> Bool
<= :: BalancingPolicy -> BalancingPolicy -> Bool
$c> :: BalancingPolicy -> BalancingPolicy -> Bool
> :: BalancingPolicy -> BalancingPolicy -> Bool
$c>= :: BalancingPolicy -> BalancingPolicy -> Bool
>= :: BalancingPolicy -> BalancingPolicy -> Bool
$cmax :: BalancingPolicy -> BalancingPolicy -> BalancingPolicy
max :: BalancingPolicy -> BalancingPolicy -> BalancingPolicy
$cmin :: BalancingPolicy -> BalancingPolicy -> BalancingPolicy
min :: BalancingPolicy -> BalancingPolicy -> BalancingPolicy
Ord, Int -> BalancingPolicy -> ShowS
[BalancingPolicy] -> ShowS
BalancingPolicy -> String
(Int -> BalancingPolicy -> ShowS)
-> (BalancingPolicy -> String)
-> ([BalancingPolicy] -> ShowS)
-> Show BalancingPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BalancingPolicy -> ShowS
showsPrec :: Int -> BalancingPolicy -> ShowS
$cshow :: BalancingPolicy -> String
show :: BalancingPolicy -> String
$cshowList :: [BalancingPolicy] -> ShowS
showList :: [BalancingPolicy] -> ShowS
Show)

instance Default BalancingPolicy where
  def :: BalancingPolicy
def = BalancingPolicy
BalanceWithFirstSigner

-- | Describe which UTxOs to use as collaterals
data CollateralUtxos
  = -- | Rely on automated computation with only-value UTxOs from the balancing
    -- wallet. Return collaterals will be sent to this wallet.
    CollateralUtxosFromBalancingWallet
  | -- | Rely on automated computation with only-value UTxOs from a given
    -- wallet. Return collaterals will be sent to this wallet.
    CollateralUtxosFromWallet Wallet
  | -- | Manually provide a set of candidate UTxOs to be used as collaterals
    -- alongside a wallet to send return collaterals back to.
    CollateralUtxosFromSet (Set Api.TxOutRef) Wallet
  deriving (CollateralUtxos -> CollateralUtxos -> Bool
(CollateralUtxos -> CollateralUtxos -> Bool)
-> (CollateralUtxos -> CollateralUtxos -> Bool)
-> Eq CollateralUtxos
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CollateralUtxos -> CollateralUtxos -> Bool
== :: CollateralUtxos -> CollateralUtxos -> Bool
$c/= :: CollateralUtxos -> CollateralUtxos -> Bool
/= :: CollateralUtxos -> CollateralUtxos -> Bool
Eq, Int -> CollateralUtxos -> ShowS
[CollateralUtxos] -> ShowS
CollateralUtxos -> String
(Int -> CollateralUtxos -> ShowS)
-> (CollateralUtxos -> String)
-> ([CollateralUtxos] -> ShowS)
-> Show CollateralUtxos
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CollateralUtxos -> ShowS
showsPrec :: Int -> CollateralUtxos -> ShowS
$cshow :: CollateralUtxos -> String
show :: CollateralUtxos -> String
$cshowList :: [CollateralUtxos] -> ShowS
showList :: [CollateralUtxos] -> ShowS
Show)

instance Default CollateralUtxos where
  def :: CollateralUtxos
def = CollateralUtxos
CollateralUtxosFromBalancingWallet

-- | Describes how to resolve anchors in proposal procedures
data AnchorResolution
  = -- | Provide a map between urls and page content as Bytestring
    AnchorResolutionLocal (Map String ByteString)
  | -- | Allow online fetch of pages from a given URL. Important note: using
    -- this option is unsafe, as it requires a web connection and inherently
    -- prevents guarantees of reproducibily. Use at your own discretion.
    AnchorResolutionHttp
  deriving (AnchorResolution -> AnchorResolution -> Bool
(AnchorResolution -> AnchorResolution -> Bool)
-> (AnchorResolution -> AnchorResolution -> Bool)
-> Eq AnchorResolution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AnchorResolution -> AnchorResolution -> Bool
== :: AnchorResolution -> AnchorResolution -> Bool
$c/= :: AnchorResolution -> AnchorResolution -> Bool
/= :: AnchorResolution -> AnchorResolution -> Bool
Eq, Int -> AnchorResolution -> ShowS
[AnchorResolution] -> ShowS
AnchorResolution -> String
(Int -> AnchorResolution -> ShowS)
-> (AnchorResolution -> String)
-> ([AnchorResolution] -> ShowS)
-> Show AnchorResolution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AnchorResolution -> ShowS
showsPrec :: Int -> AnchorResolution -> ShowS
$cshow :: AnchorResolution -> String
show :: AnchorResolution -> String
$cshowList :: [AnchorResolution] -> ShowS
showList :: [AnchorResolution] -> ShowS
Show)

instance Default AnchorResolution where
  def :: AnchorResolution
def = Map String ByteString -> AnchorResolution
AnchorResolutionLocal Map String ByteString
forall k a. Map k a
Map.empty

-- | Set of options to modify the behavior of generating and validating some
-- transaction.
data TxSkelOpts = TxSkelOpts
  { -- | Whether to increase the slot counter automatically on transaction
    -- submission.  This is useful for modelling transactions that could be
    -- submitted in parallel in reality, so there should be no explicit ordering
    -- of what comes first.
    --
    -- Default is @True@.
    TxSkelOpts -> Bool
txSkelOptAutoSlotIncrease :: Bool,
    -- | Applies an arbitrary modification to a transaction after it has been
    -- potentially adjusted and balanced. The name of this option contains
    -- /unsafe/ to draw attention to the fact that modifying a transaction at
    -- that stage might make it invalid. Still, this offers a hook for being
    -- able to alter a transaction in unforeseen ways. It is mostly used to test
    -- contracts that have been written for custom PABs.
    --
    -- One interesting use of this function is to observe a transaction just
    -- before it is being sent for validation, with
    --
    -- > txSkelOptModTx = [RawModTx Debug.Trace.traceShowId]
    --
    -- The leftmost function in the list is applied first.
    --
    -- Default is @[]@.
    TxSkelOpts -> Tx ConwayEra -> Tx ConwayEra
txSkelOptModTx :: Cardano.Tx Cardano.ConwayEra -> Cardano.Tx Cardano.ConwayEra,
    -- | Whether to balance the transaction or not, and which wallet should
    -- provide/reclaim the missing and surplus value. Balancing ensures that
    --
    -- > input + mints == output + fees + burns
    --
    -- If you decide to set @txSkelOptBalance = DoNotBalance@ you will have trouble
    -- satisfying that equation by hand unless you use @ManualFee@. You will
    -- likely see a error about value preservation.
    --
    -- Default is 'BalanceWithFirstSigner'
    TxSkelOpts -> BalancingPolicy
txSkelOptBalancingPolicy :: BalancingPolicy,
    -- | The fee to use when balancing the transaction
    --
    -- Default is 'AutoFeeComputation'
    TxSkelOpts -> FeePolicy
txSkelOptFeePolicy :: FeePolicy,
    -- | The 'BalanceOutputPolicy' to apply when balancing the transaction.
    --
    -- Default is 'AdjustExistingOutput'.
    TxSkelOpts -> BalanceOutputPolicy
txSkelOptBalanceOutputPolicy :: BalanceOutputPolicy,
    -- | Which UTxOs to use during balancing. This can either be a precise list,
    -- or rely on automatic searches for utxos with values only belonging to the
    -- balancing wallet.
    --
    -- Default is 'BalancingUtxosFromBalancingWallet'.
    TxSkelOpts -> BalancingUtxos
txSkelOptBalancingUtxos :: BalancingUtxos,
    -- | Apply an arbitrary modification to the protocol parameters that are
    -- used to balance and submit the transaction. This is obviously a very
    -- unsafe thing to do if you want to preserve compatibility with the actual
    -- chain. It is useful mainly for testing purposes, when you might want to
    -- use extremely big transactions or transactions that exhaust the maximum
    -- execution budget. Such a thing could be accomplished with
    --
    -- > txSkelOptModParams = Just $ ModParams increaseTransactionLimits
    --
    -- for example.
    --
    -- Default is 'Nothing'.
    TxSkelOpts -> Params -> Params
txSkelOptModParams :: Emulator.Params -> Emulator.Params,
    -- | Which utxos to use as collaterals. They can be given manually, or
    -- computed automatically from a given, or the balancing, wallet.
    --
    -- Default is 'CollateralUtxosFromBalancingWallet'
    TxSkelOpts -> CollateralUtxos
txSkelOptCollateralUtxos :: CollateralUtxos,
    -- | How to resolve anchor in proposal procedures
    --
    -- Default is 'AnchorResolutionLocal Map.Empty'
    TxSkelOpts -> AnchorResolution
txSkelOptAnchorResolution :: AnchorResolution
  }

-- | Comparing 'TxSkelOpts' is possible as long as we ignore modifications to the
-- generated transaction and the parameters.
instance Eq TxSkelOpts where
  (TxSkelOpts Bool
slotIncrease Tx ConwayEra -> Tx ConwayEra
_ BalancingPolicy
balancingPol FeePolicy
feePol BalanceOutputPolicy
balOutputPol BalancingUtxos
balUtxos Params -> Params
_ CollateralUtxos
colUtxos AnchorResolution
anchorRes)
    == :: TxSkelOpts -> TxSkelOpts -> Bool
== (TxSkelOpts Bool
slotIncrease' Tx ConwayEra -> Tx ConwayEra
_ BalancingPolicy
balancingPol' FeePolicy
feePol' BalanceOutputPolicy
balOutputPol' BalancingUtxos
balUtxos' Params -> Params
_ CollateralUtxos
colUtxos' AnchorResolution
anchorRes') =
      Bool
slotIncrease Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
slotIncrease'
        Bool -> Bool -> Bool
&& BalancingPolicy
balancingPol BalancingPolicy -> BalancingPolicy -> Bool
forall a. Eq a => a -> a -> Bool
== BalancingPolicy
balancingPol'
        Bool -> Bool -> Bool
&& FeePolicy
feePol FeePolicy -> FeePolicy -> Bool
forall a. Eq a => a -> a -> Bool
== FeePolicy
feePol'
        Bool -> Bool -> Bool
&& BalanceOutputPolicy
balOutputPol BalanceOutputPolicy -> BalanceOutputPolicy -> Bool
forall a. Eq a => a -> a -> Bool
== BalanceOutputPolicy
balOutputPol'
        Bool -> Bool -> Bool
&& BalancingUtxos
balUtxos BalancingUtxos -> BalancingUtxos -> Bool
forall a. Eq a => a -> a -> Bool
== BalancingUtxos
balUtxos'
        Bool -> Bool -> Bool
&& CollateralUtxos
colUtxos CollateralUtxos -> CollateralUtxos -> Bool
forall a. Eq a => a -> a -> Bool
== CollateralUtxos
colUtxos'
        Bool -> Bool -> Bool
&& AnchorResolution
anchorRes AnchorResolution -> AnchorResolution -> Bool
forall a. Eq a => a -> a -> Bool
== AnchorResolution
anchorRes'

-- | Showing 'TxSkelOpts' is possible as long as we ignore modifications to the
-- generated transaction and the parameters.
instance Show TxSkelOpts where
  show :: TxSkelOpts -> String
show (TxSkelOpts Bool
slotIncrease Tx ConwayEra -> Tx ConwayEra
_ BalancingPolicy
balancingPol FeePolicy
feePol BalanceOutputPolicy
balOutputPol BalancingUtxos
balUtxos Params -> Params
_ CollateralUtxos
colUtxos AnchorResolution
anchorRes) =
    [String] -> String
forall a. Show a => a -> String
show [Bool -> String
forall a. Show a => a -> String
show Bool
slotIncrease, BalancingPolicy -> String
forall a. Show a => a -> String
show BalancingPolicy
balancingPol, FeePolicy -> String
forall a. Show a => a -> String
show FeePolicy
feePol, BalanceOutputPolicy -> String
forall a. Show a => a -> String
show BalanceOutputPolicy
balOutputPol, BalancingUtxos -> String
forall a. Show a => a -> String
show BalancingUtxos
balUtxos, CollateralUtxos -> String
forall a. Show a => a -> String
show CollateralUtxos
colUtxos, AnchorResolution -> String
forall a. Show a => a -> String
show AnchorResolution
anchorRes]

-- | A lens to get or set the automatic slot increase option
makeLensesFor [("txSkelOptAutoSlotIncrease", "txSkelOptAutoSlotIncreaseL")] ''TxSkelOpts

-- | A lens to get or set the Cardano transaction modifications option
makeLensesFor [("txSkelOptModTx", "txSkelOptModTxL")] ''TxSkelOpts

-- | A lens to get or set the balancing policy option
makeLensesFor [("txSkelOptBalancingPolicy", "txSkelOptBalancingPolicyL")] ''TxSkelOpts

-- | A lens to get or set the fee policy option
makeLensesFor [("txSkelOptFeePolicy", "txSkelOptFeePolicyL")] ''TxSkelOpts

-- | A lens to get or set the handling of balancing outputs option
makeLensesFor [("txSkelOptBalanceOutputPolicy", "txSkelOptBalanceOutputPolicyL")] ''TxSkelOpts

-- | A lens to get or set the balancing utxos option
makeLensesFor [("txSkelOptBalancingUtxos", "txSkelOptBalancingUtxosL")] ''TxSkelOpts

-- | A lens to get or set the changes to protocol parameters option
makeLensesFor [("txSkelOptModParams", "txSkelOptModParamsL")] ''TxSkelOpts

-- | A lens to get or set the collateral utxos option
makeLensesFor [("txSkelOptCollateralUtxos", "txSkelOptCollateralUtxosL")] ''TxSkelOpts

-- | A lens to get or set the anchor resolution option
makeLensesFor [("txSkelOptAnchorResolution", "txSkelOptAnchorResolutionL")] ''TxSkelOpts

instance Default TxSkelOpts where
  def :: TxSkelOpts
def =
    TxSkelOpts
      { txSkelOptAutoSlotIncrease :: Bool
txSkelOptAutoSlotIncrease = Bool
True,
        txSkelOptModTx :: Tx ConwayEra -> Tx ConwayEra
txSkelOptModTx = Tx ConwayEra -> Tx ConwayEra
forall a. a -> a
id,
        txSkelOptBalancingPolicy :: BalancingPolicy
txSkelOptBalancingPolicy = BalancingPolicy
forall a. Default a => a
def,
        txSkelOptBalanceOutputPolicy :: BalanceOutputPolicy
txSkelOptBalanceOutputPolicy = BalanceOutputPolicy
forall a. Default a => a
def,
        txSkelOptFeePolicy :: FeePolicy
txSkelOptFeePolicy = FeePolicy
forall a. Default a => a
def,
        txSkelOptBalancingUtxos :: BalancingUtxos
txSkelOptBalancingUtxos = BalancingUtxos
forall a. Default a => a
def,
        txSkelOptModParams :: Params -> Params
txSkelOptModParams = Params -> Params
forall a. a -> a
id,
        txSkelOptCollateralUtxos :: CollateralUtxos
txSkelOptCollateralUtxos = CollateralUtxos
forall a. Default a => a
def,
        txSkelOptAnchorResolution :: AnchorResolution
txSkelOptAnchorResolution = AnchorResolution
forall a. Default a => a
def
      }

-- | Appends a transaction modification to the given 'TxSkelOpts'
txSkelOptAddModTx :: (Cardano.Tx Cardano.ConwayEra -> Cardano.Tx Cardano.ConwayEra) -> TxSkelOpts -> TxSkelOpts
txSkelOptAddModTx :: (Tx ConwayEra -> Tx ConwayEra) -> TxSkelOpts -> TxSkelOpts
txSkelOptAddModTx Tx ConwayEra -> Tx ConwayEra
modTx = Lens' TxSkelOpts (Tx ConwayEra -> Tx ConwayEra)
-> ((Tx ConwayEra -> Tx ConwayEra) -> Tx ConwayEra -> Tx ConwayEra)
-> TxSkelOpts
-> TxSkelOpts
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
over Lens' TxSkelOpts (Tx ConwayEra -> Tx ConwayEra)
txSkelOptModTxL (Tx ConwayEra -> Tx ConwayEra
modTx (Tx ConwayEra -> Tx ConwayEra)
-> (Tx ConwayEra -> Tx ConwayEra) -> Tx ConwayEra -> Tx ConwayEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
.)

-- | Appends a parameters modification to the given 'TxSkelOpts'
txSkelOptAddModParams :: (Emulator.Params -> Emulator.Params) -> TxSkelOpts -> TxSkelOpts
txSkelOptAddModParams :: (Params -> Params) -> TxSkelOpts -> TxSkelOpts
txSkelOptAddModParams Params -> Params
modParams = Lens' TxSkelOpts (Params -> Params)
-> ((Params -> Params) -> Params -> Params)
-> TxSkelOpts
-> TxSkelOpts
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
over Lens' TxSkelOpts (Params -> Params)
txSkelOptModParamsL (Params -> Params
modParams (Params -> Params) -> (Params -> Params) -> Params -> Params
forall b c a. (b -> c) -> (a -> b) -> a -> c
.)