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

Commit a31b77a

Browse files
authored
fix: decimal precision issue with balance shell command (#80)
* fix crash when displaying in drops * fix precision issue * remove print lines * fix column alignment * add todo
1 parent 7a5f752 commit a31b77a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

slk/repl/repl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ def do_balance(self: SidechainRepl, line: str) -> None:
349349
elif not chains[0].is_asset_alias(asset_alias):
350350
print(f"Error: {asset_alias} is not a valid asset alias")
351351
return
352-
assets = [[chains[0].asset_from_alias(asset_alias)]]
352+
else:
353+
assets = [[chains[0].asset_from_alias(asset_alias)]]
353354
else:
354355
# XRP and all assets in the assets alias list
355356
assets = [
@@ -368,6 +369,7 @@ def do_balance(self: SidechainRepl, line: str) -> None:
368369
tablefmt="presto",
369370
floatfmt=",.6f",
370371
numalign="right",
372+
colalign=("left", "right"),
371373
)
372374
)
373375

slk/repl/repl_functionality.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ def get_balances_data(
308308
chain.substitute_nicknames(chain_res)
309309
if not in_drops and chain_res["currency"] == "XRP":
310310
chain_res["balance"] = drops_to_xrp(chain_res["balance"])
311+
# TODO: do this in a neater way (by removing this extra formatting)
312+
# when https://github.com/astanin/python-tabulate/pull/176 is approved
313+
chain_res["balance"] = format(chain_res["balance"], ",.6f")
311314
else:
312315
try:
313316
chain_res["balance"] = int(chain_res["balance"])

0 commit comments

Comments
 (0)