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

pull/1/head
Iuri Matias 5 years ago
parent aff1801f69
commit fd97320952
  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

@ -25,6 +25,8 @@ var CompilerImport = require('./app/compiler/compiler-imports')
var executionContext = remixLib.execution.executionContext var executionContext = remixLib.execution.executionContext
const Blockchain = require('./app/tabs/runTab/model/blockchain.js')
const PluginManagerComponent = require('./app/components/plugin-manager-component') const PluginManagerComponent = require('./app/components/plugin-manager-component')
const CompilersArtefacts = require('./app/compiler/compiler-artefacts') const CompilersArtefacts = require('./app/compiler/compiler-artefacts')
@ -223,13 +225,17 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- fileManager servive ---------------------------- // ----------------- fileManager servive ----------------------------
const fileManager = new FileManager(editor) const fileManager = new FileManager(editor)
registry.put({api: fileManager, name: 'filemanager'}) 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 ---------------------------- // ----------------- 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) ---------------------------- // ----------------- compilation result service (can keep track of compilation results) ----------------------------
const compilersArtefacts = new CompilersArtefacts() // store all the compilation results (key represent a compiler name) const compilersArtefacts = new CompilersArtefacts() // store all the compilation results (key represent a compiler name)
registry.put({api: compilersArtefacts, name: 'compilersartefacts'}) 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)) const {eventsDecoder, txlistener} = makeUdapp(udapp, executionContext, compilersArtefacts, (domEl) => mainview.getTerminal().logHtml(domEl))
// ----------------- network service (resolve network id / name) ---------------------------- // ----------------- network service (resolve network id / name) ----------------------------
const networkModule = new NetworkModule(executionContext) const networkModule = new NetworkModule(executionContext)
@ -294,6 +300,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
registry.get('filemanager').api registry.get('filemanager').api
) )
const run = new RunTab( const run = new RunTab(
blockchain,
udapp, udapp,
executionContext, executionContext,
registry.get('config').api, registry.get('config').api,

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

@ -183,6 +183,10 @@ class Blockchain {
})(this.networkcallid) })(this.networkcallid)
} }
detectNetwork (cb) {
return this.executionContext.detectNetwork(cb)
}
newAccount (passphraseCb, cb) { newAccount (passphraseCb, cb) {
return this.udapp.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 RecorderUI = require('../tabs/runTab/recorder.js')
const DropdownLogic = require('../tabs/runTab/model/dropdownlogic.js') const DropdownLogic = require('../tabs/runTab/model/dropdownlogic.js')
const ContractDropdownUI = require('../tabs/runTab/contractDropdown.js') const ContractDropdownUI = require('../tabs/runTab/contractDropdown.js')
const Blockchain = require('../tabs/runTab/model/blockchain.js')
const UniversalDAppUI = require('../ui/universal-dapp-ui') const UniversalDAppUI = require('../ui/universal-dapp-ui')
@ -34,13 +33,13 @@ const profile = {
export class RunTab extends LibraryPlugin { 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) super(udapp, profile)
this.event = new EventManager() this.event = new EventManager()
this.config = config this.config = config
this.udapp = udapp this.udapp = udapp
this.executionContext = executionContext this.executionContext = executionContext
this.blockchain = new Blockchain(this.executionContext, udapp) this.blockchain = blockchain
this.fileManager = fileManager this.fileManager = fileManager
this.editor = editor this.editor = editor
this.logCallback = (msg) => { mainView.getTerminal().logHtml(msg) } this.logCallback = (msg) => { mainView.getTerminal().logHtml(msg) }

Loading…
Cancel
Save