diff --git a/src/app/execution/eventsDecoder.js b/src/app/execution/eventsDecoder.js index 502fdbd3f4..6e72630dfe 100644 --- a/src/app/execution/eventsDecoder.js +++ b/src/app/execution/eventsDecoder.js @@ -35,8 +35,8 @@ class EventsDecoder { this._decodeEvents(tx, receipt.logs, contract, contracts, cb) } - _eventABI (contractName, compiledContracts) { - var contractabi = JSON.parse(compiledContracts[contractName].interface) + _eventABI (contractabi) { + contractabi = JSON.parse(contractabi.interface) var eventABI = {} contractabi.forEach(function (funABI, i) { if (funABI.type !== 'event') { @@ -48,13 +48,30 @@ class EventsDecoder { return eventABI } + _eventsABI (compiledContracts) { + var eventsABI = {} + for (var contract in compiledContracts) { + eventsABI[contract] = this._eventABI(compiledContracts[contract]) + } + return eventsABI + } + + _event (hash, eventsABI) { + for (var k in eventsABI) { + if (eventsABI[k][hash]) { + return eventsABI[k][hash] + } + } + return null + } + _decodeEvents (tx, logs, contractName, compiledContracts, cb) { - var eventABI = this._eventABI(contractName, compiledContracts) + var eventsABI = this._eventsABI(compiledContracts) var events = [] for (var i in logs) { // [address, topics, mem] var log = logs[i] - var abi = eventABI[log.topics[0].replace('0x', '')] + var abi = this._event(log.topics[0].replace('0x', ''), eventsABI) if (abi) { var event try { diff --git a/src/app/execution/txFormat.js b/src/app/execution/txFormat.js index 3e700803b4..5faea74eeb 100644 --- a/src/app/execution/txFormat.js +++ b/src/app/execution/txFormat.js @@ -18,8 +18,9 @@ module.exports = { * @param {Object} params - input paramater of the function to call * @param {Object} udapp - udapp * @param {Function} callback - callback + * @param {Function} callbackStep - callbackStep */ - buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, callback) { + buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, callback, callbackStep) { var funArgs = '' try { funArgs = $.parseJSON('[' + params + ']') @@ -54,7 +55,7 @@ module.exports = { bytecodeToDeploy = bytecode + dataHex return callback(null, bytecodeToDeploy) } - }) + }, callbackStep) return } else { dataHex = bytecodeToDeploy + dataHex @@ -67,7 +68,7 @@ module.exports = { atAddress: function () {}, - linkBytecode: function (contract, contracts, udapp, callback) { + linkBytecode: function (contract, contracts, udapp, callback, callbackStep) { var bytecode = contract.bytecode if (bytecode.indexOf('_') < 0) { return callback(null, bytecode) @@ -81,7 +82,7 @@ module.exports = { if (!libraryabi) { return callback('Library ' + libraryName + ' not found.') } - this.deployLibrary(libraryabi, udapp, (err, address) => { + this.deployLibrary(libraryName, libraryabi, udapp, (err, address) => { if (err) { return callback(err) } @@ -95,22 +96,23 @@ module.exports = { bytecode = bytecode.replace(libLabel, hexAddress) } contract.bytecode = bytecode - this.linkBytecode(contract, contracts, udapp, callback) - }) + this.linkBytecode(contract, contracts, udapp, callback, callbackStep) + }, callbackStep) }, - deployLibrary: function (libraryName, library, udapp, callback) { + deployLibrary: function (libraryName, library, udapp, callback, callbackStep) { var address = library.address if (address) { return callback(null, address) } var bytecode = library.bytecode if (bytecode.indexOf('_') >= 0) { - this.linkBytecode(libraryName, (err, bytecode) => { + this.linkBytecode(libraryName, library, udapp, (err, bytecode) => { if (err) callback(err) - else this.deployLibrary(libraryName, callback) - }) + else this.deployLibrary(libraryName, library, udapp, callback, callbackStep) + }, callbackStep) } else { + callbackStep(`creation of library ${libraryName} pending...`) udapp.runTx({ data: bytecode, useCall: false }, (err, txResult) => { if (err) { return callback(err) diff --git a/src/app/execution/txHelper.js b/src/app/execution/txHelper.js index a9919f1020..62ea40925e 100644 --- a/src/app/execution/txHelper.js +++ b/src/app/execution/txHelper.js @@ -91,7 +91,7 @@ module.exports = { getContractByName: function (contractName, contracts) { for (var c in contracts) { - if (contracts[c].name === contractName) { + if (c === contractName) { return contracts[c] } } diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index a568c080a0..7ee84c7591 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -323,6 +323,8 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { } else { appAPI.logMessage(`creation of ${contractName} errored: ` + error) } + }, (msg) => { + appAPI.logMessage(msg) }) } diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 42ab5e6aa6..d0a560f60c 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -417,6 +417,8 @@ UniversalDApp.prototype.getCallButton = function (args) { } else { self._api.logMessage(`${logMsg} errored: ${error} `) } + }, (msg) => { + self._api.logMessage(msg) }) }