Commit 44b09989 authored by Alex Beregszaszi's avatar Alex Beregszaszi Committed by yann300

Display reason for revert (Solidity 0.4.22 feature)

parent 75a4d125
'use strict' 'use strict'
var ethJSABI = require('ethereumjs-abi')
module.exports = { module.exports = {
/** /**
...@@ -82,7 +83,14 @@ module.exports = { ...@@ -82,7 +83,14 @@ module.exports = {
msg = `\tThe transaction ran out of gas. Please increase the Gas Limit.\n` msg = `\tThe transaction ran out of gas. Please increase the Gas Limit.\n`
ret.error = true ret.error = true
} else if (exceptionError === errorCode.REVERT) { } else if (exceptionError === errorCode.REVERT) {
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]
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.` msg = `\tThe transaction has been reverted to the initial state.\nNote: The constructor should be payable if you send value.`
}
ret.error = true ret.error = true
} else if (exceptionError === errorCode.STATIC_STATE_CHANGE) { } else if (exceptionError === errorCode.STATIC_STATE_CHANGE) {
msg = `\tState changes is not allowed in Static Call context\n` msg = `\tState changes is not allowed in Static Call context\n`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment