Skip to content

Commit

Permalink
Automatically switch on the eon for setting fields in ledger tx body
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Oct 21, 2023
1 parent 99a7a37 commit b5538b3
Showing 1 changed file with 18 additions and 45 deletions.
63 changes: 18 additions & 45 deletions cardano-api/internal/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1828,59 +1828,32 @@ createTransactionBody sbe bc =
languages = convLanguages apiScriptWitnesses
sData = convScriptData sbe apiTxOuts apiScriptWitnesses

setUpdateProposal <-
caseShelleyToBabbageOrConwayEraOnwards
(\w -> (A.updateTxBodyL w .~) <$> convTxUpdateProposal sbe (txUpdateProposal bc))
(const $ pure id)
sbe
setUpdateProposal <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
(A.updateTxBodyL w .~) <$> convTxUpdateProposal sbe (txUpdateProposal bc)

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

setMint <-
caseShelleyToAllegraOrMaryEraOnwards
(const $ pure id)
(\w -> pure $ A.mintTxBodyL w .~ convMintValue apiMintValue)
sbe
setMint <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.mintTxBodyL w .~ convMintValue apiMintValue

setScriptIntegrityHash <-
caseShelleyToMaryOrAlonzoEraOnwards
(const $ pure id)
(\w -> pure $ A.scriptIntegrityHashTxBodyL w .~ getScriptIntegrityHash apiProtocolParameters languages sData)
sbe
setScriptIntegrityHash <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.scriptIntegrityHashTxBodyL w .~ getScriptIntegrityHash apiProtocolParameters languages sData

setCollateralInputs <-
caseShelleyToMaryOrAlonzoEraOnwards
(const $ pure id)
(\w -> pure $ A.collateralInputsTxBodyL w .~ collTxIns)
sbe
setCollateralInputs <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.collateralInputsTxBodyL w .~ collTxIns

setReqSignerHashes <-
caseShelleyToMaryOrAlonzoEraOnwards
(const $ pure id)
(\w -> pure $ A.reqSignerHashesTxBodyL w .~ convExtraKeyWitnesses apiExtraKeyWitnesses)
sbe
setReqSignerHashes <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.reqSignerHashesTxBodyL w .~ convExtraKeyWitnesses apiExtraKeyWitnesses

setReferenceInputs <-
caseShelleyToAlonzoOrBabbageEraOnwards
(const $ pure id)
(\w -> pure $ A.referenceInputsTxBodyL w .~ refTxIns)
sbe
setReferenceInputs <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.referenceInputsTxBodyL w .~ refTxIns

setCollateralReturn <-
caseShelleyToAlonzoOrBabbageEraOnwards
(const $ pure id)
(\w -> pure $ A.collateralReturnTxBodyL w .~ returnCollateral)
sbe
setCollateralReturn <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.collateralReturnTxBodyL w .~ returnCollateral

setTotalCollateral <-
caseShelleyToAlonzoOrBabbageEraOnwards
(const $ pure id)
(\w -> pure $ A.totalCollateralTxBodyL w .~ totalCollateral)
sbe
setTotalCollateral <- forShelleyBasedEraInEon sbe (pure id) $ \w ->
pure $ A.totalCollateralTxBodyL w .~ totalCollateral

let ledgerTxBody =
mkCommonTxBody sbe (txIns bc) (txOuts bc) (txFee bc) (txWithdrawals bc) txAuxData
Expand Down

0 comments on commit b5538b3

Please sign in to comment.