diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 80d98b7f6c..b53391688a 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -273,8 +273,11 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { if (!error) { txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { if (!error) { + var isVM = appAPI.executionContext().isVM() + if (isVM && alertVMErrorIfAny(txResult)) return + noInstancesText.style.display = 'none' - var address = appAPI.executionContext().isVM() ? txResult.result.createdAddress : txResult.result.contractAddress + var address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value)) } else { modalDialogCustom.alert(error) @@ -286,6 +289,22 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { }) } + function alertVMErrorIfAny (txResult) { + if (!txResult.result.vm.exceptionError) { + return null + } + var error = yo` VM error: ${txResult.result.vm.exceptionError}` + var msg + if (txResult.result.vm.exceptionError === 'invalid opcode') { + msg = yo`` + } else if (txResult.result.vm.exceptionError === 'out of gas') { + msg = yo`
The transaction ran out of gas. Please increase the Gas Limit.
` + } + modalDialogCustom.alert(yo`
${error} ${msg} Debug the transaction to get more information
`) + return error + msg + } + function loadFromAddress (appAPI) { noInstancesText.style.display = 'none' var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)