Unverified Commit 9fcfdabf authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1642 from ethereum/refactorApp.js

Refactor app.js
parents 797a73fa 9cc1385c
...@@ -26,10 +26,10 @@ jobs: ...@@ -26,10 +26,10 @@ jobs:
- checkout - checkout
- restore_cache: - restore_cache:
keys: keys:
- dep-bundle-24-{{ checksum "package.json" }} - dep-bundle-27-{{ checksum "package.json" }}
- run: npm install - run: npm install
- save_cache: - save_cache:
key: dep-bundle-24-{{ checksum "package.json" }} key: dep-bundle-27-{{ checksum "package.json" }}
paths: paths:
- ~/repo/node_modules - ~/repo/node_modules
- run: npm run lint && npm run test && npm run make-mock-compiler && npm run build - run: npm run lint && npm run test && npm run make-mock-compiler && npm run build
......
...@@ -2,14 +2,18 @@ ...@@ -2,14 +2,18 @@
var fs = require('fs') var fs = require('fs')
var compiler = require('solc') var compiler = require('solc')
var compilerInput = require('remix-solidity').CompilerInput var compilerInput = require('remix-solidity').CompilerInput
var compilationResult = {} var defaultVersion = 'v0.5.1+commit.c8a2cb62'
gatherCompilationResults('./test-browser/tests/', compilationResult)
gatherCompilationResults('./test-browser/tests/units/', compilationResult) compiler.loadRemoteVersion(defaultVersion, (error, solcSnapshot) => {
replaceSolCompiler(compilationResult) if (error) console.log(error)
var compilationResult = {}
gatherCompilationResults('./test-browser/tests/', compilationResult, solcSnapshot)
gatherCompilationResults('./test-browser/tests/units/', compilationResult, solcSnapshot)
replaceSolCompiler(compilationResult, solcSnapshot)
})
function gatherCompilationResults (dir, compilationResult, callback) { function gatherCompilationResults (dir, compilationResult, solcSnapshot) {
var filenames = fs.readdirSync(dir, 'utf8') var filenames = fs.readdirSync(dir, 'utf8')
filenames.map(function (item, i) { filenames.map(function (item, i) {
if (item.endsWith('.js')) { if (item.endsWith('.js')) {
...@@ -17,10 +21,10 @@ function gatherCompilationResults (dir, compilationResult, callback) { ...@@ -17,10 +21,10 @@ function gatherCompilationResults (dir, compilationResult, callback) {
if ('@sources' in testDef) { if ('@sources' in testDef) {
var sources = testDef['@sources']() var sources = testDef['@sources']()
for (var files in sources) { for (var files in sources) {
compile(sources[files], true, function (result) { compile(solcSnapshot, sources[files], true, function (result) {
compilationResult[result.key] = result compilationResult[result.key] = result
}) })
compile(sources[files], false, function (result) { compile(solcSnapshot, sources[files], false, function (result) {
compilationResult[result.key] = result compilationResult[result.key] = result
}) })
} }
...@@ -30,11 +34,11 @@ function gatherCompilationResults (dir, compilationResult, callback) { ...@@ -30,11 +34,11 @@ function gatherCompilationResults (dir, compilationResult, callback) {
return compilationResult return compilationResult
} }
function compile (source, optimization, addCompilationResult) { function compile (solcSnapshot, source, optimization, addCompilationResult) {
var missingInputs = [] var missingInputs = []
try { try {
var input = compilerInput(source, {optimize: optimization}) var input = compilerInput(source, {optimize: optimization})
var result = compiler.compileStandardWrapper(input, function (path) { var result = solcSnapshot.compileStandardWrapper(input, function (path) {
missingInputs.push(path) missingInputs.push(path)
}) })
input = input.replace(/(\t)|(\n)|(\\n)|( )/g, '') input = input.replace(/(\t)|(\n)|(\\n)|( )/g, '')
...@@ -51,15 +55,15 @@ function compile (source, optimization, addCompilationResult) { ...@@ -51,15 +55,15 @@ function compile (source, optimization, addCompilationResult) {
addCompilationResult(ret) addCompilationResult(ret)
} }
function replaceSolCompiler (results) { function replaceSolCompiler (results, solcSnapshot) {
fs.readFile('./test-browser/mockcompiler/compiler.js', 'utf8', function (error, data) { fs.readFile('./test-browser/mockcompiler/compiler.js', 'utf8', function (error, data) {
if (error) { if (error) {
console.log(error) console.log(error)
process.exit(1) process.exit(1)
return return
} }
console.log(compiler.version()) console.log(solcSnapshot.version())
data = data + '\n\nvar mockCompilerVersion = \'' + compiler.version() + '\'' data = data + '\n\nvar mockCompilerVersion = \'' + solcSnapshot.version() + '\''
data = data + '\n\nvar mockData = ' + JSON.stringify(results) + ';\n' data = data + '\n\nvar mockData = ' + JSON.stringify(results) + ';\n'
fs.writeFile('./soljson.js', data, 'utf8', function (error) { fs.writeFile('./soljson.js', data, 'utf8', function (error) {
if (error) { if (error) {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"remix-lib": "0.4.1", "remix-lib": "0.4.1",
"remix-solidity": "0.3.1", "remix-solidity": "0.3.1",
"remix-tests": "0.1.1", "remix-tests": "0.1.1",
"remixd": "git+https://github.com/ethereum/remixd.git", "remixd": "0.1.8-alpha.6",
"request": "^2.83.0", "request": "^2.83.0",
"rimraf": "^2.6.1", "rimraf": "^2.6.1",
"selenium-standalone": "^6.0.1", "selenium-standalone": "^6.0.1",
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
}, },
"dependencies": { "dependencies": {
"http-server": "0.9.0", "http-server": "0.9.0",
"remixd": "git+https://github.com/ethereum/remixd.git" "remixd": "0.1.8-alpha.6"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
"build_debugger": "browserify src/app/debugger/remix-debugger/index.js -o src/app/debugger/remix-debugger/build/app.js", "build_debugger": "browserify src/app/debugger/remix-debugger/index.js -o src/app/debugger/remix-debugger/build/app.js",
"browsertest": "sleep 5 && npm run nightwatch_local", "browsertest": "sleep 5 && npm run nightwatch_local",
"csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='assets/css/font-awesome.min.css' assets/css/", "csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='assets/css/font-awesome.min.css' assets/css/",
"downloadsolc_root": "wget --no-check-certificate https://solc-bin.ethereum.org/soljson.js", "downloadsolc_root": "wget --no-check-certificate https://solc-bin.ethereum.org/bin/soljson-v0.5.1+commit.c8a2cb62.js -O soljson.js",
"lint": "standard | notify-error", "lint": "standard | notify-error",
"make-mock-compiler": "node ci/makeMockCompiler.js", "make-mock-compiler": "node ci/makeMockCompiler.js",
"minify": "uglifyjs --in-source-map inline --source-map-inline -c warnings=false", "minify": "uglifyjs --in-source-map inline --source-map-inline -c warnings=false",
......
This diff is collapsed.
...@@ -3,9 +3,10 @@ var remixLib = require('remix-lib') ...@@ -3,9 +3,10 @@ var remixLib = require('remix-lib')
var txHelper = remixLib.execution.txHelper var txHelper = remixLib.execution.txHelper
module.exports = class CompilerAbstract { module.exports = class CompilerAbstract {
constructor (languageversion, data) { constructor (languageversion, data, source) {
this.languageversion = languageversion this.languageversion = languageversion
this.data = data this.data = data
this.source = source // source code
} }
getContracts () { getContracts () {
...@@ -23,4 +24,19 @@ module.exports = class CompilerAbstract { ...@@ -23,4 +24,19 @@ module.exports = class CompilerAbstract {
getData () { getData () {
return this.data return this.data
} }
getAsts () {
return this.data.sources // ast
}
getSourceName (fileIndex) {
if (this.data && this.data.sources) {
return Object.keys(this.data.sources)[fileIndex]
}
return null
}
getSourceCode () {
return this.source
}
} }
...@@ -90,16 +90,10 @@ class DebuggerUI { ...@@ -90,16 +90,10 @@ class DebuggerUI {
this.contextManager = new ContextManager() this.contextManager = new ContextManager()
this.debugger = new Debugger({
web3: this.contextManager.getWeb3(),
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compiler: this.registry.get('compiler').api
})
this.contextManager.initProviders() this.contextManager.initProviders()
this.contextManager.event.register('providerChanged', () => { this.contextManager.event.register('providerChanged', () => {
this.debugger.updateWeb3(this.contextManager.getWeb3()) if (this.debugger) this.debugger.updateWeb3(this.contextManager.getWeb3())
}) })
this.isActive = false this.isActive = false
...@@ -116,7 +110,6 @@ class DebuggerUI { ...@@ -116,7 +110,6 @@ class DebuggerUI {
container.appendChild(this.render()) container.appendChild(this.render())
this.setEditor() this.setEditor()
this.listenToEvents()
} }
setEditor () { setEditor () {
...@@ -124,20 +117,22 @@ class DebuggerUI { ...@@ -124,20 +117,22 @@ class DebuggerUI {
this.editor = this.registry.get('editor').api this.editor = this.registry.get('editor').api
self.editor.event.register('breakpointCleared', (fileName, row) => { self.editor.event.register('breakpointCleared', (fileName, row) => {
self.debugger.breakPointManager.remove({fileName: fileName, row: row}) if (self.debugger) self.debugger.breakPointManager.remove({fileName: fileName, row: row})
}) })
self.editor.event.register('breakpointAdded', (fileName, row) => { self.editor.event.register('breakpointAdded', (fileName, row) => {
self.debugger.breakPointManager.add({fileName: fileName, row: row}) if (self.debugger) self.debugger.breakPointManager.add({fileName: fileName, row: row})
}) })
self.editor.event.register('contentChanged', function () { self.editor.event.register('contentChanged', function () {
self.debugger.unload() if (self.debugger) self.debugger.unload()
}) })
} }
listenToEvents () { listenToEvents () {
const self = this const self = this
if (!self.debugger) return
this.debugger.event.register('debuggerStatus', function (isActive) { this.debugger.event.register('debuggerStatus', function (isActive) {
self.sourceHighlighter.currentSourceLocation(null) self.sourceHighlighter.currentSourceLocation(null)
self.isActive = isActive self.isActive = isActive
...@@ -156,12 +151,12 @@ class DebuggerUI { ...@@ -156,12 +151,12 @@ class DebuggerUI {
this.txBrowser = txBrowser this.txBrowser = txBrowser
txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) { txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) {
self.debugger.unload() if (self.debugger) self.debugger.unload()
self.startDebugging(blockNumber, txNumber, tx) self.startDebugging(blockNumber, txNumber, tx)
}) })
txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) {
self.debugger.unload() if (self.debugger) self.debugger.unload()
}) })
} }
...@@ -171,6 +166,20 @@ class DebuggerUI { ...@@ -171,6 +166,20 @@ class DebuggerUI {
startDebugging (blockNumber, txNumber, tx) { startDebugging (blockNumber, txNumber, tx) {
const self = this const self = this
if (this.debugger) delete this.debugger
let compilers = this.registry.get('compilersartefacts').api
let lastCompilationResult
if (compilers['__last']) lastCompilationResult = compilers['__last']
// TODO debugging with source highlight is disabled. see line 98
this.debugger = new Debugger({
web3: this.contextManager.getWeb3(),
offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api,
compiler: { lastCompilationResult }
})
this.listenToEvents()
this.debugger.debugger.updateWeb3(this.executionContext.web3()) this.debugger.debugger.updateWeb3(this.executionContext.web3())
this.debugger.debug(blockNumber, txNumber, tx, () => { this.debugger.debug(blockNumber, txNumber, tx, () => {
......
...@@ -21,7 +21,7 @@ class ContextView { ...@@ -21,7 +21,7 @@ class ContextView {
self.contextualListener = opts.contextualListener self.contextualListener = opts.contextualListener
self.editor = opts.editor self.editor = opts.editor
self._deps = { self._deps = {
compiler: self._components.registry.get('compiler').api, compilersArtefacts: self._components.registry.get('compilersartefacts').api,
offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api, offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
fileManager: self._components.registry.get('filemanager').api fileManager: self._components.registry.get('filemanager').api
...@@ -97,9 +97,14 @@ class ContextView { ...@@ -97,9 +97,14 @@ class ContextView {
self.editor.gotoLine(lineColumn.start.line, lineColumn.end.column + 1) self.editor.gotoLine(lineColumn.start.line, lineColumn.end.column + 1)
} }
} }
if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { let lastCompilationResult = self._deps.compilersArtefacts['__last']
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) if (lastCompilationResult && lastCompilationResult.data) {
var filename = self._deps.compiler.getSourceName(position.file) var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(
position,
position.file,
lastCompilationResult.getSourceCode().sources,
lastCompilationResult.getAsts())
var filename = lastCompilationResult.getSourceName(position.file)
// TODO: refactor with rendererAPI.errorClick // TODO: refactor with rendererAPI.errorClick
if (filename !== self._deps.config.get('currentFile')) { if (filename !== self._deps.config.get('currentFile')) {
var provider = self._deps.fileManager.fileProviderOf(filename) var provider = self._deps.fileManager.fileProviderOf(filename)
......
...@@ -15,8 +15,9 @@ class ContextualListener { ...@@ -15,8 +15,9 @@ class ContextualListener {
self._components = {} self._components = {}
self._components.registry = localRegistry || globalRegistry self._components.registry = localRegistry || globalRegistry
self.editor = opts.editor self.editor = opts.editor
self.pluginManager = opts.pluginManager
self._deps = { self._deps = {
compiler: self._components.registry.get('compiler').api, compilersArtefacts: self._components.registry.get('compilersartefacts').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api
} }
...@@ -26,15 +27,13 @@ class ContextualListener { ...@@ -26,15 +27,13 @@ class ContextualListener {
} }
this._activeHighlights = [] this._activeHighlights = []
self._deps.compiler.event.register('compilationFinished', (success, data, source) => { self.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => {
this._stopHighlighting() this._stopHighlighting()
this._index = { this._index = {
Declarations: {}, Declarations: {},
FlatReferences: {} FlatReferences: {}
} }
if (success) { this._buildIndex(data, source)
this._buildIndex(data, source)
}
}) })
self.editor.event.register('contentChanged', () => { this._stopHighlighting() }) self.editor.event.register('contentChanged', () => { this._stopHighlighting() })
...@@ -42,7 +41,9 @@ class ContextualListener { ...@@ -42,7 +41,9 @@ class ContextualListener {
this.sourceMappingDecoder = new SourceMappingDecoder() this.sourceMappingDecoder = new SourceMappingDecoder()
this.astWalker = new AstWalker() this.astWalker = new AstWalker()
setInterval(() => { setInterval(() => {
this._highlightItems(self.editor.getCursorPosition(), self._deps.compiler.lastCompilationResult, self._deps.config.get('currentFile')) if (self._deps.compilersArtefacts['__last']) {
this._highlightItems(self.editor.getCursorPosition(), self._deps.compilersArtefacts['__last'], self._deps.config.get('currentFile'))
}
}, 1000) }, 1000)
} }
...@@ -106,15 +107,17 @@ class ContextualListener { ...@@ -106,15 +107,17 @@ class ContextualListener {
var self = this var self = this
var position = this.sourceMappingDecoder.decode(node.src) var position = this.sourceMappingDecoder.decode(node.src)
var eventId = this._highlightInternal(position, node) var eventId = this._highlightInternal(position, node)
if (eventId) { let lastCompilationResult = self._deps.compilersArtefacts['__last']
this._activeHighlights.push({ eventId, position, fileTarget: self._deps.compiler.getSourceName(position.file), nodeId: node.id }) if (eventId && lastCompilationResult) {
this._activeHighlights.push({ eventId, position, fileTarget: lastCompilationResult.getSourceName(position.file), nodeId: node.id })
} }
} }
_highlightInternal (position, node) { _highlightInternal (position, node) {
var self = this var self = this
if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { let lastCompilationResult = self._deps.compilersArtefacts['__last']
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) if (lastCompilationResult) {
var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, lastCompilationResult.getSourceCode().sources, lastCompilationResult.getAsts())
var css = 'highlightreference' var css = 'highlightreference'
if (node.children && node.children.length) { if (node.children && node.children.length) {
// If node has children, highlight the entire line. if not, just highlight the current source position of the node. // If node has children, highlight the entire line. if not, just highlight the current source position of the node.
...@@ -130,7 +133,7 @@ class ContextualListener { ...@@ -130,7 +133,7 @@ class ContextualListener {
} }
} }
} }
var fileName = self._deps.compiler.getSourceName(position.file) var fileName = lastCompilationResult.getSourceName(position.file)
if (fileName) { if (fileName) {
return self.editor.addMarker(lineColumn, fileName, css) return self.editor.addMarker(lineColumn, fileName, css)
} }
......
...@@ -14,7 +14,7 @@ class SourceHighlighter { ...@@ -14,7 +14,7 @@ class SourceHighlighter {
editor: self._components.registry.get('editor').api, editor: self._components.registry.get('editor').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
fileManager: self._components.registry.get('filemanager').api, fileManager: self._components.registry.get('filemanager').api,
compiler: self._components.registry.get('compiler').api compilerArtefacts: self._components.registry.get('compilersartefacts').api
} }
this.statementMarker = null this.statementMarker = null
this.fullLineMarker = null this.fullLineMarker = null
...@@ -24,8 +24,9 @@ class SourceHighlighter { ...@@ -24,8 +24,9 @@ class SourceHighlighter {
currentSourceLocation (lineColumnPos, location) { currentSourceLocation (lineColumnPos, location) {
if (this.statementMarker) this._deps.editor.removeMarker(this.statementMarker, this.source) if (this.statementMarker) this._deps.editor.removeMarker(this.statementMarker, this.source)
if (this.fullLineMarker) this._deps.editor.removeMarker(this.fullLineMarker, this.source) if (this.fullLineMarker) this._deps.editor.removeMarker(this.fullLineMarker, this.source)
if (location && location.file !== undefined) { let lastCompilationResult = this._deps.compilerArtefacts['__last']
var path = this._deps.compiler.getSourceName(location.file) if (location && location.file !== undefined && lastCompilationResult) {
var path = lastCompilationResult.getSourceName(location.file)
if (path) { if (path) {
this.currentSourceLocationFromfileName(lineColumnPos, path) this.currentSourceLocationFromfileName(lineColumnPos, path)
} }
......
...@@ -142,7 +142,7 @@ class TxLogger { ...@@ -142,7 +142,7 @@ class TxLogger {
editorPanel: this._components.registry.get('editorpanel').api, editorPanel: this._components.registry.get('editorpanel').api,
txListener: this._components.registry.get('txlistener').api, txListener: this._components.registry.get('txlistener').api,
eventsDecoder: this._components.registry.get('eventsdecoder').api, eventsDecoder: this._components.registry.get('eventsdecoder').api,
compiler: this._components.registry.get('compiler').api, compilersArtefacts: this._components.registry.get('compilersartefacts').api,
app: this._components.registry.get('app').api app: this._components.registry.get('app').api
} }
...@@ -216,8 +216,8 @@ function log (self, tx, receipt) { ...@@ -216,8 +216,8 @@ function log (self, tx, receipt) {
var resolvedTransaction = self._deps.txListener.resolvedTransaction(tx.hash) var resolvedTransaction = self._deps.txListener.resolvedTransaction(tx.hash)
if (resolvedTransaction) { if (resolvedTransaction) {
var compiledContracts = null var compiledContracts = null
if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { if (self._deps.compilersArtefacts['__last']) {
compiledContracts = self._deps.compiler.lastCompilationResult.data.contracts compiledContracts = self._deps.compilersArtefacts['__last'].getContracts()
} }
self._deps.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, (error, logs) => { self._deps.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, (error, logs) => {
if (!error) { if (!error) {
......
/* global chrome */
'use strict'
var modalDialogCustom = require('../ui/modal-dialog-custom')
module.exports = function (filesProviders) {
if (typeof chrome === 'undefined' || !chrome || !chrome.storage || !chrome.storage.sync) {
return
}
var obj = {}
var done = false
var count = 0
function check (key) {
chrome.storage.sync.get(key, function (resp) {
console.log('comparing to cloud', key, resp)
function confirmDialog (callback) {
modalDialogCustom.confirm('', 'Overwrite "' + key + '"? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.', () => { callback(true) }, () => { callback(false) })
}
if (typeof resp[key] !== 'undefined' && obj[key] !== resp[key]) {
confirmDialog((result) => {
if (result) {
console.log('Overwriting', key)
filesProviders['browser'].set(key, resp[key])
}
})
} else {
console.log('add to obj', obj, key)
filesProviders['browser'].get(key, (error, content) => {
if (error) {
console.log(error)
} else {
obj[key] = content
}
})
}
done++
if (done >= count) {
chrome.storage.sync.set(obj, function () {
console.log('updated cloud files with: ', obj, this, arguments)
})
}
})
}
filesProviders['browser'].resolve('browser', (error, files) => {
if (!error) {
Object.keys(files).forEach((path) => {
filesProviders['browser'].get(path, (error, content) => {
if (error) {
console.log(error)
} else {
obj[path] = content
count++
check(path)
}
})
})
}
})
}
'use strict' 'use strict'
var executionContext = require('../../execution-context') var executionContext = require('../../execution-context')
var CompilerAbstract = require('../compiler/compiler-abstract')
class CompilerMetadata { class CompilerMetadata {
constructor (events, opts) { constructor (opts) {
var self = this var self = this
self._events = events
self._opts = opts self._opts = opts
self.networks = ['VM:-', 'main:1', 'ropsten:3', 'rinkeby:4', 'kovan:42', 'Custom'] self.networks = ['VM:-', 'main:1', 'ropsten:3', 'rinkeby:4', 'kovan:42', 'Custom']
} }
syncContractMetadata () { syncContractMetadata () {
var self = this var self = this
self._events.compiler.register('compilationFinished', (success, data, source) => { self._opts.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => {
if (!success) return
if (!self._opts.config.get('settings/generate-contract-metadata')) return if (!self._opts.config.get('settings/generate-contract-metadata')) return
let compiler = new CompilerAbstract(languageVersion, data, source)
var provider = self._opts.fileManager.currentFileProvider() var provider = self._opts.fileManager.currentFileProvider()
var path = self._opts.fileManager.currentPath() var path = self._opts.fileManager.currentPath()
if (provider && path) { if (provider && path) {
self._opts.compiler.visitContracts((contract) => { compiler.visitContracts((contract) => {
if (contract.file !== source.target) return if (contract.file !== source.target) return
var fileName = path + '/' + contract.name + '.json' var fileName = path + '/' + contract.name + '.json'
......
...@@ -4,6 +4,7 @@ var $ = require('jquery') ...@@ -4,6 +4,7 @@ var $ = require('jquery')
var yo = require('yo-yo') var yo = require('yo-yo')
var EventManager = require('../../lib/events') var EventManager = require('../../lib/events')
var globalRegistry = require('../../global/registry') var globalRegistry = require('../../global/registry')
var CompilerImport = require('../compiler/compiler-imports')
/* /*
attach to files event (removed renamed) attach to files event (removed renamed)
...@@ -15,13 +16,13 @@ class FileManager { ...@@ -15,13 +16,13 @@ class FileManager {
this.tabbedFiles = {} this.tabbedFiles = {}
this.event = new EventManager() this.event = new EventManager()
this._components = {} this._components = {}
this._components.compilerImport = new CompilerImport()
this._components.registry = localRegistry || globalRegistry this._components.registry = localRegistry || globalRegistry
} }
init () { init () {
var self = this var self = this
self._deps = { self._deps = {
compilerImport: self._components.registry.get('compilerimport').api,
editor: self._components.registry.get('editor').api, editor: self._components.registry.get('editor').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
browserExplorer: self._components.registry.get('fileproviders/browser').api, browserExplorer: self._components.registry.get('fileproviders/browser').api,
...@@ -182,7 +183,7 @@ class FileManager { ...@@ -182,7 +183,7 @@ class FileManager {
if (provider !== null && this._deps.filesProviders[provider[0]]) { if (provider !== null && this._deps.filesProviders[provider[0]]) {
return this._deps.filesProviders[provider[0]] return this._deps.filesProviders[provider[0]]
} else { } else {
for (var handler of this._deps.compilerImport.handlers()) { for (var handler of this._components.compilerImport.handlers()) {
if (handler.match.exec(file)) { if (handler.match.exec(file)) {
return this._deps.filesProviders[handler.type] return this._deps.filesProviders[handler.type]
} }
......
...@@ -26,7 +26,7 @@ class EditorPanel { ...@@ -26,7 +26,7 @@ class EditorPanel {
txListener: self._components.registry.get('txlistener').api, txListener: self._components.registry.get('txlistener').api,
fileManager: self._components.registry.get('filemanager').api, fileManager: self._components.registry.get('filemanager').api,
udapp: self._components.registry.get('udapp').api, udapp: self._components.registry.get('udapp').api,
compiler: self._components.registry.get('compiler').api pluginManager: self._components.registry.get('pluginmanager').api
} }
self.data = { self.data = {
_FILE_SCROLL_DELTA: 200, _FILE_SCROLL_DELTA: 200,
...@@ -40,16 +40,18 @@ class EditorPanel { ...@@ -40,16 +40,18 @@ class EditorPanel {
self._view = {} self._view = {}
var editor = new Editor({}) var editor = new Editor({})
self._components.registry.put({api: editor, name: 'editor'}) self._components.registry.put({api: editor, name: 'editor'})
var contextualListener = new ContextualListener({editor: editor})
var contextualListener = new ContextualListener({editor, pluginManager: self._deps.pluginManager})
var contextView = new ContextView({contextualListener, editor})
self._components = { self._components = {
editor: editor, editor: editor,
contextualListener: contextualListener, contextualListener: contextualListener,
contextView: new ContextView({contextualListener: contextualListener, editor: editor}), contextView: contextView,
// TODO list of compilers is always empty; should find a path to add plugin compiler here
terminal: new Terminal({ terminal: new Terminal({
udapp: self._deps.udapp, udapp: self._deps.udapp,
compilers: { compilers: {}
'solidity': self._deps.compiler
}
}, },
{ {
getPosition: (event) => { getPosition: (event) => {
......
...@@ -49,7 +49,7 @@ function filepanel (localRegistry) { ...@@ -49,7 +49,7 @@ function filepanel (localRegistry) {
fileProviders: self._components.registry.get('fileproviders').api, fileProviders: self._components.registry.get('fileproviders').api,
fileManager: self._components.registry.get('filemanager').api, fileManager: self._components.registry.get('filemanager').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
compiler: self._components.registry.get('compiler').api pluginManager: self._components.registry.get('pluginmanager').api
} }
var fileExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['browser']) var fileExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['browser'])
var fileSystemExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['localhost']) var fileSystemExplorer = new FileExplorer(self._components.registry, self._deps.fileProviders['localhost'])
...@@ -63,11 +63,8 @@ function filepanel (localRegistry) { ...@@ -63,11 +63,8 @@ function filepanel (localRegistry) {
// ----------------- editor panel ---------------------- // ----------------- editor panel ----------------------
self._compilerMetadata = new CompilerMetadata( self._compilerMetadata = new CompilerMetadata(
{ {
compiler: self._deps.compiler.event
},
{
fileManager: self._deps.fileManager, fileManager: self._deps.fileManager,
compiler: self._deps.compiler, pluginManager: self._deps.pluginManager,
config: self._deps.config config: self._deps.config
} }
) )
......
...@@ -5,22 +5,14 @@ const EventManager = require('../../lib/events') ...@@ -5,22 +5,14 @@ const EventManager = require('../../lib/events')
var globalRegistry = require('../../global/registry') var globalRegistry = require('../../global/registry')
const styleguide = require('../ui/styles-guide/theme-chooser') const styleguide = require('../ui/styles-guide/theme-chooser')
const PluginManager = require('../plugin/pluginManager')
const TabbedMenu = require('../tabs/tabbed-menu') const TabbedMenu = require('../tabs/tabbed-menu')
const CompileTab = require('../tabs/compile-tab')
const SettingsTab = require('../tabs/settings-tab')
const AnalysisTab = require('../tabs/analysis-tab')
const DebuggerTab = require('../tabs/debugger-tab')
const SupportTab = require('../tabs/support-tab')
const PluginTab = require('../tabs/plugin-tab') const PluginTab = require('../tabs/plugin-tab')
const TestTab = require('../tabs/test-tab')
const RunTab = require('../tabs/run-tab')
const DraggableContent = require('../ui/draggableContent') const DraggableContent = require('../ui/draggableContent')
const styles = styleguide.chooser() const styles = styleguide.chooser()
module.exports = class RighthandPanel { module.exports = class RighthandPanel {
constructor (localRegistry) { constructor ({pluginManager, tabs}, localRegistry) {
const self = this const self = this
self._components = {} self._components = {}
self._components.registry = localRegistry || globalRegistry self._components.registry = localRegistry || globalRegistry
...@@ -33,57 +25,25 @@ module.exports = class RighthandPanel { ...@@ -33,57 +25,25 @@ module.exports = class RighthandPanel {
dragbar: null dragbar: null
} }
self._deps = {
fileProviders: self._components.registry.get('fileproviders').api,
fileManager: self._components.registry.get('filemanager').api,
compiler: self._components.registry.get('compiler').api,
udapp: self._components.registry.get('udapp').api,
app: self._components.registry.get('app').api,
txlistener: self._components.registry.get('txlistener').api
}
var tabbedMenu = new TabbedMenu(self._components.registry) var tabbedMenu = new TabbedMenu(self._components.registry)
var pluginManager = new PluginManager(
self._deps.app,
self._deps.compiler,
self._deps.txlistener,
self._deps.fileProviders,
self._deps.fileManager,
self._deps.udapp
)
self._components.registry.put({api: pluginManager, name: 'pluginmanager'})
var analysisTab = new AnalysisTab(self._components.registry)
analysisTab.event.register('newStaticAnaysisWarningMessage', (msg, settings) => { self._components.compile.addWarning(msg, settings) })
self._components.debuggerTab = new DebuggerTab(self._components.registry)
self._components = { self._components = {
pluginManager: pluginManager,
tabbedMenu: tabbedMenu, tabbedMenu: tabbedMenu,
compile: new CompileTab(self._components.registry), tabs
run: new RunTab(self._components.registry),
settings: new SettingsTab(self._components.registry),
analysis: analysisTab,
debug: self._components.debuggerTab,
support: new SupportTab(self._components.registry),
test: new TestTab(self._components.registry)
} }
self._components.settings.event.register('plugin-loadRequest', json => { self._components.tabs.settings.event.register('plugin-loadRequest', json => {
self.loadPlugin(json) self.loadPlugin(json)
}) })
self.loadPlugin = function (json) { self.loadPlugin = function (json) {
var modal = new DraggableContent(() => { var modal = new DraggableContent(() => {
self._components.pluginManager.unregister(json) pluginManager.unregister(json)
}) })
var tab = new PluginTab(json) var tab = new PluginTab(json)
var content = tab.render() var content = tab.render()
document.querySelector('body').appendChild(modal.render(json.title, json.url, content)) document.querySelector('body').appendChild(modal.render(json.title, json.url, content))
self._components.pluginManager.register(json, modal, content) pluginManager.register(json, modal, content)
} }
self._view.dragbar = yo`<div id="dragbar" class=${css.dragbar}></div>` self._view.dragbar = yo`<div id="dragbar" class=${css.dragbar}></div>`
...@@ -96,7 +56,7 @@ module.exports = class RighthandPanel { ...@@ -96,7 +56,7 @@ module.exports = class RighthandPanel {
</div> </div>
</div>` </div>`
const { compile, run, settings, analysis, debug, support, test } = self._components const { compile, run, settings, analysis, debug, support, test } = tabs
self._components.tabbedMenu.addTab('Compile', 'compileView', compile.render()) self._components.tabbedMenu.addTab('Compile', 'compileView', compile.render())
self._components.tabbedMenu.addTab('Run', 'runView', run.render()) self._components.tabbedMenu.addTab('Run', 'runView', run.render())
self._components.tabbedMenu.addTab('Analysis', 'staticanalysisView', analysis.render()) self._components.tabbedMenu.addTab('Analysis', 'staticanalysisView', analysis.render())
...@@ -106,11 +66,7 @@ module.exports = class RighthandPanel { ...@@ -106,11 +66,7 @@ module.exports = class RighthandPanel {
self._components.tabbedMenu.addTab('Support', 'supportView', support.render()) self._components.tabbedMenu.addTab('Support', 'supportView', support.render())
self._components.tabbedMenu.selectTabByTitle('Compile') self._components.tabbedMenu.selectTabByTitle('Compile')
} }
// showDebugger () {
// const self = this
// if (!self._components.tabbedMenu) return
// self._components.tabbedMenu.selectTab(self._view.el.querySelector('li.debugView'))
// }
render () { render () {
const self = this const self = this
if (self._view.element) return self._view.element if (self._view.element) return self._view.element
...@@ -118,7 +74,7 @@ module.exports = class RighthandPanel { ...@@ -118,7 +74,7 @@ module.exports = class RighthandPanel {
} }
debugger () { debugger () {
return this._components.debug.debugger() return this._components.tabs.debug.debugger()
} }
focusOn (x) { focusOn (x) {
......
...@@ -4,7 +4,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter') ...@@ -4,7 +4,7 @@ var SourceHighlighter = require('../editor/sourceHighlighter')
/* /*
Defines available API. `key` / `type` Defines available API. `key` / `type`
*/ */
module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => { module.exports = (pluginManager, fileProviders, fileManager, compilesrArtefacts, udapp) => {
let highlighters = {} let highlighters = {}
return { return {
app: { app: {
...@@ -51,7 +51,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => ...@@ -51,7 +51,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
}, },
compiler: { compiler: {
getCompilationResult: (mod, cb) => { getCompilationResult: (mod, cb) => {
cb(null, compiler.lastCompilationResult) cb(null, compilesrArtefacts['__last'])
}, },
sendCompilationResult: (mod, file, source, languageVersion, data, cb) => { sendCompilationResult: (mod, file, source, languageVersion, data, cb) => {
pluginManager.receivedDataFrom('sendCompilationResult', mod, [file, source, languageVersion, data]) pluginManager.receivedDataFrom('sendCompilationResult', mod, [file, source, languageVersion, data])
......
...@@ -79,14 +79,14 @@ const PluginAPI = require('./pluginAPI') ...@@ -79,14 +79,14 @@ const PluginAPI = require('./pluginAPI')
* *
*/ */
module.exports = class PluginManager { module.exports = class PluginManager {
constructor (app, compiler, txlistener, fileProviders, fileManager, udapp) { constructor (app, compilersArtefacts, txlistener, fileProviders, fileManager, udapp) {
const self = this const self = this
self.event = new EventManager() self.event = new EventManager()
var pluginAPI = new PluginAPI( var pluginAPI = new PluginAPI(
this, this,
fileProviders, fileProviders,
fileManager, fileManager,
compiler, compilersArtefacts,
udapp udapp
) )
self._components = { pluginAPI } self._components = { pluginAPI }
...@@ -101,14 +101,6 @@ module.exports = class PluginManager { ...@@ -101,14 +101,6 @@ module.exports = class PluginManager {
value: [ file ] value: [ file ]
})) }))
}) })
compiler.event.register('compilationFinished', (success, data, source) => {
self.broadcast(JSON.stringify({
action: 'notification',
key: 'compiler',
type: 'compilationFinished',
value: [ success, data, source ]
}))
})
txlistener.event.register('newTransaction', (tx) => { txlistener.event.register('newTransaction', (tx) => {
self.broadcast(JSON.stringify({ self.broadcast(JSON.stringify({
...@@ -119,38 +111,6 @@ module.exports = class PluginManager { ...@@ -119,38 +111,6 @@ module.exports = class PluginManager {
})) }))
}) })
app.event.register('tabChanged', (tabName) => {
// TODO Fix this cause this event is no longer triggered
if (self.inFocus && self.inFocus !== tabName) {
// trigger unfocus
self.post(self.inFocus, JSON.stringify({
action: 'notification',
key: 'app',
type: 'unfocus',
value: []
}))
}
if (self.plugins[tabName]) {
// trigger focus
self.post(tabName, JSON.stringify({
action: 'notification',
key: 'app',
type: 'focus',
value: []
}))
self.inFocus = tabName
pluginAPI.compiler.getCompilationResult(tabName, (error, data) => {
if (!error) return
self.post(tabName, JSON.stringify({
action: 'notification',
key: 'compiler',
type: 'compilationData',
value: [data]
}))
})
}
})
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
if (event.type !== 'message') return if (event.type !== 'message') return
var extension = self.origins[event.origin] var extension = self.origins[event.origin]
...@@ -202,7 +162,13 @@ module.exports = class PluginManager { ...@@ -202,7 +162,13 @@ module.exports = class PluginManager {
receivedDataFrom (methodName, mod, argumentsArray) { receivedDataFrom (methodName, mod, argumentsArray) {
// TODO check whether 'mod' as right to do that // TODO check whether 'mod' as right to do that
console.log(argumentsArray) console.log(argumentsArray)
this.event.trigger(methodName, argumentsArray) this.event.trigger(methodName, argumentsArray) // forward to internal modules
this.broadcast(JSON.stringify({ // forward to plugins
action: 'notification',
key: mod,
type: methodName,
value: argumentsArray
}))
} }
post (name, value) { post (name, value) {
const self = this const self = this
......
...@@ -25,21 +25,19 @@ function staticAnalysisView (localRegistry) { ...@@ -25,21 +25,19 @@ function staticAnalysisView (localRegistry) {
self._components.registry = localRegistry || globlalRegistry self._components.registry = localRegistry || globlalRegistry
// dependencies // dependencies
self._deps = { self._deps = {
compiler: self._components.registry.get('compiler').api, pluginManager: self._components.registry.get('pluginmanager').api,
renderer: self._components.registry.get('renderer').api, renderer: self._components.registry.get('renderer').api,
offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api
} }
self._deps.compiler.event.register('compilationFinished', function (success, data, source) { self._deps.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => {
self.lastCompilationResult = null self.lastCompilationResult = null
self.lastCompilationSource = null self.lastCompilationSource = null
$('#staticanalysisresult').empty() $('#staticanalysisresult').empty()
if (success) { self.lastCompilationResult = data
self.lastCompilationResult = data self.lastCompilationSource = source
self.lastCompilationSource = source if (self.view.querySelector('#autorunstaticanalysis').checked) {
if (self.view.querySelector('#autorunstaticanalysis').checked) { self.run()
self.run()
}
} }
}) })
} }
...@@ -113,7 +111,10 @@ staticAnalysisView.prototype.run = function () { ...@@ -113,7 +111,10 @@ staticAnalysisView.prototype.run = function () {
start: parseInt(split[0]), start: parseInt(split[0]),
length: parseInt(split[1]) length: parseInt(split[1])
} }
location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, parseInt(file), self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location,
parseInt(file),
self.lastCompilationSource.sources,
self.lastCompilationResult.sources)
location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':' location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':'
} }
warningCount++ warningCount++
......
...@@ -13,17 +13,15 @@ module.exports = class AnalysisTab { ...@@ -13,17 +13,15 @@ module.exports = class AnalysisTab {
self.data = {} self.data = {}
self._components = {} self._components = {}
self._components.registry = localRegistry || globalRegistry self._components.registry = localRegistry || globalRegistry
self._deps = { self._deps = {}
rightHandPanel: self._components.registry.get('righthandpanel').api
}
} }
render () { render () {
const self = this const self = this
var staticanalysis = new StaticAnalysis() var staticanalysis = new StaticAnalysis()
staticanalysis.event.register('staticAnaysisWarning', (count) => { staticanalysis.event.register('staticAnaysisWarning', (count) => {
if (count > 0) { if (count > 0) {
const msg = `Static Analysis raised ${count} warning(s) that requires your attention. Click here to show the warning(s).` const msg = `Static Analysis raised ${count} warning(s) that requires your attention. Check Solidity Static Analysis Module for more information.`
const settings = { type: 'staticAnalysisWarning', click: () => self._deps.rightHandPanel.focusOn('staticanalysisView'), useSpan: true } const settings = { type: 'staticAnalysisWarning', useSpan: true }
self.event.trigger('newStaticAnaysisWarningMessage', [msg, settings]) self.event.trigger('newStaticAnaysisWarningMessage', [msg, settings])
} }
}) })
......
This diff is collapsed.
...@@ -71,7 +71,6 @@ function runTab (opts, localRegistry) { ...@@ -71,7 +71,6 @@ function runTab (opts, localRegistry) {
} }
// dependencies // dependencies
self._deps = { self._deps = {
compiler: self._components.registry.get('compiler').api,
udapp: self._components.registry.get('udapp').api, udapp: self._components.registry.get('udapp').api,
udappUI: self._components.registry.get('udappUI').api, udappUI: self._components.registry.get('udappUI').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
...@@ -310,21 +309,10 @@ function contractDropdown (events, self) { ...@@ -310,21 +309,10 @@ function contractDropdown (events, self) {
} }
self._deps.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => { self._deps.pluginManager.event.register('sendCompilationResult', (file, source, languageVersion, data) => {
// TODO check whether the tab is configured let compiler = new CompilerAbstract(languageVersion, data, source)
let compiler = new CompilerAbstract(languageVersion, data)
self._deps.compilersArtefacts[languageVersion] = compiler
self._deps.compilersArtefacts['__last'] = compiler
newlyCompiled(true, data, source, compiler, languageVersion) newlyCompiled(true, data, source, compiler, languageVersion)
}) })
self._deps.compiler.event.register('compilationFinished', (success, data, source) => {
var name = 'solidity'
let compiler = new CompilerAbstract(name, data)
self._deps.compilersArtefacts[name] = compiler
self._deps.compilersArtefacts['__last'] = compiler
newlyCompiled(success, data, source, self._deps.compiler, name)
})
var deployAction = (value) => { var deployAction = (value) => {
self._view.createPanel.style.display = value self._view.createPanel.style.display = value
self._view.orLabel.style.display = value self._view.orLabel.style.display = value
...@@ -350,7 +338,7 @@ function contractDropdown (events, self) { ...@@ -350,7 +338,7 @@ function contractDropdown (events, self) {
function getSelectedContract () { function getSelectedContract () {
var contract = selectContractNames.children[selectContractNames.selectedIndex] var contract = selectContractNames.children[selectContractNames.selectedIndex]
var contractName = contract.innerHTML var contractName = contract.innerHTML
var compiler = self._deps.compilersArtefacts[contract.getAttribute('compiler')] var compiler = self._deps.compilersArtefacts['__last']
if (!compiler) return null if (!compiler) return null
if (contractName) { if (contractName) {
......
...@@ -18,11 +18,9 @@ module.exports = class SettingsTab { ...@@ -18,11 +18,9 @@ module.exports = class SettingsTab {
self._components.registry = localRegistry || globalRegistry self._components.registry = localRegistry || globalRegistry
// dependencies // dependencies
self._deps = { self._deps = {
compiler: self._components.registry.get('compiler').api,
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
editorPanel: self._components.registry.get('editorpanel').api, editorPanel: self._components.registry.get('editorpanel').api,
editor: self._components.registry.get('editor').api, editor: self._components.registry.get('editor').api
righthandpanel: self._components.registry.get('righthandpanel').api
} }
self._view = { /* eslint-disable */ self._view = { /* eslint-disable */
el: null, el: null,
......
...@@ -8,15 +8,16 @@ var css = require('./styles/test-tab-styles') ...@@ -8,15 +8,16 @@ var css = require('./styles/test-tab-styles')
var remixTests = require('remix-tests') var remixTests = require('remix-tests')
module.exports = class TestTab { module.exports = class TestTab {
constructor (localRegistry) { constructor (localRegistry, compileTab) {
// TODO here is a direct reference to compile tab, should be removed
const self = this const self = this
self.compileTab = compileTab
self._view = { el: null } self._view = { el: null }
self._components = {} self._components = {}
self._components.registry = localRegistry || globalRegistry self._components.registry = localRegistry || globalRegistry
// dependencies // dependencies
self._deps = { self._deps = {
fileManager: self._components.registry.get('filemanager').api, fileManager: self._components.registry.get('filemanager').api,
app: self._components.registry.get('app').api,
filePanel: self._components.registry.get('filepanel').api filePanel: self._components.registry.get('filepanel').api
} }
self.data = {} self.data = {}
...@@ -76,7 +77,7 @@ module.exports = class TestTab { ...@@ -76,7 +77,7 @@ module.exports = class TestTab {
remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => {
updateFinalResult(error, result, testFilePath) updateFinalResult(error, result, testFilePath)
callback(error) callback(error)
}, (url, cb) => { self._deps.app.importFileCb(url, cb) }) }, (url, cb) => { self.compileTab.importFileCb(url, cb) })
} }
}) })
} }
......
...@@ -24,7 +24,7 @@ class CmdInterpreterAPI { ...@@ -24,7 +24,7 @@ class CmdInterpreterAPI {
app: self._components.registry.get('app').api, app: self._components.registry.get('app').api,
fileManager: self._components.registry.get('filemanager').api, fileManager: self._components.registry.get('filemanager').api,
editor: self._components.registry.get('editor').api, editor: self._components.registry.get('editor').api,
compiler: self._components.registry.get('compiler').api, compilersArtefacts: self._components.registry.get('compilersartefacts').api,
offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api
} }
self.commandHelp = { self.commandHelp = {
...@@ -47,7 +47,9 @@ class CmdInterpreterAPI { ...@@ -47,7 +47,9 @@ class CmdInterpreterAPI {
self._components.sourceHighlighter.currentSourceLocation(null) self._components.sourceHighlighter.currentSourceLocation(null)
return return
} }
var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file,
self._deps.compilersArtefacts['__last'].getSourceCode().sources,
self._deps.compilersArtefacts['__last'].getAsts())
self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation)
} }
debug (hash, cb) { debug (hash, cb) {
...@@ -57,7 +59,7 @@ class CmdInterpreterAPI { ...@@ -57,7 +59,7 @@ class CmdInterpreterAPI {
if (error) return cb(error) if (error) return cb(error)
var debugSession = new RemixDebug({ var debugSession = new RemixDebug({
compilationResult: () => { compilationResult: () => {
return self._deps.compiler.lastCompilationResult.data return self._deps.compilersArtefacts['__last'].getData()
} }
}) })
debugSession.addProvider('web3', executionContext.web3()) debugSession.addProvider('web3', executionContext.web3())
...@@ -108,7 +110,9 @@ class CmdInterpreterAPI { ...@@ -108,7 +110,9 @@ class CmdInterpreterAPI {
self.d.goTo = (row) => { self.d.goTo = (row) => {
if (self._deps.editor.current()) { if (self._deps.editor.current()) {
var breakPoint = new remixLib.code.BreakpointManager(self.d, (sourceLocation) => { var breakPoint = new remixLib.code.BreakpointManager(self.d, (sourceLocation) => {
return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file,
self._deps.compilersArtefacts['__last'].getSourceCode().sources,
self._deps.compilersArtefacts['__last'].getAsts())
}) })
breakPoint.event.register('breakpointHit', (sourceLocation, currentStep) => { breakPoint.event.register('breakpointHit', (sourceLocation, currentStep) => {
self.log(null, 'step index ' + currentStep) self.log(null, 'step index ' + currentStep)
......
'use strict' 'use strict'
var SourceMappingDecoder = require('remix-lib').SourceMappingDecoder var SourceMappingDecoder = require('remix-lib').SourceMappingDecoder
function offsetToColumnConverter (compilerEvent) { function offsetToColumnConverter () {
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.sourceMappingDecoder = new SourceMappingDecoder() this.sourceMappingDecoder = new SourceMappingDecoder()
var self = this // we don't listen anymore on compilation result for clearing the cache
compilerEvent.register('compilationFinished', function (success, data, source) {
self.clear()
})
} }
offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources, asts) { offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources, asts) {
......
...@@ -31,7 +31,7 @@ function UniversalDApp (opts, localRegistry) { ...@@ -31,7 +31,7 @@ function UniversalDApp (opts, localRegistry) {
self.removable_instances = opts.removable_instances self.removable_instances = opts.removable_instances
self._deps = { self._deps = {
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
compiler: self._components.registry.get('compiler').api, compilersartefacts: self._components.registry.get('compilersartefacts').api,
logCallback: self._components.registry.get('logCallback').api logCallback: self._components.registry.get('logCallback').api
} }
executionContext.event.register('contextChanged', this, function (context) { executionContext.event.register('contextChanged', this, function (context) {
...@@ -47,10 +47,6 @@ function UniversalDApp (opts, localRegistry) { ...@@ -47,10 +47,6 @@ function UniversalDApp (opts, localRegistry) {
} }
} }
self.txRunner = new TxRunner({}, self._txRunnerAPI) self.txRunner = new TxRunner({}, self._txRunnerAPI)
self.data.contractsDetails = {}
self._deps.compiler.event.register('compilationFinished', (success, data, source) => {
self.data.contractsDetails = success && data ? data.contracts : {}
})
self.accounts = {} self.accounts = {}
self.resetEnvironment() self.resetEnvironment()
} }
...@@ -204,8 +200,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, ...@@ -204,8 +200,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
logMsg = `call to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}` logMsg = `call to ${args.contractName}.${(args.funABI.name) ? args.funABI.name : '(fallback)'}`
} }
} }
// contractsDetails is used to resolve libraries txFormat.buildData(args.contractName, args.contractAbi, self._deps.compilersartefacts['__last'].getData().contracts, false, args.funABI, args.funABI.type !== 'fallback' ? value : '', (error, data) => {
txFormat.buildData(args.contractName, args.contractAbi, self.data.contractsDetails, false, args.funABI, args.funABI.type !== 'fallback' ? value : '', (error, data) => {
if (!error) { if (!error) {
if (isUserAction) { if (isUserAction) {
if (!args.funABI.constant) { if (!args.funABI.constant) {
......
...@@ -48,7 +48,7 @@ function runTests (browser, testData) { ...@@ -48,7 +48,7 @@ function runTests (browser, testData) {
.pause(2000) .pause(2000)
.perform(function (client, done) { .perform(function (client, done) {
console.log('goToVMtraceStep') console.log('goToVMtraceStep')
contractHelper.goToVMtraceStep(browser, 55, () => { contractHelper.goToVMtraceStep(browser, 59, () => {
done() done()
}) })
}) })
......
...@@ -58,6 +58,11 @@ function runTests (browser, testData) { ...@@ -58,6 +58,11 @@ function runTests (browser, testData) {
browser.end() browser.end()
return return
} }
if (browserName === 'chrome') {
console.log('do not run remixd test for ' + browserName + ': TODO to reenable later')
browser.end()
return
}
browser browser
.waitForElementVisible('.newFile', 10000) .waitForElementVisible('.newFile', 10000)
.click('.websocketconn') .click('.websocketconn')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment