Merge pull request #4026 from ethereum/add_ephemery_testnet

add ephemery provider
pull/5370/head
yann300 2 years ago committed by GitHub
commit 98cb68cb26
  1. 112
      apps/remix-ide/src/app.js
  2. 4
      apps/remix-ide/src/app/providers/injected-arbitrum-one-provider.tsx
  3. 8
      apps/remix-ide/src/app/providers/injected-custom-provider.tsx
  4. 17
      apps/remix-ide/src/app/providers/injected-ephemery-testnet-provider.tsx
  5. 4
      apps/remix-ide/src/app/providers/injected-optimism-provider.tsx
  6. 38
      apps/remix-ide/src/app/udapp/run-tab.js
  7. 142
      apps/remix-ide/src/remixAppManager.js

@ -41,6 +41,7 @@ import { InjectedProviderDefault } from './app/providers/injected-provider-defau
import {InjectedProviderTrustWallet} from './app/providers/injected-provider-trustwallet' import {InjectedProviderTrustWallet} from './app/providers/injected-provider-trustwallet'
import {Injected0ptimismProvider} from './app/providers/injected-optimism-provider' import {Injected0ptimismProvider} from './app/providers/injected-optimism-provider'
import {InjectedArbitrumOneProvider} from './app/providers/injected-arbitrum-one-provider' import {InjectedArbitrumOneProvider} from './app/providers/injected-arbitrum-one-provider'
import {InjectedEphemeryTestnetProvider} from './app/providers/injected-ephemery-testnet-provider'
import {FileDecorator} from './app/plugins/file-decorator' import {FileDecorator} from './app/plugins/file-decorator'
import {CodeFormat} from './app/plugins/code-format' import {CodeFormat} from './app/plugins/code-format'
import {SolidityUmlGen} from './app/plugins/solidity-umlgen' import {SolidityUmlGen} from './app/plugins/solidity-umlgen'
@ -93,9 +94,7 @@ class AppComponent {
api: this._components.filesProviders.browser, api: this._components.filesProviders.browser,
name: 'fileproviders/browser' name: 'fileproviders/browser'
}) })
this._components.filesProviders.localhost = new RemixDProvider( this._components.filesProviders.localhost = new RemixDProvider(this.appManager)
this.appManager
)
Registry.getInstance().put({ Registry.getInstance().put({
api: this._components.filesProviders.localhost, api: this._components.filesProviders.localhost,
name: 'fileproviders/localhost' name: 'fileproviders/localhost'
@ -119,7 +118,7 @@ class AppComponent {
this.panels = {} this.panels = {}
this.workspace = pluginLoader.get() this.workspace = pluginLoader.get()
this.engine = new RemixEngine() this.engine = new RemixEngine()
this.engine.register(appManager); this.engine.register(appManager)
const matomoDomains = { const matomoDomains = {
'remix-alpha.ethereum.org': 27, 'remix-alpha.ethereum.org': 27,
@ -127,15 +126,8 @@ class AppComponent {
'remix.ethereum.org': 23, 'remix.ethereum.org': 23,
'6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod': 35 // remix desktop '6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod': 35 // remix desktop
} }
this.showMatamo = this.showMatamo = matomoDomains[window.location.hostname] && !Registry.getInstance().get('config').api.exists('settings/matomo-analytics')
matomoDomains[window.location.hostname] && this.walkthroughService = new WalkthroughService(appManager, this.showMatamo)
!Registry.getInstance()
.get('config')
.api.exists('settings/matomo-analytics')
this.walkthroughService = new WalkthroughService(
appManager,
this.showMatamo
)
const hosts = ['127.0.0.1:8080', '192.168.0.101:8080', 'localhost:8080'] const hosts = ['127.0.0.1:8080', '192.168.0.101:8080', 'localhost:8080']
// workaround for Electron support // workaround for Electron support
@ -221,9 +213,10 @@ class AppComponent {
const foundryProvider = new FoundryProvider(blockchain) const foundryProvider = new FoundryProvider(blockchain)
const externalHttpProvider = new ExternalHttpProvider(blockchain) const externalHttpProvider = new ExternalHttpProvider(blockchain)
const trustWalletInjectedProvider = new InjectedProviderTrustWallet() const trustWalletInjectedProvider = new InjectedProviderTrustWallet()
const defaultInjectedProvider = new InjectedProviderDefault const defaultInjectedProvider = new InjectedProviderDefault()
const injected0ptimismProvider = new Injected0ptimismProvider() const injected0ptimismProvider = new Injected0ptimismProvider()
const injectedArbitrumOneProvider = new InjectedArbitrumOneProvider() const injectedArbitrumOneProvider = new InjectedArbitrumOneProvider()
const injectedEphemeryTestnetProvider = new InjectedEphemeryTestnetProvider()
// ----------------- convert offset to line/column service ----------- // ----------------- convert offset to line/column service -----------
const offsetToLineColumnConverter = new OffsetToLineColumnConverter() const offsetToLineColumnConverter = new OffsetToLineColumnConverter()
Registry.getInstance().put({ Registry.getInstance().put({
@ -233,11 +226,11 @@ class AppComponent {
// ----------------- run script after each compilation results ----------- // ----------------- run script after each compilation results -----------
const compileAndRun = new CompileAndRun() const compileAndRun = new CompileAndRun()
// -------------------Terminal---------------------------------------- // -------------------Terminal----------------------------------------
makeUdapp(blockchain, compilersArtefacts, domEl => terminal.logHtml(domEl)) makeUdapp(blockchain, compilersArtefacts, (domEl) => terminal.logHtml(domEl))
const terminal = new Terminal( const terminal = new Terminal(
{appManager, blockchain}, {appManager, blockchain},
{ {
getPosition: event => { getPosition: (event) => {
const limitUp = 36 const limitUp = 36
const limitDown = 20 const limitDown = 20
const height = window.innerHeight const height = window.innerHeight
@ -299,6 +292,7 @@ class AppComponent {
trustWalletInjectedProvider, trustWalletInjectedProvider,
injected0ptimismProvider, injected0ptimismProvider,
injectedArbitrumOneProvider, injectedArbitrumOneProvider,
injectedEphemeryTestnetProvider,
this.walkthroughService, this.walkthroughService,
search, search,
solidityumlgen, solidityumlgen,
@ -317,42 +311,18 @@ class AppComponent {
this.sidePanel = new SidePanel() this.sidePanel = new SidePanel()
this.hiddenPanel = new HiddenPanel() this.hiddenPanel = new HiddenPanel()
const pluginManagerComponent = new PluginManagerComponent( const pluginManagerComponent = new PluginManagerComponent(appManager, this.engine)
appManager,
this.engine
)
const filePanel = new FilePanel(appManager) const filePanel = new FilePanel(appManager)
const landingPage = new LandingPage( const landingPage = new LandingPage(appManager, this.menuicons, fileManager, filePanel, contentImport)
appManager, this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor, appManager)
this.menuicons,
fileManager,
filePanel,
contentImport
)
this.settings = new SettingsTab(
Registry.getInstance().get('config').api,
editor,
appManager
)
this.engine.register([ this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, filePanel, pluginManagerComponent, this.settings])
this.menuicons,
landingPage,
this.hiddenPanel,
this.sidePanel,
filePanel,
pluginManagerComponent,
this.settings
])
// CONTENT VIEWS & DEFAULT PLUGINS // CONTENT VIEWS & DEFAULT PLUGINS
const openZeppelinProxy = new OpenZeppelinProxy(blockchain) const openZeppelinProxy = new OpenZeppelinProxy(blockchain)
const linkLibraries = new LinkLibraries(blockchain) const linkLibraries = new LinkLibraries(blockchain)
const deployLibraries = new DeployLibraries(blockchain) const deployLibraries = new DeployLibraries(blockchain)
const compileTab = new CompileTab( const compileTab = new CompileTab(Registry.getInstance().get('config').api, Registry.getInstance().get('filemanager').api)
Registry.getInstance().get('config').api,
Registry.getInstance().get('filemanager').api
)
const run = new RunTab( const run = new RunTab(
blockchain, blockchain,
Registry.getInstance().get('config').api, Registry.getInstance().get('config').api,
@ -411,27 +381,44 @@ class AppComponent {
await this.appManager.activatePlugin(['layout']) await this.appManager.activatePlugin(['layout'])
await this.appManager.activatePlugin(['notification']) await this.appManager.activatePlugin(['notification'])
await this.appManager.activatePlugin(['editor']) await this.appManager.activatePlugin(['editor'])
await this.appManager.activatePlugin(['permissionhandler', 'theme', 'locale', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) await this.appManager.activatePlugin([
'permissionhandler',
'theme',
'locale',
'fileManager',
'compilerMetadata',
'compilerArtefacts',
'network',
'web3Provider',
'offsetToLineColumnConverter'
])
await this.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs']) await this.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
await this.appManager.activatePlugin(['sidePanel']) // activating host plugin separately await this.appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await this.appManager.activatePlugin(['home']) await this.appManager.activatePlugin(['home'])
await this.appManager.activatePlugin(['settings', 'config']) await this.appManager.activatePlugin(['settings', 'config'])
await this.appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'codeParser', 'codeFormatter', 'fileDecorator', 'terminal', 'blockchain', 'fetchAndCompile', 'contentImport', 'gistHandler']) await this.appManager.activatePlugin([
'hiddenPanel',
'pluginManager',
'codeParser',
'codeFormatter',
'fileDecorator',
'terminal',
'blockchain',
'fetchAndCompile',
'contentImport',
'gistHandler'
])
await this.appManager.activatePlugin(['settings']) await this.appManager.activatePlugin(['settings'])
await this.appManager.activatePlugin(['walkthrough', 'storage', 'search', 'compileAndRun', 'recorder']) await this.appManager.activatePlugin(['walkthrough', 'storage', 'search', 'compileAndRun', 'recorder'])
await this.appManager.activatePlugin(['solidity-script']) await this.appManager.activatePlugin(['solidity-script'])
this.appManager.on( this.appManager.on('filePanel', 'workspaceInitializationCompleted', async () => {
'filePanel',
'workspaceInitializationCompleted',
async () => {
// for e2e tests // for e2e tests
const loadedElement = document.createElement('span') const loadedElement = document.createElement('span')
loadedElement.setAttribute('data-id', 'workspaceloaded') loadedElement.setAttribute('data-id', 'workspaceloaded')
document.body.appendChild(loadedElement) document.body.appendChild(loadedElement)
await this.appManager.registerContextMenuItems() await this.appManager.registerContextMenuItems()
} })
)
await this.appManager.activatePlugin(['filePanel']) await this.appManager.activatePlugin(['filePanel'])
// Set workspace after initial activation // Set workspace after initial activation
@ -442,9 +429,7 @@ class AppComponent {
.then(async () => { .then(async () => {
try { try {
if (params.deactivate) { if (params.deactivate) {
await this.appManager.deactivatePlugin( await this.appManager.deactivatePlugin(params.deactivate.split(','))
params.deactivate.split(',')
)
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
@ -454,10 +439,7 @@ class AppComponent {
this.menuicons.select('solidity') this.menuicons.select('solidity')
} else { } else {
// If plugins are loaded from the URL params, we focus on the last one. // If plugins are loaded from the URL params, we focus on the last one.
if ( if (this.appManager.pluginLoader.current === 'queryParams' && this.workspace.length > 0) {
this.appManager.pluginLoader.current === 'queryParams' &&
this.workspace.length > 0
) {
this.menuicons.select(this.workspace[this.workspace.length - 1]) this.menuicons.select(this.workspace[this.workspace.length - 1])
} else { } else {
this.appManager.call('tabs', 'focus', 'home') this.appManager.call('tabs', 'focus', 'home')
@ -474,17 +456,13 @@ class AppComponent {
} }
if (params.calls) { if (params.calls) {
const calls = params.calls.split("///"); const calls = params.calls.split('///')
// call all functions in the list, one after the other // call all functions in the list, one after the other
for (const call of calls) { for (const call of calls) {
const callDetails = call.split("//"); const callDetails = call.split('//')
if (callDetails.length > 1) { if (callDetails.length > 1) {
this.appManager.call( this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`)
"notification",
"toast",
`initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`
);
// @todo(remove the timeout when activatePlugin is on 0.3.0) // @todo(remove the timeout when activatePlugin is on 0.3.0)
try { try {

@ -1,5 +1,5 @@
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
import {InjectedL2Provider} from './injected-L2-provider' import {InjectedCustomProvider} from './injected-custom-provider'
const profile = { const profile = {
name: 'injected-arbitrum-one-provider', name: 'injected-arbitrum-one-provider',
@ -10,7 +10,7 @@ const profile = {
version: packageJson.version version: packageJson.version
} }
export class InjectedArbitrumOneProvider extends InjectedL2Provider { export class InjectedArbitrumOneProvider extends InjectedCustomProvider {
constructor() { constructor() {
super(profile, 'Arbitrum One', '0xa4b1', ['https://arb1.arbitrum.io/rpc']) super(profile, 'Arbitrum One', '0xa4b1', ['https://arb1.arbitrum.io/rpc'])
} }

@ -1,6 +1,6 @@
import {InjectedProviderDefaultBase} from './injected-provider-default' import {InjectedProviderDefaultBase} from './injected-provider-default'
export class InjectedL2Provider extends InjectedProviderDefaultBase { export class InjectedCustomProvider extends InjectedProviderDefaultBase {
chainName: string chainName: string
chainId: string chainId: string
rpcUrls: Array<string> rpcUrls: Array<string>
@ -14,13 +14,13 @@ export class InjectedL2Provider extends InjectedProviderDefaultBase {
async init() { async init() {
await super.init() await super.init()
if (this.chainName && this.rpcUrls && this.rpcUrls.length > 0) await addL2Network(this.chainName, this.chainId, this.rpcUrls) if (this.chainName && this.rpcUrls && this.rpcUrls.length > 0) await addCustomNetwork(this.chainName, this.chainId, this.rpcUrls)
else throw new Error('Cannot add the L2 network to main injected provider') else throw new Error('Cannot add the custom network to main injected provider')
return {} return {}
} }
} }
export const addL2Network = async (chainName: string, chainId: string, rpcUrls: Array<string>) => { export const addCustomNetwork = async (chainName: string, chainId: string, rpcUrls: Array<string>) => {
try { try {
await (window as any).ethereum.request({ await (window as any).ethereum.request({
method: 'wallet_switchEthereumChain', method: 'wallet_switchEthereumChain',

@ -0,0 +1,17 @@
import * as packageJson from '../../../../../package.json'
import {InjectedCustomProvider} from './injected-custom-provider'
const profile = {
name: 'injected-ephemery-testnet-provider',
displayName: 'Injected Ephemery Testnet Provider',
kind: 'provider',
description: 'Injected Ephemery Testnet Provider',
methods: ['sendAsync', 'init'],
version: packageJson.version
}
export class InjectedEphemeryTestnetProvider extends InjectedCustomProvider {
constructor() {
super(profile, 'Ephemery Testnet', '0x259C709', ['https://otter.bordel.wtf/erigon', 'https://eth.ephemeral.zeus.fyi'])
}
}

@ -1,5 +1,5 @@
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
import {InjectedL2Provider} from './injected-L2-provider' import {InjectedCustomProvider} from './injected-custom-provider'
const profile = { const profile = {
name: 'injected-optimism-provider', name: 'injected-optimism-provider',
@ -10,7 +10,7 @@ const profile = {
version: packageJson.version version: packageJson.version
} }
export class Injected0ptimismProvider extends InjectedL2Provider { export class Injected0ptimismProvider extends InjectedCustomProvider {
constructor() { constructor() {
super(profile, 'Optimism', '0xa', ['https://mainnet.optimism.io']) super(profile, 'Optimism', '0xa', ['https://mainnet.optimism.io'])
} }

@ -6,7 +6,7 @@ import * as packageJson from '../../../../../package.json'
const EventManager = require('../../lib/events') const EventManager = require('../../lib/events')
const Recorder = require('../tabs/runTab/model/recorder.js') const Recorder = require('../tabs/runTab/model/recorder.js')
const _paq = window._paq = window._paq || [] const _paq = (window._paq = window._paq || [])
const profile = { const profile = {
name: 'udapp', name: 'udapp',
@ -20,7 +20,17 @@ const profile = {
maintainedBy: 'Remix', maintainedBy: 'Remix',
permission: true, permission: true,
events: ['newTransaction'], events: ['newTransaction'],
methods: ['createVMAccount', 'sendTransaction', 'getAccounts', 'pendingTransactionsCount', 'getSettings', 'setEnvironmentMode', 'clearAllInstances', 'addInstance', 'resolveContractAndAddInstance'] methods: [
'createVMAccount',
'sendTransaction',
'getAccounts',
'pendingTransactionsCount',
'getSettings',
'setEnvironmentMode',
'clearAllInstances',
'addInstance',
'resolveContractAndAddInstance'
]
} }
export class RunTab extends ViewPlugin { export class RunTab extends ViewPlugin {
@ -91,7 +101,11 @@ export class RunTab extends ViewPlugin {
} }
render() { render() {
return <div><RunTabUI plugin={this} /></div> return (
<div>
<RunTabUI plugin={this} />
</div>
)
} }
onReady(api) { onReady(api) {
@ -134,10 +148,17 @@ export class RunTab extends ViewPlugin {
// basic injected // basic injected
// if it's the trust wallet provider, we have a specific provider for that, see below // if it's the trust wallet provider, we have a specific provider for that, see below
if (window && window.ethereum && !(window.ethereum.isTrustWallet || window.ethereum.selectedProvider?.isTrustWallet)) { if (window && window.ethereum && !(window.ethereum.isTrustWallet || window.ethereum.selectedProvider?.isTrustWallet)) {
const displayNameInjected = `Injected Provider${(window && window.ethereum && !(window.ethereum.providers && !window.ethereum.selectedProvider)) ? const displayNameInjected = `Injected Provider${
window.ethereum.isCoinbaseWallet || window.ethereum.selectedProvider?.isCoinbaseWallet ? ' - Coinbase' : window && window.ethereum && !(window.ethereum.providers && !window.ethereum.selectedProvider)
window.ethereum.isBraveWallet || window.ethereum.selectedProvider?.isBraveWallet ? ' - Brave' : ? window.ethereum.isCoinbaseWallet || window.ethereum.selectedProvider?.isCoinbaseWallet
window.ethereum.isMetaMask || window.ethereum.selectedProvider?.isMetaMask ? ' - MetaMask' : '' : ''}` ? ' - Coinbase'
: window.ethereum.isBraveWallet || window.ethereum.selectedProvider?.isBraveWallet
? ' - Brave'
: window.ethereum.isMetaMask || window.ethereum.selectedProvider?.isMetaMask
? ' - MetaMask'
: ''
: ''
}`
await addProvider('injected', displayNameInjected, true, false) await addProvider('injected', displayNameInjected, true, false)
} else if (window && !window.ethereum) { } else if (window && !window.ethereum) {
// we still add "injected" if there's no provider (just so it's visible to the user). // we still add "injected" if there's no provider (just so it's visible to the user).
@ -163,6 +184,9 @@ export class RunTab extends ViewPlugin {
// wallet connect // wallet connect
await addProvider('walletconnect', 'WalletConnect', false, false) await addProvider('walletconnect', 'WalletConnect', false, false)
// testnet
await addProvider('injected-ephemery-testnet-provider', 'Ephemery Testnet', true, false)
// external provider // external provider
await addProvider('basic-http-provider', 'Custom - External Http Provider', false, false) await addProvider('basic-http-provider', 'Custom - External Http Provider', false, false)
await addProvider('hardhat-provider', 'Dev - Hardhat Provider', false, false) await addProvider('hardhat-provider', 'Dev - Hardhat Provider', false, false)

@ -2,34 +2,115 @@ import { PluginManager } from '@remixproject/engine'
import {EventEmitter} from 'events' import {EventEmitter} from 'events'
import {QueryParams} from '@remix-project/remix-lib' import {QueryParams} from '@remix-project/remix-lib'
import {IframePlugin} from '@remixproject/engine-web' import {IframePlugin} from '@remixproject/engine-web'
const _paq = window._paq = window._paq || [] const _paq = (window._paq = window._paq || [])
// requiredModule removes the plugin from the plugin manager list on UI // requiredModule removes the plugin from the plugin manager list on UI
const requiredModules = [ // services + layout views + system views const requiredModules = [
'manager', 'config', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'locale', // services + layout views + system views
'fileManager', 'contentImport', 'blockchain', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'manager',
'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity', 'solidity-logic', 'gistHandler', 'layout', 'config',
'notification', 'permissionhandler', 'walkthrough', 'storage', 'restorebackupzip', 'link-libraries', 'deploy-libraries', 'openzeppelin-proxy', 'compilerArtefacts',
'hardhat-provider', 'ganache-provider', 'foundry-provider', 'basic-http-provider', 'injected', 'injected-trustwallet', 'injected-optimism-provider', 'injected-arbitrum-one-provider', 'vm-custom-fork', 'vm-goerli-fork', 'vm-mainnet-fork', 'vm-sepolia-fork', 'vm-merge', 'vm-london', 'vm-berlin', 'compilerMetadata',
'contextualListener',
'editor',
'offsetToLineColumnConverter',
'network',
'theme',
'locale',
'fileManager',
'contentImport',
'blockchain',
'web3Provider',
'scriptRunner',
'fetchAndCompile',
'mainPanel',
'hiddenPanel',
'sidePanel',
'menuicons',
'filePanel',
'terminal',
'settings',
'pluginManager',
'tabs',
'udapp',
'dGitProvider',
'solidity',
'solidity-logic',
'gistHandler',
'layout',
'notification',
'permissionhandler',
'walkthrough',
'storage',
'restorebackupzip',
'link-libraries',
'deploy-libraries',
'openzeppelin-proxy',
'hardhat-provider',
'ganache-provider',
'foundry-provider',
'basic-http-provider',
'injected',
'injected-trustwallet',
'injected-optimism-provider',
'injected-arbitrum-one-provider',
'injected-ephemery-testnet-provider',
'vm-custom-fork',
'vm-goerli-fork',
'vm-mainnet-fork',
'vm-sepolia-fork',
'vm-merge',
'vm-london',
'vm-berlin',
'vm-shanghai', 'vm-shanghai',
'compileAndRun', 'search', 'recorder', 'fileDecorator', 'codeParser', 'codeFormatter', 'solidityumlgen', 'contractflattener', 'solidity-script'] 'compileAndRun',
'search',
'recorder',
'fileDecorator',
'codeParser',
'codeFormatter',
'solidityumlgen',
'contractflattener',
'solidity-script'
]
// dependentModules shouldn't be manually activated (e.g hardhat is activated by remixd) // dependentModules shouldn't be manually activated (e.g hardhat is activated by remixd)
const dependentModules = ['foundry', 'hardhat', 'truffle', 'slither'] const dependentModules = ['foundry', 'hardhat', 'truffle', 'slither']
const loadLocalPlugins = ["doc-gen", "doc-viewer", "etherscan", "vyper", "solhint", "walletconnect", "circuit-compiler"] const loadLocalPlugins = ['doc-gen', 'doc-viewer', 'etherscan', 'vyper', 'solhint', 'walletconnect', 'circuit-compiler']
const sensitiveCalls = { const sensitiveCalls = {
'fileManager': ['writeFile', 'copyFile', 'rename', 'copyDir'], fileManager: ['writeFile', 'copyFile', 'rename', 'copyDir'],
'contentImport': ['resolveAndSave'], contentImport: ['resolveAndSave'],
'web3Provider': ['sendAsync'], web3Provider: ['sendAsync']
} }
export function isNative(name) { export function isNative(name) {
// nativePlugin allows to bypass the permission request // nativePlugin allows to bypass the permission request
const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'solidity-logic', 'solidityStaticAnalysis', 'solidityUnitTesting', const nativePlugins = [
'layout', 'notification', 'hardhat-provider', 'ganache-provider', 'foundry-provider', 'basic-http-provider', 'injected-optimism-provider', 'vyper',
'tabs', 'injected-arbitrum-one-provider', 'injected', 'doc-gen', 'doc-viewer'] 'workshops',
'debugger',
'remixd',
'menuicons',
'solidity',
'solidity-logic',
'solidityStaticAnalysis',
'solidityUnitTesting',
'layout',
'notification',
'hardhat-provider',
'ganache-provider',
'foundry-provider',
'basic-http-provider',
'injected-optimism-provider',
'tabs',
'injected-arbitrum-one-provider',
'injected-ephemery-testnet-provider',
'injected',
'doc-gen',
'doc-viewer'
]
return nativePlugins.includes(name) || requiredModules.includes(name) return nativePlugins.includes(name) || requiredModules.includes(name)
} }
@ -44,9 +125,7 @@ export function isNative(name) {
* @returns {boolean} * @returns {boolean}
*/ */
export function canActivate(from, to) { export function canActivate(from, to) {
return ['ethdoc'].includes(from.name) || return ['ethdoc'].includes(from.name) || isNative(from.name) || (to && from && from.canActivate && from.canActivate.includes(to.name))
isNative(from.name) ||
(to && from && from.canActivate && from.canActivate.includes(to.name))
} }
export class RemixAppManager extends PluginManager { export class RemixAppManager extends PluginManager {
@ -72,10 +151,7 @@ export class RemixAppManager extends PluginManager {
async deactivatePlugin(name) { async deactivatePlugin(name) {
const profile = await this.getProfile(name) const profile = await this.getProfile(name)
const [to, from] = [ const [to, from] = [profile, await this.getProfile(this.requestFrom)]
profile,
await this.getProfile(this.requestFrom)
]
if (this.canDeactivatePlugin(from, to)) { if (this.canDeactivatePlugin(from, to)) {
if (profile.methods.includes('deactivate')) { if (profile.methods.includes('deactivate')) {
try { try {
@ -104,7 +180,10 @@ export class RemixAppManager extends PluginManager {
} }
onPluginActivated(plugin) { onPluginActivated(plugin) {
this.pluginLoader.set(plugin, this.actives.filter((plugin) => !this.isDependent(plugin))) this.pluginLoader.set(
plugin,
this.actives.filter((plugin) => !this.isDependent(plugin))
)
this.event.emit('activate', plugin) this.event.emit('activate', plugin)
this.emit('activate', plugin) this.emit('activate', plugin)
if (!requiredModules.includes(plugin.name)) _paq.push(['trackEvent', 'pluginManager', 'activate', plugin.name]) if (!requiredModules.includes(plugin.name)) _paq.push(['trackEvent', 'pluginManager', 'activate', plugin.name])
@ -121,7 +200,10 @@ export class RemixAppManager extends PluginManager {
} }
onPluginDeactivated(plugin) { onPluginDeactivated(plugin) {
this.pluginLoader.set(plugin, this.actives.filter((plugin) => !this.isDependent(plugin))) this.pluginLoader.set(
plugin,
this.actives.filter((plugin) => !this.isDependent(plugin))
)
this.event.emit('deactivate', plugin) this.event.emit('deactivate', plugin)
_paq.push(['trackEvent', 'pluginManager', 'deactivate', plugin.name]) _paq.push(['trackEvent', 'pluginManager', 'deactivate', plugin.name])
} }
@ -142,7 +224,7 @@ export class RemixAppManager extends PluginManager {
plugins = await res.json() plugins = await res.json()
plugins = plugins.filter((plugin) => { plugins = plugins.filter((plugin) => {
if (plugin.targets && Array.isArray(plugin.targets) && plugin.targets.length > 0) { if (plugin.targets && Array.isArray(plugin.targets) && plugin.targets.length > 0) {
return (plugin.targets.includes('remix')) return plugin.targets.includes('remix')
} }
return true return true
}) })
@ -177,7 +259,7 @@ export class RemixAppManager extends PluginManager {
} }
} }
return plugins.map(plugin => { return plugins.map((plugin) => {
if (plugin.name === testPluginName) plugin.url = testPluginUrl if (plugin.name === testPluginName) plugin.url = testPluginUrl
return new IframePlugin(plugin) return new IframePlugin(plugin)
}) })
@ -249,11 +331,15 @@ class PluginLoader {
const saved = actives.filter((name) => !this.donotAutoReload.includes(name)) const saved = actives.filter((name) => !this.donotAutoReload.includes(name))
localStorage.setItem('workspace', JSON.stringify(saved)) localStorage.setItem('workspace', JSON.stringify(saved))
}, },
get: () => { return JSON.parse(localStorage.getItem('workspace')) } get: () => {
return JSON.parse(localStorage.getItem('workspace'))
}
} }
this.loaders.queryParams = { this.loaders.queryParams = {
set: () => { /* Do nothing. */ }, set: () => {
/* Do nothing. */
},
get: () => { get: () => {
const {activate} = queryParams.get() const {activate} = queryParams.get()
if (!activate) return [] if (!activate) return []

Loading…
Cancel
Save