Merge pull request #1323 from ethereum/dontcreateinstanceiffailure

don't add instances if the creation fails
pull/3094/head
yann300 7 years ago committed by GitHub
commit 58b85736ef
  1. 10
      src/app/tabs/run-tab.js

@ -355,7 +355,9 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
if (!error) {
appAPI.logMessage(`creation of ${selectedContract.name} pending...`)
opts.udapp.createContract(data, (error, txResult) => {
if (!error) {
if (error) {
appAPI.logMessage(`creation of ${selectedContract.name} errored: ` + error)
} else {
var isVM = executionContext.isVM()
if (isVM) {
var vmError = txExecution.checkVMError(txResult)
@ -364,12 +366,14 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
return
}
}
if (txResult.result.status && txResult.result.status === '0x0') {
appAPI.logMessage(`creation of ${selectedContract.name} errored: transaction execution failed`)
return
}
var noInstancesText = self._view.noInstancesText
if (noInstancesText.parentNode) { noInstancesText.parentNode.removeChild(noInstancesText) }
var address = isVM ? txResult.result.createdAddress : txResult.result.contractAddress
instanceContainer.appendChild(opts.udappUI.renderInstance(selectedContract.contract.object, address, selectContractNames.value))
} else {
appAPI.logMessage(`creation of ${selectedContract.name} errored: ` + error)
}
})
} else {

Loading…
Cancel
Save