diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js
index 905751a24f8..3cfaf86edd7 100644
--- a/src/app/tabs/run-tab.js
+++ b/src/app/tabs/run-tab.js
@@ -177,19 +177,42 @@ var pendingTxsText = yo`
`
var pendingTxsContainer = yo`${pendingTxsText}
`
function runTab (container, appAPI, appEvents, opts) {
+ var self = {
+ _view: {},
+ addInstance: addInstance
+ }
+ var udapp = appAPI.udapp()
var el = yo`
- ${settings(appAPI, appEvents)}
- ${contractDropdown(appAPI, appEvents, instanceContainer)}
+ ${settings(self, appAPI, appEvents)}
+ ${contractDropdown(self, appAPI, appEvents, instanceContainer)}
${pendingTxsContainer}
${instanceContainer}
`
container.appendChild(el)
+ function addInstance (result) {
+ // {
+ // "result": {
+ // "gasUsed": "5318",
+ // "vm": { "exception": 1, "selfdestruct": {} },
+ // "bloom": { "bitvector": { "type": "Buffer", "data": [0, /* ... */ 0, 0] } },
+ // "amountSpent": "5318"
+ // },
+ // "transactionHash": "0x84f68f96944a47b27af4b4ed1986637aa1bc05fd7a6f5cb1d6a53f68058276d8"
+ // }
+ console.log(result)
+ var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`)
+ var contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerHTML]
+ var address = self._view.atAddressButtonInput.value
+ var instance = udapp.renderInstance(contract, address, self._view.selectContractNames.value)
+ instanceContainer.appendChild(instance)
+ }
+
// PENDING transactions
function updatePendingTxs (container, appAPI) {
- var pendingCount = Object.keys(appAPI.udapp().pendingTransactions()).length
+ var pendingCount = Object.keys(udapp.pendingTransactions()).length
pendingTxsText.innerText = pendingCount + ' pending transactions'
}
@@ -244,7 +267,7 @@ function updateAccountBalances (container, appAPI) {
/* ------------------------------------------------
RECORDER
------------------------------------------------ */
-function makeRecorder (appAPI, appEvents) {
+function makeRecorder (self, appAPI, appEvents) {
var udapp = appAPI.udapp()
var recorder = new Recorder({
events: {
@@ -292,29 +315,15 @@ function makeRecorder (appAPI, appEvents) {
modalDialogCustom.alert('Invalid JSON, please try again')
}
if (txArray.length) {
- txArray.forEach(tx => udapp.replayTx(tx.record, CALLBACK))
+ txArray.forEach(tx => udapp.rerunTx(tx.record, CALLBACK))
}
}, function cancel () { })
}
function CALLBACK (err, result) {
if (err) console.error(err)
else {
- console.log(result)
- // {
- // "result": {
- // "gasUsed": "5318",
- // "vm": { "exception": 1, "selfdestruct": {} },
- // "bloom": { "bitvector": { "type": "Buffer", "data": [0, /* ... */ 0, 0] } },
- // "amountSpent": "5318"
- // },
- // "transactionHash": "0x84f68f96944a47b27af4b4ed1986637aa1bc05fd7a6f5cb1d6a53f68058276d8"
- // }
- /*
- at each callback call, if the transaction succeed and if this is a creation transaction, we should call
-
- runtab.addInstance( ... ) // which basically does:
- instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value))
- */
+ // at each callback call, if the transaction succeed and if this is a creation transaction, we should call
+ self.addInstance(result)
}
}
return el
@@ -323,7 +332,7 @@ function makeRecorder (appAPI, appEvents) {
section CONTRACT DROPDOWN and BUTTONS
------------------------------------------------ */
-function contractDropdown (appAPI, appEvents, instanceContainer) {
+function contractDropdown (self, appAPI, appEvents, instanceContainer) {
instanceContainer.appendChild(noInstancesText)
var compFails = yo``
appEvents.compiler.register('compilationFinished', function (success, data, source) {
@@ -338,6 +347,8 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
var atAddressButtonInput = yo``
var createButtonInput = yo``
var selectContractNames = yo``
+ self._view.atAddressButtonInput = atAddressButtonInput
+ self._view.selectContractNames = selectContractNames
var el = yo`
@@ -509,7 +520,7 @@ function settings (appAPI, appEvents) {
- ${makeRecorder(appAPI, appEvents)}
+ ${makeRecorder(self, appAPI, appEvents)}
`
diff --git a/src/app/ui/modal-dialog-custom.js b/src/app/ui/modal-dialog-custom.js
index 07d47e3f12b..6e029696d0e 100644
--- a/src/app/ui/modal-dialog-custom.js
+++ b/src/app/ui/modal-dialog-custom.js
@@ -25,7 +25,7 @@ module.exports = {
},
promptMulti: function ({ title, text, inputValue }, ok, cancel) {
if (!inputValue) inputValue = ''
- var input =yo``
+ var input = yo``
modal(title, yo``,
{
fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) }
diff --git a/src/universal-dapp.js b/src/universal-dapp.js
index eb6a9a18606..f69bd63cf8c 100644
--- a/src/universal-dapp.js
+++ b/src/universal-dapp.js
@@ -467,7 +467,7 @@ function execute (pipeline, env, callback) {
next(null, env)
}
-UniversalDApp.prototype.replayTx = function (args, cb) {
+UniversalDApp.prototype.rerunTx = function (args, cb) {
var self = this
self.getAccounts(function (err, accounts = []) {
if (err) console.error(err)