refactor gasprice format

pull/1/head
yann300 7 years ago
parent 9127dc6543
commit 93287919a2
  1. 12
      src/app/execution/txRunner.js

@ -245,6 +245,8 @@ function confirmDialog (tx, gasEstimation, self) {
</div> </div>
</div> </div>
` `
var warnMessage = ' Please fix this issue before sending any transaction. '
function gasPriceChanged () { function gasPriceChanged () {
try { try {
var gasPrice = el.querySelector('#gasprice').value var gasPrice = el.querySelector('#gasprice').value
@ -252,22 +254,20 @@ function confirmDialog (tx, gasEstimation, self) {
el.querySelector('#txfee').innerHTML = ' ' + executionContext.web3().fromWei(fee.toString(10), 'ether') + ' Ether' el.querySelector('#txfee').innerHTML = ' ' + executionContext.web3().fromWei(fee.toString(10), 'ether') + ' Ether'
el.gasPriceStatus = true el.gasPriceStatus = true
} catch (e) { } catch (e) {
el.querySelector('#txfee').innerHTML = ' Please fix this issue before sending any transaction. ' + e.message el.querySelector('#txfee').innerHTML = warnMessage + e.message
el.gasPriceStatus = false el.gasPriceStatus = false
} }
} }
executionContext.web3().eth.getGasPrice((error, gasPrice) => { executionContext.web3().eth.getGasPrice((error, gasPrice) => {
if (error) { if (error) {
el.querySelector('#txfee').innerHTML = 'Unable to retrieve the current network gas price. Please fix this issue before sending any transaction. <br/>' + error el.querySelector('#txfee').innerHTML = 'Unable to retrieve the current network gas price.' + warnMessage + error
} else { } else {
try { try {
var fee = executionContext.web3().toBigNumber(tx.gas).mul(gasPrice)
el.querySelector('#txfee').innerHTML = ' ' + executionContext.web3().fromWei(fee.toString(10), 'ether') + ' Ether'
el.querySelector('#gasprice').value = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei') el.querySelector('#gasprice').value = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei')
el.gasPriceStatus = true gasPriceChanged()
} catch (e) { } catch (e) {
el.querySelector('#txfee').innerHTML = ' Please fix this issue before sending any transaction. ' + e.message el.querySelector('#txfee').innerHTML = warnMessage + e.message
el.gasPriceStatus = false el.gasPriceStatus = false
} }
} }

Loading…
Cancel
Save