From 14faf263273e125708b210bcf03a9304544e975d Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 20 Dec 2019 19:30:06 +0530 Subject: [PATCH] execution context updated --- src/app/tabs/runTab/model/dropdownlogic.js | 18 +++++++++--------- src/app/tabs/runTab/model/recorder.js | 10 +++++----- src/app/udapp/run-tab.js | 2 +- src/app/ui/universal-dapp-ui.js | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/tabs/runTab/model/dropdownlogic.js b/src/app/tabs/runTab/model/dropdownlogic.js index 46ae90ddff..6c22d965a3 100644 --- a/src/app/tabs/runTab/model/dropdownlogic.js +++ b/src/app/tabs/runTab/model/dropdownlogic.js @@ -106,17 +106,17 @@ class DropdownLogic { fromWei (value, doTypeConversion, unit) { if (doTypeConversion) { - return executionContext.web3().fromWei(typeConversion.toInt(value), unit || 'ether') + return executionContext.web3().utils.fromWei(typeConversion.toInt(value), unit || 'ether') } - return executionContext.web3().fromWei(value.toString(10), unit || 'ether') + return executionContext.web3().utils.fromWei(value.toString(10), unit || 'ether') } toWei (value, unit) { - return executionContext.web3().toWei(value, unit || 'gwei') + return executionContext.web3().utils.toWei(value, unit || 'gwei') } calculateFee (gas, gasPrice, unit) { - return executionContext.web3().toBigNumber(gas).mul(executionContext.web3().toBigNumber(executionContext.web3().toWei(gasPrice.toString(10), unit || 'gwei'))) + return executionContext.web3().utils.toBN(gas).mul(executionContext.web3().utils.toBN(executionContext.web3().utils.toWei(gasPrice.toString(10), unit || 'gwei'))) } getGasPrice (cb) { @@ -139,7 +139,7 @@ class DropdownLogic { if (network.name !== 'Main') { return continueTxExecution(null) } - var amount = executionContext.web3().fromWei(typeConversion.toInt(tx.value), 'ether') + var amount = executionContext.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 +148,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().toBigNumber(tx.gas).mul(executionContext.web3().toBigNumber(executionContext.web3().toWei(gasPrice.toString(10), 'gwei'))) - txFeeText = ' ' + executionContext.web3().fromWei(fee.toString(10), 'ether') + ' Ether' + 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' priceStatus = true } catch (e) { txFeeText = ' Please fix this issue before sending any transaction. ' + e.message @@ -164,7 +164,7 @@ class DropdownLogic { return cb('Unable to retrieve the current network gas price.' + warnMessage + error) } try { - var gasPriceValue = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei') + var gasPriceValue = executionContext.web3().utils.fromWei(gasPrice.toString(10), 'gwei') cb(null, gasPriceValue) } catch (e) { cb(warnMessage + e.message, null, false) @@ -180,7 +180,7 @@ class DropdownLogic { if (!content.gasPriceStatus) { cancelCb('Given gas price is not correct') } else { - var gasPrice = executionContext.web3().toWei(content.querySelector('#gasprice').value, 'gwei') + var gasPrice = executionContext.web3().utils.toWei(content.querySelector('#gasprice').value, 'gwei') continueTxExecution(gasPrice) } }}, { diff --git a/src/app/tabs/runTab/model/recorder.js b/src/app/tabs/runTab/model/recorder.js index 5d8ef594fc..2d49a3795b 100644 --- a/src/app/tabs/runTab/model/recorder.js +++ b/src/app/tabs/runTab/model/recorder.js @@ -315,7 +315,7 @@ class Recorder { if (network.name !== 'Main') { return continueTxExecution(null) } - var amount = executionContext.web3().fromWei(typeConversion.toInt(tx.value), 'ether') + var amount = executionContext.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, @@ -324,8 +324,8 @@ class Recorder { // 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().toBigNumber(tx.gas).mul(executionContext.web3().toBigNumber(executionContext.web3().toWei(gasPrice.toString(10), 'gwei'))) - txFeeText = ' ' + executionContext.web3().fromWei(fee.toString(10), 'ether') + ' Ether' + var fee = executionContext.web3().utils.toBN(tx.gas).mul(executionContext.web3().utils.toBN(executionContext.web3().toWei(gasPrice.toString(10), 'gwei'))) + txFeeText = ' ' + executionContext.web3().utils.fromWei(fee.toString(10), 'ether') + ' Ether' priceStatus = true } catch (e) { txFeeText = ' Please fix this issue before sending any transaction. ' + e.message @@ -340,7 +340,7 @@ class Recorder { return cb('Unable to retrieve the current network gas price.' + warnMessage + error) } try { - var gasPriceValue = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei') + var gasPriceValue = executionContext.web3().utils.fromWei(gasPrice.toString(10), 'gwei') cb(null, gasPriceValue) } catch (e) { cb(warnMessage + e.message, null, false) @@ -356,7 +356,7 @@ class Recorder { if (!content.gasPriceStatus) { cancelCb('Given gas price is not correct') } else { - var gasPrice = executionContext.web3().toWei(content.querySelector('#gasprice').value, 'gwei') + var gasPrice = executionContext.web3().utils.toWei(content.querySelector('#gasprice').value, 'gwei') continueTxExecution(gasPrice) } }}, { diff --git a/src/app/udapp/run-tab.js b/src/app/udapp/run-tab.js index 781b18545f..e554970b71 100644 --- a/src/app/udapp/run-tab.js +++ b/src/app/udapp/run-tab.js @@ -63,7 +63,7 @@ export class RunTab extends LibraryPlugin { if (['ether', 'finney', 'gwei', 'wei'].indexOf(selectedUnit) >= 0) { unit = selectedUnit } - cb(null, executionContext.web3().toWei(number, unit)) + cb(null, executionContext.web3().utils.toWei(number, unit)) } catch (e) { cb(e) } diff --git a/src/app/ui/universal-dapp-ui.js b/src/app/ui/universal-dapp-ui.js index d0ed0c6498..656d992d5b 100644 --- a/src/app/ui/universal-dapp-ui.js +++ b/src/app/ui/universal-dapp-ui.js @@ -163,14 +163,14 @@ UniversalDAppUI.prototype.getCallButton = function (args) { if (network.name !== 'Main') { return continueTxExecution(null) } - const amount = executionContext.web3().fromWei(typeConversion.toInt(tx.value), 'ether') - const content = confirmDialog(tx, amount, gasEstimation, self.udapp, + var amount = executionContext.web3().utils.fromWei(typeConversion.toInt(tx.value), 'ether') + var content = confirmDialog(tx, amount, gasEstimation, self.udapp, (gasPrice, cb) => { let txFeeText, priceStatus // TODO: this try catch feels like an anti pattern, can/should be // removed, but for now keeping the original logic try { - const fee = executionContext.web3().toBigNumber(tx.gas).mul(executionContext.web3().toBigNumber(executionContext.web3().toWei(gasPrice.toString(10), 'gwei'))) + var fee = executionContext.web3().utils.toBN(tx.gas).mul(executionContext.web3().utils.toBN(executionContext.web3().utils.toWei(gasPrice.toString(10), 'gwei'))) txFeeText = ' ' + executionContext.web3().fromWei(fee.toString(10), 'ether') + ' Ether' priceStatus = true } catch (e) { @@ -186,7 +186,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) { return cb('Unable to retrieve the current network gas price.' + warnMessage + error) } try { - const gasPriceValue = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei') + var gasPriceValue = executionContext.web3().utils.fromWei(gasPrice.toString(10), 'gwei') cb(null, gasPriceValue) } catch (e) { cb(warnMessage + e.message, null, false) @@ -207,7 +207,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) { if (!content.gasPriceStatus) { cancelCb('Given gas price is not correct') } else { - var gasPrice = executionContext.web3().toWei(content.querySelector('#gasprice').value, 'gwei') + var gasPrice = executionContext.web3().utils.toWei(content.querySelector('#gasprice').value, 'gwei') continueTxExecution(gasPrice) } }}, {