diff --git a/src/app.js b/src/app.js index 109c222810..ba8da8d78f 100644 --- a/src/app.js +++ b/src/app.js @@ -384,6 +384,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } }) + registry.put({api: (msg) => { + self._components.editorpanel.logHtmlMessage(msg) + }, name: 'logCallback'}) + // ----------------- Compiler ----------------- self._components.compiler = new Compiler((url, cb) => self.importFileCb(url, cb)) var compiler = self._components.compiler diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 93dac6926c..8c6ec40eee 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -42,8 +42,7 @@ function runTab (localRegistry) { udappUI: self._components.registry.get('udappUI').api, config: self._components.registry.get('config').api, fileManager: self._components.registry.get('filemanager').api, - editorPanel: self._components.registry.get('editorpanel').api, - editor: self._components.registry.get('editor').api + logCallback: self._components.registry.get('logCallback').api } self._view.recorderCount = yo`0` self._view.instanceContainer = yo`
` @@ -198,9 +197,7 @@ function updateAccountBalances (container, self) { RECORDER ------------------------------------------------ */ function makeRecorder (registry, runTabEvent, self) { - var recorder = new Recorder(self._deps.compiler, self._deps.udapp, (msg) => { - self._deps.editorPanel.logMessage(msg) - }) + var recorder = new Recorder(self._deps.compiler, self._deps.udapp, self._deps.logCallback) recorder.event.register('newTxRecorded', (count) => { self.data.count = count @@ -370,21 +367,21 @@ function contractDropdown (events, self) { var constructor = txHelper.getConstructorInterface(selectedContract.contract.object.abi) txFormat.buildData(selectedContract.name, selectedContract.contract.object, self._deps.compiler.getContracts(), true, constructor, args, (error, data) => { if (!error) { - self._deps.editorPanel.logMessage(`creation of ${selectedContract.name} pending...`) + self._deps.logCallback(`creation of ${selectedContract.name} pending...`) self._deps.udapp.createContract(data, (error, txResult) => { if (error) { - self._deps.editorPanel.logMessage(`creation of ${selectedContract.name} errored: ` + error) + self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error) } else { var isVM = executionContext.isVM() if (isVM) { var vmError = txExecution.checkVMError(txResult) if (vmError.error) { - self._deps.editorPanel.logMessage(vmError.message) + self._deps.logCallback(vmError.message) return } } if (txResult.result.status && txResult.result.status === '0x0') { - self._deps.editorPanel.logMessage(`creation of ${selectedContract.name} errored: transaction execution failed`) + self._deps.logCallback(`creation of ${selectedContract.name} errored: transaction execution failed`) return } var noInstancesText = self._view.noInstancesText @@ -394,10 +391,10 @@ function contractDropdown (events, self) { } }) } else { - self._deps.editorPanel.logMessage(`creation of ${selectedContract.name} errored: ` + error) + self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error) } }, (msg) => { - self._deps.editorPanel.logMessage(msg) + self._deps.logCallback(msg) }, (data, runTxCallback) => { // called for libraries deployment self._deps.udapp.runTx(data, runTxCallback) diff --git a/src/recorder.js b/src/recorder.js index 36d5705cd3..5bf6bd7863 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -13,9 +13,9 @@ var modal = require('./app/ui/modal-dialog-custom') * */ class Recorder { - constructor (compiler, udapp, msgCallBack) { + constructor (compiler, udapp, logCallBack) { var self = this - self.msgCallBack = msgCallBack + self.logCallBack = logCallBack self.event = new EventManager() self.data = { _listen: true, _replay: false, journal: [], _createdContracts: {}, _createdContractsReverse: {}, _usedAccounts: {}, _abis: {}, _contractABIReferences: {}, _linkReferences: {} } @@ -178,7 +178,7 @@ class Recorder { run (records, accounts, options, abis, linkReferences, udapp, newContractFn) { var self = this self.setListen(false) - self.msgCallBack(`Running ${records.length} transaction(s) ...`) + self.logCallBack(`Running ${records.length} transaction(s) ...`) async.eachOfSeries(records, function (tx, index, cb) { var record = self.resolveAddress(tx.record, accounts, options) var abi = abis[tx.record.abi] @@ -235,14 +235,14 @@ class Recorder { cb(data.error) return } else { - self.msgCallBack(`(${index}) ${JSON.stringify(record, null, '\t')}`) - self.msgCallBack(`(${index}) data: ${data.data}`) + self.logCallBack(`(${index}) ${JSON.stringify(record, null, '\t')}`) + self.logCallBack(`(${index}) data: ${data.data}`) record.data = { dataHex: data.data, funArgs: tx.record.parameters, funAbi: fnABI, contractBytecode: tx.record.bytecode, contractName: tx.record.contractName } } udapp.runTx(record, function (err, txResult) { if (err) { console.error(err) - self.msgCallBack(err + '. Execution failed at ' + index) + self.logCallBack(err + '. Execution failed at ' + index) } else { var address = executionContext.isVM() ? txResult.result.createdAddress : txResult.result.contractAddress if (address) { diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 780a984eff..4725c98f8f 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -29,7 +29,7 @@ function UniversalDApp (opts, localRegistry) { self.removable = opts.removable self.removable_instances = opts.removable_instances self._deps = { - config: self._components.registry.get('config').api + logCallback: self._components.registry.get('logCallback').api } executionContext.event.register('contextChanged', this, function (context) { self.reset(self.contracts) @@ -190,9 +190,9 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, if (!error) { if (isUserAction) { if (!args.funABI.constant) { - self._deps.editorpanel.logMessage(`${logMsg} pending ... `) + self._deps.logCallback(`${logMsg} pending ... `) } else { - self._deps.editorpanel.logMessage(`${logMsg}`) + self._deps.logCallback(`${logMsg}`) } } self.callFunction(args.address, data, args.funABI, (error, txResult) => { @@ -201,7 +201,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, if (isVM) { var vmError = txExecution.checkVMError(txResult) if (vmError.error) { - self._deps.editorpanel.logMessage(`${logMsg} errored: ${vmError.message} `) + self._deps.logCallback(`${logMsg} errored: ${vmError.message} `) return } } @@ -210,14 +210,14 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, outputCb(decoded) } } else { - self._deps.editorpanel.logMessage(`${logMsg} errored: ${error} `) + self._deps.logCallback(`${logMsg} errored: ${error} `) } }) } else { - self._deps.editorpanel.logMessage(`${logMsg} errored: ${error} `) + self._deps.logCallback(`${logMsg} errored: ${error} `) } }, (msg) => { - self._deps.editorpanel.logMessage(msg) + self._deps.logCallback(msg) }, (data, runTxCallback) => { // called for libraries deployment self.runTx(data, runTxCallback)