@@ -207,6 +207,8 @@ module Cardano.Api.Tx.Internal.Body
207
207
, fromByronTxIn
208
208
, fromLedgerTxOuts
209
209
, renderTxIn
210
+ , toLedgerValidityInterval
211
+ , fromLedgerValidityInterval
210
212
211
213
-- ** Misc helpers
212
214
, calculateExecutionUnitsLovelace
@@ -276,7 +278,7 @@ import Cardano.Ledger.Alonzo.Tx qualified as Alonzo (hashScriptIntegrity)
276
278
import Cardano.Ledger.Alonzo.TxWits qualified as Alonzo
277
279
import Cardano.Ledger.Api qualified as L
278
280
import Cardano.Ledger.Babbage.UTxO qualified as L
279
- import Cardano.Ledger.BaseTypes (StrictMaybe (.. ))
281
+ import Cardano.Ledger.BaseTypes (StrictMaybe (.. ), maybeToStrictMaybe )
280
282
import Cardano.Ledger.Binary (Annotated (.. ))
281
283
import Cardano.Ledger.Binary qualified as CBOR
282
284
import Cardano.Ledger.Coin qualified as L
@@ -3129,3 +3131,31 @@ getReferenceInputsSizeForTxIds beo utxo txIds = babbageEraOnwardsConstraints beo
3129
3131
calculateExecutionUnitsLovelace :: Ledger. Prices -> ExecutionUnits -> Maybe L. Coin
3130
3132
calculateExecutionUnitsLovelace prices eUnits =
3131
3133
return $ Alonzo. txscriptfee prices (toAlonzoExUnits eUnits)
3134
+
3135
+ toLedgerValidityInterval
3136
+ :: (TxValidityLowerBound era , TxValidityUpperBound era )
3137
+ -> L. ValidityInterval
3138
+ toLedgerValidityInterval (lowerBound, upperBound) =
3139
+ L. ValidityInterval
3140
+ { L. invalidBefore =
3141
+ case lowerBound of
3142
+ TxValidityNoLowerBound -> SNothing
3143
+ TxValidityLowerBound _ s -> SJust s
3144
+ , L. invalidHereafter =
3145
+ case upperBound of
3146
+ TxValidityUpperBound _ s -> maybeToStrictMaybe s
3147
+ }
3148
+
3149
+ fromLedgerValidityInterval
3150
+ :: AllegraEraOnwards era
3151
+ -> L. ValidityInterval
3152
+ -> (TxValidityLowerBound era , TxValidityUpperBound era )
3153
+ fromLedgerValidityInterval aeo validityInterval =
3154
+ let L. ValidityInterval {L. invalidBefore = invalidBefore, L. invalidHereafter = invalidHereAfter} = validityInterval
3155
+ lowerBound = case invalidBefore of
3156
+ SNothing -> TxValidityNoLowerBound
3157
+ SJust s -> TxValidityLowerBound aeo s
3158
+ upperBound = case invalidHereAfter of
3159
+ SNothing -> TxValidityUpperBound (convert aeo) Nothing
3160
+ SJust s -> TxValidityUpperBound (convert aeo) (Just s)
3161
+ in (lowerBound, upperBound)
0 commit comments