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

Use appropriate units when printing wallet balances. #2323

Closed
5 tasks
lemmih opened this issue Dec 5, 2022 · 0 comments · Fixed by #2385
Closed
5 tasks

Use appropriate units when printing wallet balances. #2323

lemmih opened this issue Dec 5, 2022 · 0 comments · Fixed by #2385
Assignees
Labels
Ready Issue is ready for work and anyone can freely assign it to themselves

Comments

@lemmih
Copy link
Contributor

lemmih commented Dec 5, 2022

Issue summary

Right now we always print wallet balances with six fractional digits. Example:

$ ./target/release/forest-cli wallet list
Address                                   Default Balance
f1ahjaxhd4w4qu47t2kasdescbttcgv2ha2doaney           0.000000 FIL
f1necwjawankvg7yyszvzm4oqntlculkfklyzug2q  X        0.000000 FIL
f1phxedvr5653h7gvf7jfg6plrbcgyjl2lkjlxhgi           0.000000 FIL
f1uatkwrkzfn5yuw67sxoosh37rujleu6xvb2dhwq           100.000000 FIL

It would improve the user experience if we default to fewer digits but use appropriate units. For example, someone has 0.001 FIL then it should be printed out as "1 milli FIL" or "1 mFIL". We should also limit the output to, say, 4 significant digits. This can be overridden by a flag, --exact-balance. Additionally, the --fixed-unit flag should force the balance to be in FIL.

Tasks:

  • Use 4 significant digits.
  • Use appropriate units (FIL, milli FIL, atto FIL, etc).
  • Add --exact-balance flag.
  • Add --fixed-unit flag.
  • Inlcude ~ when the printed balance is not exact.

Example output:

$ ./target/release/forest-cli wallet list
Address                                   Default Balance
f1ahjaxhd4w4qu47t2kasdescbttcgv2ha2doaney           0 FIL
f1necwjawankvg7yyszvzm4oqntlculkfklyzug2q  X        8 atto FIL
f1phxedvr5653h7gvf7jfg6plrbcgyjl2lkjlxhgi           ~500.2 milli FIL
f1uatkwrkzfn5yuw67sxoosh37rujleu6xvb2dhwq           100 FIL
$ ./target/release/forest-cli wallet list --exact-balance
Address                                   Default Balance
f1ahjaxhd4w4qu47t2kasdescbttcgv2ha2doaney           0 FIL
f1necwjawankvg7yyszvzm4oqntlculkfklyzug2q  X        8 atto FIL
f1phxedvr5653h7gvf7jfg6plrbcgyjl2lkjlxhgi           500.236 milli FIL
f1uatkwrkzfn5yuw67sxoosh37rujleu6xvb2dhwq           100 FIL
$ ./target/release/forest-cli wallet list --fixed-unit
Address                                   Default Balance
f1ahjaxhd4w4qu47t2kasdescbttcgv2ha2doaney           0 FIL
f1necwjawankvg7yyszvzm4oqntlculkfklyzug2q  X        ~0 FIL
f1phxedvr5653h7gvf7jfg6plrbcgyjl2lkjlxhgi           ~0 FIL
f1uatkwrkzfn5yuw67sxoosh37rujleu6xvb2dhwq           100 FIL
$ ./target/release/forest-cli wallet list --fixed-unit --exact-balance
Address                                   Default Balance
f1ahjaxhd4w4qu47t2kasdescbttcgv2ha2doaney           0 FIL
f1necwjawankvg7yyszvzm4oqntlculkfklyzug2q  X        0.000000000000000008 FIL
f1phxedvr5653h7gvf7jfg6plrbcgyjl2lkjlxhgi           0.500236 FIL
f1uatkwrkzfn5yuw67sxoosh37rujleu6xvb2dhwq           100 FIL

Other information and links

@lemmih lemmih added the Ready Issue is ready for work and anyone can freely assign it to themselves label Dec 5, 2022
@tyshko5 tyshko5 self-assigned this Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready Issue is ready for work and anyone can freely assign it to themselves
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants