Improve autobalancing errors when change has no lovelace#816
Conversation
| | L.isZero outValue -> pure () -- empty TxOut - ok, it's removed at the end | ||
| | L.isZero coin -> -- no ADA, just non-ADA assets | ||
| Left $ | ||
| TxBodyErrorAdaBalanceTooSmall |
There was a problem hiding this comment.
You may want to give @mkoura a heads up if he is depending on the error output for this failure case.
palas
left a comment
There was a problem hiding this comment.
I have limited understanding of this code. But I am pretty confident it is all refactoring except for the addition of the TxBodyErrorAdaBalanceTooSmall error, which I don't understand why it is there, but I imagine it is correct.
I just added a suggestion that I think can improve readability a little bit
| else do | ||
| -- check if the balance is positive or negative | ||
| -- in one case we can produce change, in the other the inputs are insufficient | ||
| balanceCheck sbe pp change |
There was a problem hiding this comment.
I would put this check outside the if, even though I understand it is equivalent (since the balanceCheck already has an exception for this). But the code would be slightly simpler
There was a problem hiding this comment.
Good idea. I think I'll do a single check for the txout emptiness in the balance check only i.e. I'll change the output type to:
balanceCheck :: ... -> Either (TxBodyErrorAutoBalance era) IsEmpty
data IsEmpty = Empty | NonEmpty3487606 to
266eb04
Compare
Changelog
Context
Previously for txout with 0 lovelace and some non-ada assets the returned error was about negative balance, which doesn't make sense.
Checklist