-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TokenAmountV2.fromNumber for decimals < 8 (#629)
# Motivation When creating a `TokenAmountV2` from a `number`, we first convert it to a string with 8 decimals. When the number has more decimals, they are just truncated. But number input components in gix-components don't allow more than 8 decimals. But when the token allows fewer than 8 decimals, this results in an error. The happened to be one of the few combinations without a unit test but will be needed for ckUSDC. # Changes When converting the number to a string with a fixed number of decimals, instead of always using 8 decimals, use the minimum of 8 and the number of decimals the token allows. # Tests 1. Added a unit test. 2. Tested in NNS dapp that this error no longer appears: <img width="356" alt="image" src="https://github.com/dfinity/ic-js/assets/122978264/a1002c5e-234b-4fee-af8b-44fafff5343b"> # Todos - [x] Add entry to changelog (if necessary). --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
65e23d1
commit 86a58da
Showing
4 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters