Merge pull request #698 from ethereum/warnifvmtxfailed

Alert vm error if any
pull/1/head
yann300 7 years ago committed by GitHub
commit 3460f05c2d
  1. 21
      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`<span> VM error: ${txResult.result.vm.exceptionError}</span>`
var msg
if (txResult.result.vm.exceptionError === 'invalid opcode') {
msg = yo`<ul><li>The constructor should be payable if you send it value.</li>
<li>The execution might have thrown.</li></ul>`
} else if (txResult.result.vm.exceptionError === 'out of gas') {
msg = yo`<div>The transaction ran out of gas. Please increase the Gas Limit.</div>`
}
modalDialogCustom.alert(yo`<div>${error} ${msg} Debug the transaction to get more information</div>`)
return error + msg
}
function loadFromAddress (appAPI) {
noInstancesText.style.display = 'none'
var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)

Loading…
Cancel
Save