Skip to content

Commit

Permalink
Add ErrTxOutValueSizeExceedsLimit and `ErrTxOutTokenQuantityExceeds…
Browse files Browse the repository at this point in the history
…Limit`

While it's not possible to send assets from the deposit wallet ui, this
is currently possible with the internal 'createPayment' function.
  • Loading branch information
Anviking committed Dec 19, 2024
1 parent a2778c7 commit efcbc07
Showing 1 changed file with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ data ErrCreatePayment

| ErrTxOutAdaInsufficient { outputIx :: Int, suggestedMinimum :: Coin }

-- | Only possible when sending (non-ada) assets.
| ErrTxOutValueSizeExceedsLimit { outputIx :: Int }

-- | Only possible when sending (non-ada) assets.
| ErrTxOutTokenQuantityExceedsLimit
{ outputIx :: Int
, quantity :: Natural
, quantityMaxBound :: Natural
}

-- | The final balanced tx was too big. Either because the payload was too
-- big to begin with, or because we failed to select enough inputs without
-- making it too big, e.g. due to the UTxO containing lots of dust.
Expand Down Expand Up @@ -129,12 +139,22 @@ translateBalanceTxError = \case
impossible "unresolved inputs"
Write.ErrBalanceTxUnresolvedRefunds _ ->
impossible "unresolved refunds"
Write.ErrBalanceTxOutputError (Write.ErrBalanceTxOutputErrorOf ix (Write.ErrBalanceTxOutputAdaQuantityInsufficient{minimumExpectedCoin})) ->
ErrTxOutAdaInsufficient { outputIx = ix, suggestedMinimum = minimumExpectedCoin }
Write.ErrBalanceTxOutputError (Write.ErrBalanceTxOutputErrorOf _ix (Write.ErrBalanceTxOutputSizeExceedsLimit{})) ->
impossible "value can't be too big if there are no assets"
Write.ErrBalanceTxOutputError (Write.ErrBalanceTxOutputErrorOf _ix (Write.ErrBalanceTxOutputTokenQuantityExceedsLimit{})) ->
impossible "tokenQuantity can't be too big if there are no tokens"
Write.ErrBalanceTxOutputError (Write.ErrBalanceTxOutputErrorOf ix info) -> case info of
Write.ErrBalanceTxOutputAdaQuantityInsufficient{minimumExpectedCoin} ->
ErrTxOutAdaInsufficient
{ outputIx = ix
, suggestedMinimum = minimumExpectedCoin
}
Write.ErrBalanceTxOutputSizeExceedsLimit{} ->
ErrTxOutValueSizeExceedsLimit
{ outputIx = ix
}
Write.ErrBalanceTxOutputTokenQuantityExceedsLimit{quantity, quantityMaxBound} ->
ErrTxOutTokenQuantityExceedsLimit
{ outputIx = ix
, quantity
, quantityMaxBound
}
Write.ErrBalanceTxUnableToCreateChange
Write.ErrBalanceTxUnableToCreateChangeError{shortfall} ->
ErrNotEnoughAda
Expand Down

0 comments on commit efcbc07

Please sign in to comment.