Skip to content

Separate IO from txBuild and txBuildRaw functions #4491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cardano-api/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- Expose convenience functions `executeQueryCardanoMode`, `determineEra`, `constructBalancedTx` and `queryStateForBalancedTx` ([PR 4446](https://github.com/input-output-hk/cardano-node/pull/4446))

- Expand `BalancedTxBody` to include `TxBodyContent` ([PR 4491](https://github.com/input-output-hk/cardano-node/pull/4491))

### Bugs

- Allow reading text envelopes from pipes ([PR 4384](https://github.com/input-output-hk/cardano-node/pull/4384))
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api/Convenience/Construction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ constructBalancedTx
-> Either TxBodyErrorAutoBalance (Tx era)
constructBalancedTx eInMode txbodcontent changeAddr mOverrideWits utxo pparams
eraHistory systemStart stakePools shelleyWitSigningKeys = do
BalancedTxBody txbody _txBalanceOutput _fee
BalancedTxBody _ txbody _txBalanceOutput _fee
<- makeTransactionBodyAutoBalance
eInMode systemStart eraHistory
pparams stakePools utxo txbodcontent
Expand Down
12 changes: 8 additions & 4 deletions cardano-api/src/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ handleExUnitsErrors ScriptInvalid failuresMap exUnitsMap

data BalancedTxBody era
= BalancedTxBody
(TxBodyContent BuildTx era)
(TxBody era)
(TxOut CtxTx era) -- ^ Transaction balance (change output)
Lovelace -- ^ Estimated transaction fee
Expand Down Expand Up @@ -1025,17 +1026,20 @@ makeTransactionBodyAutoBalance eraInMode systemstart history pparams
-- fit within the encoding size we picked above when calculating the fee.
-- Yes this could be an over-estimate by a few bytes if the fee or change
-- would fit within 2^16-1. That's a possible optimisation.
txbody3 <-
first TxBodyError $ -- TODO: impossible to fail now
createAndValidateTransactionBody txbodycontent1 {
let finalTxBodyContent = txbodycontent1 {
txFee = TxFeeExplicit explicitTxFees fee,
txOuts = accountForNoChange
(TxOut changeaddr balance TxOutDatumNone ReferenceScriptNone)
(txOuts txbodycontent),
txReturnCollateral = retColl,
txTotalCollateral = reqCol
}
return (BalancedTxBody txbody3 (TxOut changeaddr balance TxOutDatumNone ReferenceScriptNone) fee)
txbody3 <-
first TxBodyError $ -- TODO: impossible to fail now. We need to implement a function
-- that simply creates a transaction body because we have already
-- validated the transaction body earlier within makeTransactionBodyAutoBalance
createAndValidateTransactionBody finalTxBodyContent
return (BalancedTxBody finalTxBodyContent txbody3 (TxOut changeaddr balance TxOutDatumNone ReferenceScriptNone) fee)
where
-- Essentially we check for the existence of collateral inputs. If they exist we
-- create a fictitious collateral return output. Why? Because we need to put dummy values
Expand Down
Loading