{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Cardano.Ledger.Api.Tx.Out (
module Cardano.Ledger.Api.Tx.Address,
EraTxOut (TxOut),
mkBasicTxOut,
upgradeTxOut,
valueTxOutL,
coinTxOutL,
isAdaOnlyTxOutF,
addrTxOutL,
bootAddrTxOutF,
getMinCoinTxOut,
setMinCoinTxOut,
getMinCoinSizedTxOut,
setMinCoinSizedTxOut,
ensureMinCoinTxOut,
ensureMinCoinSizedTxOut,
AlonzoEraTxOut,
dataHashTxOutL,
DataHash,
datumTxOutF,
BabbageEraTxOut,
dataTxOutL,
Data (..),
datumTxOutL,
Datum (..),
referenceScriptTxOutL,
)
where
import Cardano.Ledger.Alonzo.Core (AlonzoEraTxOut (..))
import Cardano.Ledger.Api.Era ()
import Cardano.Ledger.Api.Scripts.Data (Data (..), DataHash, Datum (..))
import Cardano.Ledger.Api.Tx.Address
import Cardano.Ledger.Babbage.Core (BabbageEraTxOut (..))
import Cardano.Ledger.Binary
import Cardano.Ledger.Coin
import Cardano.Ledger.Core (
EraTxOut (..),
PParams,
bootAddrTxOutF,
coinTxOutL,
eraProtVerLow,
isAdaOnlyTxOutF,
)
import Cardano.Ledger.Tools (ensureMinCoinTxOut, setMinCoinTxOut)
import Lens.Micro
setMinCoinSizedTxOutInternal ::
forall era.
EraTxOut era =>
(Coin -> Coin -> Bool) ->
PParams era ->
Sized (TxOut era) ->
Sized (TxOut era)
setMinCoinSizedTxOutInternal :: forall era.
EraTxOut era =>
(Coin -> Coin -> Bool)
-> PParams era -> Sized (TxOut era) -> Sized (TxOut era)
setMinCoinSizedTxOutInternal Coin -> Coin -> Bool
f PParams era
pp = Sized (TxOut era) -> Sized (TxOut era)
go
where
version :: Version
version = forall era. Era era => Version
eraProtVerLow @era
go :: Sized (TxOut era) -> Sized (TxOut era)
go !Sized (TxOut era)
txOut =
let curMinCoin :: Coin
curMinCoin = forall era.
EraTxOut era =>
PParams era -> Sized (TxOut era) -> Coin
getMinCoinSizedTxOut PParams era
pp Sized (TxOut era)
txOut
curCoin :: Coin
curCoin = Sized (TxOut era)
txOut forall s a. s -> Getting a s a -> a
^. forall s a. EncCBOR s => Version -> Lens' s a -> Lens' (Sized s) a
toSizedL Version
version forall era. (HasCallStack, EraTxOut era) => Lens' (TxOut era) Coin
coinTxOutL
in if Coin
curCoin Coin -> Coin -> Bool
`f` Coin
curMinCoin
then Sized (TxOut era)
txOut
else Sized (TxOut era) -> Sized (TxOut era)
go (Sized (TxOut era)
txOut forall a b. a -> (a -> b) -> b
& forall s a. EncCBOR s => Version -> Lens' s a -> Lens' (Sized s) a
toSizedL Version
version forall era. (HasCallStack, EraTxOut era) => Lens' (TxOut era) Coin
coinTxOutL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin
curMinCoin)
setMinCoinSizedTxOut ::
forall era.
EraTxOut era =>
PParams era ->
Sized (TxOut era) ->
Sized (TxOut era)
setMinCoinSizedTxOut :: forall era.
EraTxOut era =>
PParams era -> Sized (TxOut era) -> Sized (TxOut era)
setMinCoinSizedTxOut = forall era.
EraTxOut era =>
(Coin -> Coin -> Bool)
-> PParams era -> Sized (TxOut era) -> Sized (TxOut era)
setMinCoinSizedTxOutInternal forall a. Eq a => a -> a -> Bool
(==)
ensureMinCoinSizedTxOut ::
forall era.
EraTxOut era =>
PParams era ->
Sized (TxOut era) ->
Sized (TxOut era)
ensureMinCoinSizedTxOut :: forall era.
EraTxOut era =>
PParams era -> Sized (TxOut era) -> Sized (TxOut era)
ensureMinCoinSizedTxOut = forall era.
EraTxOut era =>
(Coin -> Coin -> Bool)
-> PParams era -> Sized (TxOut era) -> Sized (TxOut era)
setMinCoinSizedTxOutInternal forall a. Ord a => a -> a -> Bool
(>=)