Commit c8cea2c4 authored by yann300's avatar yann300

manage several edge case:

- some inputs parameters can have a name, other not. - when no devdoc is defined, the devdoc property is still defined but the 'error' inside it is not defined
parent b04203ec
...@@ -112,18 +112,32 @@ export function checkVMError (execResult, abi, contract) { ...@@ -112,18 +112,32 @@ export function checkVMError (execResult, abi, contract) {
// "contract" reprensents the compilation result containing the NATSPEC documentation // "contract" reprensents the compilation result containing the NATSPEC documentation
if (contract && fn.functions && Object.keys(fn.functions).length) { if (contract && fn.functions && Object.keys(fn.functions).length) {
const functionSignature = Object.keys(fn.functions)[0] const functionSignature = Object.keys(fn.functions)[0]
// we check in the 'devdoc' if there's a developer documentation for this error // we check in the 'devdoc' if there's a developer documentation for this error
devdoc = contract.object.devdoc.errors[functionSignature][0] || {} try {
// we check in the 'userdoc' if there's an user documentation for this error devdoc = (contract.object.devdoc.errors && contract.object.devdoc.errors[functionSignature][0]) || {}
const userdoc = contract.object.userdoc.errors[functionSignature][0] || {} } catch (e) {
if (userdoc) customError += ' : ' + (userdoc as any).notice // we append the user doc if any console.error(e.message)
}
// we check in the 'userdoc' if there's an user documentation for this error
try {
const userdoc = (contract.object.userdoc.errors && contract.object.userdoc.errors[functionSignature][0]) || {}
if (userdoc && (userdoc as any).notice) customError += ' : ' + (userdoc as any).notice // we append the user doc if any
} catch (e) {
console.error(e.message)
}
} }
let inputIndex = 0
for (const input of functionDesc.inputs) { for (const input of functionDesc.inputs) {
const v = decodedCustomErrorInputs[input.name] const inputKey = input.name || inputIndex
decodedCustomErrorInputsClean[input.name] = { const v = decodedCustomErrorInputs[inputKey]
value: v.toString ? v.toString() : v,
documentation: (devdoc as any).params[input.name] // we add the developer documentation for this input parameter if any decodedCustomErrorInputsClean[inputKey] = {
value: v.toString ? v.toString() : v
}
if (devdoc && (devdoc as any).params) {
decodedCustomErrorInputsClean[input.name].documentation = (devdoc as any).params[inputKey] // we add the developer documentation for this input parameter if any
} }
inputIndex++
} }
break break
} }
......
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