diff --git a/src/app/ui/multiParamManager.js b/src/app/ui/multiParamManager.js index 8195c6ace4..ab56d80b83 100644 --- a/src/app/ui/multiParamManager.js +++ b/src/app/ui/multiParamManager.js @@ -186,7 +186,7 @@ class MultiParamManager { expandedButton.classList.add('btn-info') funcButton.setAttribute('title', (title + ' - call')) funcButton.classList.add('btn-info') - } else if (this.funABI.stateMutability === 'payable' || this.funABI.payable === true) { + } else if (this.funABI.stateMutability === 'payable' || this.funABI.payable) { // transact. stateMutability = payable expandedButton.setAttribute('title', (title + ' - transact (payable)')) expandedButton.innerHTML = 'transact' @@ -194,7 +194,7 @@ class MultiParamManager { funcButton.setAttribute('title', (title + ' - transact (payable)')) funcButton.classList.add('btn-danger') } else { - // transact. stateMutability = not payable + // transact. stateMutability = nonpayable expandedButton.setAttribute('title', (title + ' - transact (not payable)')) expandedButton.innerHTML = 'transact' expandedButton.classList.add('btn-warning') diff --git a/src/app/ui/universal-dapp-ui.js b/src/app/ui/universal-dapp-ui.js index 65a72b836b..18a0c4b5f3 100644 --- a/src/app/ui/universal-dapp-ui.js +++ b/src/app/ui/universal-dapp-ui.js @@ -142,35 +142,35 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address // TODO this is used by renderInstance when a new instance is displayed. // this returns a DOM element. UniversalDAppUI.prototype.getCallButton = function (args) { - var self = this + let self = this // args.funABI, args.address [fun only] // args.contractName [constr only] - var lookupOnly = args.funABI.constant + const lookupOnly = args.funABI.stateMutability === 'view' || args.funABI.stateMutability === 'pure' || args.funABI.constant var outputOverride = yo`
` // show return value function clickButton (valArr, inputsValues) { - var logMsg - if (!args.funABI.constant) { - logMsg = `transact to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}` - } else { + let logMsg + if (lookupOnly) { logMsg = `call to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}` + } else { + logMsg = `transact to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}` } var value = inputsValues - var confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => { + const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => { if (network.name !== 'Main') { return continueTxExecution(null) } - var amount = executionContext.web3().fromWei(typeConversion.toInt(tx.value), 'ether') - var content = confirmDialog(tx, amount, gasEstimation, self.udapp, + const amount = executionContext.web3().fromWei(typeConversion.toInt(tx.value), 'ether') + const 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 { - var fee = executionContext.web3().toBigNumber(tx.gas).mul(executionContext.web3().toBigNumber(executionContext.web3().toWei(gasPrice.toString(10), 'gwei'))) + const 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' priceStatus = true } catch (e) { @@ -181,12 +181,12 @@ UniversalDAppUI.prototype.getCallButton = function (args) { }, (cb) => { executionContext.web3().eth.getGasPrice((error, gasPrice) => { - var warnMessage = ' Please fix this issue before sending any transaction. ' + const warnMessage = ' Please fix this issue before sending any transaction. ' if (error) { return cb('Unable to retrieve the current network gas price.' + warnMessage + error) } try { - var gasPriceValue = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei') + const gasPriceValue = executionContext.web3().fromWei(gasPrice.toString(10), 'gwei') cb(null, gasPriceValue) } catch (e) { cb(warnMessage + e.message, null, false) @@ -194,10 +194,15 @@ UniversalDAppUI.prototype.getCallButton = function (args) { }) } ) - modalDialog('Confirm transaction', content, + modalDialog( + 'Confirm transaction', + content, { label: 'Confirm', fn: () => { - self.udapp.config.setUnpersistedProperty('doNotShowTransactionConfirmationAgain', content.querySelector('input#confirmsetting').checked) + self.udapp.config.setUnpersistedProperty( + 'doNotShowTransactionConfirmationAgain', + content.querySelector('input#confirmsetting').checked + ) // TODO: check if this is check is still valid given the refactor if (!content.gasPriceStatus) { cancelCb('Given gas price is not correct') @@ -210,44 +215,46 @@ UniversalDAppUI.prototype.getCallButton = function (args) { fn: () => { return cancelCb('Transaction canceled by user.') } - }) + } + ) } - var continueCb = (error, continueTxExecution, cancelCb) => { + const continueCb = (error, continueTxExecution, cancelCb) => { if (error) { - var msg = typeof error !== 'string' ? error.message : error - modalDialog('Gas estimation failed', yo`