move compiler-data into blockchain module; load blockchain module from run-tab

pull/5370/head
Iuri Matias 5 years ago
parent 9113dc690e
commit a429956706
  1. 13
      src/app.js
  2. 22
      src/app/files/compiler-metadata.js
  3. 4
      src/app/tabs/runTab/model/blockchain.js
  4. 5
      src/app/udapp/run-tab.js

@ -24,6 +24,8 @@ var CompilerImport = require('./app/compiler/compiler-imports')
var executionContext = remixLib.execution.executionContext
const Blockchain = require('./app/tabs/runTab/model/blockchain.js')
const PluginManagerComponent = require('./app/components/plugin-manager-component')
const CompilersArtefacts = require('./app/compiler/compiler-artefacts')
@ -222,13 +224,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- fileManager servive ----------------------------
const fileManager = new FileManager(editor)
registry.put({api: fileManager, name: 'filemanager'})
// ----------------- universal dapp: run transaction, listen on transactions, decode events
const udapp = new UniversalDApp(registry.get('config').api, executionContext)
const blockchain = new Blockchain(executionContext, udapp)
// ----------------- compilation metadata generation servive ----------------------------
const compilerMetadataGenerator = new CompilerMetadata(executionContext, fileManager, registry.get('config').api)
const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api)
// ----------------- compilation result service (can keep track of compilation results) ----------------------------
const compilersArtefacts = new CompilersArtefacts() // store all the compilation results (key represent a compiler name)
registry.put({api: compilersArtefacts, name: 'compilersartefacts'})
// ----------------- universal dapp: run transaction, listen on transactions, decode events
const udapp = new UniversalDApp(registry.get('config').api, executionContext)
const {eventsDecoder, txlistener} = makeUdapp(udapp, executionContext, compilersArtefacts, (domEl) => mainview.getTerminal().logHtml(domEl))
// ----------------- network service (resolve network id / name) ----------------------------
const networkModule = new NetworkModule(executionContext)
@ -293,6 +299,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
registry.get('filemanager').api
)
const run = new RunTab(
blockchain,
udapp,
executionContext,
registry.get('config').api,

@ -11,14 +11,13 @@ const profile = {
}
class CompilerMetadata extends Plugin {
constructor (executionContext, fileManager, config) {
constructor (blockchain, fileManager, config) {
super(profile)
var self = this
self.executionContext = executionContext
self.fileManager = fileManager
self.config = config
self.networks = ['VM:-', 'main:1', 'ropsten:3', 'rinkeby:4', 'kovan:42', 'görli:5', 'Custom']
self.innerPath = 'artifacts'
this.blockchain = blockchain
this.fileManager = fileManager
this.config = config
this.networks = ['VM:-', 'main:1', 'ropsten:3', 'rinkeby:4', 'kovan:42', 'görli:5', 'Custom']
this.innerPath = 'artifacts'
}
_JSONFileName (path, contractName) {
@ -93,15 +92,14 @@ class CompilerMetadata extends Plugin {
// TODO: is only called by dropdownLogic and can be moved there
deployMetadataOf (contractName) {
return new Promise((resolve, reject) => {
var self = this
var provider = self.fileManager.currentFileProvider()
var path = self.fileManager.currentPath()
var provider = this.fileManager.currentFileProvider()
var path = this.fileManager.currentPath()
if (provider && path) {
self.executionContext.detectNetwork((err, { id, name } = {}) => {
this.blockchain.detectNetwork((err, { id, name } = {}) => {
if (err) {
console.log(err)
} else {
var fileName = self._JSONFileName(path, contractName)
var fileName = this._JSONFileName(path, contractName)
provider.get(fileName, (error, content) => {
if (error) return reject(error)
if (!content) return resolve()

@ -183,6 +183,10 @@ class Blockchain {
})(this.networkcallid)
}
detectNetwork (cb) {
return this.executionContext.detectNetwork(cb)
}
newAccount (passphraseCb, cb) {
return this.udapp.newAccount('', passphraseCb, cb)
}

@ -14,7 +14,6 @@ const Recorder = require('../tabs/runTab/model/recorder.js')
const RecorderUI = require('../tabs/runTab/recorder.js')
const DropdownLogic = require('../tabs/runTab/model/dropdownlogic.js')
const ContractDropdownUI = require('../tabs/runTab/contractDropdown.js')
const Blockchain = require('../tabs/runTab/model/blockchain.js')
const UniversalDAppUI = require('../ui/universal-dapp-ui')
@ -34,13 +33,13 @@ const profile = {
export class RunTab extends LibraryPlugin {
constructor (udapp, executionContext, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) {
constructor (blockchain, udapp, executionContext, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) {
super(udapp, profile)
this.event = new EventManager()
this.config = config
this.udapp = udapp
this.executionContext = executionContext
this.blockchain = new Blockchain(this.executionContext, udapp)
this.blockchain = blockchain
this.fileManager = fileManager
this.editor = editor
this.logCallback = (msg) => { mainView.getTerminal().logHtml(msg) }

Loading…
Cancel
Save