From 72e9c09b6c4908dbe16936432b56b2dc7b89a2af Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 9 Aug 2021 16:06:43 +0200 Subject: [PATCH 1/9] added 'Set path for Unit Testing' to context menu --- apps/remix-ide/src/app/tabs/test-tab.js | 33 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 83665e8ed5..08d57ee334 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -13,7 +13,7 @@ const TestTabLogic = require('./testTab/testTab') const profile = { name: 'solidityUnitTesting', displayName: 'Solidity unit testing', - methods: ['testFromPath', 'testFromSource'], + methods: ['testFromPath', 'testFromSource', 'setTestFolderPath'], events: [], icon: 'assets/img/unitTesting.webp', description: 'Fast tool to generate unit tests for your contracts', @@ -50,6 +50,21 @@ module.exports = class TestTab extends ViewPlugin { onActivationInternal () { this.testTabLogic = new TestTabLogic(this.fileManager) this.listenToEvents() + this.call('filePanel', 'registerContextMenuItem', { + id: 'solidityUnitTesting', + name: 'setTestFolderPath', + label: 'Set path for Unit Testing', + type: ['folder'], + extension: [], + path: [], + pattern: [] + }) + } + + async setTestFolderPath (event) { + if (event.path.length > 0) { + await this.setCurrentPath(event.path[0]) + } } onDeactivation () { @@ -76,10 +91,7 @@ module.exports = class TestTab extends ViewPlugin { }) this.on('filePanel', 'setWorkspace', async () => { - this.testTabLogic.setCurrentPath(this.defaultPath) - this.inputPath.value = this.defaultPath - this.updateDirList(this.defaultPath) - await this.updateForNewCurrent() + this.setCurrentPath(this.defaultPath) }) this.fileManager.events.on('noFileSelected', () => { @@ -384,6 +396,17 @@ module.exports = class TestTab extends ViewPlugin { return this.testFromSource(fileContent, path) } + /** + * Changes the current path of Unit Testing Plugin + * @param path - the path from where UT plugin takes _test.sol files to run + */ + async setCurrentPath (path) { + this.testTabLogic.setCurrentPath(path) + this.inputPath.value = path + this.updateDirList(path) + await this.updateForNewCurrent() + } + /* Test is not associated with the UI */ From e5273e4ecf88f7682cbf88ae7af8283bac6c875c Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 12 Aug 2021 09:49:56 +0200 Subject: [PATCH 2/9] added flatten to menu (WIP) --- apps/remix-ide/src/app.js | 4 +- .../components/plugin-manager-component.js | 51 ++++++++++++++++--- apps/remix-ide/src/app/tabs/compile-tab.js | 10 +++- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 67ede9b1bd..32ea13d547 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -356,8 +356,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org landingPage, hiddenPanel, sidePanel, - pluginManagerComponent, filePanel, + pluginManagerComponent, settings ]) @@ -481,7 +481,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org await appManager.activatePlugin(['sidePanel']) // activating host plugin separately await appManager.activatePlugin(['home']) await appManager.activatePlugin(['settings']) - await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport']) + await appManager.activatePlugin(['hiddenPanel', 'filePanel', 'pluginManager', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport']) // Set workspace after initial activation if (Array.isArray(workspace)) { diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index 34ddc8ee5e..fd75d3918f 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -71,7 +71,7 @@ const css = csjs` const profile = { name: 'pluginManager', displayName: 'Plugin manager', - methods: [], + methods: ['registerFlattener'], events: [], icon: 'assets/img/pluginManager.webp', description: 'Start/stop services, modules and plugins', @@ -102,17 +102,52 @@ class PluginManagerComponent extends ViewPlugin { return this.appManager.actives.includes(name) } - activateP (name) { + async registerFlattener (event) { + if (!this.appManager.isActive('solidity')) { await this.appManager.activatePlugin('solidity') } + const compiledSuccessfully = await this.call('solidity', 'compileFile', event) + const reporCompileIssue = () => { + this.call('fileManager', 'open', event.path[0]) + addToolTip('Cannot flatten the file. Please make sure it is compiling successfully.') + this.call('menuicons', 'select', 'solidity') + } + setTimeout(async () => { + if (compiledSuccessfully) { + const res = await this.call('solidity', 'getCompilationResult') + if (!res) { + reporCompileIssue() + } else { + this.call('menuicons', 'select', 'flattener1') + await this.call('flattener1', 'flatten', res) + } + } else { + reporCompileIssue() + } + }, 1000) + } + + onActivation () { + this.call('filePanel', 'registerContextMenuItem', { + id: 'pluginManager', + name: 'registerFlattener', + label: 'Flatten', + type: [], + extension: ['.sol'], + path: [], + pattern: [] + }) + } + + activateP(name) { this.appManager.activatePlugin(name) _paq.push(['trackEvent', 'manager', 'activate', name]) } - deactivateP (name) { + deactivateP(name) { this.call('manager', 'deactivatePlugin', name) _paq.push(['trackEvent', 'manager', 'deactivate', name]) } - renderItem (profile) { + renderItem(profile) { const displayName = (profile.displayName) ? profile.displayName : profile.name const doclink = profile.documentation ? yo`` : yo`` @@ -171,7 +206,7 @@ class PluginManagerComponent extends ViewPlugin { /** * Add a local plugin to the list of plugins */ - async openLocalPlugin () { + async openLocalPlugin() { try { const profile = await this.localPlugin.open(this.appManager.getAll()) if (!profile) return @@ -188,7 +223,7 @@ class PluginManagerComponent extends ViewPlugin { } } - render () { + render() { // Filtering helpers const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) @@ -255,13 +290,13 @@ class PluginManagerComponent extends ViewPlugin { return rootView } - reRender () { + reRender() { if (this.views.root) { yo.update(this.views.root, this.render()) } } - filterPlugins ({ target }) { + filterPlugins({ target }) { this.filter = target.value.toLowerCase() this.reRender() } diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 6d84a9721f..1a04f97843 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -292,10 +292,16 @@ class CompileTab extends ViewPlugin { }) } - compileFile (event) { + // Returns if the compilation was successfull + async compileFile (event) { if (event.path.length > 0) { - this.compileTabLogic.compileFile(event.path[0]) + try { + return await this.compileTabLogic.compileFile(event.path[0]) + } catch (error) { + return false + } } + return false } onDeactivation () { From d8f40b12c4bd67d6066c94fc160a0cf34f068f3c Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 12 Aug 2021 12:23:16 +0200 Subject: [PATCH 3/9] added save to the action (wip) --- .../src/app/components/plugin-manager-component.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index fd75d3918f..1e6f2c8813 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -105,10 +105,10 @@ class PluginManagerComponent extends ViewPlugin { async registerFlattener (event) { if (!this.appManager.isActive('solidity')) { await this.appManager.activatePlugin('solidity') } const compiledSuccessfully = await this.call('solidity', 'compileFile', event) - const reporCompileIssue = () => { + const reporCompileIssue = async () => { this.call('fileManager', 'open', event.path[0]) addToolTip('Cannot flatten the file. Please make sure it is compiling successfully.') - this.call('menuicons', 'select', 'solidity') + await this.call('menuicons', 'select', 'solidity') } setTimeout(async () => { if (compiledSuccessfully) { @@ -116,8 +116,9 @@ class PluginManagerComponent extends ViewPlugin { if (!res) { reporCompileIssue() } else { - this.call('menuicons', 'select', 'flattener1') - await this.call('flattener1', 'flatten', res) + await this.call('menuicons', 'select', 'flattener1') + const path = await this.call('flattener1', 'flattenAndSave', res) + await this.call('fileManager', 'open', path) } } else { reporCompileIssue() @@ -125,8 +126,8 @@ class PluginManagerComponent extends ViewPlugin { }, 1000) } - onActivation () { - this.call('filePanel', 'registerContextMenuItem', { + async onActivation () { + await this.call('filePanel', 'registerContextMenuItem', { id: 'pluginManager', name: 'registerFlattener', label: 'Flatten', From 6b977811f1b709346747db8f258f47a2149319c4 Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 12 Aug 2021 12:39:38 +0200 Subject: [PATCH 4/9] linter --- .../src/app/components/plugin-manager-component.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index 1e6f2c8813..7d166eb5ec 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -138,17 +138,17 @@ class PluginManagerComponent extends ViewPlugin { }) } - activateP(name) { + activateP (name) { this.appManager.activatePlugin(name) _paq.push(['trackEvent', 'manager', 'activate', name]) } - deactivateP(name) { + deactivateP (name) { this.call('manager', 'deactivatePlugin', name) _paq.push(['trackEvent', 'manager', 'deactivate', name]) } - renderItem(profile) { + renderItem (profile) { const displayName = (profile.displayName) ? profile.displayName : profile.name const doclink = profile.documentation ? yo`` : yo`` @@ -207,7 +207,7 @@ class PluginManagerComponent extends ViewPlugin { /** * Add a local plugin to the list of plugins */ - async openLocalPlugin() { + async openLocalPlugin () { try { const profile = await this.localPlugin.open(this.appManager.getAll()) if (!profile) return @@ -224,7 +224,7 @@ class PluginManagerComponent extends ViewPlugin { } } - render() { + render () { // Filtering helpers const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(this.filter) const isNotRequired = (profile) => !this.appManager.isRequired(profile.name) @@ -291,13 +291,13 @@ class PluginManagerComponent extends ViewPlugin { return rootView } - reRender() { + reRender () { if (this.views.root) { yo.update(this.views.root, this.render()) } } - filterPlugins({ target }) { + filterPlugins ({ target }) { this.filter = target.value.toLowerCase() this.reRender() } From 7ef381e64c7f6aff6d88bf4deddf60821b7db4ce Mon Sep 17 00:00:00 2001 From: lianahus Date: Thu, 12 Aug 2021 13:10:46 +0200 Subject: [PATCH 5/9] added 'compile with optimism --- .../components/plugin-manager-component.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index 7d166eb5ec..f6d577db5c 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -71,7 +71,7 @@ const css = csjs` const profile = { name: 'pluginManager', displayName: 'Plugin manager', - methods: ['registerFlattener'], + methods: ['registerFlattener', 'registerOptimismCompiler'], events: [], icon: 'assets/img/pluginManager.webp', description: 'Start/stop services, modules and plugins', @@ -116,8 +116,8 @@ class PluginManagerComponent extends ViewPlugin { if (!res) { reporCompileIssue() } else { - await this.call('menuicons', 'select', 'flattener1') - const path = await this.call('flattener1', 'flattenAndSave', res) + await this.call('menuicons', 'select', 'flattener') + const path = await this.call('flattener', 'flattenAndSave', res) await this.call('fileManager', 'open', path) } } else { @@ -126,6 +126,12 @@ class PluginManagerComponent extends ViewPlugin { }, 1000) } + async registerOptimismCompiler (event) { + await this.call('optimism-compiler', 'compile', event.path[0]) + await this.call('menuicons', 'select', 'optimism-compiler') + await this.call('fileManager', 'open', event.path[0]) + } + async onActivation () { await this.call('filePanel', 'registerContextMenuItem', { id: 'pluginManager', @@ -136,6 +142,15 @@ class PluginManagerComponent extends ViewPlugin { path: [], pattern: [] }) + await this.call('filePanel', 'registerContextMenuItem', { + id: 'pluginManager', + name: 'registerOptimismCompiler', + label: 'Compile with Optimism', + type: [], + extension: ['.sol'], + path: [], + pattern: [] + }) } activateP (name) { From 97396e69d96b7ebcbde616915db350a75a98cd09 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 16 Aug 2021 13:00:46 +0200 Subject: [PATCH 6/9] typo --- .../src/app/components/plugin-manager-component.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index f6d577db5c..62d1dd5ace 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -105,7 +105,7 @@ class PluginManagerComponent extends ViewPlugin { async registerFlattener (event) { if (!this.appManager.isActive('solidity')) { await this.appManager.activatePlugin('solidity') } const compiledSuccessfully = await this.call('solidity', 'compileFile', event) - const reporCompileIssue = async () => { + const reportCompileIssue = async () => { this.call('fileManager', 'open', event.path[0]) addToolTip('Cannot flatten the file. Please make sure it is compiling successfully.') await this.call('menuicons', 'select', 'solidity') @@ -114,14 +114,14 @@ class PluginManagerComponent extends ViewPlugin { if (compiledSuccessfully) { const res = await this.call('solidity', 'getCompilationResult') if (!res) { - reporCompileIssue() + reportCompileIssue() } else { await this.call('menuicons', 'select', 'flattener') const path = await this.call('flattener', 'flattenAndSave', res) await this.call('fileManager', 'open', path) } } else { - reporCompileIssue() + reportCompileIssue() } }, 1000) } From fded51d244787884fa2a00c31e5e02f6d0922280 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Tue, 17 Aug 2021 13:14:20 +0200 Subject: [PATCH 7/9] test flattener --- .../components/plugin-manager-component.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index 62d1dd5ace..b929398968 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -105,25 +105,25 @@ class PluginManagerComponent extends ViewPlugin { async registerFlattener (event) { if (!this.appManager.isActive('solidity')) { await this.appManager.activatePlugin('solidity') } const compiledSuccessfully = await this.call('solidity', 'compileFile', event) + console.log(compiledSuccessfully) const reportCompileIssue = async () => { this.call('fileManager', 'open', event.path[0]) addToolTip('Cannot flatten the file. Please make sure it is compiling successfully.') await this.call('menuicons', 'select', 'solidity') } - setTimeout(async () => { - if (compiledSuccessfully) { - const res = await this.call('solidity', 'getCompilationResult') - if (!res) { - reportCompileIssue() - } else { - await this.call('menuicons', 'select', 'flattener') - const path = await this.call('flattener', 'flattenAndSave', res) - await this.call('fileManager', 'open', path) - } - } else { + + if (compiledSuccessfully) { + const res = await this.call('solidity', 'getCompilationResult') + if (!res) { reportCompileIssue() + } else { + await this.call('menuicons', 'select', 'f3') + console.log(res) + await this.call('f3', 'flattenAndSave', res) } - }, 1000) + } else { + reportCompileIssue() + } } async registerOptimismCompiler (event) { From 2f9a6afce6567f1bad8c18fb735283d3016be0a7 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Thu, 19 Aug 2021 13:14:55 +0200 Subject: [PATCH 8/9] mv context menu reg to app manager --- apps/remix-ide/src/app.js | 2 +- .../components/plugin-manager-component.js | 53 +------------------ apps/remix-ide/src/remixAppManager.js | 23 ++++++++ 3 files changed, 25 insertions(+), 53 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index b726125cef..38b0d9f809 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -483,7 +483,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org await appManager.activatePlugin(['home']) await appManager.activatePlugin(['settings']) await appManager.activatePlugin(['hiddenPanel', 'filePanel', 'pluginManager', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport']) - + await appManager.registerContextMenuItems() // Set workspace after initial activation if (Array.isArray(workspace)) { appManager.activatePlugin(workspace).then(async () => { diff --git a/apps/remix-ide/src/app/components/plugin-manager-component.js b/apps/remix-ide/src/app/components/plugin-manager-component.js index b929398968..34ddc8ee5e 100644 --- a/apps/remix-ide/src/app/components/plugin-manager-component.js +++ b/apps/remix-ide/src/app/components/plugin-manager-component.js @@ -71,7 +71,7 @@ const css = csjs` const profile = { name: 'pluginManager', displayName: 'Plugin manager', - methods: ['registerFlattener', 'registerOptimismCompiler'], + methods: [], events: [], icon: 'assets/img/pluginManager.webp', description: 'Start/stop services, modules and plugins', @@ -102,57 +102,6 @@ class PluginManagerComponent extends ViewPlugin { return this.appManager.actives.includes(name) } - async registerFlattener (event) { - if (!this.appManager.isActive('solidity')) { await this.appManager.activatePlugin('solidity') } - const compiledSuccessfully = await this.call('solidity', 'compileFile', event) - console.log(compiledSuccessfully) - const reportCompileIssue = async () => { - this.call('fileManager', 'open', event.path[0]) - addToolTip('Cannot flatten the file. Please make sure it is compiling successfully.') - await this.call('menuicons', 'select', 'solidity') - } - - if (compiledSuccessfully) { - const res = await this.call('solidity', 'getCompilationResult') - if (!res) { - reportCompileIssue() - } else { - await this.call('menuicons', 'select', 'f3') - console.log(res) - await this.call('f3', 'flattenAndSave', res) - } - } else { - reportCompileIssue() - } - } - - async registerOptimismCompiler (event) { - await this.call('optimism-compiler', 'compile', event.path[0]) - await this.call('menuicons', 'select', 'optimism-compiler') - await this.call('fileManager', 'open', event.path[0]) - } - - async onActivation () { - await this.call('filePanel', 'registerContextMenuItem', { - id: 'pluginManager', - name: 'registerFlattener', - label: 'Flatten', - type: [], - extension: ['.sol'], - path: [], - pattern: [] - }) - await this.call('filePanel', 'registerContextMenuItem', { - id: 'pluginManager', - name: 'registerOptimismCompiler', - label: 'Compile with Optimism', - type: [], - extension: ['.sol'], - path: [], - pattern: [] - }) - } - activateP (name) { this.appManager.activatePlugin(name) _paq.push(['trackEvent', 'manager', 'activate', name]) diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index d58f6403a9..40bdee7de5 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -133,6 +133,29 @@ export class RemixAppManager extends PluginManager { return new IframePlugin(plugin) }) } + + async registerContextMenuItems () { + await this.call('filePanel', 'registerContextMenuItem', { + id: 'flattener', + name: 'flattenFileCustomAction', + label: 'Flatten', + type: [], + extension: ['.sol'], + path: [], + pattern: [], + sticky: true + }) + await this.call('filePanel', 'registerContextMenuItem', { + id: '2o', + name: 'compileCustomAction', + label: 'Compile with Optimism', + type: [], + extension: ['.sol'], + path: [], + pattern: [], + sticky: true + }) + } } /** @class Reference loaders. From f5f76d62b4263134a4eff68d80830f5afebd91e8 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Thu, 19 Aug 2021 13:15:27 +0200 Subject: [PATCH 9/9] rn plugin --- apps/remix-ide/src/remixAppManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 40bdee7de5..09571d67b8 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -146,7 +146,7 @@ export class RemixAppManager extends PluginManager { sticky: true }) await this.call('filePanel', 'registerContextMenuItem', { - id: '2o', + id: 'optimism-compiler', name: 'compileCustomAction', label: 'Compile with Optimism', type: [],