From cf33de80c49d332166e719df046692aefa912dd6 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 23 Jan 2019 11:43:56 -0500 Subject: [PATCH 01/18] move settings styles to its own file --- src/app/tabs/settings-tab.js | 94 +--------------------- src/app/tabs/styles/settings-tab-styles.js | 65 +++++++++------ 2 files changed, 41 insertions(+), 118 deletions(-) diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index fc86d8a9b8..6e3c7128a0 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -1,5 +1,4 @@ var yo = require('yo-yo') -var csjs = require('csjs-inject') var remixLib = require('remix-lib') var globalRegistry = require('../../global/registry') @@ -8,7 +7,7 @@ var copyToClipboard = require('../ui/copy-to-clipboard') var styleGuide = require('../ui/styles-guide/theme-chooser') var Storage = remixLib.Storage var EventManager = require('../../lib/events') - +var css = require('./styles/settings-tab-styles') import { ApiFactory } from 'remix-plugin' module.exports = class SettingsTab extends ApiFactory { @@ -179,94 +178,3 @@ module.exports = class SettingsTab extends ApiFactory { return self._view.el } } - -const css = csjs` - .settingsTabView { - padding: 2%; - } - .info { - margin-bottom: .6rem; - word-break: break-word; - font-size: .8rem; - } - .info h7 { - margin-bottom: .5rem; - } - .title { - // font-size: 1.1em; - // font-weight: bold; - // margin-bottom: 1em; - } - .frow { - margin-bottom: .5rem; - } - .crow { - // display: flex; - // overflow: auto; - // clear: both; - // padding: .2em; - } - .checkboxText { - font-weight: normal; - } - .crow label { - cursor:pointer; - } - .crowNoFlex { - overflow: auto; - clear: both; - } - .attention { - margin-bottom: 1em; - padding: .5em; - font-weight: bold; - } - .heading { - margin-bottom: 0; - } - .explaination { - margin-top: 3px; - margin-bottom: 3px; - } - input { - margin-right: 5px; - cursor: pointer; - width: inherit; - } - input[type=radio] { - margin-top: 2px; - } - .pluginTextArea { - font-family: unset; - } - - .removePlugin { - cursor: pointer; - } - .icon { - margin-right: .5em; - } - .savegisttoken { - margin-left: 5px; - } - .aPlugin { - display: inline-block; - padding-left: 10px; - padding-top: 4px; - padding-bottom: 6px; - max-width: 100px; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - vertical-align: middle; - } - .removePlugin{ - padding-left: 7px; - padding-right: 7px; - margin-left: 10px; - } - .inline { - display: inline; - width: 50%; - } -` diff --git a/src/app/tabs/styles/settings-tab-styles.js b/src/app/tabs/styles/settings-tab-styles.js index ba3c0506a6..44bc2dd3d7 100644 --- a/src/app/tabs/styles/settings-tab-styles.js +++ b/src/app/tabs/styles/settings-tab-styles.js @@ -1,24 +1,30 @@ var csjs = require('csjs-inject') -var css = csjs` +const css = csjs` .settingsTabView { padding: 2%; - display: flex; } .info { - margin-bottom: 1em; + margin-bottom: .6rem; word-break: break-word; + font-size: .8rem; + } + .info h7 { + margin-bottom: .5rem; } .title { - font-size: 1.1em; - font-weight: bold; - margin-bottom: 1em; + // font-size: 1.1em; + // font-weight: bold; + // margin-bottom: 1em; + } + .frow { + margin-bottom: .5rem; } .crow { - display: flex; - overflow: auto; - clear: both; - padding: .2em; + // display: flex; + // overflow: auto; + // clear: both; + // padding: .2em; } .checkboxText { font-weight: normal; @@ -35,10 +41,6 @@ var css = csjs` padding: .5em; font-weight: bold; } - .select { - font-weight: bold; - margin-top: 1em; - } .heading { margin-bottom: 0; } @@ -49,6 +51,7 @@ var css = csjs` input { margin-right: 5px; cursor: pointer; + width: inherit; } input[type=radio] { margin-top: 2px; @@ -56,24 +59,36 @@ var css = csjs` .pluginTextArea { font-family: unset; } - .pluginLoad { - vertical-align: top; - } - i.warnIt { - color: var(--warning); + + .removePlugin { + cursor: pointer; } .icon { margin-right: .5em; } - .remixdinstallation { - padding: 3px; - border-radius: 2px; - margin-left: 5px; - } .savegisttoken { margin-left: 5px; } -} + .aPlugin { + display: inline-block; + padding-left: 10px; + padding-top: 4px; + padding-bottom: 6px; + max-width: 100px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + vertical-align: middle; + } + .removePlugin{ + padding-left: 7px; + padding-right: 7px; + margin-left: 10px; + } + .inline { + display: inline; + width: 50%; + } ` module.exports = css From f67b394e5f77e08a1d086702845f24ebcdb869f8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 15:13:34 -0500 Subject: [PATCH 02/18] simplify & refactor settings tab --- src/app.js | 6 +++- src/app/tabs/settings-tab.js | 56 +++++++++++++++--------------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/app.js b/src/app.js index 046fc5a640..a7056d11be 100644 --- a/src/app.js +++ b/src/app.js @@ -444,7 +444,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org registry.get('pluginmanager').api, registry.get('compilersartefacts').api ) - let settings = new SettingsTab(self._components.registry) + let settings = new SettingsTab( + registry.get('config').api, + registry.get('editor').api, + appManager + ) let analysis = new AnalysisTab(registry) let debug = new DebuggerTab() const landingPage = new LandingPage(appManager, appStore) diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 6e3c7128a0..3b929841d7 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -1,7 +1,6 @@ var yo = require('yo-yo') var remixLib = require('remix-lib') -var globalRegistry = require('../../global/registry') var tooltip = require('../ui/tooltip') var copyToClipboard = require('../ui/copy-to-clipboard') var styleGuide = require('../ui/styles-guide/theme-chooser') @@ -11,34 +10,25 @@ var css = require('./styles/settings-tab-styles') import { ApiFactory } from 'remix-plugin' module.exports = class SettingsTab extends ApiFactory { - constructor (localRegistry) { + constructor (config, editor, appManager) { super() - const self = this - self._components = {} - self._components.registry = localRegistry || globalRegistry - // dependencies - self._deps = { - config: self._components.registry.get('config').api, - editorPanel: self._components.registry.get('editorpanel').api, - editor: self._components.registry.get('editor').api, - appManager: self._components.registry.get('appmanager').api - } - self._view = { /* eslint-disable */ + this.config = config + this.editor = editor + this.appManager = appManager + this._components = {} + this._view = { /* eslint-disable */ el: null, optionVM: null, personal: null, warnPersonalMode: null, generateContractMetadata: null, - pluginInput: null, versionSelector: null, version: null, theme: { dark: null, light: null, clean: null }, - plugins: {}, config: { - general: null, themes: null, - plugin: null + general: null, themes: null } } /* eslint-enable */ - self.data = {} - self.event = new EventManager() - self._components.themeStorage = new Storage('style:') - self.data.currentTheme = self._components.themeStorage.get('theme') || 'light' + this.event = new EventManager() + const themeStorage = new Storage('style:') + this.currentTheme = themeStorage.get('theme') || 'light' } + get profile () { return { displayName: 'settings', @@ -58,16 +48,16 @@ module.exports = class SettingsTab extends ApiFactory { // Gist settings var gistAccessToken = yo`` - var token = self._deps.config.get('settings/gist-access-token') + var token = self.config.get('settings/gist-access-token') if (token) gistAccessToken.value = token - var gistAddToken = yo` { self._deps.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">` - var gistRemoveToken = yo` { gistAccessToken.value = ''; self._deps.config.set('settings/gist-access-token', ''); tooltip('Access token removed') }} value="Remove" type="button">` - self._view.gistToken = yo`
${gistAccessToken}${copyToClipboard(() => self._deps.config.get('settings/gist-access-token'))}${gistAddToken}${gistRemoveToken}
` + var gistAddToken = yo` { self.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">` + var gistRemoveToken = yo` { gistAccessToken.value = ''; self.config.set('settings/gist-access-token', ''); tooltip('Access token removed') }} value="Remove" type="button">` + self._view.gistToken = yo`
${gistAccessToken}${copyToClipboard(() => self.config.get('settings/gist-access-token'))}${gistAddToken}${gistRemoveToken}
` // self._view.optionVM = yo`` - if (self._deps.config.get('settings/always-use-vm')) self._view.optionVM.setAttribute('checked', '') + if (self.config.get('settings/always-use-vm')) self._view.optionVM.setAttribute('checked', '') self._view.personal = yo`` - if (self._deps.config.get('settings/personal-mode')) self._view.personal.setAttribute('checked', '') + if (self.config.get('settings/personal-mode')) self._view.personal.setAttribute('checked', '') var warnText = `Transaction sent over Web3 will use the web3.personal API - be sure the endpoint is opened before enabling it. This mode allows to provide the passphrase in the Remix interface without having to unlock the account. Although this is very convenient, you should completely trust the backend you are connected to (Geth, Parity, ...). @@ -76,7 +66,7 @@ module.exports = class SettingsTab extends ApiFactory { self._view.warnPersonalMode = yo`` self._view.generateContractMetadata = yo`` - if (self._deps.config.get('settings/generate-contract-metadata')) self._view.generateContractMetadata.setAttribute('checked', '') + if (self.config.get('settings/generate-contract-metadata')) self._view.generateContractMetadata.setAttribute('checked', '') self._view.pluginInput = yo`` @@ -90,7 +80,7 @@ module.exports = class SettingsTab extends ApiFactory {
Home
- +
@@ -108,7 +98,7 @@ module.exports = class SettingsTab extends ApiFactory {
-
+
@@ -157,10 +147,10 @@ module.exports = class SettingsTab extends ApiFactory {
` function onchangeGenerateContractMetadata (event) { - self._deps.config.set('settings/generate-contract-metadata', !self._deps.config.get('settings/generate-contract-metadata')) + self.config.set('settings/generate-contract-metadata', !self.config.get('settings/generate-contract-metadata')) } function onchangeOption (event) { - self._deps.config.set('settings/always-use-vm', !self._deps.config.get('settings/always-use-vm')) + self.config.set('settings/always-use-vm', !self.config.get('settings/always-use-vm')) } function onswitch2darkTheme (event) { styleGuide.switchTheme('dark') @@ -172,7 +162,7 @@ module.exports = class SettingsTab extends ApiFactory { styleGuide.switchTheme('clean') } function onchangePersonal (event) { - self._deps.config.set('settings/personal-mode', !self._deps.config.get('settings/personal-mode')) + self.config.set('settings/personal-mode', !self.config.get('settings/personal-mode')) } styleGuide.switchTheme() return self._view.el From ceea86050f1d5b4eec05bd448d31e991145c6437 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 15:35:37 -0500 Subject: [PATCH 03/18] simplify settings tab render method --- src/app/tabs/settings-tab.js | 80 +++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 3b929841d7..57cee609db 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -25,6 +25,10 @@ module.exports = class SettingsTab extends ApiFactory { } } /* eslint-enable */ this.event = new EventManager() + this.initTheme() + } + + initTheme () { const themeStorage = new Storage('style:') this.currentTheme = themeStorage.get('theme') || 'light' } @@ -48,34 +52,34 @@ module.exports = class SettingsTab extends ApiFactory { // Gist settings var gistAccessToken = yo`` - var token = self.config.get('settings/gist-access-token') + var token = this.config.get('settings/gist-access-token') if (token) gistAccessToken.value = token - var gistAddToken = yo` { self.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">` - var gistRemoveToken = yo` { gistAccessToken.value = ''; self.config.set('settings/gist-access-token', ''); tooltip('Access token removed') }} value="Remove" type="button">` - self._view.gistToken = yo`
${gistAccessToken}${copyToClipboard(() => self.config.get('settings/gist-access-token'))}${gistAddToken}${gistRemoveToken}
` + var gistAddToken = yo` { this.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">` + var gistRemoveToken = yo` { gistAccessToken.value = ''; this.config.set('settings/gist-access-token', ''); tooltip('Access token removed') }} value="Remove" type="button">` + this._view.gistToken = yo`
${gistAccessToken}${copyToClipboard(() => this.config.get('settings/gist-access-token'))}${gistAddToken}${gistRemoveToken}
` // - self._view.optionVM = yo`` - if (self.config.get('settings/always-use-vm')) self._view.optionVM.setAttribute('checked', '') - self._view.personal = yo`` - if (self.config.get('settings/personal-mode')) self._view.personal.setAttribute('checked', '') + this._view.optionVM = yo`` + if (this.config.get('settings/always-use-vm')) this._view.optionVM.setAttribute('checked', '') + this._view.personal = yo`` + if (this.config.get('settings/personal-mode')) this._view.personal.setAttribute('checked', '') var warnText = `Transaction sent over Web3 will use the web3.personal API - be sure the endpoint is opened before enabling it. This mode allows to provide the passphrase in the Remix interface without having to unlock the account. Although this is very convenient, you should completely trust the backend you are connected to (Geth, Parity, ...). It is not recommended (and also most likely not relevant) to use this mode with an injected provider (Mist, Metamask, ...) or with JavaScript VM. Remix never persist any passphrase.`.split('\n').map(s => s.trim()).join(' ') - self._view.warnPersonalMode = yo`` - self._view.generateContractMetadata = yo`` + this._view.warnPersonalMode = yo`` + this._view.generateContractMetadata = yo`` - if (self.config.get('settings/generate-contract-metadata')) self._view.generateContractMetadata.setAttribute('checked', '') + if (this.config.get('settings/generate-contract-metadata')) this._view.generateContractMetadata.setAttribute('checked', '') - self._view.pluginInput = yo`` + this._view.pluginInput = yo`` - self._view.theme.light = yo`` - self._view.theme.dark = yo`` - self._view.theme.clean = yo`` - self._view.theme[self.data.currentTheme].setAttribute('checked', 'checked') + this._view.theme.light = yo`` + this._view.theme.dark = yo`` + this._view.theme.clean = yo`` + this._view.theme[this.data.currentTheme].setAttribute('checked', 'checked') - self._view.config.homePage = yo` + this._view.config.homePage = yo`
Home
@@ -85,72 +89,72 @@ module.exports = class SettingsTab extends ApiFactory {
` - self._view.config.general = yo` + this._view.config.general = yo`
General settings
-
${self._view.generateContractMetadata}
+
${this._view.generateContractMetadata}
-
${self._view.optionVM}
+
${this._view.optionVM}
-
+
-
${self._view.personal}>
- +
${this._view.personal}>
+
` - self._view.gistToken = yo` + this._view.gistToken = yo`
Gist Access Token

Manage the access token used to publish to Gist and retrieve Github contents.

Go to github token page (link below) to create a new token and save it in Remix. Make sure this token has only 'create gist' permission.

https://github.com/settings/tokens

-
${self._view.gistToken}
+
${this._view.gistToken}
` - self._view.config.themes = yo` + this._view.config.themes = yo`
Themes
- ${self._view.theme.light} + ${this._view.theme.light}
- ${self._view.theme.dark} + ${this._view.theme.dark}
- ${self._view.theme.clean} + ${this._view.theme.clean}
` - self._view.el = yo` + this._view.el = yo`
- ${self._view.config.homePage} - ${self._view.config.general} - ${self._view.gistToken} - ${self._view.config.themes} + ${this._view.config.homePage} + ${this._view.config.general} + ${this._view.gistToken} + ${this._view.config.themes}
` function onchangeGenerateContractMetadata (event) { - self.config.set('settings/generate-contract-metadata', !self.config.get('settings/generate-contract-metadata')) + this.config.set('settings/generate-contract-metadata', !this.config.get('settings/generate-contract-metadata')) } function onchangeOption (event) { - self.config.set('settings/always-use-vm', !self.config.get('settings/always-use-vm')) + this.config.set('settings/always-use-vm', !this.config.get('settings/always-use-vm')) } function onswitch2darkTheme (event) { styleGuide.switchTheme('dark') @@ -162,9 +166,9 @@ module.exports = class SettingsTab extends ApiFactory { styleGuide.switchTheme('clean') } function onchangePersonal (event) { - self.config.set('settings/personal-mode', !self.config.get('settings/personal-mode')) + this.config.set('settings/personal-mode', !this.config.get('settings/personal-mode')) } styleGuide.switchTheme() - return self._view.el + return this._view.el } } From a014379379160b712baaa1ad7e6ccecdd4ea8f36 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 16:38:13 -0500 Subject: [PATCH 04/18] refactor test tab --- src/app.js | 6 +- src/app/tabs/test-tab.js | 215 ++++++++++++++++++++------------------- 2 files changed, 113 insertions(+), 108 deletions(-) diff --git a/src/app.js b/src/app.js index a7056d11be..67d019122d 100644 --- a/src/app.js +++ b/src/app.js @@ -453,7 +453,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org let debug = new DebuggerTab() const landingPage = new LandingPage(appManager, appStore) // let support = new SupportTab() - let test = new TestTab(self._components.registry, compileTab) + let test = new TestTab( + registry.get('filemanager').api, + registry.get('filepanel').api, + compileTab + ) let sourceHighlighters = registry.get('editor').api.sourceHighlighters let configProvider = self._components.filesProviders['config'] diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index d94fba0145..632abc7a59 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -3,28 +3,22 @@ var async = require('async') var helper = require('../../lib/helper.js') var tooltip = require('../ui/tooltip') var modalDialogCustom = require('../ui/modal-dialog-custom') -var globalRegistry = require('../../global/registry') var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') import { ApiFactory } from 'remix-plugin' module.exports = class TestTab extends ApiFactory { - constructor (localRegistry, compileTab) { + constructor (fileManager, filePanel, compileTab) { super() - // TODO here is a direct reference to compile tab, should be removed - const self = this - self.compileTab = compileTab - self._view = { el: null } - self._components = {} - self._components.registry = localRegistry || globalRegistry - // dependencies - self._deps = { - fileManager: self._components.registry.get('filemanager').api, - filePanel: self._components.registry.get('filepanel').api - } - self.data = {} - self.testList = yo`
` + this.compileTab = compileTab + this._view = { el: null } + this._components = {} + this.fileManager = fileManager + this.filePanel = filePanel + this.data = {} + this.testList = yo`
` + this.listenToEvents() } get profile () { @@ -38,19 +32,90 @@ module.exports = class TestTab extends ApiFactory { } } + listenToEvents () { + const self = this + + self.filePanel.event.register('newTestFileCreated', file => { + var testList = self.view.querySelector("[class^='testList']") + var test = yo`` + testList.appendChild(test) + self.data.allTests.push(file) + self.data.selectedTests.push(file) + }) + + self.fileManager.event.register('currentFileChanged', (file, provider) => { + self.getTests(self, (error, tests) => { + if (error) return tooltip(error) + self.data.allTests = tests + self.data.selectedTests = [...self.data.allTests] + if (!tests.length) { + yo.update(self.testList, yo`
No test file available
`) + } else { + yo.update(self.testList, yo`
${self.listTests()}
`) + } + + if (!self.testsOutput || !self.testsSummary) return + + self.testsOutput.hidden = true + self.testsSummary.hidden = true + self.testsOutput.innerHTML = '' + self.testsSummary.innerHTML = '' + }) + }) + } + + getTests (self, cb) { + var path = self.fileManager.currentPath() + if (!path) return cb(null, []) + var provider = self.fileManager.fileProviderOf(path) + if (!provider) return cb(null, []) + var tests = [] + self.fileManager.filesFromPath(path, (error, files) => { + if (error) return cb(error) + if (!error) { + for (var file in files) { + if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file) + } + cb(null, tests) + } + }) + } + + listTests () { + const self = this + var tests = self.data.allTests + return tests.map(test => yo``) + } + + toggleCheckbox (eChecked, test) { + const self = this + if (!self.data.selectedTests) { + self.data.selectedTests = self._view.el.querySelectorAll('.singleTest:checked') + } + let selectedTests = self.data.selectedTests + selectedTests = eChecked ? [...selectedTests, test] : selectedTests.filter(el => el !== test) + self.data.selectedTests = selectedTests + let checkAll = self._view.el.querySelector('[id="checkAllTests"]') + if (eChecked) { + checkAll.checked = true + } else if (!selectedTests.length) { + checkAll.checked = false + } + } + render () { const self = this - var testsOutput = yo`` - var testsSummary = yo`` + self.testsOutput = yo`` + self.testsSummary = yo`` var testCallback = function (result) { - testsOutput.hidden = false + self.testsOutput.hidden = false if (result.type === 'contract') { - testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) + self.testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) } else if (result.type === 'testPass') { - testsOutput.appendChild(yo`
✓ (${result.value})
`) + self.testsOutput.appendChild(yo`
✓ (${result.value})
`) } else if (result.type === 'testFailure') { - testsOutput.appendChild(yo`
✘ (${result.value})
`) + self.testsOutput.appendChild(yo`
✘ (${result.value})
`) } } @@ -63,106 +128,40 @@ module.exports = class TestTab extends ApiFactory { } var updateFinalResult = function (_err, result, filename) { - testsSummary.hidden = false + self.testsSummary.hidden = false if (_err) { - testsSummary.appendChild(yo`
${_err.message}
`) + self.testsSummary.appendChild(yo`
${_err.message}
`) return } - testsSummary.appendChild(yo`
${filename}
`) + self.testsSummary.appendChild(yo`
${filename}
`) if (result.totalPassing > 0) { - testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) - testsSummary.appendChild(yo`
`) + self.testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) + self.testsSummary.appendChild(yo`
`) } if (result.totalFailing > 0) { - testsSummary.appendChild(yo`
${result.totalFailing} failing
`) - testsSummary.appendChild(yo`
`) + self.testsSummary.appendChild(yo`
${result.totalFailing} failing
`) + self.testsSummary.appendChild(yo`
`) } result.errors.forEach((error, index) => { - testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) - testsSummary.appendChild(yo`
${error.message}
`) - testsSummary.appendChild(yo`
`) + self.testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) + self.testsSummary.appendChild(yo`
${error.message}
`) + self.testsSummary.appendChild(yo`
`) }) } function runTest (testFilePath, callback) { - self._deps.fileManager.fileProviderOf(testFilePath).get(testFilePath, (error, content) => { + self.fileManager.fileProviderOf(testFilePath).get(testFilePath, (error, content) => { if (!error) { var runningTest = {} runningTest[testFilePath] = { content } remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { updateFinalResult(error, result, testFilePath) callback(error) - }, (url, cb) => { self.compileTab.compileTabLogic.importFileCb(url, cb) }) - } - }) - } - - function getTests (self, cb) { - var path = self._deps.fileManager.currentPath() - if (!path) return cb(null, []) - var provider = self._deps.fileManager.fileProviderOf(path) - if (!provider) return cb(null, []) - var tests = [] - self._deps.fileManager.getFilesFromPath(path) - .then((files) => { - for (var file in files) { - if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file) - } - cb(null, tests) - }) - .catch(err => cb(err)) - } - - self._deps.filePanel.event.register('newTestFileCreated', file => { - var testList = self.view.querySelector("[class^='testList']") - var test = yo`` - testList.appendChild(test) - self.data.allTests.push(file) - self.data.selectedTests.push(file) - }) - - self._deps.fileManager.events.on('currentFileChanged', (file) => { - getTests(self, (error, tests) => { - if (error) return tooltip(error) - self.data.allTests = tests - self.data.selectedTests = [...self.data.allTests] - if (!tests.length) { - yo.update(self.testList, yo`
No test file available
`) - } else { - yo.update(self.testList, yo`
${listTests()}
`) + }, (url, cb) => { + return self.compileTab.compileTabLogic.importFileCb(url, cb) + }) } - testsOutput.hidden = true - testsSummary.hidden = true - testsOutput.innerHTML = '' - testsSummary.innerHTML = '' }) - }) - - // self._events.filePanel.register('fileRenamed', (oldName, newName, isFolder) => { - // debugger - // self.data.allTests = self.data.allTests.filter(e => e != oldName) - // self.data.selectedTests = self.data.selectedTests.filter(e => e !== oldName) - // if (/.(_test.sol)$/.exec(newName)) self.data.allTests.push(newName) - // }) - - function listTests () { - var tests = self.data.allTests - return tests.map(test => yo``) - } - - function toggleCheckbox (eChecked, test) { - if (!self.data.selectedTests) { - self.data.selectedTests = self._view.el.querySelectorAll('.singleTest:checked') - } - let selectedTests = self.data.selectedTests - selectedTests = eChecked ? [...selectedTests, test] : selectedTests.filter(el => el !== test) - self.data.selectedTests = selectedTests - let checkAll = self._view.el.querySelector('[id="checkAllTests"]') - if (eChecked) { - checkAll.checked = true - } else if (!selectedTests.length) { - checkAll.checked = false - } } function checkAll (event) { @@ -171,18 +170,19 @@ module.exports = class TestTab extends ApiFactory { // checks/unchecks all for (let i = 0; i < checkBoxes.length; i++) { checkBoxes[i].checked = event.target.checked - toggleCheckbox(event.target.checked, checkboxesLabels[i].innerText) + self.toggleCheckbox(event.target.checked, checkboxesLabels[i].innerText) } } var runTests = function () { - testsOutput.innerHTML = 'Running tests ...' + self.testsOutput.innerHTML = 'Running tests ...' + self.testsSummary.innerHTML = '' var tests = self.data.selectedTests async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) }) } var generateTestFile = function () { - var fileManager = self._deps.fileManager + var fileManager = self.fileManager var path = fileManager.currentPath() var fileProvider = fileManager.fileProviderOf(path) if (fileProvider) { @@ -224,14 +224,15 @@ module.exports = class TestTab extends ApiFactory { Check/Uncheck all - ${testsOutput} - ${testsSummary} + ${self.testsOutput} + ${self.testsSummary} ` if (!self._view.el) self._view.el = el return el } + } var testContractSample = `pragma solidity >=0.4.0 <0.6.0; @@ -258,7 +259,7 @@ contract test_1 { } contract test_2 { - + function beforeAll() public { // here should instantiate tested contract Assert.equal(uint(4), uint(3), "error in before all function"); From 5e4eff559a7ac05ad45ee5f3c86cd4d946a9b5c1 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 16:55:18 -0500 Subject: [PATCH 05/18] refactor test tab --- src/app/tabs/test-tab.js | 175 ++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 85 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 632abc7a59..daeea0562c 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -103,99 +103,105 @@ module.exports = class TestTab extends ApiFactory { } } - render () { + checkAll (event) { const self = this - self.testsOutput = yo`` - self.testsSummary = yo`` - - var testCallback = function (result) { - self.testsOutput.hidden = false - if (result.type === 'contract') { - self.testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) - } else if (result.type === 'testPass') { - self.testsOutput.appendChild(yo`
✓ (${result.value})
`) - } else if (result.type === 'testFailure') { - self.testsOutput.appendChild(yo`
✘ (${result.value})
`) - } + let checkBoxes = self._view.el.querySelectorAll('.singleTest') + const checkboxesLabels = self._view.el.querySelectorAll('.singleTestLabel') + // checks/unchecks all + for (let i = 0; i < checkBoxes.length; i++) { + checkBoxes[i].checked = event.target.checked + self.toggleCheckbox(event.target.checked, checkboxesLabels[i].innerText) } + } - var resultsCallback = function (_err, result, cb) { - // total stats for the test - // result.passingNum - // result.failureNum - // result.timePassed - cb() + testCallback (result) { + const self = this + self.testsOutput.hidden = false + if (result.type === 'contract') { + self.testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) + } else if (result.type === 'testPass') { + self.testsOutput.appendChild(yo`
✓ (${result.value})
`) + } else if (result.type === 'testFailure') { + self.testsOutput.appendChild(yo`
✘ (${result.value})
`) } + } - var updateFinalResult = function (_err, result, filename) { - self.testsSummary.hidden = false - if (_err) { - self.testsSummary.appendChild(yo`
${_err.message}
`) - return - } - self.testsSummary.appendChild(yo`
${filename}
`) - if (result.totalPassing > 0) { - self.testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) - self.testsSummary.appendChild(yo`
`) - } - if (result.totalFailing > 0) { - self.testsSummary.appendChild(yo`
${result.totalFailing} failing
`) - self.testsSummary.appendChild(yo`
`) - } - result.errors.forEach((error, index) => { - self.testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) - self.testsSummary.appendChild(yo`
${error.message}
`) - self.testsSummary.appendChild(yo`
`) - }) - } + resultsCallback (_err, result, cb) { + // total stats for the test + // result.passingNum + // result.failureNum + // result.timePassed + cb() + } - function runTest (testFilePath, callback) { - self.fileManager.fileProviderOf(testFilePath).get(testFilePath, (error, content) => { - if (!error) { - var runningTest = {} - runningTest[testFilePath] = { content } - remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { - updateFinalResult(error, result, testFilePath) - callback(error) - }, (url, cb) => { - return self.compileTab.compileTabLogic.importFileCb(url, cb) - }) - } - }) + updateFinalResult (_err, result, filename) { + const self = this + self.testsSummary.hidden = false + if (_err) { + self.testsSummary.appendChild(yo`
${_err.message}
`) + return } - - function checkAll (event) { - let checkBoxes = self._view.el.querySelectorAll('.singleTest') - const checkboxesLabels = self._view.el.querySelectorAll('.singleTestLabel') - // checks/unchecks all - for (let i = 0; i < checkBoxes.length; i++) { - checkBoxes[i].checked = event.target.checked - self.toggleCheckbox(event.target.checked, checkboxesLabels[i].innerText) - } + self.testsSummary.appendChild(yo`
${filename}
`) + if (result.totalPassing > 0) { + self.testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) + self.testsSummary.appendChild(yo`
`) } - - var runTests = function () { - self.testsOutput.innerHTML = 'Running tests ...' - self.testsSummary.innerHTML = '' - var tests = self.data.selectedTests - async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) }) + if (result.totalFailing > 0) { + self.testsSummary.appendChild(yo`
${result.totalFailing} failing
`) + self.testsSummary.appendChild(yo`
`) } + result.errors.forEach((error, index) => { + self.testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) + self.testsSummary.appendChild(yo`
${error.message}
`) + self.testsSummary.appendChild(yo`
`) + }) + } - var generateTestFile = function () { - var fileManager = self.fileManager - var path = fileManager.currentPath() - var fileProvider = fileManager.fileProviderOf(path) - if (fileProvider) { - helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { - if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) - if (!fileProvider.set(newFile, testContractSample)) { - modalDialogCustom.alert('Failed to create test file ' + newFile) - } else { - fileManager.switchFile(newFile) - } + runTest (testFilePath, callback) { + const self = this + self.fileManager.fileProviderOf(testFilePath).get(testFilePath, (error, content) => { + if (!error) { + var runningTest = {} + runningTest[testFilePath] = { content } + remixTests.runTestSources(runningTest, self.testCallback, self.resultsCallback, (error, result) => { + self.updateFinalResult(error, result, testFilePath) + callback(error) + }, (url, cb) => { + return self.compileTab.compileTabLogic.importFileCb(url, cb) }) } + }) + } + + runTests () { + const self = this + self.testsOutput.innerHTML = '' + self.testsSummary.innerHTML = '' + var tests = self.data.selectedTests + async.eachOfSeries(tests, (value, key, callback) => { self.runTest(value, callback) }) + } + + generateTestFile () { + const self = this + var fileManager = self.fileManager + var path = fileManager.currentPath() + var fileProvider = fileManager.fileProviderOf(path) + if (fileProvider) { + helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { + if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) + if (!fileProvider.set(newFile, testContractSample)) { + modalDialogCustom.alert('Failed to create test file ' + newFile) + } else { + fileManager.switchFile(newFile) + } + }) } + } + + render () { + const self = this + this.testsOutput = yo`` + this.testsSummary = yo`` var el = yo`
@@ -208,17 +214,16 @@ module.exports = class TestTab extends ApiFactory {
For more details, see How to test smart contracts guide in our documentation. -
- +
Generate test file
${self.testList} -
- +
+
Run Tests
- ${self.testList} + ${this.testList}
-
Run Tests
+
Run Tests
- ${self.testsOutput} - ${self.testsSummary} + ${this.testsOutput} + ${this.testsSummary}
` - if (!self._view.el) self._view.el = el + if (!this._view.el) this._view.el = el return el } From 1bba536d258a8264f8ae74cd0f90fae266b09b6b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 17:18:48 -0500 Subject: [PATCH 07/18] clean up test tab code --- src/app/tabs/test-tab.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index a58a1d4f11..3ff71ce636 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -13,7 +13,6 @@ module.exports = class TestTab extends ApiFactory { super() this.compileTab = compileTab this._view = { el: null } - this._components = {} this.fileManager = fileManager this.filePanel = filePanel this.data = {} @@ -46,11 +45,9 @@ module.exports = class TestTab extends ApiFactory { if (error) return tooltip(error) this.data.allTests = tests this.data.selectedTests = [...this.data.allTests] - if (!tests.length) { - yo.update(this.testList, yo`
No test file available
`) - } else { - yo.update(this.testList, yo`
${this.listTests()}
`) - } + + const testsMessage = (tests.length ? this.listTests() : 'No test file available') + yo.update(this.testList, yo`
${testsMessage}
`) if (!this.testsOutput || !this.testsSummary) return @@ -169,16 +166,13 @@ module.exports = class TestTab extends ApiFactory { } generateTestFile () { - var fileManager = this.fileManager - var path = fileManager.currentPath() - var fileProvider = fileManager.fileProviderOf(path) + var path = this.fileManager.currentPath() + var fileProvider = this.fileManager.fileProviderOf(path) if (!fileProvider) return helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) - if (!fileProvider.set(newFile, testContractSample)) { - return modalDialogCustom.alert('Failed to create test file ' + newFile) - } - fileManager.switchFile(newFile) + if (!fileProvider.set(newFile, testContractSample)) return modalDialogCustom.alert('Failed to create test file ' + newFile) + this.fileManager.switchFile(newFile) }) } From f94f767ca69f159b0b497e58f7982ca8d60f250e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 17:36:19 -0500 Subject: [PATCH 08/18] create initial class to hold test tab logic --- src/app/tabs/test-tab.js | 119 +++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 54 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 3ff71ce636..8c5f7e23f5 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -8,6 +8,69 @@ var remixTests = require('remix-tests') import { ApiFactory } from 'remix-plugin' +class TestTabLogic { + + constructor (fileManager) { + this.fileManager = fileManager + } + + generateTestFile () { + var path = this.fileManager.currentPath() + var fileProvider = this.fileManager.fileProviderOf(path) + if (!fileProvider) return + helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { + if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) + if (!fileProvider.set(newFile, this.generateTestContractSample())) return modalDialogCustom.alert('Failed to create test file ' + newFile) + this.fileManager.switchFile(newFile) + }) + } + + generateTestContractSample () { + return `pragma solidity >=0.4.0 <0.6.0; + import "remix_tests.sol"; // this import is automatically injected by Remix. + + // file name has to end with '_test.sol' + contract test_1 { + + function beforeAll() public { + // here should instantiate tested contract + Assert.equal(uint(4), uint(3), "error in before all function"); + } + + function check1() public { + // use 'Assert' to test the contract + Assert.equal(uint(2), uint(1), "error message"); + Assert.equal(uint(2), uint(2), "error message"); + } + + function check2() public view returns (bool) { + // use the return value (true or false) to test the contract + return true; + } + } + + contract test_2 { + + function beforeAll() public { + // here should instantiate tested contract + Assert.equal(uint(4), uint(3), "error in before all function"); + } + + function check1() public { + // use 'Assert' to test the contract + Assert.equal(uint(2), uint(1), "error message"); + Assert.equal(uint(2), uint(2), "error message"); + } + + function check2() public view returns (bool) { + // use the return value (true or false) to test the contract + return true; + } + }` + } + +} + module.exports = class TestTab extends ApiFactory { constructor (fileManager, filePanel, compileTab) { super() @@ -15,6 +78,7 @@ module.exports = class TestTab extends ApiFactory { this._view = { el: null } this.fileManager = fileManager this.filePanel = filePanel + this.testTabLogic = new TestTabLogic(fileManager) this.data = {} this.testList = yo`
` this.listenToEvents() @@ -165,17 +229,6 @@ module.exports = class TestTab extends ApiFactory { async.eachOfSeries(tests, (value, key, callback) => { this.runTest(value, callback) }) } - generateTestFile () { - var path = this.fileManager.currentPath() - var fileProvider = this.fileManager.fileProviderOf(path) - if (!fileProvider) return - helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { - if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) - if (!fileProvider.set(newFile, testContractSample)) return modalDialogCustom.alert('Failed to create test file ' + newFile) - this.fileManager.switchFile(newFile) - }) - } - render () { this.testsOutput = yo`` this.testsSummary = yo`` @@ -191,7 +244,7 @@ module.exports = class TestTab extends ApiFactory {
For more details, see How to test smart contracts guide in our documentation. -
Generate test file
+
Generate test file
${this.testList} @@ -216,45 +269,3 @@ module.exports = class TestTab extends ApiFactory { } } - -var testContractSample = `pragma solidity >=0.4.0 <0.6.0; -import "remix_tests.sol"; // this import is automatically injected by Remix. - -// file name has to end with '_test.sol' -contract test_1 { - - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } - - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } - - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } -} - -contract test_2 { - - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } - - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } - - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } -}` From 463710267478ef5639f2babf150fc0f88bd6009e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 15 Feb 2019 17:40:21 -0500 Subject: [PATCH 09/18] move test tab logic to its own file --- src/app/tabs/test-tab.js | 66 +------------------------------- src/app/tabs/testTab/testTab.js | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 65 deletions(-) create mode 100644 src/app/tabs/testTab/testTab.js diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 8c5f7e23f5..bd626ad892 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -1,75 +1,11 @@ var yo = require('yo-yo') var async = require('async') -var helper = require('../../lib/helper.js') var tooltip = require('../ui/tooltip') -var modalDialogCustom = require('../ui/modal-dialog-custom') var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') - import { ApiFactory } from 'remix-plugin' -class TestTabLogic { - - constructor (fileManager) { - this.fileManager = fileManager - } - - generateTestFile () { - var path = this.fileManager.currentPath() - var fileProvider = this.fileManager.fileProviderOf(path) - if (!fileProvider) return - helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { - if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) - if (!fileProvider.set(newFile, this.generateTestContractSample())) return modalDialogCustom.alert('Failed to create test file ' + newFile) - this.fileManager.switchFile(newFile) - }) - } - - generateTestContractSample () { - return `pragma solidity >=0.4.0 <0.6.0; - import "remix_tests.sol"; // this import is automatically injected by Remix. - - // file name has to end with '_test.sol' - contract test_1 { - - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } - - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } - - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } - } - - contract test_2 { - - function beforeAll() public { - // here should instantiate tested contract - Assert.equal(uint(4), uint(3), "error in before all function"); - } - - function check1() public { - // use 'Assert' to test the contract - Assert.equal(uint(2), uint(1), "error message"); - Assert.equal(uint(2), uint(2), "error message"); - } - - function check2() public view returns (bool) { - // use the return value (true or false) to test the contract - return true; - } - }` - } - -} +const TestTabLogic = require('./testTab/testTab') module.exports = class TestTab extends ApiFactory { constructor (fileManager, filePanel, compileTab) { diff --git a/src/app/tabs/testTab/testTab.js b/src/app/tabs/testTab/testTab.js new file mode 100644 index 0000000000..e1d41a544e --- /dev/null +++ b/src/app/tabs/testTab/testTab.js @@ -0,0 +1,67 @@ +var helper = require('../../../lib/helper.js') +var modalDialogCustom = require('../../ui/modal-dialog-custom') + +class TestTabLogic { + + constructor (fileManager) { + this.fileManager = fileManager + } + + generateTestFile () { + var path = this.fileManager.currentPath() + var fileProvider = this.fileManager.fileProviderOf(path) + if (!fileProvider) return + helper.createNonClashingNameWithPrefix(path + '/test.sol', fileProvider, '_test', (error, newFile) => { + if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error) + if (!fileProvider.set(newFile, this.generateTestContractSample())) return modalDialogCustom.alert('Failed to create test file ' + newFile) + this.fileManager.switchFile(newFile) + }) + } + + generateTestContractSample () { + return `pragma solidity >=0.4.0 <0.6.0; + import "remix_tests.sol"; // this import is automatically injected by Remix. + + // file name has to end with '_test.sol' + contract test_1 { + + function beforeAll() public { + // here should instantiate tested contract + Assert.equal(uint(4), uint(3), "error in before all function"); + } + + function check1() public { + // use 'Assert' to test the contract + Assert.equal(uint(2), uint(1), "error message"); + Assert.equal(uint(2), uint(2), "error message"); + } + + function check2() public view returns (bool) { + // use the return value (true or false) to test the contract + return true; + } + } + + contract test_2 { + + function beforeAll() public { + // here should instantiate tested contract + Assert.equal(uint(4), uint(3), "error in before all function"); + } + + function check1() public { + // use 'Assert' to test the contract + Assert.equal(uint(2), uint(1), "error message"); + Assert.equal(uint(2), uint(2), "error message"); + } + + function check2() public view returns (bool) { + // use the return value (true or false) to test the contract + return true; + } + }` + } + +} + +module.exports = TestTabLogic From f55b60f8d12d66f4b37c7f2bb33c9bf3c39f1805 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 Feb 2019 14:35:45 -0500 Subject: [PATCH 10/18] move get tests to test tab logic --- src/app/tabs/test-tab.js | 17 +---------------- src/app/tabs/testTab/testTab.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index bd626ad892..c1afcbf666 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -41,7 +41,7 @@ module.exports = class TestTab extends ApiFactory { }) this.fileManager.event.register('currentFileChanged', (file, provider) => { - this.getTests((error, tests) => { + this.testTabLogic.getTests((error, tests) => { if (error) return tooltip(error) this.data.allTests = tests this.data.selectedTests = [...this.data.allTests] @@ -59,21 +59,6 @@ module.exports = class TestTab extends ApiFactory { }) } - getTests (cb) { - var path = this.fileManager.currentPath() - if (!path) return cb(null, []) - var provider = this.fileManager.fileProviderOf(path) - if (!provider) return cb(null, []) - var tests = [] - this.fileManager.filesFromPath(path, (error, files) => { - if (error) return cb(error) - for (var file in files) { - if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file) - } - cb(null, tests) - }) - } - listTests () { return this.data.allTests.map(test => yo``) } diff --git a/src/app/tabs/testTab/testTab.js b/src/app/tabs/testTab/testTab.js index e1d41a544e..fa1ef369ca 100644 --- a/src/app/tabs/testTab/testTab.js +++ b/src/app/tabs/testTab/testTab.js @@ -18,6 +18,21 @@ class TestTabLogic { }) } + getTests (cb) { + var path = this.fileManager.currentPath() + if (!path) return cb(null, []) + var provider = this.fileManager.fileProviderOf(path) + if (!provider) return cb(null, []) + var tests = [] + this.fileManager.filesFromPath(path, (error, files) => { + if (error) return cb(error) + for (var file in files) { + if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file) + } + cb(null, tests) + }) + } + generateTestContractSample () { return `pragma solidity >=0.4.0 <0.6.0; import "remix_tests.sol"; // this import is automatically injected by Remix. From 2cb926dc2a2cd969fb62f99dddfee823c8ccdd9e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 Feb 2019 14:43:48 -0500 Subject: [PATCH 11/18] simplify support tab render --- src/app/tabs/support-tab.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/tabs/support-tab.js b/src/app/tabs/support-tab.js index 9b751e66a9..b168af1258 100644 --- a/src/app/tabs/support-tab.js +++ b/src/app/tabs/support-tab.js @@ -37,6 +37,7 @@ class SupportTab extends ApiFactory { this.gitterIframe = yo`
` + generateRemixdUI () { const remixd = yo`
Accessing local files
@@ -49,7 +50,10 @@ class SupportTab extends ApiFactory {
Installation:
npm install remixd -g
` + return remixd + } + generateLocalRemixdUI () { const localremixd = yo`
Running Remix locally
@@ -63,6 +67,13 @@ class SupportTab extends ApiFactory {
https://github.com/horizon-games/remix-app
` + return localremixd + } + + render () { + if (this.el) return this.el + + this.gitterIframe = yo`
` this.el = yo`
@@ -78,8 +89,8 @@ class SupportTab extends ApiFactory {
${this.gitterIframe} - ${remixd} - ${localremixd} + ${this.generateRemixdUI()} + ${this.generateLocalRemixdUI()} ` return this.el From b16488e08b560f72eb6871a2338098877f2617f6 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 Feb 2019 16:08:20 -0500 Subject: [PATCH 12/18] refactor compile tab --- src/app.js | 10 ++++++++- src/app/tabs/analysis-tab.js | 3 +++ src/app/tabs/compile-tab.js | 41 ++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/app.js b/src/app.js index 67d019122d..9ca8c69923 100644 --- a/src/app.js +++ b/src/app.js @@ -432,7 +432,15 @@ 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(registry) + let compileTab = new CompileTab( + registry.get('editor').api, + registry.get('config').api, + registry.get('renderer').api, + registry.get('fileproviders/swarm').api, + registry.get('filemanager').api, + registry.get('fileproviders').api, + registry.get('pluginmanager').api + ) let run = new RunTab( registry.get('udapp').api, registry.get('udappUI').api, diff --git a/src/app/tabs/analysis-tab.js b/src/app/tabs/analysis-tab.js index 68e78afd87..390082c84c 100644 --- a/src/app/tabs/analysis-tab.js +++ b/src/app/tabs/analysis-tab.js @@ -12,6 +12,7 @@ class AnalysisTab extends ApiFactory { this.event = new EventManager() this.registry = registry } + get profile () { return { name: 'solidityStaticAnalysis', @@ -23,6 +24,7 @@ class AnalysisTab extends ApiFactory { kind: 'analysis' } } + render () { var staticanalysis = new StaticAnalysis() this.registry.put({api: staticanalysis, name: 'staticanalysis'}) @@ -31,6 +33,7 @@ class AnalysisTab extends ApiFactory { this.el = yo`
${staticanalysis.render()}
` return this.el } + } module.exports = AnalysisTab diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index 88c1e1d5ff..677516c52a 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -21,7 +21,7 @@ import { ApiFactory } from 'remix-plugin' class CompileTab extends ApiFactory { - constructor (registry) { + constructor (editor, config, renderer, swarmfileProvider, fileManager, fileProviders, pluginManager) { super() this.events = new EventEmitter() this._view = { @@ -34,27 +34,26 @@ class CompileTab extends ApiFactory { this.queryParams = new QueryParams() // dependencies - this._deps = { - editor: registry.get('editor').api, - config: registry.get('config').api, - renderer: registry.get('renderer').api, - swarmfileProvider: registry.get('fileproviders/swarm').api, - fileManager: registry.get('filemanager').api, - fileProviders: registry.get('fileproviders').api, - pluginManager: registry.get('pluginmanager').api - } + this.editor = editor + this.config = config + this.renderer = renderer + this.swarmfileProvider = swarmfileProvider + this.fileManager = fileManager + this.fileProviders = fileProviders + this.pluginManager = pluginManager + this.data = { contractsDetails: {} } - this.compileTabLogic = new CompileTabLogic(this.queryParams, this._deps.fileManager, this._deps.editor, this._deps.config, this._deps.fileProviders) + this.compileTabLogic = new CompileTabLogic(this.queryParams, this.fileManager, this.editor, this.config, this.fileProviders) this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() this.compilerContainer = new CompilerContainer( this.compileTabLogic, - this._deps.editor, - this._deps.config, + this.editor, + this.config, this.queryParams ) } @@ -82,7 +81,7 @@ class CompileTab extends ApiFactory { } }) - this._deps.fileManager.events.on('currentFileChanged', (name) => { + this.fileManager.events.on('currentFileChanged', (name) => { this.compilerContainer.currentFile = name }) this.compiler.event.register('compilationFinished', (success, data, source) => { @@ -106,7 +105,7 @@ class CompileTab extends ApiFactory { yo.update(this._view.contractSelection, contractSelection) if (data['error']) { - this._deps.renderer.error(data['error'].formattedMessage, this._view.errorContainer, {type: data['error'].severity || 'error'}) + this.renderer.error(data['error'].formattedMessage, this._view.errorContainer, {type: data['error'].severity || 'error'}) if (data['error'].mode === 'panic') { return modalDialogCustom.alert(yo`
The compiler returned with the following internal error:
${data['error'].formattedMessage}.
@@ -117,12 +116,12 @@ class CompileTab extends ApiFactory { } if (data.errors && data.errors.length) { data.errors.forEach((err) => { - if (this._deps.config.get('hideWarnings')) { + if (this.config.get('hideWarnings')) { if (err.severity !== 'warning') { - this._deps.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) + this.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) } } else { - this._deps.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) + this.renderer.error(err.formattedMessage, this._view.errorContainer, {type: err.severity}) } }) } @@ -215,7 +214,7 @@ class CompileTab extends ApiFactory { if (contract.metadata === undefined || contract.metadata.length === 0) { modalDialogCustom.alert('This contract may be abstract, may not implement an abstract parent\'s methods completely or not invoke an inherited contract\'s constructor correctly.') } else { - publishOnSwarm(contract, this._deps.fileManager, function (err, uploaded) { + publishOnSwarm(contract, this.fileManager, function (err, uploaded) { if (err) { try { err = JSON.stringify(err) @@ -229,7 +228,7 @@ class CompileTab extends ApiFactory { modalDialogCustom.alert(yo`Metadata published successfully.
${result}
`) } }, (item) => { // triggered each time there's a new verified publish (means hash correspond) - this._deps.swarmfileProvider.addReadOnly(item.hash, item.content) + this.swarmfileProvider.addReadOnly(item.hash, item.content) }) } } @@ -339,7 +338,7 @@ class CompileTab extends ApiFactory { this._view.errorContainer = yo`
` this._view.contractSelection = this.contractSelection() this._view.compilerContainer = this.compilerContainer.render() - const currentFile = this._deps.fileManager.currentFile() + const currentFile = this.fileManager.currentFile() if (currentFile) this.compilerContainer.currentFile = currentFile this._view.el = yo` From f808f37d085895e0ad060df17cf62b796dea7429 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 Feb 2019 16:09:13 -0500 Subject: [PATCH 13/18] remove unused tabbed menu files --- src/app/tabs/styles/tabbed-menu-styles.js | 36 --------- src/app/tabs/tabbed-menu.js | 90 ----------------------- 2 files changed, 126 deletions(-) delete mode 100644 src/app/tabs/styles/tabbed-menu-styles.js delete mode 100644 src/app/tabs/tabbed-menu.js diff --git a/src/app/tabs/styles/tabbed-menu-styles.js b/src/app/tabs/styles/tabbed-menu-styles.js deleted file mode 100644 index 4480912135..0000000000 --- a/src/app/tabs/styles/tabbed-menu-styles.js +++ /dev/null @@ -1,36 +0,0 @@ -const csjs = require('csjs-inject') - -const css = csjs` - .menu { - display: flex; - list-style: none; - margin: 0; - padding: 0; - } - .active { - } - .options { - float: left; - padding-top: 0.7em; - min-width: 60px; - font-size: 0.9em; - cursor: pointer; - font-size: 1em; - text-align: center; - } - .optionViews { - overflow: scroll; - height: 100%; - } - .optionViews > div { - display: none; - } - .optionViews .pre { - word-wrap: break-word; - border-radius: 3px; - display: inline-block; - padding: 0 0.6em; - } -` - -module.exports = css diff --git a/src/app/tabs/tabbed-menu.js b/src/app/tabs/tabbed-menu.js deleted file mode 100644 index dbbb798b73..0000000000 --- a/src/app/tabs/tabbed-menu.js +++ /dev/null @@ -1,90 +0,0 @@ -var yo = require('yo-yo') -var css = require('./styles/tabbed-menu-styles') - -var globalRegistry = require('../../global/registry') -var helper = require('../../lib/helper') - -var EventManager = require('../../lib/events') - -class TabbedMenu { - constructor (localRegistry) { - const self = this - self.event = new EventManager() - self._components = {} - self._components.registry = localRegistry || globalRegistry - self._deps = { - app: self._components.registry.get('app').api - } - self._view = { el: null, viewport: null, tabs: {}, contents: {} } - } - render () { - const self = this - if (self._view.el) return self._view.el - self._view.el = yo`
    ${Object.values(self._view.tabs)}
` - return self._view.el - } - renderViewport () { - const self = this - if (self._view.viewport) return self._view.viewport - self._view.viewport = yo` -
- ${Object.values(self._view.contents)} -
` - return self._view.viewport - } - addTab (title, cssClass, content) { - const self = this - if (helper.checkSpecialChars(title)) return - if (self._view.contents[title] || self._view.tabs[title]) throw new Error('tab already exists') - self._view.contents[title] = content - self._view.tabs[title] = yo`
  • ${title}
  • ` - if (self._view.el) self._view.el.appendChild(self._view.tabs[title]) - if (self._view.viewport) self._view.viewport.appendChild(self._view.contents[title]) - } - removeTabByTitle (title) { - const self = this - if (self._view.tabs[title]) { - self._view.tabs[title].parentNode.removeChild(self._view.tabs[title]) - } - if (self._view.contents[title]) { - self._view.contents[title].parentNode.removeChild(self._view.contents[title]) - } - delete self._view.contents[title] - delete self._view.tabs[title] - } - getTabByClass (tabClass) { - const self = this - return self._view.el.querySelector(`li.${tabClass}`) - } - updateTabTitle (tabClass, title) { - const self = this - var tab = self.getTabByClass(tabClass) - if (tab) tab.innerHTML = title - } - selectTabByTitle (title) { - const self = this - self.selectTab(self._view.tabs[title]) - } - selectTabByClassName (tabClass) { - const self = this - var tab = self.getTabByClass(tabClass) - if (tab) self.selectTab(tab) - return tab - } - selectTab (el) { - const self = this - if (!el.classList.contains(css.active)) { - var nodes = Object.values(self._view.tabs) - for (var i = 0; i < nodes.length; ++i) { - nodes[i].classList.remove(css.active) - self._view.contents[nodes[i].getAttribute('title')].style.display = 'none' - } - } - var title = el.getAttribute('title') - self._view.contents[el.getAttribute('title')].style.display = 'block' - el.classList.add(css.active) - self._deps.app.event.trigger('tabChanged', [title]) - } -} - -module.exports = TabbedMenu From e5e623c0f54007b89ec56a88cc9cc38c91f19580 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Mar 2019 12:22:31 +0100 Subject: [PATCH 14/18] include in promise --- src/app/files/fileManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 63966ba15f..63da3a3026 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -198,10 +198,10 @@ class FileManager extends ApiFactory { } getFilesFromPath (path) { - const provider = this.fileProviderOf(path) - if (!provider) throw new Error(`provider for path ${path} not found`) // TODO : Change provider with promise return new Promise((resolve, reject) => { + const provider = this.fileProviderOf(path) + if (!provider) return reject(`provider for path ${path} not found`) provider.resolveDirectory(path, (error, filesTree) => { if (error) reject(error) resolve(filesTree) From 3e57367e5c8628a8e9fb858a19a29e6813a7dbb5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Mar 2019 12:22:43 +0100 Subject: [PATCH 15/18] fix settings tab --- src/app/tabs/settings-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 57cee609db..630d34cf1b 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -77,7 +77,7 @@ module.exports = class SettingsTab extends ApiFactory { this._view.theme.light = yo`` this._view.theme.dark = yo`` this._view.theme.clean = yo`` - this._view.theme[this.data.currentTheme].setAttribute('checked', 'checked') + this._view.theme[this.currentTheme].setAttribute('checked', 'checked') this._view.config.homePage = yo`
    From 8f7543bbb9aaf4ff344d5ca9861227c68e5c18a8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Mar 2019 12:22:49 +0100 Subject: [PATCH 16/18] fix test tab --- src/app/tabs/test-tab.js | 37 ++++++++++++++++++++------------- src/app/tabs/testTab/testTab.js | 19 ++++++++++------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index c1afcbf666..78b140b833 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -12,12 +12,12 @@ module.exports = class TestTab extends ApiFactory { super() this.compileTab = compileTab this._view = { el: null } + this.compileTab = compileTab this.fileManager = fileManager this.filePanel = filePanel this.testTabLogic = new TestTabLogic(fileManager) this.data = {} this.testList = yo`
    ` - this.listenToEvents() } get profile () { @@ -31,6 +31,13 @@ module.exports = class TestTab extends ApiFactory { } } + activate () { + this.listenToEvents() + } + + deactivate () { + } + listenToEvents () { this.filePanel.event.register('newTestFileCreated', file => { var testList = this.view.querySelector("[class^='testList']") @@ -40,7 +47,7 @@ module.exports = class TestTab extends ApiFactory { this.data.selectedTests.push(file) }) - this.fileManager.event.register('currentFileChanged', (file, provider) => { + this.fileManager.events.on('currentFileChanged', (file, provider) => { this.testTabLogic.getTests((error, tests) => { if (error) return tooltip(error) this.data.allTests = tests @@ -93,9 +100,9 @@ module.exports = class TestTab extends ApiFactory { if (result.type === 'contract') { this.testsOutput.appendChild(yo`
    ${result.filename} (${result.value})
    `) } else if (result.type === 'testPass') { - this.testsOutput.appendChild(yo`
    ✓ (${result.value})
    `) + this.testsOutput.appendChild(yo`
    ✓ (${result.value})
    `) } else if (result.type === 'testFailure') { - this.testsOutput.appendChild(yo`
    ✘ (${result.value})
    `) + this.testsOutput.appendChild(yo`
    ✘ (${result.value})
    `) } } @@ -110,21 +117,21 @@ module.exports = class TestTab extends ApiFactory { updateFinalResult (_err, result, filename) { this.testsSummary.hidden = false if (_err) { - this.testsSummary.appendChild(yo`
    ${_err.message}
    `) + this.testsSummary.appendChild(yo`
    ${_err.message}
    `) return } this.testsSummary.appendChild(yo`
    ${filename}
    `) if (result.totalPassing > 0) { - this.testsSummary.appendChild(yo`
    ${result.totalPassing} passing (${result.totalTime}s)
    `) + this.testsSummary.appendChild(yo`
    ${result.totalPassing} passing (${result.totalTime}s)
    `) this.testsSummary.appendChild(yo`
    `) } if (result.totalFailing > 0) { - this.testsSummary.appendChild(yo`
    ${result.totalFailing} failing
    `) + this.testsSummary.appendChild(yo`
    ${result.totalFailing} failing
    `) this.testsSummary.appendChild(yo`
    `) } result.errors.forEach((error, index) => { - this.testsSummary.appendChild(yo`
    ${error.context} - ${error.value}
    `) - this.testsSummary.appendChild(yo`
    ${error.message}
    `) + this.testsSummary.appendChild(yo`
    ${error.context} - ${error.value}
    `) + this.testsSummary.appendChild(yo`
    ${error.message}
    `) this.testsSummary.appendChild(yo`
    `) }) } @@ -134,7 +141,7 @@ module.exports = class TestTab extends ApiFactory { if (error) return var runningTest = {} runningTest[testFilePath] = { content } - remixTests.runTestSources(runningTest, this.testCallback, this.resultsCallback, (error, result) => { + remixTests.runTestSources(runningTest, (result) => { this.testCallback(result) }, (_err, result, cb) => { this.resultsCallback(_err, result, cb) }, (error, result) => { this.updateFinalResult(error, result, testFilePath) callback(error) }, (url, cb) => { @@ -151,8 +158,8 @@ module.exports = class TestTab extends ApiFactory { } render () { - this.testsOutput = yo`` - this.testsSummary = yo`` + this.testsOutput = yo`` + this.testsSummary = yo`` var el = yo`
    @@ -165,12 +172,12 @@ module.exports = class TestTab extends ApiFactory {
    For more details, see How to test smart contracts guide in our documentation. -
    Generate test file
    +
    Generate test file
    ${this.testList} -
    -
    Run Tests
    +
    +
    Run Tests
    ` + var self = this function onchangeGenerateContractMetadata (event) { - this.config.set('settings/generate-contract-metadata', !this.config.get('settings/generate-contract-metadata')) + self.config.set('settings/generate-contract-metadata', !self.config.get('settings/generate-contract-metadata')) } function onchangeOption (event) { - this.config.set('settings/always-use-vm', !this.config.get('settings/always-use-vm')) + self.config.set('settings/always-use-vm', !self.config.get('settings/always-use-vm')) } function onswitch2darkTheme (event) { styleGuide.switchTheme('dark') @@ -166,7 +167,7 @@ module.exports = class SettingsTab extends ApiFactory { styleGuide.switchTheme('clean') } function onchangePersonal (event) { - this.config.set('settings/personal-mode', !this.config.get('settings/personal-mode')) + self.config.set('settings/personal-mode', !self.config.get('settings/personal-mode')) } styleGuide.switchTheme() return this._view.el From 74deeb2e8a2557aba2cd4a3cb0fdd0e53020459b Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Mar 2019 17:39:19 +0100 Subject: [PATCH 18/18] fix debugger --- src/app.js | 2 - src/app/debugger/debuggerUI.js | 96 +++++++------------------------ src/app/tabs/settings-tab.js | 1 - src/app/tabs/support-tab.js | 101 --------------------------------- 4 files changed, 22 insertions(+), 178 deletions(-) delete mode 100644 src/app/tabs/support-tab.js diff --git a/src/app.js b/src/app.js index 9ca8c69923..097d9e79c4 100644 --- a/src/app.js +++ b/src/app.js @@ -46,7 +46,6 @@ const CompileTab = require('./app/tabs/compile-tab') const SettingsTab = require('./app/tabs/settings-tab') const AnalysisTab = require('./app/tabs/analysis-tab') const DebuggerTab = require('./app/tabs/debugger-tab') -// const SupportTab = require('./app/tabs/support-tab') const TestTab = require('./app/tabs/test-tab') const RunTab = require('./app/tabs/run-tab') const FilePanel = require('./app/panels/file-panel') @@ -460,7 +459,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org let analysis = new AnalysisTab(registry) let debug = new DebuggerTab() const landingPage = new LandingPage(appManager, appStore) - // let support = new SupportTab() let test = new TestTab( registry.get('filemanager').api, registry.get('filepanel').api, diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 1055169a18..30f69c8f1d 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -12,8 +12,6 @@ var executionContext = require('../../execution-context') var globalRegistry = require('../../global/registry') var remixLib = require('remix-lib') -var Web3Providers = remixLib.vm.Web3Providers -var DummyProvider = remixLib.vm.DummyProvider var init = remixLib.init @@ -30,72 +28,12 @@ var css = csjs` } ` -class ContextManager { - constructor () { - this.executionContext = executionContext - this.web3 = this.executionContext.web3() - this.event = new EventManager() - } - - initProviders () { - this.web3Providers = new Web3Providers() - this.addProvider('DUMMYWEB3', new DummyProvider()) - this.switchProvider('DUMMYWEB3') - - this.addProvider('vm', this.executionContext.vm()) - this.addProvider('injected', this.executionContext.internalWeb3()) - this.addProvider('web3', this.executionContext.internalWeb3()) - this.switchProvider(this.executionContext.getProvider()) - } - - getWeb3 () { - return this.web3 - } - - addProvider (type, obj) { - this.web3Providers.addProvider(type, obj) - this.event.trigger('providerAdded', [type]) - } - - switchProvider (type) { - var self = this - this.web3Providers.get(type, function (error, obj) { - if (error) { - console.log('provider ' + type + ' not defined') - } else { - self.web3 = obj - self.executionContext.detectNetwork((error, network) => { - if (error || !network) { - self.web3 = obj - } else { - var webDebugNode = init.web3DebugNode(network.name) - self.web3 = (!webDebugNode ? obj : webDebugNode) - } - self.event.trigger('providerChanged', [type, self.web3]) - }) - self.event.trigger('providerChanged', [type, self.web3]) - } - }) - } - -} - class DebuggerUI { constructor (container) { this.registry = globalRegistry this.event = new EventManager() - this.executionContext = executionContext - - this.contextManager = new ContextManager() - - this.contextManager.initProviders() - - this.contextManager.event.register('providerChanged', () => { - if (this.debugger) this.debugger.updateWeb3(this.contextManager.getWeb3()) - }) - this.isActive = false this.sourceHighlighter = new SourceHighlighter() @@ -173,19 +111,29 @@ class DebuggerUI { if (compilers['__last']) lastCompilationResult = compilers['__last'] // TODO debugging with source highlight is disabled. see line 98 - this.debugger = new Debugger({ - web3: this.contextManager.getWeb3(), - offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api, - compiler: { lastCompilationResult } - }) - this.listenToEvents() - - this.debugger.debugger.updateWeb3(this.executionContext.web3()) - this.debugger.debug(blockNumber, txNumber, tx, () => { - self.stepManager = new StepManagerUI(this.debugger.step_manager) - self.vmDebugger = new VmDebugger(this.debugger.vmDebuggerLogic) - self.renderDebugger() + executionContext.detectNetwork((error, network) => { + let web3 + if (error || !network) { + web3 = init.web3DebugNode(executionContext.web3()) + } else { + var webDebugNode = init.web3DebugNode(network.name) + web3 = (!webDebugNode ? executionContext.web3() : webDebugNode) + } + init.extendWeb3(web3) + this.debugger = new Debugger({ + web3, + offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api, + compiler: { lastCompilationResult } + }) + + this.listenToEvents() + + this.debugger.debug(blockNumber, txNumber, tx, () => { + self.stepManager = new StepManagerUI(this.debugger.step_manager) + self.vmDebugger = new VmDebugger(this.debugger.vmDebuggerLogic) + self.renderDebugger() + }) }) } diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 657219a964..2fb7ca8997 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -150,7 +150,6 @@ module.exports = class SettingsTab extends ApiFactory { ${this._view.config.themes}
    ` - var self = this function onchangeGenerateContractMetadata (event) { self.config.set('settings/generate-contract-metadata', !self.config.get('settings/generate-contract-metadata')) } diff --git a/src/app/tabs/support-tab.js b/src/app/tabs/support-tab.js deleted file mode 100644 index b168af1258..0000000000 --- a/src/app/tabs/support-tab.js +++ /dev/null @@ -1,101 +0,0 @@ -const yo = require('yo-yo') -var css = require('./styles/support-tab-styles') - -import { ApiFactory } from 'remix-plugin' - -class SupportTab extends ApiFactory { - - constructor (localRegistry) { - super() - this.el = null - this.gitterIframe = '' - this.gitterIsLoaded = false - } - - __showing () { - if (this.gitterIsLoaded) return - - const iframe = yo`` - this.gitterIframe.parentNode.replaceChild(iframe, this.gitterIframe) - this.gitterIframe = iframe - this.el.style.display = 'block' - this.gitterIsLoaded = true - } - - get profile () { - return { - name: 'support', - methods: [], - events: [], - icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03MDQgMTkycTAtMjYtMTktNDV0LTQ1LTE5LTQ1IDE5LTE5IDQ1IDE5IDQ1IDQ1IDE5IDQ1LTE5IDE5LTQ1em04OTYtMzJ2MzIwcTAgMTYtMTIgMjUtOCA3LTIwIDctNCAwLTctMWwtNDQ4LTk2cS0xMS0yLTE4LTExdC03LTIwaC0yNTZ2MTAycTExMSAyMyAxODMuNSAxMTF0NzIuNSAyMDN2ODAwcTAgMjYtMTkgNDV0LTQ1IDE5aC01MTJxLTI2IDAtNDUtMTl0LTE5LTQ1di04MDBxMC0xMDYgNjIuNS0xOTAuNXQxNjEuNS0xMTQuNXYtMTExaC0zMnEtNTkgMC0xMTUgMjMuNXQtOTEuNSA1My02NiA2Ni41LTQwLjUgNTMuNS0xNCAyNC41cS0xNyAzNS01NyAzNS0xNiAwLTI5LTctMjMtMTItMzEuNS0zN3QzLjUtNDlxNS0xMCAxNC41LTI2dDM3LjUtNTMuNSA2MC41LTcwIDg1LTY3IDEwOC41LTUyLjVxLTI1LTQyLTI1LTg2IDAtNjYgNDctMTEzdDExMy00NyAxMTMgNDcgNDcgMTEzcTAgMzMtMTQgNjRoMzAycTAtMTEgNy0yMHQxOC0xMWw0NDgtOTZxMy0xIDctMSAxMiAwIDIwIDcgMTIgOSAxMiAyNXoiLz48L3N2Zz4=', - description: 'help center' - } - } - - render () { - if (this.el) return this.el - - this.gitterIframe = yo`
    ` - - generateRemixdUI () { - const remixd = yo` -
    -
    Accessing local files
    -
    - Remixd is a tool which allow Remix IDE to access files located in your local computer. - it can also be used to setup a development environment. -
    -
    More infos:
    - - -
    Installation:
    npm install remixd -g
    -
    ` - return remixd - } - - generateLocalRemixdUI () { - const localremixd = yo` -
    -
    Running Remix locally
    -
    - as a NPM module: -
    - https://www.npmjs.com/package/remix-ide -
    npm install remix-ide -g
    -
    - as an electron app: -
    - https://github.com/horizon-games/remix-app -
    ` - return localremixd - } - - render () { - if (this.el) return this.el - - this.gitterIframe = yo`
    ` - - this.el = yo` -
    -
    - Have a question, found a bug or want to propose a feature? Have a look at the - issues or check out - the documentation page on Remix or - Solidity. -
    -
    -
    { window.open('https://gitter.im/ethereum/remix') }} title='Click to open chat in Gitter'> -
    ethereum/remix community chat
    -
    - ${this.gitterIframe} -
    - ${this.generateRemixdUI()} - ${this.generateLocalRemixdUI()} -
    ` - - return this.el - } - -} - -module.exports = SupportTab