-
Notifications
You must be signed in to change notification settings - Fork 10
Add More WalletAPIError Types
#141
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
Conversation
| calculateMinUtxo pabConf datums txOut = do | ||
| let outs = txOutOpts pabConf datums [txOut] | ||
| case outs of | ||
| [] -> pure $ Left "When constructing the transaction, no output values were specified." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check should also be in buildTx.
Additional thing to consider, is that there will be no calculateMinUtxo in Vasil compliant version, so check here will be no more and build-raw in buildTx will start to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the check for empty list is redundant because, when we call calculateMinUtxo from calculateMinUtxos (present in Balance.hs) there's always some value present in the txOut. But it nevertheless make sense to handle this case, in case anyone tries to call calculateMinUtxo where the txOutValue is not always non-zero. But after vasil compliance of BPI this function would be redundant, and so would be the need to check for if txOutValue is non-zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the check for empty list is redundant because, when we call calculateMinUtxo from calculateMinUtxos (present in Balance.hs) there's always some value present in the txOut.
Why does it always have some value there? Because of minimum Ada adjustment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to call calculateMinUtxo when we want to get minimum amount of lovelace that should be present in a TxOut of a Tx, this is required during balancing. But, if there's a TxOut with zero value then we don't need to consider it as an actual output to a Tx, hence don't need to call calculateMinUtxo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree that this check should be moved to buildTx.
@IAmPara0x This check was added for the specific case in which a transaction would only contain a zero Value as the output. Which would result in an empty list from the changes that I made here:
txOutOpts :: PABConfig -> Map DatumHash Datum -> [TxOut] -> [Text]
txOutOpts pabConf datums =
concatMap
( \TxOut {txOutAddress, txOutValue, txOutDatumHash} ->
if Value.isZero txOutValue
then []
elseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MitchyCola oh, I get it now. Thanks for pointing it out!.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the error is originating from the use of calculateMinUtxos inside of balanceTxLoop (in Balance.hs), the error gets thrown before the use of buildTx. Therefore, I decided to move the check into preBalancedTx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if just put check in both calculateMinUtxos and buildTx? It will keep this commit in working state, and vasil update will just remove calculateMinUtxos.
It feels like omitting check that result of txOutOpts can return [] will shoot one day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Revert "Merge pull request #141 from mlabs-haskell/mitch/error-messages"
This PR resolves issue #71