From b5296d11647da1f4c5070ca78ae9e5bb32e024b0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 11 Jan 2019 17:50:02 -0500 Subject: [PATCH] remove _deps --- src/app.js | 13 +++++++-- src/app/tabs/run-tab.js | 62 ++++++++++++----------------------------- 2 files changed, 29 insertions(+), 46 deletions(-) diff --git a/src/app.js b/src/app.js index 6fb4a4b4cf..e766ee5de9 100644 --- a/src/app.js +++ b/src/app.js @@ -7,7 +7,6 @@ var request = require('request') var remixLib = require('remix-lib') var EventManager = require('./lib/events') var EventEmitter = require('events') - var registry = require('./global/registry') var UniversalDApp = require('./universal-dapp.js') var UniversalDAppUI = require('./universal-dapp-ui.js') @@ -432,7 +431,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org let filePanel = new FilePanel() registry.put({api: filePanel, name: 'filepanel'}) let compileTab = new CompileTab(self._components.registry) - let run = new RunTab(self._components.registry) + let run = new RunTab( + registry.get('udapp').api, + registry.get('udappUI').api, + registry.get('config').api, + registry.get('filemanager').api, + registry.get('editor').api, + registry.get('logCallback').api, + registry.get('filepanel').api, + registry.get('pluginmanager').api, + registry.get('compilersartefacts').api + ) let settings = new SettingsTab(self._components.registry) let analysis = new AnalysisTab(self._components.registry) let debug = new DebuggerTab(self._components.registry) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 6c04698122..a53a3b88ae 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -17,18 +17,14 @@ var RecorderUI = require('./runTab/recorder.js') class RunTab { - constructor () { + constructor (udapp, udappUI, config, fileManager, editor, logCallback, filePanel, pluginManager, compilersArtefacts) { var self = this - self.event = new EventManager() - self._view = {} - self.data = { - count: 0, - text: `All transactions (deployed contracts and function executions) in this environment can be saved and replayed in - another environment. e.g Transactions created in Javascript VM can be replayed in the Injected Web3.` - } - self._components = {} - self._components.registry = globalRegistry - self._components.transactionContextAPI = { + this.event = new EventManager() + + this._view = {} + this.registry = globalRegistry + + this.transactionContextAPI = { getAddress: (cb) => { cb(null, $('#txorigin').val()) }, @@ -51,19 +47,7 @@ class RunTab { cb(null, $('#gasLimit').val()) } } - // dependencies - self._deps = { - udapp: self._components.registry.get('udapp').api, - udappUI: self._components.registry.get('udappUI').api, - config: self._components.registry.get('config').api, - fileManager: self._components.registry.get('filemanager').api, - editor: self._components.registry.get('editor').api, - logCallback: self._components.registry.get('logCallback').api, - filePanel: self._components.registry.get('filepanel').api, - pluginManager: self._components.registry.get('pluginmanager').api, - compilersArtefacts: self._components.registry.get('compilersartefacts').api - } - self._deps.udapp.resetAPI(self._components.transactionContextAPI) + udapp.resetAPI(this.transactionContextAPI) self._view.recorderCount = yo`0` self._view.instanceContainer = yo`
` self._view.clearInstanceElement = yo` @@ -83,24 +67,22 @@ class RunTab { var container = yo`
` - var recorder = new Recorder(self._deps.udapp, self._deps.fileManager, self._deps.config) + var recorder = new Recorder(udapp, fileManager, config) recorder.event.register('newTxRecorded', (count) => { - this.data.count = count this._view.recorderCount.innerText = count }) recorder.event.register('cleared', () => { - this.data.count = 0 this._view.recorderCount.innerText = 0 }) executionContext.event.register('contextChanged', recorder.clearAll.bind(recorder)) self.event.register('clearInstance', recorder.clearAll.bind(recorder)) - var recorderInterface = new RecorderUI(recorder, self._deps.logCallback) + var recorderInterface = new RecorderUI(recorder, logCallback) recorderInterface.event.register('newScenario', (abi, address, contractName) => { var noInstancesText = this._view.noInstancesText if (noInstancesText.parentNode) { noInstancesText.parentNode.removeChild(noInstancesText) } - this._view.instanceContainer.appendChild(this._deps.udappUI.renderInstanceFromABI(abi, address, contractName)) + this._view.instanceContainer.appendChild(udappUI.renderInstanceFromABI(abi, address, contractName)) }) recorderInterface.render() @@ -113,7 +95,8 @@ class RunTab { self._view.expandedView = yo`
- ${self.data.text} + All transactions (deployed contracts and function executions) in this environment can be saved and replayed in + another environment. e.g Transactions created in Javascript VM can be replayed in the Injected Web3.
${recorderInterface.recordButton} @@ -139,7 +122,7 @@ class RunTab { } }) - var settings = new Settings(self._deps.udapp) + var settings = new Settings(udapp) var settingsUI = new SettingsUI(settings) self.event.register('clearInstance', () => { @@ -151,27 +134,18 @@ class RunTab { this.event.trigger('clearInstance', []) }) - var dropdownLogic = new DropdownLogic( - this._deps.fileManager, - this._deps.pluginManager, - this._deps.compilersArtefacts, - this._deps.compiler, - this._deps.config, - this._deps.editor, - this._deps.udapp, - this._deps.filePanel - ) - var contractDropdownUI = new ContractDropdownUI(dropdownLogic, this._deps.logCallback) + var dropdownLogic = new DropdownLogic(fileManager, pluginManager, compilersArtefacts, null, config, editor, udapp, filePanel) + var contractDropdownUI = new ContractDropdownUI(dropdownLogic, logCallback) contractDropdownUI.event.register('clearInstance', () => { var noInstancesText = this._view.noInstancesText if (noInstancesText.parentNode) { noInstancesText.parentNode.removeChild(noInstancesText) } }) contractDropdownUI.event.register('newContractABIAdded', (abi, address) => { - this._view.instanceContainer.appendChild(this._deps.udappUI.renderInstanceFromABI(abi, address, address)) + this._view.instanceContainer.appendChild(udappUI.renderInstanceFromABI(abi, address, address)) }) contractDropdownUI.event.register('newContractInstanceAdded', (contractObject, address, value) => { - this._view.instanceContainer.appendChild(this._deps.udappUI.renderInstance(contractObject, address, value)) + this._view.instanceContainer.appendChild(udappUI.renderInstance(contractObject, address, value)) }) this._view.instanceContainer.appendChild(this._view.instanceContainerTitle)