14
14
{-# LANGUAGE TypeApplications #-}
15
15
{-# LANGUAGE TypeFamilies #-}
16
16
{-# LANGUAGE TypeOperators #-}
17
- {-# LANGUAGE ViewPatterns #-}
18
17
19
18
-- | Transaction bodies
20
19
module Cardano.Api.Tx.Body
21
20
( parseTxId
22
21
23
22
-- * Transaction bodies
24
- , TxBody (.. , TxBody )
25
23
, createTransactionBody
26
24
, createAndValidateTransactionBody
27
25
, TxBodyContent (.. )
@@ -2148,12 +2146,8 @@ createAndValidateTransactionBody
2148
2146
-> Either TxBodyError (TxBody era )
2149
2147
createAndValidateTransactionBody = makeShelleyTransactionBody
2150
2148
2151
- pattern TxBody :: TxBodyContent ViewTx era -> TxBody era
2152
- pattern TxBody txbodycontent <- (getTxBodyContent -> txbodycontent)
2153
-
2154
- {-# COMPLETE TxBody #-}
2155
-
2156
- getTxBodyContent :: TxBody era -> TxBodyContent ViewTx era
2149
+ getTxBodyContent
2150
+ :: TxBody era -> Either CostModelNotEnoughParametersError (TxBodyContent ViewTx era )
2157
2151
getTxBodyContent = \ case
2158
2152
ShelleyTxBody sbe body _scripts scriptdata mAux scriptValidity ->
2159
2153
fromLedgerTxBody sbe scriptValidity body scriptdata mAux
@@ -2164,34 +2158,36 @@ fromLedgerTxBody
2164
2158
-> Ledger. TxBody (ShelleyLedgerEra era )
2165
2159
-> TxBodyScriptData era
2166
2160
-> Maybe (L. TxAuxData (ShelleyLedgerEra era ))
2167
- -> TxBodyContent ViewTx era
2161
+ -> Either CostModelNotEnoughParametersError ( TxBodyContent ViewTx era )
2168
2162
fromLedgerTxBody sbe scriptValidity body scriptdata mAux =
2169
- TxBodyContent
2170
- { txIns = fromLedgerTxIns sbe body
2171
- , txInsCollateral = fromLedgerTxInsCollateral sbe body
2172
- , txInsReference = fromLedgerTxInsReference sbe body
2173
- , txOuts = fromLedgerTxOuts sbe body scriptdata
2174
- , txTotalCollateral = fromLedgerTxTotalCollateral sbe body
2175
- , txReturnCollateral = fromLedgerTxReturnCollateral sbe body
2176
- , txFee = fromLedgerTxFee sbe body
2177
- , txValidityLowerBound = fromLedgerTxValidityLowerBound sbe (A. TxBody body)
2178
- , txValidityUpperBound = fromLedgerTxValidityUpperBound sbe (A. TxBody body)
2179
- , txWithdrawals = fromLedgerTxWithdrawals sbe body
2180
- , txCertificates = fromLedgerTxCertificates sbe body
2181
- , txUpdateProposal = maybeFromLedgerTxUpdateProposal sbe body
2182
- , txMintValue = fromLedgerTxMintValue sbe body
2183
- , txExtraKeyWits = fromLedgerTxExtraKeyWitnesses sbe body
2184
- , txProtocolParams = ViewTx
2185
- , txMetadata
2186
- , txAuxScripts
2187
- , txScriptValidity = scriptValidity
2188
- , txProposalProcedures = fromLedgerProposalProcedures sbe body
2189
- , txVotingProcedures = fromLedgerVotingProcedures sbe body
2190
- , txCurrentTreasuryValue = fromLedgerCurrentTreasuryValue sbe body
2191
- , txTreasuryDonation = fromLedgerTreasuryDonation sbe body
2192
- }
2163
+ txUpdateProposal <&> \ txup ->
2164
+ TxBodyContent
2165
+ { txIns = fromLedgerTxIns sbe body
2166
+ , txInsCollateral = fromLedgerTxInsCollateral sbe body
2167
+ , txInsReference = fromLedgerTxInsReference sbe body
2168
+ , txOuts = fromLedgerTxOuts sbe body scriptdata
2169
+ , txTotalCollateral = fromLedgerTxTotalCollateral sbe body
2170
+ , txReturnCollateral = fromLedgerTxReturnCollateral sbe body
2171
+ , txFee = fromLedgerTxFee sbe body
2172
+ , txValidityLowerBound = fromLedgerTxValidityLowerBound sbe (A. TxBody body)
2173
+ , txValidityUpperBound = fromLedgerTxValidityUpperBound sbe (A. TxBody body)
2174
+ , txWithdrawals = fromLedgerTxWithdrawals sbe body
2175
+ , txCertificates = fromLedgerTxCertificates sbe body
2176
+ , txUpdateProposal = txup
2177
+ , txMintValue = fromLedgerTxMintValue sbe body
2178
+ , txExtraKeyWits = fromLedgerTxExtraKeyWitnesses sbe body
2179
+ , txProtocolParams = ViewTx
2180
+ , txMetadata
2181
+ , txAuxScripts
2182
+ , txScriptValidity = scriptValidity
2183
+ , txProposalProcedures = fromLedgerProposalProcedures sbe body
2184
+ , txVotingProcedures = fromLedgerVotingProcedures sbe body
2185
+ , txCurrentTreasuryValue = fromLedgerCurrentTreasuryValue sbe body
2186
+ , txTreasuryDonation = fromLedgerTreasuryDonation sbe body
2187
+ }
2193
2188
where
2194
2189
(txMetadata, txAuxScripts) = fromLedgerTxAuxiliaryData sbe mAux
2190
+ txUpdateProposal = maybeFromLedgerTxUpdateProposal sbe body
2195
2191
2196
2192
fromLedgerProposalProcedures
2197
2193
:: ShelleyBasedEra era
@@ -2544,15 +2540,15 @@ maybeFromLedgerTxUpdateProposal
2544
2540
:: ()
2545
2541
=> ShelleyBasedEra era
2546
2542
-> Ledger. TxBody (ShelleyLedgerEra era )
2547
- -> TxUpdateProposal era
2543
+ -> Either CostModelNotEnoughParametersError ( TxUpdateProposal era )
2548
2544
maybeFromLedgerTxUpdateProposal sbe body =
2549
2545
caseShelleyToBabbageOrConwayEraOnwards
2550
2546
( \ w ->
2551
2547
case body ^. L. updateTxBodyL of
2552
- SNothing -> TxUpdateProposalNone
2553
- SJust p -> TxUpdateProposal w (fromLedgerUpdate sbe p)
2548
+ SNothing -> pure TxUpdateProposalNone
2549
+ SJust p -> TxUpdateProposal w <$> (fromLedgerUpdate sbe p)
2554
2550
)
2555
- (const TxUpdateProposalNone )
2551
+ (const $ pure TxUpdateProposalNone )
2556
2552
sbe
2557
2553
2558
2554
fromLedgerTxMintValue
0 commit comments