Balance unit detection with pre-defined values (#8753)

This commit is contained in:
Jaco 2023-01-10 21:38:10 +02:00 committed by GitHub
parent 5aa74708c9
commit 96af3c1f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ function reformat (value?: string | BN, isDisabled?: boolean, siDecimals?: numbe
? formatBalance.getDefaults().decimals
: siDecimals;
const maxDisabled = BN_TEN.pow(new BN(decimals - 1)).toString(10);
const siDefault = isDisabled && isString(value) && (value.length < maxDisabled.length) && value !== '0'
const siDefault = isString(value) && (value.length < maxDisabled.length) && value !== '0'
? formatBalance.calcSi(value.toString(), decimals)
: formatBalance.findSi('-');
const defaultValue = formatBalance(value, {