diff --git a/src/screens/CreateToken.js b/src/screens/CreateToken.js
index 6589c1b5..4f92db68 100644
--- a/src/screens/CreateToken.js
+++ b/src/screens/CreateToken.js
@@ -68,8 +68,7 @@ function CreateToken() {
}
// Validating maximum amount
- const tokensValue = walletUtils.decimalToInteger(amount, decimalPlaces);
- if (tokensValue > hathorLib.constants.MAX_OUTPUT_VALUE) {
+ if (amount > hathorLib.constants.MAX_OUTPUT_VALUE) {
const max_output_value_str = hathorLib.numberUtils.prettyValue(hathorLib.constants.MAX_OUTPUT_VALUE, decimalPlaces);
setErrorMessage(t`Maximum value to mint token is ${max_output_value_str}`);
return false;
@@ -122,7 +121,7 @@ function CreateToken() {
transaction = await wallet.prepareCreateNewToken(
shortNameRef.current.value,
symbolRef.current.value,
- walletUtils.decimalToInteger(amount, decimalPlaces),
+ amount,
{ address, pinCode: pin }
);
@@ -276,7 +275,6 @@ function CreateToken() {
required
className="form-control"
onValueChange={onAmountChange}
- placeholder={hathorLib.numberUtils.prettyValue(0, decimalPlaces)}
/>
diff --git a/src/screens/nano-contract/NanoContractExecuteMethod.js b/src/screens/nano-contract/NanoContractExecuteMethod.js
index 02025988..aaf3a6bd 100644
--- a/src/screens/nano-contract/NanoContractExecuteMethod.js
+++ b/src/screens/nano-contract/NanoContractExecuteMethod.js
@@ -9,7 +9,6 @@ import React, { useContext, useEffect, useRef, useState } from 'react';
import { t } from 'ttag'
import BackButton from '../../components/BackButton';
import InputNumber from '../../components/InputNumber';
-import colors from '../../index.module.scss';
import hathorLib from '@hathor/wallet-lib';
import { useNavigate, useLocation } from 'react-router-dom';
import { get, pullAt } from 'lodash';
@@ -264,8 +263,7 @@ function NanoContractExecuteMethod() {
}
if (typeToCheck === 'Amount') {
- const amountValue = walletUtils.decimalToInteger(value, decimalPlaces);
- argValues.push(amountValue);
+ argValues.push(value);
continue;
}
@@ -282,10 +280,6 @@ function NanoContractExecuteMethod() {
// We will skip if the user has just added an empty action
continue;
}
-
- const amountValue = isNFT(action.token) ? action.amount : walletUtils.decimalToInteger(action.amount, decimalPlaces);
- action.amount = amountValue;
-
actionsData.push(action);
}
@@ -377,9 +371,9 @@ function NanoContractExecuteMethod() {
return
ref.current.value = value}
className="form-control output-value"
- placeholder={hathorLib.numberUtils.prettyValue(0, decimalPlaces)}
/>
}
@@ -520,21 +514,6 @@ function NanoContractExecuteMethod() {
// I start the ref as null, then I set it in the input if it's a withdrawal
actionAddressesRef.current[index] = null;
- const token = actions[index].token;
- // Depending on the token, the input for the amount changes because it might be an NFT
- const nft = isNFT(token);
- let inputNumberProps;
- if (nft) {
- inputNumberProps = {
- placeholder: '0',
- precision: 0,
- };
- } else {
- inputNumberProps = {
- placeholder: hathorLib.numberUtils.prettyValue(0, decimalPlaces)
- };
- }
-
const renderCommon = () => {
return (
@@ -549,7 +528,7 @@ function NanoContractExecuteMethod() {
requirePositive={true}
onValueChange={amount => onActionValueChange(index, 'amount', amount)}
className="form-control output-value"
- {...inputNumberProps}
+ isNFT={isNFT(actions[index].token)}
/>
diff --git a/src/utils/tokens.js b/src/utils/tokens.js
index cae65ba3..a76a4368 100644
--- a/src/utils/tokens.js
+++ b/src/utils/tokens.js
@@ -96,8 +96,7 @@ const tokens = {
*/
getDepositAmount(mintAmount, depositPercent, decimalPlaces) {
if (mintAmount) {
- const amountValue = wallet.decimalToInteger(mintAmount, decimalPlaces);
- const deposit = hathorLib.tokensUtils.getDepositAmount(amountValue, depositPercent);
+ const deposit = hathorLib.tokensUtils.getDepositAmount(mintAmount, depositPercent);
return hathorLib.numberUtils.prettyValue(deposit, decimalPlaces);
} else {
return '0';
diff --git a/src/utils/wallet.js b/src/utils/wallet.js
index 796cae64..bfefdc2e 100644
--- a/src/utils/wallet.js
+++ b/src/utils/wallet.js
@@ -614,25 +614,6 @@ const wallet = {
return Object.keys(alwaysShowMap);
},
- /**
- * Converts a decimal value to integer. On the full node and the wallet lib, we only deal with
- * integer values for amount. So a value of 45.97 for the user is handled by them as 4597.
- * We need the Math.round because of some precision errors in js
- * 35.05*100 = 3504.9999999999995 Precision error
- * Math.round(35.05*100) = 3505
- *
- * @param {number} value The decimal amount
- * @param {number} decimalPlaces Number of decimal places
- *
- * @return {number} Value as an integer
- *
- * @memberof Wallet
- * @inner
- */
- decimalToInteger(value, decimalPlaces) {
- return Math.round(value*(10**decimalPlaces));
- },
-
/**
* Returns a string map containing the identifiers for proposals currently being watched.
* @returns {Record
}