From 9e7b52b7dfe447c596485ec05c4b1ac56b5f5749 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 22 Sep 2021 00:04:52 +0530 Subject: [PATCH] Truncate extra decimal places from token amount for sending (#12169) --- ui/components/ui/token-input/token-input.component.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/components/ui/token-input/token-input.component.js b/ui/components/ui/token-input/token-input.component.js index 5a879cb22..60665ac20 100644 --- a/ui/components/ui/token-input/token-input.component.js +++ b/ui/components/ui/token-input/token-input.component.js @@ -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',