Skip to content

Commit

Permalink
fix wrong custom gas value
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 committed Mar 28, 2019
1 parent 2666b48 commit acb09d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/components/UI/CustomGas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getRenderableEthGasFee,
getRenderableFiatGasFee,
apiEstimateModifiedToWEI,
apiEstimateModifiedToGWEI,
fetchBasicGasEstimates
} from '../../../util/custom-gas';
import { BN } from 'ethereumjs-util';
Expand Down Expand Up @@ -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: ''
Expand Down Expand Up @@ -306,7 +307,7 @@ class CustomGas extends Component {
keyboardType="numeric"
style={styles.gasInput}
onChangeText={this.onGasPriceChange}
value={customGasPrice}
value={apiEstimateModifiedToGWEI(customGasPrice).toString()}
/>
<Text style={styles.text}>{warningGasPrice}</Text>
</View>
Expand Down
10 changes: 10 additions & 0 deletions app/util/custom-gas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit acb09d9

Please sign in to comment.