Skip to content

Commit

Permalink
Provide HTTP server support for ErrBalanceTxBalanceInsufficient.
Browse files Browse the repository at this point in the history
The server handler is an exact duplicate of the handler for the internal
coin selection error `BalanceInsufficient`, with exactly the same
message string.

Unfortunately, we're not yet in a position to remove the old error
handler, as even after `balanceTransaction` is converted to use this
error, there will still be some wallet endpoints that call into coin
selection modules directly, and thus the old error handler will still
be reachable.

But once all endpoints have been converted to use `balanceTransaction`,
we can remove this handler.
  • Loading branch information
jonathanknowles committed Feb 6, 2023
1 parent 7d68042 commit ff13bf0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Error.hs
Expand Up @@ -462,6 +462,12 @@ instance IsServerError ErrBalanceTx where
, "Please sign the transaction after it is balanced instead."
]
ErrBalanceTxSelectAssets err -> toServerError err
ErrBalanceTxBalanceInsufficient err ->
apiError err403 NotEnoughMoney $ mconcat
[ "I can't process this payment as there are not "
, "enough funds available in the wallet. I am "
, "missing: ", pretty . Flat $ err ^. #utxoBalanceShortfall
]
ErrBalanceTxAssignRedeemers err -> toServerError err
ErrBalanceTxConflictingNetworks ->
apiError err403 BalanceTxConflictingNetworks $ T.unwords
Expand Down Expand Up @@ -946,6 +952,14 @@ instance IsServerError ErrSelectAssets where

instance IsServerError (SelectionBalanceError WalletSelectionContext) where
toServerError = \case
-- NOTE: [ADP-2540]
--
-- This server handler is an exact copy of the handler for the newer
-- `ErrBalanceTxBalanceInsufficient` error.
--
-- We can't delete this handler just yet: it's still used for endpoints
-- that call into coin selection directly.
--
BalanceInsufficient e ->
apiError err403 NotEnoughMoney $ mconcat
[ "I can't process this payment as there are not "
Expand Down

0 comments on commit ff13bf0

Please sign in to comment.