From 4aa89a2581cfcaf13caa2f383614055790db021a Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 11:05:01 +0200 Subject: [PATCH 01/14] fix abi parameter typo --- apps/remix-ide/src/app/ui/universal-dapp-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/ui/universal-dapp-ui.js b/apps/remix-ide/src/app/ui/universal-dapp-ui.js index 0af660c010..17fe7058c8 100644 --- a/apps/remix-ide/src/app/ui/universal-dapp-ui.js +++ b/apps/remix-ide/src/app/ui/universal-dapp-ui.js @@ -253,7 +253,7 @@ UniversalDAppUI.prototype.runTransaction = function (lookupOnly, args, valArr, i const params = args.funABI.type !== 'fallback' ? inputsValues : '' this.blockchain.runOrCallContractMethod( args.contractName, - args.contractAbi, + args.contractABI, args.funABI, inputsValues, args.address, From 4ecf784e6833e48f2a931913f6831cecfb8899c2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 11:05:23 +0200 Subject: [PATCH 02/14] log to the terminal using "pre" tag --- apps/remix-ide/src/app/udapp/run-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/udapp/run-tab.js b/apps/remix-ide/src/app/udapp/run-tab.js index cc0d2f6ab6..b966287690 100644 --- a/apps/remix-ide/src/app/udapp/run-tab.js +++ b/apps/remix-ide/src/app/udapp/run-tab.js @@ -41,7 +41,7 @@ export class RunTab extends ViewPlugin { this.blockchain = blockchain this.fileManager = fileManager this.editor = editor - this.logCallback = (msg) => { mainView.getTerminal().logHtml(msg) } + this.logCallback = (msg) => { mainView.getTerminal().logHtml(yo`
${msg}
`) } this.filePanel = filePanel this.compilersArtefacts = compilersArtefacts this.networkModule = networkModule From e2a55f06566b10883796df20e65d892d0d5ce19f Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 11:06:07 +0200 Subject: [PATCH 03/14] make sure contract abi is passed to the whols stack --- apps/remix-ide/src/blockchain/blockchain.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index 27f9be195d..a5afab15c5 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -262,6 +262,10 @@ class Blockchain { } if (funABI.type === 'fallback') data.dataHex = value + if (data) { + data.contractName = contractName + data.contractABI = contractAbi + } const useCall = funABI.stateMutability === 'view' || funABI.stateMutability === 'pure' this.runTx({ to: address, data, useCall }, confirmationCb, continueCb, promptCb, (error, txResult, _address, returnValue) => { if (error) { @@ -477,7 +481,7 @@ class Blockchain { if (execResult) { // if it's not the VM, we don't have return value. We only have the transaction, and it does not contain the return value. returnValue = (execResult && isVM) ? execResult.returnValue : txResult - const vmError = txExecution.checkVMError(execResult) + const vmError = txExecution.checkVMError(execResult, args.data.contractABI) if (vmError.error) { return cb(vmError.message) } From 521ab4afabdb3c1b8190a18f1d2180ef96d05a5f Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 11:06:27 +0200 Subject: [PATCH 04/14] add custom error --- libs/remix-lib/src/execution/txExecution.ts | 54 ++++++++++++++++----- libs/remix-lib/src/execution/txHelper.ts | 20 ++++++-- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/libs/remix-lib/src/execution/txExecution.ts b/libs/remix-lib/src/execution/txExecution.ts index 8eb1c927dd..f8111f60eb 100644 --- a/libs/remix-lib/src/execution/txExecution.ts +++ b/libs/remix-lib/src/execution/txExecution.ts @@ -1,5 +1,6 @@ 'use strict' import { ethers } from 'ethers' +import { getFunctionFragment } from './txHelper' /** * deploy the given contract @@ -56,7 +57,7 @@ export function callFunction (from, to, data, value, gasLimit, funAbi, txRunner, * @param {Object} execResult - execution result given by the VM * @return {Object} - { error: true/false, message: DOMNode } */ -export function checkVMError (execResult) { +export function checkVMError (txResult, abi) { const errorCode = { OUT_OF_GAS: 'out of gas', STACK_UNDERFLOW: 'stack underflow', @@ -74,10 +75,10 @@ export function checkVMError (execResult) { error: false, message: '' } - if (!execResult.exceptionError) { + if (!txResult.result.execResult.exceptionError) { return ret } - const exceptionError = execResult.exceptionError.error || '' + const exceptionError = txResult.result.execResult.exceptionError.error || '' const error = `VM error: ${exceptionError}.\n` let msg if (exceptionError === errorCode.INVALID_OPCODE) { @@ -87,20 +88,49 @@ export function checkVMError (execResult) { msg = '\tThe transaction ran out of gas. Please increase the Gas Limit.\n' ret.error = true } else if (exceptionError === errorCode.REVERT) { - const returnData = execResult.returnValue - // It is the hash of Error(string) - if (returnData && (returnData.slice(0, 4).toString('hex') === '08c379a0')) { - const abiCoder = new ethers.utils.AbiCoder() - const reason = abiCoder.decode(['string'], returnData.slice(4))[0] - msg = `\tThe transaction has been reverted to the initial state.\nReason provided by the contract: "${reason}".` - } else { - msg = '\tThe transaction has been reverted to the initial state.\nNote: The called function should be payable if you send value and the value you send should be less than your current balance.' + const returnData = txResult.result.execResult.returnValue + const returnDataHex = returnData.slice(0, 4).toString('hex') + let customError + if (abi) { + let decodedCustomErrorInputs + for (const item of abi) { + if (item.type === 'error') { + // ethers doesn't crash anymore if "error" type is specified, but it doesn't extract the errors. see: + // https://github.com/ethers-io/ethers.js/commit/bd05aed070ac9e1421a3e2bff2ceea150bedf9b7 + // we need here to fake the type, so the "getSighash" function works properly + const fn = getFunctionFragment({ ...item, type: 'function', stateMutability: "nonpayable" }) + if (!fn) continue + const sign = fn.getSighash(item.name) + if (!sign) continue + if (returnDataHex === sign.replace('0x', '')) { + customError = item.name + decodedCustomErrorInputs = fn.decodeFunctionData(fn.getFunction(item.name), returnData) + break + } + } + } + if (decodedCustomErrorInputs) { + msg = `\tThe transaction has been reverted to the initial state.\nError provided by the contract:` + msg += `\n${customError}` + msg += `\nParameters:` + msg += `\n${decodedCustomErrorInputs}` + } + } + if (!customError) { + // It is the hash of Error(string) + if (returnData && (returnDataHex === '08c379a0')) { + const abiCoder = new ethers.utils.AbiCoder() + const reason = abiCoder.decode(['string'], returnData.slice(4))[0] + msg = `\tThe transaction has been reverted to the initial state.\nReason provided by the contract: "${reason}".` + } else { + msg = '\tThe transaction has been reverted to the initial state.\nNote: The called function should be payable if you send value and the value you send should be less than your current balance.' + } } ret.error = true } else if (exceptionError === errorCode.STATIC_STATE_CHANGE) { msg = '\tState changes is not allowed in Static Call context\n' ret.error = true } - ret.message = `${error}${exceptionError}${msg}\tDebug the transaction to get more information.` + ret.message = `${error}\n${exceptionError}\n${msg}\Debug the transaction to get more information.` return ret } diff --git a/libs/remix-lib/src/execution/txHelper.ts b/libs/remix-lib/src/execution/txHelper.ts index 1ee42e14bb..236ad191e5 100644 --- a/libs/remix-lib/src/execution/txHelper.ts +++ b/libs/remix-lib/src/execution/txHelper.ts @@ -38,6 +38,11 @@ export function encodeFunctionId (funABI) { return abi.getSighash(funABI.name) } +export function getFunctionFragment (funABI): ethers.utils.Interface { + if (funABI.type === 'fallback' || funABI.type === 'receive') return null + return new ethers.utils.Interface([funABI]) +} + export function sortAbiFunction (contractabi) { // Check if function is constant (introduced with Solidity 0.6.0) const isConstant = ({ stateMutability }) => stateMutability === 'view' || stateMutability === 'pure' @@ -97,10 +102,14 @@ export function extractSize (type) { return size ? size[2] : '' } -export function getFunction (abi, fnName) { +export function getError (abi, fnName) { + return getFromInterface(abi, fnName, 'error') +} + +export function getFromInterface (abi, fnName, type) { for (let i = 0; i < abi.length; i++) { const fn = abi[i] - if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => { + if (fn.type === type && fnName === fn.name + '(' + fn.inputs.map((value) => { if (value.components) { const fullType = this.makeFullTypeDefinition(value) return fullType.replace(/tuple/g, '') // return of makeFullTypeDefinition might contain `tuple`, need to remove it cause `methodIdentifier` (fnName) does not include `tuple` keyword @@ -111,7 +120,12 @@ export function getFunction (abi, fnName) { return fn } } - return null + return null +} + + +export function getFunction (abi, fnName) { + return getFromInterface(abi, fnName, 'function') } export function getFallbackInterface (abi) { From 88bee8904d7d482b7325e84e5e2d49f3ccdafdd1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 11:26:36 +0200 Subject: [PATCH 05/14] linting --- libs/remix-lib/src/execution/txExecution.ts | 8 ++++---- libs/remix-lib/src/execution/txHelper.ts | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/remix-lib/src/execution/txExecution.ts b/libs/remix-lib/src/execution/txExecution.ts index f8111f60eb..cb702d1b5a 100644 --- a/libs/remix-lib/src/execution/txExecution.ts +++ b/libs/remix-lib/src/execution/txExecution.ts @@ -91,14 +91,14 @@ export function checkVMError (txResult, abi) { const returnData = txResult.result.execResult.returnValue const returnDataHex = returnData.slice(0, 4).toString('hex') let customError - if (abi) { + if (abi) { let decodedCustomErrorInputs for (const item of abi) { if (item.type === 'error') { // ethers doesn't crash anymore if "error" type is specified, but it doesn't extract the errors. see: // https://github.com/ethers-io/ethers.js/commit/bd05aed070ac9e1421a3e2bff2ceea150bedf9b7 // we need here to fake the type, so the "getSighash" function works properly - const fn = getFunctionFragment({ ...item, type: 'function', stateMutability: "nonpayable" }) + const fn = getFunctionFragment({ ...item, type: 'function', stateMutability: 'nonpayable' }) if (!fn) continue const sign = fn.getSighash(item.name) if (!sign) continue @@ -110,9 +110,9 @@ export function checkVMError (txResult, abi) { } } if (decodedCustomErrorInputs) { - msg = `\tThe transaction has been reverted to the initial state.\nError provided by the contract:` + msg = '\tThe transaction has been reverted to the initial state.\nError provided by the contract:' msg += `\n${customError}` - msg += `\nParameters:` + msg += '\nParameters:' msg += `\n${decodedCustomErrorInputs}` } } diff --git a/libs/remix-lib/src/execution/txHelper.ts b/libs/remix-lib/src/execution/txHelper.ts index 236ad191e5..d6ca8a02bd 100644 --- a/libs/remix-lib/src/execution/txHelper.ts +++ b/libs/remix-lib/src/execution/txHelper.ts @@ -40,7 +40,7 @@ export function encodeFunctionId (funABI) { export function getFunctionFragment (funABI): ethers.utils.Interface { if (funABI.type === 'fallback' || funABI.type === 'receive') return null - return new ethers.utils.Interface([funABI]) + return new ethers.utils.Interface([funABI]) } export function sortAbiFunction (contractabi) { @@ -120,10 +120,9 @@ export function getFromInterface (abi, fnName, type) { return fn } } - return null + return null } - export function getFunction (abi, fnName) { return getFromInterface(abi, fnName, 'function') } From 7f9e48c345ffeff5b064f958f6bb1e16558c8916 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 12:14:55 +0200 Subject: [PATCH 06/14] typo --- libs/remix-lib/src/execution/txExecution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-lib/src/execution/txExecution.ts b/libs/remix-lib/src/execution/txExecution.ts index cb702d1b5a..584da6027d 100644 --- a/libs/remix-lib/src/execution/txExecution.ts +++ b/libs/remix-lib/src/execution/txExecution.ts @@ -131,6 +131,6 @@ export function checkVMError (txResult, abi) { msg = '\tState changes is not allowed in Static Call context\n' ret.error = true } - ret.message = `${error}\n${exceptionError}\n${msg}\Debug the transaction to get more information.` + ret.message = `${error}\n${exceptionError}\n${msg}\nDebug the transaction to get more information.` return ret } From 0b67aa953e994d6b9ed90c983d4531fab468c765 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 12:37:48 +0200 Subject: [PATCH 07/14] rollback uneeded refactoring --- libs/remix-lib/src/execution/txHelper.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libs/remix-lib/src/execution/txHelper.ts b/libs/remix-lib/src/execution/txHelper.ts index d6ca8a02bd..099e57868b 100644 --- a/libs/remix-lib/src/execution/txHelper.ts +++ b/libs/remix-lib/src/execution/txHelper.ts @@ -102,14 +102,10 @@ export function extractSize (type) { return size ? size[2] : '' } -export function getError (abi, fnName) { - return getFromInterface(abi, fnName, 'error') -} - -export function getFromInterface (abi, fnName, type) { +export function getFunction (abi, fnName) { for (let i = 0; i < abi.length; i++) { const fn = abi[i] - if (fn.type === type && fnName === fn.name + '(' + fn.inputs.map((value) => { + if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => { if (value.components) { const fullType = this.makeFullTypeDefinition(value) return fullType.replace(/tuple/g, '') // return of makeFullTypeDefinition might contain `tuple`, need to remove it cause `methodIdentifier` (fnName) does not include `tuple` keyword @@ -123,10 +119,6 @@ export function getFromInterface (abi, fnName, type) { return null } -export function getFunction (abi, fnName) { - return getFromInterface(abi, fnName, 'function') -} - export function getFallbackInterface (abi) { for (let i = 0; i < abi.length; i++) { if (abi[i].type === 'fallback') { From 9cc1e7ec2138d383263fa484ae623a73ca54108f Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 15:11:58 +0200 Subject: [PATCH 08/14] add e2e tests --- .../src/tests/transactionExecution.spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index 17fb82c644..14dcddb9c4 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -137,6 +137,22 @@ module.exports = { .selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') // this account will be used for this test suite .click('#runTabView button[class^="instanceButton"]') .waitForElementPresent('.instance:nth-of-type(2)') + }, + + 'Should Compile and Deploy a contract which define a custom error, the error should be logged in the terminal': function (browser: NightwatchBrowser) { + browser.testContracts('customError.sol', sources[4]['customError.sol'], ['C']) + .clickLaunchIcon('udapp') + .selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') // this account will be used for this test suite + .click('#runTabView button[class^="instanceButton"]') + .waitForElementPresent('.instance:nth-of-type(3)') + .click('.instance:nth-of-type(3) > div > button') + .clickFunction('g - transact (not payable)', { types: '', values: '' }) + .testFunction('latest', {}) + .journalLastChildIncludes(`Error provided by the contract: + E + Parameters: + 2 + Debug the transaction to get more information.`) .end() } } @@ -218,5 +234,23 @@ contract C { event Test(function() external); }` } + }, + // https://github.com/ethereum/remix-project/issues/1152 + { + 'customError.sol': { + content: `// SPDX-License-Identifier: GPL-3.0 + + pragma solidity ^0.8.4; + + error E(uint a); + contract C { + function f() public pure { + revert E(2); + } + function g() public { + revert E(2); + } + }` + } } ] From f8dcbb211d0e7da5ec6fcf3b383e7f7c33084f49 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 10 May 2021 22:11:58 +0200 Subject: [PATCH 09/14] linting --- apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index 14dcddb9c4..dc307c3a86 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -152,7 +152,7 @@ module.exports = { E Parameters: 2 - Debug the transaction to get more information.`) + Debug the transaction to get more information.`) .end() } } From ef883c354ea01d421eace94839b536228173ece5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 11 May 2021 09:59:10 +0200 Subject: [PATCH 10/14] linting --- apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index dc307c3a86..b2b1f8509f 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -152,7 +152,7 @@ module.exports = { E Parameters: 2 - Debug the transaction to get more information.`) + Debug the transaction to get more information.`) .end() } } From 1e84ad2806b8fafad12fe04b0db1a71579f788f4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 11 May 2021 10:32:04 +0200 Subject: [PATCH 11/14] fix e2e tests --- apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index b2b1f8509f..7b3038b52d 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -147,7 +147,6 @@ module.exports = { .waitForElementPresent('.instance:nth-of-type(3)') .click('.instance:nth-of-type(3) > div > button') .clickFunction('g - transact (not payable)', { types: '', values: '' }) - .testFunction('latest', {}) .journalLastChildIncludes(`Error provided by the contract: E Parameters: From 9a6586a03c669c1da4fbe2e379b5759a24adf852 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 11 May 2021 10:53:12 +0200 Subject: [PATCH 12/14] fix e2e tests --- .../src/tests/transactionExecution.spec.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index 7b3038b52d..c5c8309a82 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -147,11 +147,11 @@ module.exports = { .waitForElementPresent('.instance:nth-of-type(3)') .click('.instance:nth-of-type(3) > div > button') .clickFunction('g - transact (not payable)', { types: '', values: '' }) - .journalLastChildIncludes(`Error provided by the contract: - E - Parameters: - 2 - Debug the transaction to get more information.`) + .journalLastChildIncludes('Error provided by the contract:') + .journalLastChildIncludes('CustomError') + .journalLastChildIncludes('Parameters:') + .journalLastChildIncludes('2, 3, error_string_2') + .journalLastChildIncludes('Debug the transaction to get more information.') .end() } } @@ -241,13 +241,13 @@ contract C { pragma solidity ^0.8.4; - error E(uint a); + error CustomError(uint a, uint b, uint c); contract C { function f() public pure { - revert E(2); + revert CustomError(2, 3, "error_string"); } function g() public { - revert E(2); + revert CustomError(2, 3, "error_string_2"); } }` } From 55e0e7ca2eeae9701be6c557515e04a29195aa44 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 11 May 2021 11:11:31 +0200 Subject: [PATCH 13/14] fix e2e tests --- apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts index c5c8309a82..be8c0b936e 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.spec.ts @@ -146,11 +146,11 @@ module.exports = { .click('#runTabView button[class^="instanceButton"]') .waitForElementPresent('.instance:nth-of-type(3)') .click('.instance:nth-of-type(3) > div > button') - .clickFunction('g - transact (not payable)', { types: '', values: '' }) + .clickFunction('g - transact (not payable)') .journalLastChildIncludes('Error provided by the contract:') .journalLastChildIncludes('CustomError') .journalLastChildIncludes('Parameters:') - .journalLastChildIncludes('2, 3, error_string_2') + .journalLastChildIncludes('2,3,error_string_2') .journalLastChildIncludes('Debug the transaction to get more information.') .end() } @@ -241,7 +241,7 @@ contract C { pragma solidity ^0.8.4; - error CustomError(uint a, uint b, uint c); + error CustomError(uint a, uint b, string c); contract C { function f() public pure { revert CustomError(2, 3, "error_string"); From d36fe1ce822e92a3cd07f41c2a235f358393ad22 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 20 May 2021 09:51:44 +0200 Subject: [PATCH 14/14] fix checkVMError params --- libs/remix-lib/src/execution/txExecution.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-lib/src/execution/txExecution.ts b/libs/remix-lib/src/execution/txExecution.ts index 584da6027d..639151c781 100644 --- a/libs/remix-lib/src/execution/txExecution.ts +++ b/libs/remix-lib/src/execution/txExecution.ts @@ -57,7 +57,7 @@ export function callFunction (from, to, data, value, gasLimit, funAbi, txRunner, * @param {Object} execResult - execution result given by the VM * @return {Object} - { error: true/false, message: DOMNode } */ -export function checkVMError (txResult, abi) { +export function checkVMError (execResult, abi) { const errorCode = { OUT_OF_GAS: 'out of gas', STACK_UNDERFLOW: 'stack underflow', @@ -75,10 +75,10 @@ export function checkVMError (txResult, abi) { error: false, message: '' } - if (!txResult.result.execResult.exceptionError) { + if (!execResult.exceptionError) { return ret } - const exceptionError = txResult.result.execResult.exceptionError.error || '' + const exceptionError = execResult.exceptionError.error || '' const error = `VM error: ${exceptionError}.\n` let msg if (exceptionError === errorCode.INVALID_OPCODE) { @@ -88,7 +88,7 @@ export function checkVMError (txResult, abi) { msg = '\tThe transaction ran out of gas. Please increase the Gas Limit.\n' ret.error = true } else if (exceptionError === errorCode.REVERT) { - const returnData = txResult.result.execResult.returnValue + const returnData = execResult.returnValue const returnDataHex = returnData.slice(0, 4).toString('hex') let customError if (abi) {