Skip to content
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

ZkSync: Check balance before operations #1184

Merged
merged 1 commit into from
Mar 29, 2021
Merged

Conversation

Wiezzel
Copy link

@Wiezzel Wiezzel commented Mar 25, 2021

Check account balance before making a zkSync account unlock or withdrawal. This allows to display better error messages to the user and avoid panic in the withdraw function (balance and withdraw_fee are of BigUint type so balance - withdraw_fee would cause panic in case the fee is bigger than the account balance).


Testing intructions:

  1. Try init in send mode without funds.
$ cargo run payment init --sender
Error: GenericError { inner: "Not enough balance to unlock account" }  HINT: Did you run `yagna payment fund` and follow the instructions?
  1. Try exit without funds.
$ cargo run payment exit
Error: Not enough balance to exit. Minimum required balance to pay withdraw fees is 0.02957 tGLM
$ cargo run payment exit --network=mainnet
Error: Not enough balance to exit. Minimum required balance to pay withdraw fees is 55.36 GLM
  1. Regression (init and exit with funds).

Check account balance before making a zkSync account unlock or
withdrawal. This allows to display better error messages to the user and
avoid panic in the `withdraw` function (`balance` and `withdraw_fee` are
of `BigUint` type so `balance - withdraw_fee` would cause panic in case
the fee is bigger than the account balance).

Signed-off-by: Adam Wierzbicki <awierzbicki@golem.network>
@Wiezzel Wiezzel added bug Something isn't working m-payment labels Mar 25, 2021
@Wiezzel Wiezzel requested review from maaktweluit and tworec March 25, 2021 12:19
@Wiezzel Wiezzel self-assigned this Mar 25, 2021
@Wiezzel Wiezzel requested a review from a team March 25, 2021 12:19
Copy link
Contributor

@maaktweluit maaktweluit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

One nitty comment, still approving!

@maaktweluit
Copy link
Contributor

Tested this PR with the payment_api examples and yapapi

@Wiezzel Wiezzel merged commit de06421 into release/v0.6 Mar 29, 2021
@Wiezzel Wiezzel deleted the wiezzel/fix_exit branch March 29, 2021 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants