Unverified Commit 7c7f624e authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1536 from ethereum/supportSeveralCompiler

Support several compiler
parents 445e673c a4ff239a
......@@ -396,6 +396,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
var offsetToLineColumnConverter = new OffsetToLineColumnConverter(self._components.compiler.event)
registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'})
self._components.compilersArtefacts = {} // store all the possible compilation data (key represent a compiler name)
registry.put({api: self._components.compilersArtefacts, name: 'compilersartefacts'})
// ----------------- UniversalDApp -----------------
var udapp = new UniversalDApp({
removable: false,
......@@ -412,9 +415,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
var txlistener = new Txlistener({
api: {
contracts: function () {
if (self._components.compiler.lastCompilationResult && self._components.compiler.lastCompilationResult.data) {
return self._components.compiler.lastCompilationResult.data.contracts
}
if (self._components.compilersArtefacts['__last']) return self._components.compilersArtefacts['__last'].getContracts()
return null
},
resolveReceipt: function (tx, cb) {
......
'use strict'
var remixLib = require('remix-lib')
var txHelper = remixLib.execution.txHelper
module.exports = class CompilerAbstract {
constructor (languageversion, data) {
this.languageversion = languageversion
this.data = data
}
getContracts () {
return this.data.contracts
}
getContract (name) {
return txHelper.getContract(name, this.data.contracts)
}
visitContracts (calllback) {
return txHelper.visitContracts(this.data.contracts, calllback)
}
getData () {
return this.data
}
}
......@@ -17,16 +17,14 @@ function Debugger (container, sourceHighlighter, localRegistry) {
this._deps = {
offsetToLineColumnConverter: this._components.registry.get('offsettolinecolumnconverter').api,
editor: this._components.registry.get('editor').api,
compiler: this._components.registry.get('compiler').api
compiler: this._components.registry.get('compiler').api,
compilersArtefacts: this._components.registry.get('compilersartefacts').api
}
this.debugger = new Ethdebugger(
{
executionContext: executionContext,
compilationResult: () => {
var compilationResult = this._deps.compiler.lastCompilationResult
if (compilationResult) {
return compilationResult.data
}
if (this._deps.compilersArtefacts['__last']) return this._deps.compilersArtefacts['__last'].getData()
return null
}
})
......
......@@ -52,7 +52,9 @@ module.exports = class RighthandPanel {
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) })
......
......@@ -44,6 +44,9 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
compiler: {
getCompilationResult: (mod, cb) => {
cb(null, compiler.lastCompilationResult)
},
sendCompilationResult: (mod, file, source, languageVersion, data, cb) => {
pluginManager.receivedDataFrom('sendCompilationResult', mod, [file, source, languageVersion, data])
}
},
udapp: {
......
'use strict'
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager
var executionContext = require('../../execution-context')
const PluginAPI = require('./pluginAPI')
/**
......@@ -80,6 +82,7 @@ const PluginAPI = require('./pluginAPI')
module.exports = class PluginManager {
constructor (app, compiler, txlistener, fileProviders, fileManager, udapp) {
const self = this
self.event = new EventManager()
var pluginAPI = new PluginAPI(
this,
fileProviders,
......@@ -90,6 +93,14 @@ module.exports = class PluginManager {
self.plugins = {}
self.origins = {}
self.inFocus
fileManager.event.register('currentFileChanged', (file, provider) => {
self.broadcast(JSON.stringify({
action: 'notification',
key: 'editor',
type: 'currentFileChanged',
value: [ file ]
}))
})
compiler.event.register('compilationFinished', (success, data, source) => {
self.broadcast(JSON.stringify({
action: 'notification',
......@@ -184,6 +195,11 @@ module.exports = class PluginManager {
this.post(this.origins[origin], value)
}
}
receivedDataFrom (methodName, mod, argumentsArray) {
// TODO check whether 'mod' as right to do that
console.log(argumentsArray)
this.event.trigger(methodName, argumentsArray)
}
post (name, value) {
const self = this
if (self.plugins[name]) {
......
This diff is collapsed.
......@@ -183,6 +183,9 @@ class MultiParamManager {
if (this.funABI.inputs && this.funABI.inputs.length > 0) {
contractProperty.classList.add(css.hasArgs)
} else if (this.funABI.type === 'fallback') {
contractProperty.classList.add(css.hasArgs)
this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden'
} else {
this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden'
this.basicInputField.style.display = 'none'
......
......@@ -13,7 +13,7 @@ var modal = require('./app/ui/modal-dialog-custom')
*
*/
class Recorder {
constructor (compiler, udapp, logCallBack) {
constructor (udapp, logCallBack) {
var self = this
self.logCallBack = logCallBack
self.event = new EventManager()
......@@ -27,25 +27,22 @@ class Recorder {
if (this.data._listen) {
var record = { value, parameters: payLoad.funArgs }
if (!to) {
var selectedContract = compiler.getContract(payLoad.contractName)
if (selectedContract) {
var abi = selectedContract.object.abi
var sha3 = ethutil.bufferToHex(ethutil.sha3(abi))
record.abi = sha3
record.contractName = payLoad.contractName
record.bytecode = payLoad.contractBytecode
record.linkReferences = selectedContract.object.evm.bytecode.linkReferences
if (record.linkReferences && Object.keys(record.linkReferences).length) {
for (var file in record.linkReferences) {
for (var lib in record.linkReferences[file]) {
self.data._linkReferences[lib] = '<address>'
}
var abi = payLoad.contractABI
var sha3 = ethutil.bufferToHex(ethutil.sha3(abi))
record.abi = sha3
record.contractName = payLoad.contractName
record.bytecode = payLoad.contractBytecode
record.linkReferences = payLoad.linkReferences
if (record.linkReferences && Object.keys(record.linkReferences).length) {
for (var file in record.linkReferences) {
for (var lib in record.linkReferences[file]) {
self.data._linkReferences[lib] = '<address>'
}
}
self.data._abis[sha3] = abi
this.data._contractABIReferences[timestamp] = sha3
}
self.data._abis[sha3] = abi
this.data._contractABIReferences[timestamp] = sha3
} else {
var creationTimestamp = this.data._createdContracts[to]
record.to = `created{${creationTimestamp}}`
......
......@@ -205,7 +205,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
}
}
// contractsDetails is used to resolve libraries
txFormat.buildData(args.contractName, args.contractAbi, self.data.contractsDetails, false, args.funABI, 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 (isUserAction) {
if (!args.funABI.constant) {
......@@ -214,6 +214,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
self._deps.logCallback(`${logMsg}`)
}
}
if (args.funABI.type === 'fallback') data.dataHex = value
self.callFunction(args.address, data, args.funABI, (error, txResult) => {
if (!error) {
var isVM = executionContext.isVM()
......@@ -349,7 +350,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
},
function runTransaction (fromAddress, value, gasLimit, next) {
var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit }
var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName }
var payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName, contractABI: args.data.contractABI, linkReferences: args.data.linkReferences }
var timestamp = Date.now()
self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
......
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