Skip to content

Commit

Permalink
wip: simplify fromTokenMinimalUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Oct 28, 2024
1 parent 0cda5f4 commit 9598284
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/util/number/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ export function fromWei(value = 0, unit = 'ether') {
export function fromTokenMinimalUnit(
minimalInput,
decimals = 0,
isRounding = true,
_isRounding = true,
) {
const value = new BigNumber(
(isBN(minimalInput) ? minimalInput.toString(10) : minimalInput),
10,
)

Check warning on line 124 in app/util/number/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Missing semicolon
return value.div(new BigNumber(decimals, 10)).toString(10, decimals);
/*
minimalInput = isRounding ? Number(minimalInput) : minimalInput;
const prefixedInput = addHexPrefix(minimalInput.toString(16));
let minimal = safeNumberToBN(prefixedInput);
Expand All @@ -138,6 +144,7 @@ export function fromTokenMinimalUnit(
value = '-' + value;
}
return value;
*/
}

/**
Expand Down Expand Up @@ -385,6 +392,9 @@ export function toBN(value) {
if (typeof value === 'number' && isNaN(value) || !value || value === 'NaN') {
return new BN(0);
}
if (isBN(value)) {
return value;
}
return value?.startsWith('0x')
? hexToBN(value)
: new BN(value || '0');
Expand Down

0 comments on commit 9598284

Please sign in to comment.