|
|
|
@ -7,6 +7,7 @@ var typeConversion = remixLib.execution.typeConversion |
|
|
|
|
var txExecution = remixLib.execution.txExecution |
|
|
|
|
var CompilerAbstract = require('../../../compiler/compiler-abstract') |
|
|
|
|
var EventManager = remixLib.EventManager |
|
|
|
|
var Web3 = require('web3') |
|
|
|
|
|
|
|
|
|
class DropdownLogic { |
|
|
|
|
constructor (fileManager, compilersArtefacts, config, editor, udapp, filePanel, runView) { |
|
|
|
@ -106,17 +107,17 @@ class DropdownLogic { |
|
|
|
|
|
|
|
|
|
fromWei (value, doTypeConversion, unit) { |
|
|
|
|
if (doTypeConversion) { |
|
|
|
|
return executionContext.web3().utils.fromWei(typeConversion.toInt(value), unit || 'ether') |
|
|
|
|
return Web3.utils.fromWei(typeConversion.toInt(value), unit || 'ether') |
|
|
|
|
} |
|
|
|
|
return executionContext.web3().utils.fromWei(value.toString(10), unit || 'ether') |
|
|
|
|
return Web3.utils.fromWei(value.toString(10), unit || 'ether') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
toWei (value, unit) { |
|
|
|
|
return executionContext.web3().utils.toWei(value, unit || 'gwei') |
|
|
|
|
return Web3.utils.toWei(value, unit || 'gwei') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
calculateFee (gas, gasPrice, unit) { |
|
|
|
|
return executionContext.web3().utils.toBN(gas).mul(executionContext.web3().utils.toBN(executionContext.web3().utils.toWei(gasPrice.toString(10), unit || 'gwei'))) |
|
|
|
|
return Web3.utils.toBN(gas).mul(Web3.utils.toBN(Web3.utils.toWei(gasPrice.toString(10), unit || 'gwei'))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getGasPrice (cb) { |
|
|
|
@ -139,7 +140,7 @@ class DropdownLogic { |
|
|
|
|
if (network.name !== 'Main') { |
|
|
|
|
return continueTxExecution(null) |
|
|
|
|
} |
|
|
|
|
var amount = executionContext.web3().utils.fromWei(typeConversion.toInt(tx.value), 'ether') |
|
|
|
|
var amount = Web3.utils.fromWei(typeConversion.toInt(tx.value), 'ether') |
|
|
|
|
|
|
|
|
|
// TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily
|
|
|
|
|
var content = confirmDialog(tx, amount, gasEstimation, this.recorder, |
|
|
|
@ -148,8 +149,8 @@ class DropdownLogic { |
|
|
|
|
// TODO: this try catch feels like an anti pattern, can/should be
|
|
|
|
|
// removed, but for now keeping the original logic
|
|
|
|
|
try { |
|
|
|
|
var fee = executionContext.web3().utils.toBN(tx.gas).mul(executionContext.web3().utils.toBN(executionContext.web3().utils.toWei(gasPrice.toString(10), 'gwei'))) |
|
|
|
|
txFeeText = ' ' + executionContext.web3().utils.fromWei(fee.toString(10), 'ether') + ' Ether' |
|
|
|
|
var fee = Web3.utils.toBN(tx.gas).mul(Web3.utils.toBN(Web3.utils.toWei(gasPrice.toString(10), 'gwei'))) |
|
|
|
|
txFeeText = ' ' + Web3.utils.fromWei(fee.toString(10), 'ether') + ' Ether' |
|
|
|
|
priceStatus = true |
|
|
|
|
} catch (e) { |
|
|
|
|
txFeeText = ' Please fix this issue before sending any transaction. ' + e.message |
|
|
|
@ -164,7 +165,7 @@ class DropdownLogic { |
|
|
|
|
return cb('Unable to retrieve the current network gas price.' + warnMessage + error) |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
var gasPriceValue = executionContext.web3().utils.fromWei(gasPrice.toString(10), 'gwei') |
|
|
|
|
var gasPriceValue = Web3.utils.fromWei(gasPrice.toString(10), 'gwei') |
|
|
|
|
cb(null, gasPriceValue) |
|
|
|
|
} catch (e) { |
|
|
|
|
cb(warnMessage + e.message, null, false) |
|
|
|
@ -180,7 +181,7 @@ class DropdownLogic { |
|
|
|
|
if (!content.gasPriceStatus) { |
|
|
|
|
cancelCb('Given gas price is not correct') |
|
|
|
|
} else { |
|
|
|
|
var gasPrice = executionContext.web3().utils.toWei(content.querySelector('#gasprice').value, 'gwei') |
|
|
|
|
var gasPrice = Web3.utils.toWei(content.querySelector('#gasprice').value, 'gwei') |
|
|
|
|
continueTxExecution(gasPrice) |
|
|
|
|
} |
|
|
|
|
}}, { |
|
|
|
|