1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Truncate extra decimal places from token amount for sending (#12169)

This commit is contained in:
Jyoti Puri 2021-09-22 00:04:52 +05:30 committed by GitHub
parent c9ce848f47
commit 9e7b52b7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,8 +78,13 @@ export default class TokenInput extends PureComponent {
handleChange = (decimalValue) => {
const { token: { decimals } = {}, onChange } = this.props;
let newDecimalValue = decimalValue;
if (decimals) {
newDecimalValue = parseFloat(decimalValue).toFixed(decimals);
}
const multiplier = Math.pow(10, Number(decimals || 0));
const hexValue = multiplyCurrencies(decimalValue || 0, multiplier, {
const hexValue = multiplyCurrencies(newDecimalValue || 0, multiplier, {
multiplicandBase: 10,
multiplierBase: 10,
toNumericBase: 'hex',