-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add form when failing to register with low balance #1092
Conversation
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 get Looks like you do not have enough funds
even if the failure is because I put in the wrong app password. The popup looks good to me, but it would really be better if it didn't have the possibility of showing misleading information.
Thanks for the review joe, fixed it. |
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.
It seems I only get the new form if I have exactly 0 in the account. If I have, say, .01 and the dex want's 1, I do not see the form, although I do have insufficient funds.
Are you trying to register to I added an |
client/asset/dcr/dcr.go
Outdated
@@ -2444,7 +2444,7 @@ func (dcr *ExchangeWallet) sendRegFee(addr dcrutil.Address, regFee, netFeeRate u | |||
} | |||
coins, _, _, _, err := dcr.fund(enough) | |||
if err != nil { | |||
return nil, 0, fmt.Errorf("unable to pay registration fee of %s DCR with fee rate of %d atoms/byte: %w", | |||
return nil, 0, fmt.Errorf("Insufficient funds for fee rate. Unable to pay registration fee of %s DCR with fee rate of %d atoms/byte: %w", |
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 must be lowercase i
in order to match the string.
But really, would be good to have an error code or something, as matching strings is very fragile.
Also, one day fees may be payable by different coins. So, other assets must also pay attention to their error messages. Also, this may cause problems with internationalization.
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.
Yup, this approach is what I had in mind. Just a little clean-up and docs, and maybe consider something for js not to fail if code
is undefined.
<div class="bg2 px-2 py-1 text-center fs18">Insuficient funds</div> | ||
<div class="p-4"> | ||
<div class="fs16"> | ||
Looks like you do not have enough funds for paying the fee in the | ||
selected account. Please fund the account and try again. | ||
</div> | ||
<div class="fs15 pt-3 text-center d-hide errcolor" id="regFundsErr"></div> | ||
<hr class="dashed mt-4"> | ||
</div> |
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.
This is still just a guess that it's insufficient funds, but really it's any error from wallet.PayFee
, which causes (*Core).Register
to return a feeSendErr
-coded error.
It could be many things including a bad fee address, or an error from sendWithReturn
such as failure to sign the tx or failure to broadcast with sendrawtransaction.
Thus, I think it's warranted to soften the language in this dialog to indicate an error, but suggest the most likely cause of insufficient funds, and ofc show the whole error message as you are doing.
We could make it that specific with changes to the each asset's PayFee
implementation to return a new error defined in client/asset/interface.go, which (*Core).Register
recognizes and replaces with a more specific error code. But the most likely scenario is balance, and the form does show the full error, so I'm OK with simply framing this dialog as a suggestion rather than definitively saying it is balance.
This PR is ready for another review. |
client/webserver/types.go
Outdated
Msg string `json:"msg,omitempty"` | ||
OK bool `json:"ok"` | ||
Msg string `json:"msg,omitempty"` | ||
Code int `json:"code,omitempty"` |
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 walletErr = iota
(0), this first code
in the enumeration will not be marshalled. Nothing breaks in this PR, but it should allow 0.
- Code int `json:"code,omitempty"`
+ Code *int `json:"code,omitempty"`
- Code: code,
+ Code: &code,
In retrospect, it would have been better to define walletErr = iota + 1
, but I'm hesitant to make that change now.
Thanks for the review chapp. Addressed your comments |
I've revised the PR description so it doesn't close #768 when merged. This PR will recognize an error from PayFee and then show the following: However, because the above comes after confirming the following dialog, the issue isn't quite resolved. In #768, @buck54321 was pointing out that instead of showing them this dialog when the frontend already knows the balance is insufficient, it should show a different dialog that prevents the registration and fee payment attempt entirely. (or modifies this Confirm Registration dialog with a clear note about balance and a disabled Register button). Detecting a certain fee payment error code and displaying an appropriate dialog, as done in this PR, makes complete sense, but it does not quite resolve #768. Note that instead of getfee, we are now using getdexinfo |
f41c32a
to
22b4aad
Compare
okay, now it goes directly to the registration failed form, if there are not enough funds. If available funds are equal the reg fee, than the process occurs and only fails in the end, as we do not check for the network fee. |
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.
Working well for me now.
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.
Msg: errMsg, | ||
OK: false, | ||
Msg: err.Error(), | ||
Code: code, |
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.
Good. Code is omitted when there is no error (just OK=true).
Resolves #768