Skip to content

Commit

Permalink
Inline mkTxBody
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 21, 2023
1 parent f689889 commit 64936bc
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,40 +1803,40 @@ createTransactionBody
:: forall era. 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

setUpdateProposal <-
caseShelleyToBabbageOrConwayEraOnwards
(\w -> (L.apiUpdateTxBodyL w .~) <$> convTxUpdateProposal sbe (txUpdateProposal txBodyContent))
(\w -> (L.apiUpdateTxBodyL w .~) <$> convTxUpdateProposal sbe (txUpdateProposal bc))
(const $ pure id)
sbe

setInvalidBefore <-
caseShelleyEraOnlyOrAllegraEraOnwards
(const $ pure id)
(\aOn -> pure $ L.invalidBeforeTxBodyL aOn .~ convValidityLowerBound (txValidityLowerBound txBodyContent))
(\aOn -> pure $ L.invalidBeforeTxBodyL aOn .~ convValidityLowerBound (txValidityLowerBound bc))
sbe

setMint <-
Expand Down Expand Up @@ -1881,23 +1881,10 @@ createTransactionBody sbe txBodyContent =
(const $ pure $ 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)
& modifyWith setUpdateProposal
& modifyWith setInvalidBefore
& modifyWith setMint
Expand Down

0 comments on commit 64936bc

Please sign in to comment.