diff --git a/remix-lib/src/execution/txExecution.js b/remix-lib/src/execution/txExecution.js index 7c2bd24c11..71bf676fb6 100644 --- a/remix-lib/src/execution/txExecution.js +++ b/remix-lib/src/execution/txExecution.js @@ -43,7 +43,7 @@ module.exports = { * @param {Function} finalCallback - last callback. */ callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) { - var tx = { from: from, to: to, data: data, useCall: false, value: value, gasLimit: gasLimit } + var tx = { from: from, to: to, data: data, useCall: funAbi.constant, value: value, gasLimit: gasLimit } txRunner.rawRun(tx, callbacks.confirmationCb, callbacks.gasEstimationForceSend, callbacks.promptCb, (error, txResult) => { // see universaldapp.js line 660 => 700 to check possible values of txResult (error case) finalCallback(error, txResult) diff --git a/remix-lib/src/execution/txRunner.js b/remix-lib/src/execution/txRunner.js index d0f3fdf3d9..3f660d32d3 100644 --- a/remix-lib/src/execution/txRunner.js +++ b/remix-lib/src/execution/txRunner.js @@ -133,6 +133,9 @@ class TxRunner { ++self.blockNumber this.runBlockInVm(tx, block, callback) } else { + console.dir("============") + console.dir("========= useCall") + console.dir("============") executionContext.vm().stateManager.checkpoint(() => { this.runBlockInVm(tx, block, (err, result) => { executionContext.vm().stateManager.revert(() => { diff --git a/remix-simulator/src/methods/transactions.js b/remix-simulator/src/methods/transactions.js index a942dcdfdf..41cc5be22a 100644 --- a/remix-simulator/src/methods/transactions.js +++ b/remix-simulator/src/methods/transactions.js @@ -50,8 +50,8 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { 'cumulativeGasUsed': Web3.utils.toHex(receipt.gas), 'contractAddress': receipt.contractAddress, 'logs': receipt.logs, - // 'status': receipt.status - 'status': "0x01" + 'status': receipt.status + // 'status': "0x01" } if (r.blockNumber === '0x') { @@ -83,6 +83,9 @@ Transactions.prototype.eth_call = function (payload, cb) { if (payload.params && payload.params.length > 0 && payload.params[0].from) { payload.params[0].from = ethJSUtil.toChecksumAddress(payload.params[0].from) } + if (payload.params && payload.params.length > 0 && payload.params[0].to) { + payload.params[0].to = ethJSUtil.toChecksumAddress(payload.params[0].to) + } processTx(this.accounts, payload, true, cb) } diff --git a/remix-simulator/src/methods/txProcess.js b/remix-simulator/src/methods/txProcess.js index 83b5e9a1d6..69fdc0bd8b 100644 --- a/remix-simulator/src/methods/txProcess.js +++ b/remix-simulator/src/methods/txProcess.js @@ -9,6 +9,9 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, return callback(err) } + console.dir(result.result.vm) + console.dir(result.result.vm.error) + console.dir(result.result) let toReturn = '0x' + result.result.vm.return.toString('hex') if (toReturn === '0x') { toReturn = '0x0' @@ -16,7 +19,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, return callback(null, toReturn) } - TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, true) + TxExecution.callFunction(from, to, data, value, gasLimit, {constant: true}, txRunner, callbacks, finalCallback, true) } function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { @@ -27,7 +30,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c callback(null, result.transactionHash) } - TxExecution.callFunction(from, to, data, value, gasLimit, null, txRunner, callbacks, finalCallback, false) + TxExecution.callFunction(from, to, data, value, gasLimit, {constant: false}, txRunner, callbacks, finalCallback, false) } function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) {