@ -27,8 +27,6 @@ var Config = require('./config')
var Renderer = require ( './app/ui/renderer' )
var Renderer = require ( './app/ui/renderer' )
var Compiler = require ( 'remix-solidity' ) . Compiler
var Compiler = require ( 'remix-solidity' ) . Compiler
var executionContext = require ( './execution-context' )
var executionContext = require ( './execution-context' )
var Debugger = require ( './app/debugger/debugger' )
var StaticAnalysis = require ( './app/staticanalysis/staticAnalysisView' )
var FilePanel = require ( './app/panels/file-panel' )
var FilePanel = require ( './app/panels/file-panel' )
var EditorPanel = require ( './app/panels/editor-panel' )
var EditorPanel = require ( './app/panels/editor-panel' )
var RighthandPanel = require ( './app/panels/righthand-panel' )
var RighthandPanel = require ( './app/panels/righthand-panel' )
@ -43,7 +41,6 @@ var BasicReadOnlyExplorer = require('./app/files/basicReadOnlyExplorer')
var NotPersistedExplorer = require ( './app/files/NotPersistedExplorer' )
var NotPersistedExplorer = require ( './app/files/NotPersistedExplorer' )
var toolTip = require ( './app/ui/tooltip' )
var toolTip = require ( './app/ui/tooltip' )
var TransactionReceiptResolver = require ( './transactionReceiptResolver' )
var TransactionReceiptResolver = require ( './transactionReceiptResolver' )
var SourceHighlighter = require ( './app/editor/sourceHighlighter' )
var styleGuide = require ( './app/ui/styles-guide/theme-chooser' )
var styleGuide = require ( './app/ui/styles-guide/theme-chooser' )
var styles = styleGuide . chooser ( )
var styles = styleGuide . chooser ( )
@ -113,6 +110,7 @@ var css = csjs`
class App {
class App {
constructor ( api = { } , events = { } , opts = { } ) {
constructor ( api = { } , events = { } , opts = { } ) {
var self = this
var self = this
this . event = new EventManager ( )
self . _components = { }
self . _components = { }
registry . put ( { api : self , name : 'app' } )
registry . put ( { api : self , name : 'app' } )
@ -230,7 +228,7 @@ class App {
}
}
runCompiler ( ) {
runCompiler ( ) {
const self = this
const self = this
if ( self . _view . transactionDebugger . isActive ) return
if ( self . _components . righthandpanel . debugger ( ) . isActive ) return
self . _components . fileManager . saveCurrentFile ( )
self . _components . fileManager . saveCurrentFile ( )
self . _components . editorpanel . getEditor ( ) . clearAnnotations ( )
self . _components . editorpanel . getEditor ( ) . clearAnnotations ( )
@ -259,7 +257,7 @@ class App {
startdebugging ( txHash ) {
startdebugging ( txHash ) {
const self = this
const self = this
self . event . trigger ( 'debuggingRequested' , [ ] )
self . event . trigger ( 'debuggingRequested' , [ ] )
self . _view . transactionDebugger . debug ( txHash )
self . _components . righthandpanel . debugger ( ) . debug ( txHash )
}
}
loadFromGist ( params ) {
loadFromGist ( params ) {
const self = this
const self = this
@ -388,10 +386,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- Compiler -----------------
// ----------------- Compiler -----------------
self . _components . compiler = new Compiler ( ( url , cb ) => self . importFileCb ( url , cb ) )
self . _components . compiler = new Compiler ( ( url , cb ) => self . importFileCb ( url , cb ) )
var compiler = self . _components . compiler
registry . put ( { api : self . _components . compiler , name : 'compiler' } )
registry . put ( { api : compiler , name : 'compiler' } )
var offsetToLineColumnConverter = new OffsetToLineColumnConverter ( compiler . event )
var offsetToLineColumnConverter = new OffsetToLineColumnConverter ( self . _components . compiler . event )
registry . put ( { api : offsetToLineColumnConverter , name : 'offsettolinecolumnconverter' } )
registry . put ( { api : offsetToLineColumnConverter , name : 'offsettolinecolumnconverter' } )
// ----------------- UniversalDApp -----------------
// ----------------- UniversalDApp -----------------
@ -407,15 +404,14 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// ----------------- Tx listener -----------------
// ----------------- Tx listener -----------------
var transactionReceiptResolver = new TransactionReceiptResolver ( )
var transactionReceiptResolver = new TransactionReceiptResolver ( )
var compiledContracts = function ( ) {
if ( compiler . lastCompilationResult && compiler . lastCompilationResult . data ) {
return compiler . lastCompilationResult . data . contracts
}
return null
}
var txlistener = new Txlistener ( {
var txlistener = new Txlistener ( {
api : {
api : {
contracts : compiledContracts ,
contracts : function ( ) {
if ( self . _components . compiler . lastCompilationResult && self . _components . compiler . lastCompilationResult . data ) {
return self . _components . compiler . lastCompilationResult . data . contracts
}
return null
} ,
resolveReceipt : function ( tx , cb ) {
resolveReceipt : function ( tx , cb ) {
transactionReceiptResolver . resolve ( tx , cb )
transactionReceiptResolver . resolve ( tx , cb )
}
}
@ -452,7 +448,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
self . _components . editorpanel . event . register ( 'resize' , direction => self . _adjustLayout ( direction ) )
self . _components . editorpanel . event . register ( 'resize' , direction => self . _adjustLayout ( direction ) )
self . _view . centerpanel . appendChild ( self . _components . editorpanel . render ( ) )
self . _view . centerpanel . appendChild ( self . _components . editorpanel . render ( ) )
var editor = self . _components . editorpanel . getEditor ( )
// The event listener needs to be registered as early as possible, because the
// The event listener needs to be registered as early as possible, because the
// parent will send the message upon the "load" event.
// parent will send the message upon the "load" event.
@ -465,8 +460,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}
}
} , false )
} , false )
this . event = new EventManager ( )
// Replace early callback with instant response
// Replace early callback with instant response
loadFilesCallback = function ( files ) {
loadFilesCallback = function ( files ) {
self . loadFiles ( files )
self . loadFiles ( files )
@ -478,68 +471,22 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
}
}
// ---------------- FilePanel --------------------
// ---------------- FilePanel --------------------
var filePanel = new FilePanel ( )
self . _components . filePanel = new FilePanel ( )
self . _view . leftpanel . appendChild ( filePanel . render ( ) )
self . _view . leftpanel . appendChild ( self . _components . filePanel . render ( ) )
filePanel . event . register ( 'resize' , delta => self . _adjustLayout ( 'left' , delta ) )
self . _components . filePanel . event . register ( 'resize' , delta => self . _adjustLayout ( 'left' , delta ) )
// ----------------- Renderer -----------------
// ----------------- Renderer -----------------
var renderer = new Renderer ( )
var renderer = new Renderer ( )
registry . put ( { api : renderer , name : 'renderer' } )
registry . put ( { api : renderer , name : 'renderer' } )
// ----------------- StaticAnalysis -----------------
var staticanalysis = new StaticAnalysis ( )
registry . put ( { api : staticanalysis , name : 'staticanalysis' } )
// ---------------- Righthand-panel --------------------
// ---------------- Righthand-panel --------------------
self . _components . righthandpanel = new RighthandPanel ( )
self . _components . righthandpanel = new RighthandPanel ( )
self . _view . rightpanel . appendChild ( self . _components . righthandpanel . render ( ) )
self . _view . rightpanel . appendChild ( self . _components . righthandpanel . render ( ) )
self . _components . righthandpanel . init ( )
self . _components . righthandpanel . init ( )
self . _components . righthandpanel . event . register ( 'resize' , delta => self . _adjustLayout ( 'right' , delta ) )
self . _components . righthandpanel . event . register ( 'resize' , delta => self . _adjustLayout ( 'right' , delta ) )
var node = document . getElementById ( 'staticanalysisView' )
node . insertBefore ( staticanalysis . render ( ) , node . childNodes [ 0 ] )
// ----------------- Debugger -----------------
self . _view . transactionDebugger = new Debugger ( '#debugger' , new SourceHighlighter ( ) )
self . _view . transactionDebugger . addProvider ( 'vm' , executionContext . vm ( ) )
self . _view . transactionDebugger . addProvider ( 'injected' , executionContext . internalWeb3 ( ) )
self . _view . transactionDebugger . addProvider ( 'web3' , executionContext . internalWeb3 ( ) )
self . _view . transactionDebugger . switchProvider ( executionContext . getProvider ( ) )
var txLogger = new TxLogger ( ) // eslint-disable-line
var txLogger = new TxLogger ( ) // eslint-disable-line
var previousInput = ''
var saveTimeout = null
function editorOnChange ( ) {
var currentFile = self . _components . config . get ( 'currentFile' )
if ( ! currentFile ) {
return
}
var input = editor . get ( currentFile )
if ( ! input ) {
return
}
// if there's no change, don't do anything
if ( input === previousInput ) {
return
}
previousInput = input
// fire storage update
// NOTE: save at most once per 5 seconds
if ( saveTimeout ) {
window . clearTimeout ( saveTimeout )
}
saveTimeout = window . setTimeout ( ( ) => {
fileManager . saveCurrentFile ( )
} , 5000 )
}
// auto save the file when content changed
editor . event . register ( 'contentChanged' , editorOnChange )
// save the file when switching
editor . event . register ( 'sessionSwitched' , editorOnChange )
executionContext . event . register ( 'contextChanged' , this , function ( context ) {
executionContext . event . register ( 'contextChanged' , this , function ( context ) {
self . runCompiler ( )
self . runCompiler ( )
} )
} )
@ -552,8 +499,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
var queryParams = new QueryParams ( )
var queryParams = new QueryParams ( )
// check init query parameters from the URL once the compiler is loaded
// check init query parameters from the URL once the compiler is loaded
compiler . event . register ( 'compilerLoaded' , this , function ( version ) {
self . _components . compiler . event . register ( 'compilerLoaded' , this , function ( version ) {
previousInput = ''
self . runCompiler ( )
self . runCompiler ( )
if ( queryParams . get ( ) . context ) {
if ( queryParams . get ( ) . context ) {