From ba962301d371496834125abc911b6e50e4c39f41 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 21 Jun 2021 15:26:11 +0200 Subject: [PATCH] log with error input name --- libs/remix-lib/src/execution/txExecution.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/remix-lib/src/execution/txExecution.ts b/libs/remix-lib/src/execution/txExecution.ts index 639151c781..e87db02eb1 100644 --- a/libs/remix-lib/src/execution/txExecution.ts +++ b/libs/remix-lib/src/execution/txExecution.ts @@ -92,7 +92,7 @@ export function checkVMError (execResult, abi) { const returnDataHex = returnData.slice(0, 4).toString('hex') let customError if (abi) { - let decodedCustomErrorInputs + let decodedCustomErrorInputsClean 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: @@ -104,16 +104,22 @@ export function checkVMError (execResult, abi) { if (!sign) continue if (returnDataHex === sign.replace('0x', '')) { customError = item.name - decodedCustomErrorInputs = fn.decodeFunctionData(fn.getFunction(item.name), returnData) + let functionDesc = fn.getFunction(item.name) + let decodedCustomErrorInputs = fn.decodeFunctionData(functionDesc, returnData) + decodedCustomErrorInputsClean = {} + for (const input of functionDesc.inputs) { + const v = decodedCustomErrorInputs[input.name] + decodedCustomErrorInputsClean[input.name] = v.toString ? v.toString() : v + } break } } } - if (decodedCustomErrorInputs) { + if (decodedCustomErrorInputsClean) { msg = '\tThe transaction has been reverted to the initial state.\nError provided by the contract:' msg += `\n${customError}` msg += '\nParameters:' - msg += `\n${decodedCustomErrorInputs}` + msg += `\n${JSON.stringify(decodedCustomErrorInputsClean, null, ' ')}` } } if (!customError) {