Skip to content

Commit

Permalink
Fix bignumber display in CLI (#2212)
Browse files Browse the repository at this point in the history
  • Loading branch information
nambrot authored and celo-ci-bot-user committed Dec 12, 2019
1 parent 521bbbb commit 014bb6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@celo/celocli",
"description": "CLI Tool for transacting with the Celo protocol",
"version": "0.0.30-beta9",
"version": "0.0.32-beta3",
"author": "Celo",
"license": "Apache-2.0",
"repository": "celo-org/celo-monorepo",
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/utils/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export function printValueMapRecursive(valueMap: Record<string, any>) {
function toStringValueMapRecursive(valueMap: Record<string, any>, prefix: string): string {
const printValue = (v: any): string => {
if (typeof v === 'object' && v != null) {
if (v instanceof BigNumber) return v.toFixed()
if (BigNumber.isBigNumber(v)) {
const factor = new BigNumber(10).pow(18)
const extra = v.isGreaterThan(factor) ? `(~${v.div(factor).decimalPlaces(2)} 10^18)` : ''
return `${v.toFixed()} ${extra}`
}
return '\n' + toStringValueMapRecursive(v, prefix + ' ')
}
return chalk`${v}`
Expand Down

0 comments on commit 014bb6b

Please sign in to comment.