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

fix: decimal precision issue with balance shell command #80

Merged
merged 5 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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