Skip to content

Commit

Permalink
Inline mkTxBody
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 20, 2023
1 parent 37ecdc5 commit 6c5a15b
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions cardano-api/internal/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,26 +1803,26 @@ createTransactionBody :: ()
=> ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> Either TxBodyError (TxBody era)
createTransactionBody sbe txBodyContent =
createTransactionBody sbe bc =
shelleyBasedEraConstraints sbe $ do
let apiTxOuts = txOuts txBodyContent
apiScriptWitnesses = collectTxBodyScriptWitnesses sbe txBodyContent
apiScriptValidity = txScriptValidity txBodyContent
apiMintValue = txMintValue txBodyContent
apiProtocolParameters = txProtocolParams txBodyContent
apiCollateralTxIns = txInsCollateral txBodyContent
apiReferenceInputs = txInsReference txBodyContent
apiExtraKeyWitnesses = txExtraKeyWits txBodyContent
apiReturnCollateral = txReturnCollateral txBodyContent
apiTotalCollateral = txTotalCollateral txBodyContent
let apiTxOuts = txOuts bc
apiScriptWitnesses = collectTxBodyScriptWitnesses sbe bc
apiScriptValidity = txScriptValidity bc
apiMintValue = txMintValue bc
apiProtocolParameters = txProtocolParams bc
apiCollateralTxIns = txInsCollateral bc
apiReferenceInputs = txInsReference bc
apiExtraKeyWitnesses = txExtraKeyWits bc
apiReturnCollateral = txReturnCollateral bc
apiTotalCollateral = txTotalCollateral bc

-- Ledger types
collTxIns = convCollateralTxIns apiCollateralTxIns
refTxIns = convReferenceInputs apiReferenceInputs
returnCollateral = convReturnCollateral sbe apiReturnCollateral
totalCollateral = convTotalCollateral apiTotalCollateral
certs = convCertificates sbe $ txCertificates txBodyContent
txAuxData = toAuxiliaryData sbe (txMetadata txBodyContent) (txAuxScripts txBodyContent)
certs = convCertificates sbe $ txCertificates bc
txAuxData = toAuxiliaryData sbe (txMetadata bc) (txAuxScripts bc)
scripts = convScripts apiScriptWitnesses
languages = convLanguages apiScriptWitnesses
sData = convScriptData sbe apiTxOuts apiScriptWitnesses
Expand All @@ -1831,7 +1831,7 @@ createTransactionBody sbe txBodyContent =
modifiesLedgerTxBody sbe $
caseShelleyToBabbageOrConwayEraOnwards
(\w -> do
update <- convTxUpdateProposal sbe (txUpdateProposal txBodyContent)
update <- convTxUpdateProposal sbe (txUpdateProposal bc)
pure $ L.apiUpdateTxBodyL w .~ update)
(const $ pure id)
sbe
Expand All @@ -1840,7 +1840,7 @@ createTransactionBody sbe txBodyContent =
modifiesLedgerTxBody sbe $ pure $
caseShelleyEraOnlyOrAllegraEraOnwards
(const id)
(\aOn -> L.invalidBeforeTxBodyL aOn .~ convValidityLowerBound (txValidityLowerBound txBodyContent))
(\aOn -> L.invalidBeforeTxBodyL aOn .~ convValidityLowerBound (txValidityLowerBound bc))
sbe

setMint <-
Expand Down Expand Up @@ -1892,23 +1892,10 @@ createTransactionBody sbe txBodyContent =
(const $ L.totalCollateralTxBodyL .~ totalCollateral)
sbe

let mkTxBody :: ()
=> ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> Maybe (L.TxAuxData (ShelleyLedgerEra era))
-> L.TxBody (ShelleyLedgerEra era)
mkTxBody sbe' bc =
mkCommonTxBody
sbe'
(txIns bc)
(txOuts bc)
(txFee bc)
(txWithdrawals bc)

let ledgerTxBody =
mkTxBody sbe txBodyContent txAuxData
mkCommonTxBody sbe (txIns bc) (txOuts bc) (txFee bc) (txWithdrawals bc) txAuxData
& L.certsTxBodyL .~ certs
& L.invalidHereAfterTxBodyL sbe .~ convValidityUpperBound sbe (txValidityUpperBound txBodyContent)
& L.invalidHereAfterTxBodyL sbe .~ convValidityUpperBound sbe (txValidityUpperBound bc)
& setUpdateProposal
& setInvalidBefore
& setMint
Expand Down

0 comments on commit 6c5a15b

Please sign in to comment.