add appWeb3Provider

pull/5370/head
yann300 5 years ago
parent de25fc8304
commit 78cc6e57ed
  1. 8
      src/app.js
  2. 31
      src/app/tabs/web3-provider.js
  3. 2
      src/remixAppManager.js

@ -48,6 +48,7 @@ import { FramingService } from './framingService'
import { MainView } from './app/panels/main-view' import { MainView } from './app/panels/main-view'
import { ThemeModule } from './app/tabs/theme-module' import { ThemeModule } from './app/tabs/theme-module'
import { NetworkModule } from './app/tabs/network-module' import { NetworkModule } from './app/tabs/network-module'
import { Web3ProviderModule } from './app/tabs/web3-provider'
import { SidePanel } from './app/components/side-panel' import { SidePanel } from './app/components/side-panel'
import { HiddenPanel } from './app/components/hidden-panel' import { HiddenPanel } from './app/components/hidden-panel'
import { VerticalIcons } from './app/components/vertical-icons' import { VerticalIcons } from './app/components/vertical-icons'
@ -267,6 +268,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- network service (resolve network id / name) ----- // ----------------- network service (resolve network id / name) -----
const networkModule = new NetworkModule(blockchain) const networkModule = new NetworkModule(blockchain)
// ----------------- represent the current selected web3 provider ----
const web3Provider = new Web3ProviderModule(blockchain)
// ----------------- convert offset to line/column service ----------- // ----------------- convert offset to line/column service -----------
const offsetToLineColumnConverter = new OffsetToLineColumnConverter() const offsetToLineColumnConverter = new OffsetToLineColumnConverter()
registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'}) registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'})
@ -300,7 +303,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
networkModule, networkModule,
offsetToLineColumnConverter, offsetToLineColumnConverter,
contextualListener, contextualListener,
terminal terminal,
web3Provider
]) ])
// LAYOUT & SYSTEM VIEWS // LAYOUT & SYSTEM VIEWS
@ -383,7 +387,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
console.log('couldn\'t register iframe plugins', e.message) console.log('couldn\'t register iframe plugins', e.message)
} }
await appManager.activatePlugin(['contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'offsetToLineColumnConverter']) await appManager.activatePlugin(['contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await appManager.activatePlugin(['mainPanel', 'menuicons']) await appManager.activatePlugin(['mainPanel', 'menuicons'])
await appManager.activatePlugin(['home', 'sidePanel', 'hiddenPanel', 'pluginManager', 'fileExplorers', 'settings', 'contextualListener', 'scriptRunner', 'terminal']) await appManager.activatePlugin(['home', 'sidePanel', 'hiddenPanel', 'pluginManager', 'fileExplorers', 'settings', 'contextualListener', 'scriptRunner', 'terminal'])

@ -0,0 +1,31 @@
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../package.json'
export const profile = {
name: 'web3Provider',
displayName: 'Global Web3 Provider',
description: 'Represent the current web3 provider used by the app at global scope',
methods: ['sendAsync'],
version: packageJson.version,
kind: 'provider'
}
export class Web3ProviderModule extends Plugin {
constructor (blockchain) {
super(profile)
this.blockchain = blockchain
}
/*
that is used by plugins to call the current ethereum provider.
Should be taken carefully and probably not be release as it is now.
*/
sendAsync (payload) {
return new Promise((resolve, reject) => {
this.blockchain.web3().currentProvider.sendAsync(payload, (error, message) => {
if (error) return reject(error)
resolve(message)
})
})
}
}

@ -4,7 +4,7 @@ import { EventEmitter } from 'events'
import QueryParams from './lib/query-params' import QueryParams from './lib/query-params'
const requiredModules = [ // services + layout views + system views const requiredModules = [ // services + layout views + system views
'manager', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'fileManager', 'contentImport', 'scriptRunner', 'manager', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'fileManager', 'contentImport', 'web3Provider', 'scriptRunner',
'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'fileExplorers', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'fileExplorers',
'terminal', 'settings', 'pluginManager'] 'terminal', 'settings', 'pluginManager']

Loading…
Cancel
Save