Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Luu committed Apr 19, 2024
1 parent b2da839 commit 560c041
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/web3-utils/src/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,12 @@ export const toWei = (number: Numbers, unit: EtherUnits): string => {
console.warn(PrecisionLossWarning)

parsedNumber = BigInt(parsedNumber);
} else {
// in case there is a decimal point, we need to convert it to string
parsedNumber = parsedNumber.toLocaleString('fullwide', {useGrouping: false, maximumFractionDigits: 20})
}
}

parsedNumber = typeof parsedNumber === 'number' ? parsedNumber.toLocaleString('fullwide', {useGrouping: false, maximumFractionDigits: 20}) : parsedNumber;
// if value is decimal e.g. 24.56 extract `integer` and `fraction` part
// to avoid `fraction` to be null use `concat` with empty string
const [integer, fraction] = String(
Expand Down

0 comments on commit 560c041

Please sign in to comment.