Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
fix: decimal precision issue with balance shell command (#80)
Browse files Browse the repository at this point in the history
* fix crash when displaying in drops

* fix precision issue

* remove print lines

* fix column alignment

* add todo
  • Loading branch information
mvadari authored Apr 15, 2022
1 parent 7a5f752 commit a31b77a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion slk/repl/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ def do_balance(self: SidechainRepl, line: str) -> None:
elif not chains[0].is_asset_alias(asset_alias):
print(f"Error: {asset_alias} is not a valid asset alias")
return
assets = [[chains[0].asset_from_alias(asset_alias)]]
else:
assets = [[chains[0].asset_from_alias(asset_alias)]]
else:
# XRP and all assets in the assets alias list
assets = [
Expand All @@ -368,6 +369,7 @@ def do_balance(self: SidechainRepl, line: str) -> None:
tablefmt="presto",
floatfmt=",.6f",
numalign="right",
colalign=("left", "right"),
)
)

Expand Down
3 changes: 3 additions & 0 deletions slk/repl/repl_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ def get_balances_data(
chain.substitute_nicknames(chain_res)
if not in_drops and chain_res["currency"] == "XRP":
chain_res["balance"] = drops_to_xrp(chain_res["balance"])
# TODO: do this in a neater way (by removing this extra formatting)
# when https://github.com/astanin/python-tabulate/pull/176 is approved
chain_res["balance"] = format(chain_res["balance"], ",.6f")
else:
try:
chain_res["balance"] = int(chain_res["balance"])
Expand Down

0 comments on commit a31b77a

Please sign in to comment.