From 88fc2f4e751eaad3b64b9c6864e19dccbd1d7948 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 23 May 2018 14:27:46 +0200 Subject: [PATCH] don/'t add instances if the creation fails --- src/app/tabs/run-tab.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 87600a1306..3214990513 100644 --- a/src/app/tabs/run-tab.js +++ b/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 {