From 3d214db19ffd12434119b25707a2e2e15b849c77 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 24 Apr 2018 10:23:32 +0200 Subject: [PATCH] use ethers to decode revert reason --- remix-lib/src/execution/txExecution.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/remix-lib/src/execution/txExecution.js b/remix-lib/src/execution/txExecution.js index 754360c706..7f9670eaeb 100644 --- a/remix-lib/src/execution/txExecution.js +++ b/remix-lib/src/execution/txExecution.js @@ -1,5 +1,5 @@ 'use strict' -var ethJSABI = require('ethereumjs-abi') +var ethers = require('ethers') module.exports = { /** @@ -86,7 +86,8 @@ module.exports = { var returnData = txResult.result.vm.return // It is the hash of Error(string) if (returnData && (returnData.slice(0, 4).toString('hex') === '08c379a0')) { - var reason = ethJSABI.rawDecode(['string'], returnData.slice(4))[0] + var abiCoder = new ethers.utils.AbiCoder() + var 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 constructor should be payable if you send value.`