2
0
mirror of synced 2025-02-24 20:18:07 +00:00

Fixed trailing-zero issue after commify fix.

This commit is contained in:
Richard Moore 2018-09-26 16:11:38 -04:00
parent e582bd73ee
commit f4e247fc92
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

View File

@ -118,6 +118,9 @@ export function formatUnits(value: BigNumberish, unitType?: string | number): st
let fraction = value.mod(unitInfo.tenPower).toString();
while (fraction.length < unitInfo.decimals) { fraction = '0' + fraction; }
// Strip training 0
fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
let whole = value.div(unitInfo.tenPower).toString();
value = whole + '.' + fraction;