From acb09d9f614851e311335a38f699bad790565105 Mon Sep 17 00:00:00 2001 From: Bruno Barbieri Date: Thu, 28 Mar 2019 19:18:13 -0400 Subject: [PATCH] fix wrong custom gas value --- app/components/UI/CustomGas/index.js | 5 +++-- app/util/custom-gas.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/components/UI/CustomGas/index.js b/app/components/UI/CustomGas/index.js index 37da3570aaf..79dc696f0af 100644 --- a/app/components/UI/CustomGas/index.js +++ b/app/components/UI/CustomGas/index.js @@ -8,6 +8,7 @@ import { getRenderableEthGasFee, getRenderableFiatGasFee, apiEstimateModifiedToWEI, + apiEstimateModifiedToGWEI, fetchBasicGasEstimates } from '../../../util/custom-gas'; import { BN } from 'ethereumjs-util'; @@ -120,7 +121,7 @@ class CustomGas extends Component { selected: 'average', ready: false, advancedCustomGas: false, - customGasPrice: '20', + customGasPrice: '10', customGasLimit: this.props.gas.toNumber().toString(), warningGasLimit: '', warningGasPrice: '' @@ -306,7 +307,7 @@ class CustomGas extends Component { keyboardType="numeric" style={styles.gasInput} onChangeText={this.onGasPriceChange} - value={customGasPrice} + value={apiEstimateModifiedToGWEI(customGasPrice).toString()} /> {warningGasPrice} diff --git a/app/util/custom-gas.js b/app/util/custom-gas.js index a73d0cb7ebf..e84496aca98 100644 --- a/app/util/custom-gas.js +++ b/app/util/custom-gas.js @@ -12,6 +12,16 @@ export function apiEstimateModifiedToWEI(estimate) { return new BN(((estimate * GWEIRate) / 10).toString(), 10); } +/** + * Calculates value of estimate gas price in gwei + * + * @param {number} estimate - Number corresponding to api gas price estimation + * @returns {Object} - BN instance containing gas price in gwei + */ +export function apiEstimateModifiedToGWEI(estimate) { + return new BN((estimate / 10).toString(), 10); +} + /** * Calculates gas fee in wei *