Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use remix plugin 0.3 #511

Merged
merged 19 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/fileManager_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
browser
.addFile('file.js', { content: executeFile })
.executeScript(`remix.exeCurrent()`)
.pause(2000)
.pause(5000)
.journalLastChildIncludes('browser/file.js')
},

Expand Down
8 changes: 6 additions & 2 deletions apps/remix-ide-e2e/src/tests/pluginManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sauce from './sauce'
const testData = {
pluginName: 'remixIde',
pluginDisplayName: 'Remix IDE',
pluginUrl: 'https://remix-project.org/'
pluginUrl: 'https://zokrates-remix-plugin.netlify.app/'
}

module.exports = {
Expand Down Expand Up @@ -44,6 +44,7 @@ module.exports = {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentPluginManager"]')
.scrollAndClick('*[data-id="pluginManagerComponentActivateButtondebugger"]')
.pause(2000)
.waitForElementVisible('*[data-id="pluginManagerComponentDeactivateButtondebugger"]')
.scrollAndClick('*[data-id="pluginManagerComponentActivateButtonvyper"]')
.waitForElementVisible('*[data-id="pluginManagerComponentDeactivateButtonvyper"]')
Expand All @@ -54,8 +55,11 @@ module.exports = {
'Should deactivate plugins': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="pluginManagerComponentPluginManager"]')
.click('*[data-id="pluginManagerComponentPluginManager"]')
.scrollAndClick('*[data-id="pluginManagerComponentDeactivateButtondebugger"]')
.waitForElementVisible('*[data-id="pluginManagerComponentDeactivateButtondebugger"]')
.pause(2000)
.scrollAndClick('*[data-id="pluginManagerComponentDeactivateButtondebugger"]')
.waitForElementVisible('*[data-id="pluginManagerComponentActivateButtondebugger"]')
.waitForElementVisible('*[data-id="pluginManagerComponentDeactivateButtonvyper"]')
.scrollAndClick('*[data-id="pluginManagerComponentDeactivateButtonvyper"]')
.waitForElementVisible('*[data-id="pluginManagerComponentActivateButtonvyper"]')
},
Expand Down
21 changes: 7 additions & 14 deletions apps/remix-ide/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { basicLogo } from './app/ui/svgLogo'
import { RunTab, makeUdapp } from './app/udapp'

import PanelsResize from './lib/panels-resize'
import { Engine } from '@remixproject/engine'
import { RemixEngine } from './remixEngine'
import { RemixAppManager } from './remixAppManager'
import { FramingService } from './framingService'
import { MainView } from './app/panels/main-view'
Expand Down Expand Up @@ -231,13 +231,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
const appManager = self.appManager
const pluginLoader = appManager.pluginLoader
const workspace = pluginLoader.get()
const engine = new Engine(appManager)
engine.setPluginOption = ({ name, kind }) => {
if (kind === 'provider') return { queueTimeout: 60000 * 2 }
if (name === 'LearnEth') return { queueTimeout: 60000 }
return { queueTimeout: 10000 }
}
await engine.onload()
const engine = new RemixEngine()
engine.register(appManager)

// SERVICES
// ----------------- import content servive ------------------------
Expand Down Expand Up @@ -401,17 +396,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
await appManager.activatePlugin(['contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await appManager.activatePlugin(['mainPanel', 'menuicons'])
await appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await appManager.activatePlugin(['home', 'hiddenPanel', 'pluginManager', 'fileExplorers', 'settings', 'contextualListener', 'scriptRunner', 'terminal', 'fetchAndCompile'])
await appManager.activatePlugin(['home', 'hiddenPanel', 'pluginManager', 'fileExplorers', 'settings', 'contextualListener', 'terminal', 'fetchAndCompile'])

const queryParams = new QueryParams()
const params = queryParams.get()

// Set workspace after initial activation
if (Array.isArray(workspace)) {
appManager.activatePlugin(workspace).then(() => {
appManager.activatePlugin(workspace).then(async () => {
try {
if (params.deactivate) {
appManager.deactivatePlugin(params.deactivate.split(','))
await appManager.deactivatePlugin(params.deactivate.split(','))
}
} catch (e) {
console.log(e)
Expand All @@ -425,9 +420,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
if (callDetails.length > 1) {
toolTip(`initiating ${callDetails[0]} ...`)
// @todo(remove the timeout when activatePlugin is on 0.3.0)
setTimeout(() => {
appManager.call(...callDetails).catch(console.error)
}, 5000)
appManager.call(...callDetails).catch(console.error)
}
}
}).catch(console.error)
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/components/panel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventEmitter } from 'events'
import { HostPlugin } from '@remixproject/engine'
import { HostPlugin } from '@remixproject/engine-web'
const csjs = require('csjs-inject')
const yo = require('yo-yo')

Expand Down
6 changes: 3 additions & 3 deletions apps/remix-ide/src/app/components/plugin-manager-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewPlugin, IframePlugin, WebsocketPlugin } from '@remixproject/engine'
import { IframePlugin, ViewPlugin, WebsocketPlugin } from '@remixproject/engine-web'
import { PluginManagerSettings } from './plugin-manager-settings'
import * as packageJson from '../../../../../package.json'
const yo = require('yo-yo')
Expand Down Expand Up @@ -83,8 +83,8 @@ class PluginManagerComponent extends ViewPlugin {
this.filter = ''
this.appManager.event.on('activate', () => { this.reRender() })
this.appManager.event.on('deactivate', () => { this.reRender() })
this.appManager.event.on('added', () => { this.reRender() })
this.engine = engine
this.engine.event.on('onRegistration', () => { this.reRender() })
}

isActive (name) {
Expand Down Expand Up @@ -151,7 +151,7 @@ class PluginManagerComponent extends ViewPlugin {
}
const plugin = profile.type === 'iframe' ? new IframePlugin(profile) : new WebsocketPlugin(profile)
this.engine.register(plugin)
this.appManager.activatePlugin(plugin.name)
await this.appManager.activatePlugin(plugin.name)
} catch (err) {
// TODO : Use an alert to handle this error instead of a console.log
console.log(`Cannot create Plugin : ${err.message}`)
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/files/remixd-handle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isElectron from 'is-electron'
import { WebsocketPlugin } from '@remixproject/engine'
import { WebsocketPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json'
var yo = require('yo-yo')
var modalDialog = require('../ui/modaldialog')
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/panels/file-panel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'

import * as packageJson from '../../../../../package.json'
var yo = require('yo-yo')
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/tabs/analysis-tab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'
import { EventEmitter } from 'events'
import * as packageJson from '../../../../../package.json'

Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/tabs/compile-tab.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global */
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json'
import publishToStorage from '../../publishToStorage'
import { compile } from '../compiler/compiler-helpers'
Expand Down
3 changes: 1 addition & 2 deletions apps/remix-ide/src/app/tabs/debugger-tab.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import toaster from '../ui/tooltip'
import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'
import remixDebug, { TransactionDebugger as Debugger } from '@remix-project/remix-debug'
import * as packageJson from '../../../../../package.json'
import React from 'react' // eslint-disable-line
Expand Down Expand Up @@ -63,7 +63,6 @@ class DebuggerTab extends ViewPlugin {

this.renderComponent()

this.call('manager', 'activatePlugin', 'source-verification').catch(e => console.log(e.message))
// this.call('manager', 'activatePlugin', 'udapp')

return this.el
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/tabs/settings-tab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json'
const yo = require('yo-yo')
const globalRegistry = require('../../global/registry')
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/tabs/test-tab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'
import { canUseWorker, urlFromVersion } from '../compiler/compiler-utils'
var yo = require('yo-yo')
var async = require('async')
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/ui/landing-page/landing-page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as packageJson from '../../../../../../package.json'
import { ViewPlugin } from '@remixproject/engine'
import { ViewPlugin } from '@remixproject/engine-web'

const yo = require('yo-yo')
const csjs = require('csjs-inject')
Expand Down
19 changes: 7 additions & 12 deletions apps/remix-ide/src/remixAppManager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global localStorage, fetch */
import { PluginManager, IframePlugin } from '@remixproject/engine'
import { PluginManager } from '@remixproject/engine'
import { IframePlugin } from '@remixproject/engine-web'
import { EventEmitter } from 'events'
import QueryParams from './lib/query-params'
import { PermissionHandler } from './app/ui/persmission-handler'
Expand All @@ -15,7 +16,7 @@ export function isNative (name) {
}

export function canActivate (name) {
return ['manager', 'debugger', 'ethdoc'].includes(name)
return ['ethdoc'].includes(name) || isNative(name)
}

export class RemixAppManager extends PluginManager {
Expand All @@ -27,11 +28,12 @@ export class RemixAppManager extends PluginManager {
this.permissionHandler = new PermissionHandler()
}

async canActivate (from, to) {
async canActivatePlugin (from, to) {
return canActivate(from.name)
}

async canDeactivate (from, to) {
async canDeactivatePlugin (from, to) {
if (requiredModules.includes(to.name)) return false
return from.name === 'manager'
}

Expand Down Expand Up @@ -68,9 +70,7 @@ export class RemixAppManager extends PluginManager {
this.event.emit('deactivate', plugin)
}

onRegistration (plugin) {
this.event.emit('added', plugin.name)
}
onRegistration () {}

async ensureActivated (apiName) {
await this.activatePlugin(apiName)
Expand All @@ -82,11 +82,6 @@ export class RemixAppManager extends PluginManager {
this.event.emit('ensureDeactivated', apiName)
}

deactivatePlugin (name) {
if (requiredModules.includes(name)) return
super.deactivatePlugin(name)
}

isRequired (name) {
return requiredModules.includes(name)
}
Expand Down
19 changes: 19 additions & 0 deletions apps/remix-ide/src/remixEngine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Engine } from '@remixproject/engine'
import { EventEmitter } from 'events'

export class RemixEngine extends Engine {
constructor () {
super()
this.event = new EventEmitter()
}

setPluginOption ({ name, kind }) {
if (kind === 'provider') return { queueTimeout: 60000 * 2 }
if (name === 'LearnEth') return { queueTimeout: 60000 }
return { queueTimeout: 10000 }
}

onRegistration (plugin) {
this.event.emit('onRegistration', plugin)
}
}
8 changes: 4 additions & 4 deletions libs/remixd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
},
"homepage": "https://github.com/ethereum/remix-project#readme",
"dependencies": {
"@remixproject/plugin": "0.3.0-beta.5",
"@remixproject/plugin-api": "0.3.0-beta.5",
"@remixproject/plugin-utils": "0.3.0-beta.5",
"@remixproject/plugin-ws": "^0.3.0-beta.8",
"@remixproject/plugin": "^0.3.3",
"@remixproject/plugin-api": "^0.3.3",
"@remixproject/plugin-utils": "^0.3.3",
"@remixproject/plugin-ws": "^0.3.3",
"axios": "^0.20.0",
"chokidar": "^2.1.8",
"commander": "^2.20.3",
Expand Down
Loading