Fix loss of precision releasegold:withdraw CLI command #7748
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This bug fixes the loss of precision (due to converting the
BigNumber
tonumber
) in thereleasegold:withdraw
CLI Command. This was discovered by @zviadm when he tried to use the command to withdraw a contract's full balance. Due to the loss of precision, the value sent to the contract was higher than the actual balance, leading to the following error:Note that this loss of precision would still constitute a bug even when it doesn't lead to the transaction reverting (since the amount withdrawn is not exactly that requested by the user).
The PR also updates one of the tests for
releasegold:withdraw
to use a more precise assertion which would have caught this bug.Tested
Confirmed that the updated test passes, and that before the fix the updated test fails as expected:
Backwards compatibility
No change in the interface, the PR simply makes the command's behavior match the expected behavior (withdrawing the exact amount specified)