Skip to content

Commit

Permalink
Use Write.Value in ErrBalanceTxInternalError. (#4198)
Browse files Browse the repository at this point in the history
## Issue

ADP-3184

## Description

This PR changes `ErrBalanceTxInternalError.ErrFailedBalancing` to use
`Write.Value` instead of `CardanoApi.Value`.
  • Loading branch information
jonathanknowles authored Nov 1, 2023
2 parents f7ea6d4 + 5833246 commit 7aa422e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ import Internal.Cardano.Write.Tx
, modifyTxOutCoin
, outputs
, toCardanoApiTx
, toCardanoApiValue
, txBody
, withConstraints
)
Expand Down Expand Up @@ -415,7 +414,7 @@ data ErrBalanceTxAssetsInsufficientError = ErrBalanceTxAssetsInsufficientError

data ErrBalanceTxInternalError
= ErrUnderestimatedFee Coin SealedTx KeyWitnessCount
| ErrFailedBalancing CardanoApi.Value
| ErrFailedBalancing Value
deriving (Show, Eq)

-- | Errors that can occur when balancing transactions.
Expand Down Expand Up @@ -860,11 +859,13 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment
let bal = txBalance tx
if bal == mempty
then pure tx
else throwE $ ErrBalanceTxInternalError $ ErrFailedBalancing bal
else throwE
$ ErrBalanceTxInternalError
$ ErrFailedBalancing bal

txBalance :: Tx (ShelleyLedgerEra era) -> CardanoApi.Value
txBalance :: Tx (ShelleyLedgerEra era) -> Value
txBalance
= toCardanoApiValue @era
= withConstraints era
. evaluateTransactionBalance era pp combinedUTxO
. txBody era

Expand All @@ -878,7 +879,7 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment
era pp tx witCount
update = TxUpdate [] [] [] [] (UseNewTxFee minfee)
tx' <- left ErrBalanceTxUpdateError $ updateTx era tx update
let balance = txBalance tx'
let balance = CardanoApi.fromMaryValue $ txBalance tx'
minfee' = CardanoApi.Lovelace $ W.Coin.toInteger minfee
return (balance, minfee', witCount)
where
Expand Down

0 comments on commit 7aa422e

Please sign in to comment.