-
- `
- }
+ `
+ }
- var event = new EventManager()
- self.event = event
- var element = template()
- fileExplorer.ensureRoot()
- configExplorer.ensureRoot()
- self._deps.fileProviders['localhost'].event.register('connecting', (event) => {
- })
+ var event = new EventManager()
+ self.event = event
+ var element = template()
+ fileExplorer.ensureRoot()
+ configExplorer.ensureRoot()
+ self._deps.fileProviders['localhost'].event.register('connecting', (event) => {
+ })
- self._deps.fileProviders['localhost'].event.register('connected', (event) => {
- fileSystemExplorer.show()
- })
+ self._deps.fileProviders['localhost'].event.register('connected', (event) => {
+ fileSystemExplorer.show()
+ })
- self._deps.fileProviders['localhost'].event.register('errored', (event) => {
- fileSystemExplorer.hide()
- })
+ self._deps.fileProviders['localhost'].event.register('errored', (event) => {
+ fileSystemExplorer.hide()
+ })
- self._deps.fileProviders['localhost'].event.register('closed', (event) => {
- fileSystemExplorer.hide()
- })
+ self._deps.fileProviders['localhost'].event.register('closed', (event) => {
+ fileSystemExplorer.hide()
+ })
- fileExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ fileExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- configExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ configExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- fileSystemExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ fileSystemExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- swarmExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ swarmExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- githubExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ githubExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- gistExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ gistExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- httpExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ httpExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- httpsExplorer.events.register('focus', function (path) {
- self._deps.fileManager.switchFile(path)
- })
+ httpsExplorer.events.register('focus', function (path) {
+ self._deps.fileManager.switchFile(path)
+ })
- self.render = function render () { return element }
+ self.render = function render () { return element }
+
+ function uploadFile (event) {
+ // TODO The file explorer is merely a view on the current state of
+ // the files module. Please ask the user here if they want to overwrite
+ // a file and then just use `files.add`. The file explorer will
+ // pick that up via the 'fileAdded' event from the files module.
+
+ ;[...this.files].forEach((file) => {
+ var files = fileExplorer.files
+ function loadFile () {
+ var fileReader = new FileReader()
+ fileReader.onload = function (event) {
+ if (helper.checkSpecialChars(file.name)) {
+ modalDialogCustom.alert('Special characters are not allowed')
+ return
+ }
+ var success = files.set(name, event.target.result)
+ if (!success) modalDialogCustom.alert('Failed to create file ' + name)
+ else self.event.trigger('focus', [name])
+ }
+ fileReader.readAsText(file)
+ }
- self.profile = function () {
- return {
- name: 'fileExplorers',
- displayName: 'file explorers',
- methods: [],
- events: [],
- icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEyOC0yOCA3Ni00OHQ4OC0yMGg0MTZxNDAgMCA2OCAyOHQyOCA2OHYzMjhxNjgtNDAgMTI4LTQwaDQxNnptLTU0NCAyMTNsLTI5OSAyOTloMjk5di0yOTl6bS02NDAtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=',
- description: ' - ',
- kind: 'fileexplorer'
+ var name = files.type + '/' + file.name
+ files.exists(name, (error, exist) => {
+ if (error) console.log(error)
+ if (!exist) {
+ loadFile()
+ } else {
+ modalDialogCustom.confirm(null, `The file ${name} already exists! Would you like to overwrite it?`, () => { loadFile() })
+ }
+ })
+ })
}
- }
- function uploadFile (event) {
- // TODO The file explorer is merely a view on the current state of
- // the files module. Please ask the user here if they want to overwrite
- // a file and then just use `files.add`. The file explorer will
- // pick that up via the 'fileAdded' event from the files module.
-
- ;[...this.files].forEach((file) => {
- var files = fileExplorer.files
- function loadFile () {
- var fileReader = new FileReader()
- fileReader.onload = function (event) {
- if (helper.checkSpecialChars(file.name)) {
- modalDialogCustom.alert('Special characters are not allowed')
- return
+ function createNewFile () {
+ modalDialogCustom.prompt(null, 'File Name', 'Untitled.sol', (input) => {
+ helper.createNonClashingName(input, self._deps.fileProviders['browser'], (error, newName) => {
+ if (error) return modalDialogCustom.alert('Failed to create file ' + newName + ' ' + error)
+ if (!self._deps.fileProviders['browser'].set(newName, '')) {
+ modalDialogCustom.alert('Failed to create file ' + newName)
+ } else {
+ var file = self._deps.fileProviders['browser'].type + '/' + newName
+ self._deps.fileManager.switchFile(file)
+ if (file.includes('_test.sol')) {
+ self.event.trigger('newTestFileCreated', [file])
+ }
}
- var success = files.set(name, event.target.result)
- if (!success) modalDialogCustom.alert('Failed to create file ' + name)
- else self.event.trigger('focus', [name])
- }
- fileReader.readAsText(file)
+ })
+ }, null, true)
+ }
+
+ // ------------------ gist publish --------------
+
+ function updateGist () {
+ var gistId = self._deps.fileProviders['gist'].id
+ if (!gistId) {
+ tooltip('no gist content is currently loaded.')
+ } else {
+ toGist('gist', gistId)
}
+ }
- var name = files.type + '/' + file.name
- files.exists(name, (error, exist) => {
- if (error) console.log(error)
- if (!exist) {
- loadFile()
- } else {
- modalDialogCustom.confirm(null, `The file ${name} already exists! Would you like to overwrite it?`, () => { loadFile() })
- }
+ function publishToGist (fileProviderName) {
+ modalDialogCustom.confirm(null, 'Are you very sure you want to publish all your files anonymously as a public gist on github.com?', () => {
+ toGist(fileProviderName)
})
- })
- }
+ }
- function createNewFile () {
- modalDialogCustom.prompt(null, 'File Name', 'Untitled.sol', (input) => {
- helper.createNonClashingName(input, self._deps.fileProviders['browser'], (error, newName) => {
- if (error) return modalDialogCustom.alert('Failed to create file ' + newName + ' ' + error)
- if (!self._deps.fileProviders['browser'].set(newName, '')) {
- modalDialogCustom.alert('Failed to create file ' + newName)
+ function toGist (fileProviderName, id) {
+ packageFiles(self._deps.fileProviders[fileProviderName], (error, packaged) => {
+ if (error) {
+ console.log(error)
+ modalDialogCustom.alert('Failed to create gist: ' + error)
} else {
- var file = self._deps.fileProviders['browser'].type + '/' + newName
- self._deps.fileManager.switchFile(file)
- if (file.includes('_test.sol')) {
- self.event.trigger('newTestFileCreated', [file])
+ var tokenAccess = self._deps.config.get('settings/gist-access-token')
+ if (!tokenAccess) {
+ modalDialogCustom.alert('Remix requires an access token (which includes gists creation permission). Please go to the settings tab for more information.')
+ } else {
+ var description = 'Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=' + queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&gist='
+ var gists = new Gists({
+ token: tokenAccess
+ })
+ if (id) {
+ tooltip('Saving gist (' + id + ') ...')
+ gists.edit({
+ description: description,
+ public: true,
+ files: packaged,
+ id: id
+ }, (error, result) => {
+ cb(error, result)
+ })
+ } else {
+ tooltip('Creating a new gist ...')
+ gists.create({
+ description: description,
+ public: true,
+ files: packaged
+ }, (error, result) => {
+ cb(error, result)
+ })
+ }
}
}
})
- }, null, true)
- }
-
- // ------------------ gist publish --------------
-
- function updateGist () {
- var gistId = self._deps.fileProviders['gist'].id
- if (!gistId) {
- tooltip('no gist content is currently loaded.')
- } else {
- toGist('gist', gistId)
}
- }
-
- function publishToGist (fileProviderName) {
- modalDialogCustom.confirm(null, 'Are you very sure you want to publish all your files anonymously as a public gist on github.com?', () => {
- toGist(fileProviderName)
- })
- }
- function toGist (fileProviderName, id) {
- packageFiles(self._deps.fileProviders[fileProviderName], (error, packaged) => {
+ function cb (error, data) {
if (error) {
- console.log(error)
- modalDialogCustom.alert('Failed to create gist: ' + error)
+ modalDialogCustom.alert('Failed to manage gist: ' + error)
} else {
- var tokenAccess = self._deps.config.get('settings/gist-access-token')
- if (!tokenAccess) {
- modalDialogCustom.alert('Remix requires an access token (which includes gists creation permission). Please go to the settings tab for more information.')
- } else {
- var description = 'Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=' + queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&gist='
- var gists = new Gists({
- token: tokenAccess
+ if (data.html_url) {
+ modalDialogCustom.confirm(null, `The gist is at ${data.html_url}. Would you like to open it in a new window?`, () => {
+ window.open(data.html_url, '_blank')
})
- if (id) {
- tooltip('Saving gist (' + id + ') ...')
- gists.edit({
- description: description,
- public: true,
- files: packaged,
- id: id
- }, (error, result) => {
- cb(error, result)
- })
- } else {
- tooltip('Creating a new gist ...')
- gists.create({
- description: description,
- public: true,
- files: packaged
- }, (error, result) => {
- cb(error, result)
- })
- }
+ } else {
+ modalDialogCustom.alert(data.message + ' ' + data.documentation_url + ' ' + JSON.stringify(data.errors, null, '\t'))
}
}
- })
- }
+ }
+
+ // ------------------ copy files --------------
- function cb (error, data) {
- if (error) {
- modalDialogCustom.alert('Failed to manage gist: ' + error)
- } else {
- if (data.html_url) {
- modalDialogCustom.confirm(null, `The gist is at ${data.html_url}. Would you like to open it in a new window?`, () => {
- window.open(data.html_url, '_blank')
+ function copyFiles () {
+ modalDialogCustom.prompt(null, 'To which other remix-ide instance do you want to copy over all files?', 'https://remix.ethereum.org', (target) => {
+ doCopy(target)
+ })
+ function doCopy (target) {
+ // package only files from the browser storage.
+ packageFiles(self._deps.fileProviders['browser'], (error, packaged) => {
+ if (error) {
+ console.log(error)
+ } else {
+ $('
', {
+ src: target,
+ style: 'display:none;',
+ load: function () { this.contentWindow.postMessage(['loadFiles', packaged], '*') }
+ }).appendTo('body')
+ }
})
- } else {
- modalDialogCustom.alert(data.message + ' ' + data.documentation_url + ' ' + JSON.stringify(data.errors, null, '\t'))
}
}
}
- // ------------------ copy files --------------
-
- function copyFiles () {
- modalDialogCustom.prompt(null, 'To which other remix-ide instance do you want to copy over all files?', 'https://remix.ethereum.org', (target) => {
- doCopy(target)
- })
- function doCopy (target) {
- // package only files from the browser storage.
- packageFiles(self._deps.fileProviders['browser'], (error, packaged) => {
- if (error) {
- console.log(error)
- } else {
- $('
', {
- src: target,
- style: 'display:none;',
- load: function () { this.contentWindow.postMessage(['loadFiles', packaged], '*') }
- }).appendTo('body')
- }
- })
+ get profile () {
+ return {
+ name: 'fileExplorers',
+ displayName: 'file explorers',
+ methods: [],
+ events: [],
+ icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEyOC0yOCA3Ni00OHQ4OC0yMGg0MTZxNDAgMCA2OCAyOHQyOCA2OHYzMjhxNjgtNDAgMTI4LTQwaDQxNnptLTU0NCAyMTNsLTI5OSAyOTloMjk5di0yOTl6bS02NDAtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=',
+ description: ' - ',
+ kind: 'fileexplorer'
}
}
}
@@ -340,4 +346,3 @@ function packageFiles (filesProvider, callback) {
})
}
-module.exports = filepanel
diff --git a/src/app/tabs/analysis-tab.js b/src/app/tabs/analysis-tab.js
index f3fed652c6..68e78afd87 100644
--- a/src/app/tabs/analysis-tab.js
+++ b/src/app/tabs/analysis-tab.js
@@ -3,13 +3,16 @@ var StaticAnalysis = require('../staticanalysis/staticAnalysisView')
var EventManager = require('../../lib/events')
var css = require('./styles/analysis-tab-styles')
-class AnalysisTab {
+import { ApiFactory } from 'remix-plugin'
+
+class AnalysisTab extends ApiFactory {
constructor (registry) {
+ super()
this.event = new EventManager()
this.registry = registry
}
- profile () {
+ get profile () {
return {
name: 'solidityStaticAnalysis',
displayName: 'solidity static analysis',
diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js
index 1215727adf..7fececee29 100644
--- a/src/app/tabs/compile-tab.js
+++ b/src/app/tabs/compile-tab.js
@@ -17,9 +17,12 @@ var css = require('./styles/compile-tab-styles')
const CompileTabLogic = require('./compileTab/compileTab.js')
const CompilerContainer = require('./compileTab/compilerContainer.js')
-class CompileTab {
+import { ApiFactory } from 'remix-plugin'
+
+class CompileTab extends ApiFactory {
constructor (registry) {
+ super()
this.events = new EventEmitter()
this._view = {
el: null,
@@ -56,6 +59,18 @@ class CompileTab {
)
}
+ get profile () {
+ return {
+ displayName: 'solidity compiler',
+ name: 'solidity',
+ methods: ['getCompilationResult'],
+ events: ['compilationFinished'],
+ icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE2LjAuMywgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zOnNrZXRjaD0iaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoL25zIgoJIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMTMwMHB4IiBoZWlnaHQ9IjEzMDBweCIKCSB2aWV3Qm94PSIwIDAgMTMwMCAxMzAwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAxMzAwIDEzMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8dGl0bGU+VmVjdG9yIDE8L3RpdGxlPgo8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KPGcgaWQ9IlBhZ2UtMSIgc2tldGNoOnR5cGU9Ik1TUGFnZS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9Ik0yNDIuNDI0LDcxNS45NzNILTE4Ljg5M2wxMzAuNjEzLDIzMi4zMDNoMjYxLjMxNwoJCQkJTDI0Mi40MjQsNzE1Ljk3M3oiLz4KCQkJPHBhdGggaWQ9IlNoYXBlXzVfIiBvcGFjaXR5PSIwLjgiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgICAgIiBkPSJNMzczLjAzOCw0ODMuNzYxTDI0Mi40MjQsNzE1Ljk3M2wxMzAuNjE0LDIzMi4zMDMKCQkJCWwxMzAuNzA0LTIzMi4zMDNMMzczLjAzOCw0ODMuNzYxeiIvPgoJCTwvZz4KCTwvZz4KPC9nPgo8L3N2Zz4K',
+ description: 'compile solidity contracts',
+ kind: 'compile'
+ }
+ }
+
activate () {
this.listenToEvents()
this.compilerContainer.activate()
@@ -131,18 +146,6 @@ class CompileTab {
})
}
- profile () {
- return {
- displayName: 'solidity compiler',
- name: 'solidity',
- methods: ['getCompilationResult'],
- events: ['compilationFinished'],
- icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE2LjAuMywgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zOnNrZXRjaD0iaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoL25zIgoJIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnL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TU4LDM2Ny42MUwxMTAuNDU2LDU5OS44MjJ6Ii8+CgkJCTxwYXRoIGlkPSJTaGFwZV8zXyIgb3BhY2l0eT0iMC40NSIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAgICAiIGQ9Ik0xMTEuNzIxLDk0OC4yNzVsMTMwLjcwNC0yMzIuMzAzaDI2MS4zMThMMzczLjAzOCw5NDguMjc1CgkJCQlIMTExLjcyMSIvPgoJCQk8cGF0aCBpZD0iU2hhcGVfNF8iIG9wYWNpdHk9IjAuNiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAgICAiIGQ9Ik0yNDIuNDI0LDcxNS45NzNILTE4Ljg5M2wxMzAuNjEzLDIzMi4zMDNoMjYxLjMxNwoJCQkJTDI0Mi40MjQsNzE1Ljk3M3oiLz4KCQkJPHBhdGggaWQ9IlNoYXBlXzVfIiBvcGFjaXR5PSIwLjgiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgICAgIiBkPSJNMzczLjAzOCw0ODMuNzYxTDI0Mi40MjQsNzE1Ljk3M2wxMzAuNjE0LDIzMi4zMDMKCQkJCWwxMzAuNzA0LTIzMi4zMDNMMzczLjAzOCw0ODMuNzYxeiIvPgoJCTwvZz4KCTwvZz4KPC9nPgo8L3N2Zz4K',
- description: 'compile solidity contracts',
- kind: 'compile'
- }
- }
-
getCompilationResult () {
return new Promise((resolve, reject) => {
resolve(this.compileTabLogic.compiler.lastCompilationResult)
diff --git a/src/app/tabs/debugger-tab.js b/src/app/tabs/debugger-tab.js
index 440f4f0ae0..78d2790861 100644
--- a/src/app/tabs/debugger-tab.js
+++ b/src/app/tabs/debugger-tab.js
@@ -3,12 +3,16 @@ var css = require('./styles/debugger-tab-styles')
var DebuggerUI = require('../debugger/debuggerUI')
-class DebuggerTab {
+import { ApiFactory } from 'remix-plugin'
+
+class DebuggerTab extends ApiFactory {
+
constructor () {
+ super()
this.el = null
}
- profile () {
+ get profile () {
return {
displayName: 'debugger',
name: 'debugger',
diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js
index f83b787cbc..d7de0575c1 100644
--- a/src/app/tabs/run-tab.js
+++ b/src/app/tabs/run-tab.js
@@ -12,9 +12,12 @@ var ContractDropdownUI = require('./runTab/contractDropdown.js')
var Recorder = require('./runTab/model/recorder.js')
var RecorderUI = require('./runTab/recorder.js')
-class RunTab {
+import { ApiFactory } from 'remix-plugin'
+
+class RunTab extends ApiFactory {
constructor (udapp, udappUI, config, fileManager, editor, logCallback, filePanel, pluginManager, compilersArtefacts) {
+ super()
this.event = new EventManager()
this.renderInstanceContainer()
@@ -25,6 +28,18 @@ class RunTab {
this.renderContainer()
}
+ get profile () {
+ return {
+ name: 'run',
+ displayName: 'run transactions',
+ methods: [],
+ events: [],
+ icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNTc2IDkyN2wtMTMyOCA3MzhxLTIzIDEzLTM5LjUgM3QtMTYuNS0zNnYtMTQ3MnEwLTI2IDE2LjUtMzZ0MzkuNSAzbDEzMjggNzM4cTIzIDEzIDIzIDMxdC0yMyAzMXoiLz48L3N2Zz4=',
+ description: 'execute and save transactions',
+ kind: 'run'
+ }
+ }
+
renderContainer () {
this.container = yo`
`
@@ -147,17 +162,6 @@ class RunTab {
return this.container
}
- profile () {
- return {
- name: 'run',
- displayName: 'run transactions',
- methods: [],
- events: [],
- icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNTc2IDkyN2wtMTMyOCA3MzhxLTIzIDEzLTM5LjUgM3QtMTYuNS0zNnYtMTQ3MnEwLTI2IDE2LjUtMzZ0MzkuNSAzbDEzMjggNzM4cTIzIDEzIDIzIDMxdC0yMyAzMXoiLz48L3N2Zz4=',
- description: 'execute and save transactions',
- kind: 'run'
- }
- }
}
module.exports = RunTab
diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js
index 3dc4cfbd25..ce2069cd6a 100644
--- a/src/app/tabs/settings-tab.js
+++ b/src/app/tabs/settings-tab.js
@@ -9,8 +9,11 @@ var styleGuide = require('../ui/styles-guide/theme-chooser')
var Storage = remixLib.Storage
var EventManager = require('../../lib/events')
-module.exports = class SettingsTab {
+import { ApiFactory } from 'remix-plugin'
+
+module.exports = class SettingsTab extends ApiFactory {
constructor (localRegistry) {
+ super()
const self = this
self._components = {}
self._components.registry = localRegistry || globalRegistry
@@ -37,7 +40,7 @@ module.exports = class SettingsTab {
self._components.themeStorage = new Storage('style:')
self.data.currentTheme = self._components.themeStorage.get('theme') || 'light'
}
- profile () {
+ get profile () {
return {
displayName: 'settings',
name: 'settings',
@@ -45,7 +48,8 @@ module.exports = class SettingsTab {
events: [],
icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xMTUyIDg5NnEwLTEwNi03NS0xODF0LTE4MS03NS0xODEgNzUtNzUgMTgxIDc1IDE4MSAxODEgNzUgMTgxLTc1IDc1LTE4MXptNTEyLTEwOXYyMjJxMCAxMi04IDIzdC0yMCAxM2wtMTg1IDI4cS0xOSA1NC0zOSA5MSAzNSA1MCAxMDcgMTM4IDEwIDEyIDEwIDI1dC05IDIzcS0yNyAzNy05OSAxMDh0LTk0IDcxcS0xMiAwLTI2LTlsLTEzOC0xMDhxLTQ0IDIzLTkxIDM4LTE2IDEzNi0yOSAxODYtNyAyOC0zNiAyOGgtMjIycS0xNCAwLTI0LjUtOC41dC0xMS41LTIxLjVsLTI4LTE4NHEtNDktMTYtOTAtMzdsLTE0MSAxMDdxLTEwIDktMjUgOS0xNCAwLTI1LTExLTEyNi0xMTQtMTY1LTE2OC03LTEwLTctMjMgMC0xMiA4LTIzIDE1LTIxIDUxLTY2LjV0NTQtNzAuNXEtMjctNTAtNDEtOTlsLTE4My0yN3EtMTMtMi0yMS0xMi41dC04LTIzLjV2LTIyMnEwLTEyIDgtMjN0MTktMTNsMTg2LTI4cTE0LTQ2IDM5LTkyLTQwLTU3LTEwNy0xMzgtMTAtMTItMTAtMjQgMC0xMCA5LTIzIDI2LTM2IDk4LjUtMTA3LjV0OTQuNS03MS41cTEzIDAgMjYgMTBsMTM4IDEwN3E0NC0yMyA5MS0zOCAxNi0xMzYgMjktMTg2IDctMjggMzYtMjhoMjIycTE0IDAgMjQuNSA4LjV0MTEuNSAyMS41bDI4IDE4NHE0OSAxNiA5MCAzN2wxNDItMTA3cTktOSAyNC05IDEzIDAgMjUgMTAgMTI5IDExOSAxNjUgMTcwIDcgOCA3IDIyIDAgMTItOCAyMy0xNSAyMS01MSA2Ni41dC01NCA3MC41cTI2IDUwIDQxIDk4bDE4MyAyOHExMyAyIDIxIDEyLjV0OCAyMy41eiIvPjwvc3ZnPg==',
description: ' - ',
- kind: 'settings'
+ kind: 'settings',
+ location: 'swapPanel',
}
}
render () {
diff --git a/src/app/tabs/support-tab.js b/src/app/tabs/support-tab.js
index 8fba428377..9b751e66a9 100644
--- a/src/app/tabs/support-tab.js
+++ b/src/app/tabs/support-tab.js
@@ -1,9 +1,12 @@
const yo = require('yo-yo')
var css = require('./styles/support-tab-styles')
-class SupportTab {
+import { ApiFactory } from 'remix-plugin'
+
+class SupportTab extends ApiFactory {
constructor (localRegistry) {
+ super()
this.el = null
this.gitterIframe = ''
this.gitterIsLoaded = false
@@ -18,7 +21,8 @@ class SupportTab {
this.el.style.display = 'block'
this.gitterIsLoaded = true
}
- profile () {
+
+ get profile () {
return {
name: 'support',
methods: [],
@@ -27,6 +31,7 @@ class SupportTab {
description: 'help center'
}
}
+
render () {
if (this.el) return this.el
diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js
index 621fd3c33b..d94fba0145 100644
--- a/src/app/tabs/test-tab.js
+++ b/src/app/tabs/test-tab.js
@@ -7,8 +7,11 @@ var globalRegistry = require('../../global/registry')
var css = require('./styles/test-tab-styles')
var remixTests = require('remix-tests')
-module.exports = class TestTab {
+import { ApiFactory } from 'remix-plugin'
+
+module.exports = class TestTab extends ApiFactory {
constructor (localRegistry, compileTab) {
+ super()
// TODO here is a direct reference to compile tab, should be removed
const self = this
self.compileTab = compileTab
@@ -23,7 +26,8 @@ module.exports = class TestTab {
self.data = {}
self.testList = yo`
`
}
- profile () {
+
+ get profile () {
return {
name: 'solidityUnitTesting',
displayName: 'solidity unit testing',
@@ -33,6 +37,7 @@ module.exports = class TestTab {
description: ' - '
}
}
+
render () {
const self = this
var testsOutput = yo`
`
diff --git a/src/app/tabs/txlistener-module.js b/src/app/tabs/txlistener-module.js
new file mode 100644
index 0000000000..d74feb558b
--- /dev/null
+++ b/src/app/tabs/txlistener-module.js
@@ -0,0 +1,22 @@
+import { ApiFactory } from 'remix-plugin'
+import { EventEmitter } from 'events'
+
+export class TxListenerModule extends ApiFactory {
+
+ constructor (txlistener) {
+ super()
+ this.events = new EventEmitter()
+ txlistener.event.register('newTransaction', (tx) => {
+ this.events.emit('newTransaction', tx)
+ })
+ }
+
+ get profile () {
+ return {
+ name: 'txListener',
+ displayName: 'transaction listener',
+ events: ['newTransaction'],
+ description: 'service - notify new transactions'
+ }
+ }
+}
diff --git a/src/app/ui/landing-page/generate.js b/src/app/ui/landing-page/generate.js
deleted file mode 100644
index 224fd1662c..0000000000
--- a/src/app/ui/landing-page/generate.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/* global */
-import LandingPage from './landing-page'
-import Section from './section'
-import { defaultWorkspaces } from './workspace'
-
-export function homepageProfile () {
- return {
- displayName: 'home',
- name: 'home',
- methods: [],
- events: [],
- description: ' - ',
- icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDUwIDUwIiBoZWlnaHQ9IjUwcHgiIGlkPSJMYXllcl8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MCA1MCIgd2lkdGg9IjUwcHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iNTAiIHdpZHRoPSI1MCIvPjxnPjxwYXRoIGQ9IiAgIE0yNSwxQzExLjc0NSwxLDEsMTEuNzQ1LDEsMjVzMTAuNzQ1LDI0LDI0LDI0czI0LTEwLjc0NSwyNC0yNFMzOC4yNTUsMSwyNSwxTDI1LDF6IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBzdHJva2Utd2lkdGg9IjIiLz48L2c+PHBhdGggZD0iICBNNDAuNjk2LDYuOD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iIHN0cm9rZS13aWR0aD0iMi4wNTgzIi8+PC9zdmc+',
- prefferedLocation: 'mainPanel'
- }
-}
-
-export function generateHomePage (appManager, appStore) {
- /*
- var actions1 = [
- {label: 'new file', type: `callback`, payload: () => { alert(`-new file created-`) }},
- {label: 'import from GitHub', type: `callback`, payload: () => { alert(`-imported from GitHub-`) }},
- {label: 'import from gist', type: `callback`, payload: () => { alert(`-imported from gist-`) }}
- ]
-
- var actions2 = [
- {label: '...', type: `callback`, payload: () => { alert(`-...-`) }}
- ]
-
- var actions3 = [
- {label: 'Remix documentation', type: `link`, payload: `https://remix.readthedocs.io/en/latest/#`},
- {label: 'GitHub repository', type: `link`, payload: `https://github.com/ethereum/remix-ide`},
- {label: 'acces local file system (remixd)', type: `link`, payload: `https://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html`},
- {label: 'npm module for remixd', type: `link`, payload: `https://www.npmjs.com/package/remixd`},
- {label: 'medium posts', type: `link`, payload: `https://medium.com/remix-ide`},
- {label: 'tutorials', type: `link`, payload: `https://github.com/ethereum/remix-workshops`}
- ]
-
- var actions4 = [
- {label: 'Remix plugins & modules', type: `link`, payload: `https://github.com/ethereum/remix-plugin/blob/master/readme.md`},
- {label: 'repository on GitHub', type: `link`, payload: `https://github.com/ethereum/remix-plugin`},
- {label: 'examples', type: `link`, payload: `https://github.com/ethereum/remix-plugin/tree/master/examples`},
- {label: 'build plugin for Remix', type: `link`, payload: `https://medium.com/remix-ide/build-a-plugin-for-remix-90d43b209c5a`}
- ]
-
- var actions5 = [
- {label: 'Gitter channel', type: `link`, payload: `https://gitter.im/ethereum/remix`},
- {label: 'Stack Overflow', type: `link`, payload: `https://stackoverflow.com/questions/tagged/remix`},
- {label: 'Reddit', type: `link`, payload: `https://www.reddit.com/r/ethdev/search?q=remix&restrict_sr=1`}
- ]
-
- var section1 = new Section('Start', actions1)
- var section2 = new Section('Recent', actions2)
- var section3 = new Section('Learn', actions3)
- var section4 = new Section('Plugins', actions4)
- var section5 = new Section('Help', actions5)
- */
-
- var sectionsWorkspaces = []
- sectionsWorkspaces.push({
- label: 'Close All Modules',
- type: 'callback',
- payload: () => {
- appStore.getActives()
- .filter(({profile}) => !profile.required)
- .forEach((profile) => { appManager.deactivateOne(profile.name) })
- }})
- defaultWorkspaces(appManager).forEach((workspace) => {
- sectionsWorkspaces.push({label: workspace.title, type: 'callback', payload: () => { workspace.activate() }})
- })
- var sectionWorkspace = new Section('Workspaces', sectionsWorkspaces)
- return new LandingPage([sectionWorkspace])
-}
diff --git a/src/app/ui/landing-page/landing-page.js b/src/app/ui/landing-page/landing-page.js
index 32887b8899..5c3c1c9510 100644
--- a/src/app/ui/landing-page/landing-page.js
+++ b/src/app/ui/landing-page/landing-page.js
@@ -27,9 +27,79 @@ var css = csjs`
}
`
-class LandingPage {
- constructor (sections) {
- this.sections = sections
+import { defaultWorkspaces } from './workspace'
+import { ApiFactory } from 'remix-plugin'
+import Section from './section'
+
+export class LandingPage extends ApiFactory {
+
+ constructor (appManager, appStore) {
+ super()
+ /*
+ var actions1 = [
+ {label: 'new file', type: `callback`, payload: () => { alert(`-new file created-`) }},
+ {label: 'import from GitHub', type: `callback`, payload: () => { alert(`-imported from GitHub-`) }},
+ {label: 'import from gist', type: `callback`, payload: () => { alert(`-imported from gist-`) }}
+ ]
+
+ var actions2 = [
+ {label: '...', type: `callback`, payload: () => { alert(`-...-`) }}
+ ]
+
+ var actions3 = [
+ {label: 'Remix documentation', type: `link`, payload: `https://remix.readthedocs.io/en/latest/#`},
+ {label: 'GitHub repository', type: `link`, payload: `https://github.com/ethereum/remix-ide`},
+ {label: 'acces local file system (remixd)', type: `link`, payload: `https://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html`},
+ {label: 'npm module for remixd', type: `link`, payload: `https://www.npmjs.com/package/remixd`},
+ {label: 'medium posts', type: `link`, payload: `https://medium.com/remix-ide`},
+ {label: 'tutorials', type: `link`, payload: `https://github.com/ethereum/remix-workshops`}
+ ]
+
+ var actions4 = [
+ {label: 'Remix plugins & modules', type: `link`, payload: `https://github.com/ethereum/remix-plugin/blob/master/readme.md`},
+ {label: 'repository on GitHub', type: `link`, payload: `https://github.com/ethereum/remix-plugin`},
+ {label: 'examples', type: `link`, payload: `https://github.com/ethereum/remix-plugin/tree/master/examples`},
+ {label: 'build plugin for Remix', type: `link`, payload: `https://medium.com/remix-ide/build-a-plugin-for-remix-90d43b209c5a`}
+ ]
+
+ var actions5 = [
+ {label: 'Gitter channel', type: `link`, payload: `https://gitter.im/ethereum/remix`},
+ {label: 'Stack Overflow', type: `link`, payload: `https://stackoverflow.com/questions/tagged/remix`},
+ {label: 'Reddit', type: `link`, payload: `https://www.reddit.com/r/ethdev/search?q=remix&restrict_sr=1`}
+ ]
+
+ var section1 = new Section('Start', actions1)
+ var section2 = new Section('Recent', actions2)
+ var section3 = new Section('Learn', actions3)
+ var section4 = new Section('Plugins', actions4)
+ var section5 = new Section('Help', actions5)
+ */
+ const sectionsWorkspaces = []
+ sectionsWorkspaces.push({
+ label: 'Close All Modules',
+ type: 'callback',
+ payload: () => {
+ appStore.getActives()
+ .filter(({profile}) => !profile.required)
+ .forEach((profile) => { appManager.deactivateOne(profile.name) })
+ }})
+ defaultWorkspaces(appManager).forEach((workspace) => {
+ sectionsWorkspaces.push({label: workspace.title, type: 'callback', payload: () => { workspace.activate() }})
+ })
+ const sectionWorkspace = new Section('Workspaces', sectionsWorkspaces)
+ this.sections = sectionWorkspace
+ }
+
+ get profile () {
+ return {
+ displayName: 'home',
+ name: 'home',
+ methods: [],
+ events: [],
+ description: ' - ',
+ icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJ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lLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMi4wNTgzIi8+PHBhdGggZD0iICBNMS44NTIsMjIuOTMyYzAsMCw2LjQ5Myw2LjIzMiwyMy4xNDgsNi4yMzJzMjMuNDM4LTYuMjQ2LDIzLjQzOC02LjI0NiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLXdpZHRoPSIyLjA1ODMiLz48cGF0aCBkPSIgIE0yNS42NDgsMS41NDhjMCwwLTYuODk1LDcuOTM1LTYuODk1LDIzLjQ1MkMxOC43NTQsNDAuNTE4LDI1LDQ4LjYyNSwyNSw0OC42MjUiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMi4wNTgzIi8+PC9zdmc+',
+ location: 'mainPanel'
+ }
}
render () {
@@ -48,5 +118,3 @@ class LandingPage {
return totalLook
}
}
-
-module.exports = LandingPage
diff --git a/src/universal-dapp.js b/src/universal-dapp.js
index 930b22b3ef..084f8df4b7 100644
--- a/src/universal-dapp.js
+++ b/src/universal-dapp.js
@@ -7,349 +7,345 @@ var TxRunner = remixLib.execution.txRunner
var txHelper = remixLib.execution.txHelper
var EventManager = remixLib.EventManager
var executionContext = remixLib.execution.executionContext
+import { ApiFactory } from 'remix-plugin'
-function UniversalDApp (registry) {
- this.event = new EventManager()
- var self = this
- self._deps = {
- config: registry.get('config').api
- }
- self._txRunnerAPI = {
- config: self._deps.config,
- detectNetwork: (cb) => {
- executionContext.detectNetwork(cb)
- },
- personalMode: () => {
- return self._deps.config.get('settings/personal-mode')
+module.exports = class UniversalDApp extends ApiFactory {
+
+ constructor (registry) {
+ super()
+ this.event = new EventManager()
+ this._deps = {
+ config: registry.get('config').api
+ }
+ this._txRunnerAPI = {
+ config: this._deps.config,
+ detectNetwork: (cb) => {
+ executionContext.detectNetwork(cb)
+ },
+ personalMode: () => {
+ return this._deps.config.get('settings/personal-mode')
+ }
}
+ this.txRunner = new TxRunner({}, this._txRunnerAPI)
+ this.accounts = {}
+ this.resetEnvironment()
+ executionContext.event.register('contextChanged', this.resetEnvironment.bind(this))
}
- self.txRunner = new TxRunner({}, self._txRunnerAPI)
- self.accounts = {}
- self.resetEnvironment()
- executionContext.event.register('contextChanged', this.resetEnvironment.bind(this))
-}
-UniversalDApp.prototype.profile = function () {
- return {
- name: 'udapp',
- displayName: 'universal dapp',
- methods: ['runTestTx', 'getAccounts', 'createVMAccount'],
- description: 'service - run transaction and access account'
+ get profile () {
+ return {
+ name: 'udapp',
+ displayName: 'universal dapp',
+ methods: ['runTestTx', 'getAccounts', 'createVMAccount'],
+ description: 'service - run transaction and access account'
+ }
}
-}
-UniversalDApp.prototype.resetEnvironment = function () {
- this.accounts = {}
- if (executionContext.isVM()) {
- this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511', '0x56BC75E2D63100000')
- this._addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c', '0x56BC75E2D63100000')
- this._addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', '0x56BC75E2D63100000')
- this._addAccount('d74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea', '0x56BC75E2D63100000')
- this._addAccount('71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce', '0x56BC75E2D63100000')
- executionContext.vm().stateManager.cache.flush(function () {})
- }
- // TODO: most params here can be refactored away in txRunner
- this.txRunner = new TxRunner(this.accounts, {
- // TODO: only used to check value of doNotShowTransactionConfirmationAgain property
- config: this.config,
- // TODO: to refactor, TxRunner already has access to executionContext
- detectNetwork: (cb) => {
- executionContext.detectNetwork(cb)
- },
- personalMode: () => {
- return this.config.get('settings/personal-mode')
+ resetEnvironment () {
+ this.accounts = {}
+ if (executionContext.isVM()) {
+ this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511', '0x56BC75E2D63100000')
+ this._addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c', '0x56BC75E2D63100000')
+ this._addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', '0x56BC75E2D63100000')
+ this._addAccount('d74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea', '0x56BC75E2D63100000')
+ this._addAccount('71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce', '0x56BC75E2D63100000')
+ executionContext.vm().stateManager.cache.flush(function () {})
}
- })
- this.txRunner.event.register('transactionBroadcasted', (txhash) => {
- executionContext.detectNetwork((error, network) => {
- if (error || !network) return
- this.event.trigger('transactionBroadcasted', [txhash, network.name])
+ // TODO: most params here can be refactored away in txRunner
+ this.txRunner = new TxRunner(this.accounts, {
+ // TODO: only used to check value of doNotShowTransactionConfirmationAgain property
+ config: this.config,
+ // TODO: to refactor, TxRunner already has access to executionContext
+ detectNetwork: (cb) => {
+ executionContext.detectNetwork(cb)
+ },
+ personalMode: () => {
+ return this.config.get('settings/personal-mode')
+ }
})
- })
-}
-
-UniversalDApp.prototype.resetAPI = function (transactionContextAPI) {
- this.transactionContextAPI = transactionContextAPI
-}
-
-UniversalDApp.prototype.createVMAccount = function (privateKey, balance, cb) {
- return new Promise((resolve, reject) => {
- if (executionContext.getProvider() !== 'vm') return reject('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed')
- this._addAccount(privateKey, balance)
- executionContext.vm().stateManager.cache.flush(function () {})
- privateKey = Buffer.from(privateKey, 'hex')
- resolve('0x' + ethJSUtil.privateToAddress(privateKey).toString('hex'))
- })
-}
-
-UniversalDApp.prototype.newAccount = function (password, passwordPromptCb, cb) {
- if (!executionContext.isVM()) {
- if (!this.config.get('settings/personal-mode')) {
- return cb('Not running in personal mode')
- }
- passwordPromptCb((passphrase) => {
- executionContext.web3().personal.newAccount(passphrase, cb)
+ this.txRunner.event.register('transactionBroadcasted', (txhash) => {
+ executionContext.detectNetwork((error, network) => {
+ if (error || !network) return
+ this.event.trigger('transactionBroadcasted', [txhash, network.name])
+ })
})
- } else {
- var privateKey
- do {
- privateKey = crypto.randomBytes(32)
- } while (!ethJSUtil.isValidPrivate(privateKey))
- this._addAccount(privateKey, '0x56BC75E2D63100000')
- executionContext.vm().stateManager.cache.flush(function () {})
- cb(null, '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex'))
}
-}
-
-UniversalDApp.prototype._addAccount = function (privateKey, balance) {
- var self = this
- if (!executionContext.isVM()) {
- throw new Error('_addAccount() cannot be called in non-VM mode')
+ resetAPI (transactionContextAPI) {
+ this.transactionContextAPI = transactionContextAPI
}
- if (self.accounts) {
- privateKey = Buffer.from(privateKey, 'hex')
- var address = ethJSUtil.privateToAddress(privateKey)
-
- // FIXME: we don't care about the callback, but we should still make this proper
- executionContext.vm().stateManager.putAccountBalance(address, balance || '0xf00000000000000001', function cb () {})
- self.accounts['0x' + address.toString('hex')] = { privateKey: privateKey, nonce: 0 }
+ createVMAccount (privateKey, balance, cb) {
+ return new Promise((resolve, reject) => {
+ if (executionContext.getProvider() !== 'vm') return reject('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed')
+ this._addAccount(privateKey, balance)
+ executionContext.vm().stateManager.cache.flush(function () {})
+ privateKey = Buffer.from(privateKey, 'hex')
+ resolve('0x' + ethJSUtil.privateToAddress(privateKey).toString('hex'))
+ })
}
-}
-// TODO should remove this cb
-UniversalDApp.prototype.getAccounts = function (cb) {
- var self = this
- return new Promise((resolve, reject) => {
+ newAccount (password, passwordPromptCb, cb) {
if (!executionContext.isVM()) {
- // Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async
- // See: https://github.com/ethereum/web3.js/issues/442
- if (this._deps.config.get('settings/personal-mode')) {
- return executionContext.web3().personal.getListAccounts((error, accounts) => {
- if (cb) cb(error, accounts)
- if (error) return reject(error)
- resolve(accounts)
- })
- } else {
- executionContext.web3().eth.getAccounts((error, accounts) => {
- if (cb) cb(error, accounts)
- if (error) return reject(error)
- resolve(accounts)
- })
+ if (!this.config.get('settings/personal-mode')) {
+ return cb('Not running in personal mode')
}
+ passwordPromptCb((passphrase) => {
+ executionContext.web3().personal.newAccount(passphrase, cb)
+ })
} else {
- if (!self.accounts) {
- if (cb) cb('No accounts?')
- reject('No accounts?')
- return
- }
- if (cb) cb(null, Object.keys(self.accounts))
- resolve(Object.keys(self.accounts))
+ var privateKey
+ do {
+ privateKey = crypto.randomBytes(32)
+ } while (!ethJSUtil.isValidPrivate(privateKey))
+ this._addAccount(privateKey, '0x56BC75E2D63100000')
+ executionContext.vm().stateManager.cache.flush(function () {})
+ cb(null, '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex'))
}
- })
-}
+ }
-UniversalDApp.prototype.getBalance = function (address, cb) {
- var self = this
+ _addAccount (privateKey, balance) {
+ if (!executionContext.isVM()) {
+ throw new Error('_addAccount() cannot be called in non-VM mode')
+ }
- address = ethJSUtil.stripHexPrefix(address)
+ if (this.accounts) {
+ privateKey = Buffer.from(privateKey, 'hex')
+ const address = ethJSUtil.privateToAddress(privateKey)
- if (!executionContext.isVM()) {
- executionContext.web3().eth.getBalance(address, function (err, res) {
- if (err) {
- cb(err)
- } else {
- cb(null, res.toString(10))
- }
- })
- } else {
- if (!self.accounts) {
- return cb('No accounts?')
+ // FIXME: we don't care about the callback, but we should still make this proper
+ executionContext.vm().stateManager.putAccountBalance(address, balance || '0xf00000000000000001', function cb () {})
+ this.accounts['0x' + address.toString('hex')] = { privateKey, nonce: 0 }
}
+ }
- executionContext.vm().stateManager.getAccountBalance(Buffer.from(address, 'hex'), function (err, res) {
- if (err) {
- cb('Account not found')
+ getAccounts (cb) {
+ return new Promise((resolve, reject) => {
+ if (!executionContext.isVM()) {
+ // Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async
+ // See: https://github.com/ethereum/web3.js/issues/442
+ if (this._deps.config.get('settings/personal-mode')) {
+ return executionContext.web3().personal.getListAccounts((error, accounts) => {
+ if (cb) cb(error, accounts)
+ if (error) return reject(error)
+ resolve(accounts)
+ })
+ } else {
+ executionContext.web3().eth.getAccounts((error, accounts) => {
+ if (cb) cb(error, accounts)
+ if (error) return reject(error)
+ resolve(accounts)
+ })
+ }
} else {
- cb(null, new BN(res).toString(10))
+ if (!this.accounts) {
+ if (cb) cb('No accounts?')
+ reject('No accounts?')
+ return
+ }
+ if (cb) cb(null, Object.keys(this.accounts))
+ resolve(Object.keys(this.accounts))
}
})
}
-}
-UniversalDApp.prototype.getBalanceInEther = function (address, callback) {
- var self = this
- self.getBalance(address, (error, balance) => {
- if (error) {
- callback(error)
+ getBalance (address, cb) {
+ address = ethJSUtil.stripHexPrefix(address)
+
+ if (!executionContext.isVM()) {
+ executionContext.web3().eth.getBalance(address, (err, res) => {
+ if (err) {
+ cb(err)
+ } else {
+ cb(null, res.toString(10))
+ }
+ })
} else {
- callback(null, executionContext.web3().fromWei(balance, 'ether'))
+ if (!this.accounts) {
+ return cb('No accounts?')
+ }
+
+ executionContext.vm().stateManager.getAccountBalance(Buffer.from(address, 'hex'), (err, res) => {
+ if (err) {
+ cb('Account not found')
+ } else {
+ cb(null, new BN(res).toString(10))
+ }
+ })
}
- })
-}
+ }
-UniversalDApp.prototype.pendingTransactionsCount = function () {
- return Object.keys(this.txRunner.pendingTxs).length
-}
+ getBalanceInEther (address, callback) {
+ this.getBalance(address, (error, balance) => {
+ if (error) {
+ callback(error)
+ } else {
+ callback(null, executionContext.web3().fromWei(balance, 'ether'))
+ }
+ })
+ }
-/**
- * deploy the given contract
- *
- * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
- * @param {Function} callback - callback.
- */
-UniversalDApp.prototype.createContract = function (data, confirmationCb, continueCb, promptCb, callback) {
- this.runTx({data: data, useCall: false}, confirmationCb, continueCb, promptCb, (error, txResult) => {
- // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
- callback(error, txResult)
- })
-}
+ pendingTransactionsCount () {
+ return Object.keys(this.txRunner.pendingTxs).length
+ }
-/**
- * call the current given contract
- *
- * @param {String} to - address of the contract to call.
- * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
- * @param {Object} funAbi - abi definition of the function to call.
- * @param {Function} callback - callback.
- */
-UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, continueCb, promptCb, callback) {
- this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, promptCb, (error, txResult) => {
- // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
- callback(error, txResult)
- })
-}
+ /**
+ * deploy the given contract
+ *
+ * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
+ * @param {Function} callback - callback.
+ */
+ createContract (data, confirmationCb, continueCb, promptCb, callback) {
+ this.runTx({data: data, useCall: false}, confirmationCb, continueCb, promptCb, (error, txResult) => {
+ // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
+ callback(error, txResult)
+ })
+ }
-UniversalDApp.prototype.context = function () {
- return (executionContext.isVM() ? 'memory' : 'blockchain')
-}
+ /**
+ * call the current given contract
+ *
+ * @param {String} to - address of the contract to call.
+ * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
+ * @param {Object} funAbi - abi definition of the function to call.
+ * @param {Function} callback - callback.
+ */
+ callFunction (to, data, funAbi, confirmationCb, continueCb, promptCb, callback) {
+ this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, promptCb, (error, txResult) => {
+ // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
+ callback(error, txResult)
+ })
+ }
-UniversalDApp.prototype.getABI = function (contract) {
- return txHelper.sortAbiFunction(contract.abi)
-}
+ context () {
+ return (executionContext.isVM() ? 'memory' : 'blockchain')
+ }
-UniversalDApp.prototype.getFallbackInterface = function (contractABI) {
- return txHelper.getFallbackInterface(contractABI)
-}
+ getABI (contract) {
+ return txHelper.sortAbiFunction(contract.abi)
+ }
-UniversalDApp.prototype.getInputs = function (funABI) {
- if (!funABI.inputs) {
- return ''
+ getFallbackInterface (contractABI) {
+ return txHelper.getFallbackInterface(contractABI)
}
- return txHelper.inputParametersDeclarationToString(funABI.inputs)
-}
-/**
- * This function send a tx only to javascript VM or testnet, will return an error for the mainnet
- * SHOULD BE TAKEN CAREFULLY!
- *
- * @param {Object} tx - transaction.
- */
-UniversalDApp.prototype.runTestTx = function (tx) {
- return new Promise((resolve, reject) => {
- executionContext.detectNetwork((error, network) => {
- if (error) return reject(error)
- if (network.name === 'Main' && network.id === '1') {
- return reject(new Error('It is not allowed to make this action against mainnet'))
- }
- this.silentRunTx(tx, (error, result) => {
+ getInputs (funABI) {
+ if (!funABI.inputs) {
+ return ''
+ }
+ return txHelper.inputParametersDeclarationToString(funABI.inputs)
+ }
+
+ /**
+ * This function send a tx only to javascript VM or testnet, will return an error for the mainnet
+ * SHOULD BE TAKEN CAREFULLY!
+ *
+ * @param {Object} tx - transaction.
+ */
+ runTestTx (tx) {
+ return new Promise((resolve, reject) => {
+ executionContext.detectNetwork((error, network) => {
if (error) return reject(error)
- resolve({
- transactionHash: result.transactionHash,
- status: result.result.status,
- gasUsed: '0x' + result.result.gasUsed.toString('hex'),
- error: result.result.vm.exceptionError,
- return: result.result.vm.return ? '0x' + result.result.vm.return.toString('hex') : '0x',
- createdAddress: result.result.createdAddress ? '0x' + result.result.createdAddress.toString('hex') : undefined
+ if (network.name === 'Main' && network.id === '1') {
+ return reject(new Error('It is not allowed to make this action against mainnet'))
+ }
+ this.silentRunTx(tx, (error, result) => {
+ if (error) return reject(error)
+ resolve({
+ transactionHash: result.transactionHash,
+ status: result.result.status,
+ gasUsed: '0x' + result.result.gasUsed.toString('hex'),
+ error: result.result.vm.exceptionError,
+ return: result.result.vm.return ? '0x' + result.result.vm.return.toString('hex') : '0x',
+ createdAddress: result.result.createdAddress ? '0x' + result.result.createdAddress.toString('hex') : undefined
+ })
})
})
})
- })
-}
+ }
-/**
- * This function send a tx without alerting the user (if mainnet or if gas estimation too high).
- * SHOULD BE TAKEN CAREFULLY!
- *
- * @param {Object} tx - transaction.
- * @param {Function} callback - callback.
- */
-UniversalDApp.prototype.silentRunTx = function (tx, cb) {
- if (!executionContext.isVM()) return cb('Cannot silently send transaction through a web3 provider')
- this.txRunner.rawRun(
- tx,
- (network, tx, gasEstimation, continueTxExecution, cancelCb) => { continueTxExecution() },
- (error, continueTxExecution, cancelCb) => { if (error) { cb(error) } else { continueTxExecution() } },
- (okCb, cancelCb) => { okCb() },
- cb)
-}
+ /**
+ * This function send a tx without alerting the user (if mainnet or if gas estimation too high).
+ * SHOULD BE TAKEN CAREFULLY!
+ *
+ * @param {Object} tx - transaction.
+ * @param {Function} callback - callback.
+ */
+ silentRunTx (tx, cb) {
+ if (!executionContext.isVM()) return cb('Cannot silently send transaction through a web3 provider')
+ this.txRunner.rawRun(
+ tx,
+ (network, tx, gasEstimation, continueTxExecution, cancelCb) => { continueTxExecution() },
+ (error, continueTxExecution, cancelCb) => { if (error) { cb(error) } else { continueTxExecution() } },
+ (okCb, cancelCb) => { okCb() },
+ cb
+ )
+ }
-UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, promptCb, cb) {
- const self = this
- async.waterfall([
- function getGasLimit (next) {
- if (self.transactionContextAPI.getGasLimit) {
- return self.transactionContextAPI.getGasLimit(next)
- }
- next(null, 3000000)
- },
- function queryValue (gasLimit, next) {
- if (args.value) {
- return next(null, args.value, gasLimit)
- }
- if (args.useCall || !self.transactionContextAPI.getValue) {
- return next(null, 0, gasLimit)
- }
- self.transactionContextAPI.getValue(function (err, value) {
- next(err, value, gasLimit)
- })
- },
- function getAccount (value, gasLimit, next) {
- if (args.from) {
- return next(null, args.from, value, gasLimit)
- }
- if (self.transactionContextAPI.getAddress) {
- return self.transactionContextAPI.getAddress(function (err, address) {
- next(err, address, value, gasLimit)
+ runTx (args, confirmationCb, continueCb, promptCb, cb) {
+ const self = this
+ async.waterfall([
+ function getGasLimit (next) {
+ if (self.transactionContextAPI.getGasLimit) {
+ return self.transactionContextAPI.getGasLimit(next)
+ }
+ next(null, 3000000)
+ },
+ function queryValue (gasLimit, next) {
+ if (args.value) {
+ return next(null, args.value, gasLimit)
+ }
+ if (args.useCall || !self.transactionContextAPI.getValue) {
+ return next(null, 0, gasLimit)
+ }
+ self.transactionContextAPI.getValue(function (err, value) {
+ next(err, value, gasLimit)
})
- }
- self.getAccounts(function (err, accounts) {
- let address = accounts[0]
+ },
+ function getAccount (value, gasLimit, next) {
+ if (args.from) {
+ return next(null, args.from, value, gasLimit)
+ }
+ if (self.transactionContextAPI.getAddress) {
+ return self.transactionContextAPI.getAddress(function (err, address) {
+ next(err, address, value, gasLimit)
+ })
+ }
+ self.getAccounts(function (err, accounts) {
+ let address = accounts[0]
- if (err) return next(err)
- if (!address) return next('No accounts available')
- if (executionContext.isVM() && !self.accounts[address]) {
- return next('Invalid account selected')
+ if (err) return next(err)
+ if (!address) return next('No accounts available')
+ if (executionContext.isVM() && !self.accounts[address]) {
+ return next('Invalid account selected')
+ }
+ next(null, address, value, gasLimit)
+ })
+ },
+ function runTransaction (fromAddress, value, gasLimit, next) {
+ var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit, timestamp: args.data.timestamp }
+ 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()
+ if (tx.timestamp) {
+ timestamp = tx.timestamp
}
- next(null, address, value, gasLimit)
- })
- },
- function runTransaction (fromAddress, value, gasLimit, next) {
- var tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit, timestamp: args.data.timestamp }
- 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()
- if (tx.timestamp) {
- timestamp = tx.timestamp
- }
- self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
- self.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb,
- function (error, result) {
- let eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted')
- self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad])
+ self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
+ self.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb,
+ function (error, result) {
+ let eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted')
+ self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad])
- if (error && (typeof (error) !== 'string')) {
- if (error.message) error = error.message
- else {
- try { error = 'error: ' + JSON.stringify(error) } catch (e) {}
+ if (error && (typeof (error) !== 'string')) {
+ if (error.message) error = error.message
+ else {
+ try { error = 'error: ' + JSON.stringify(error) } catch (e) {}
+ }
}
+ next(error, result)
}
- next(error, result)
- }
- )
- }
- ], cb)
+ )
+ }
+ ], cb)
+ }
}
-
-module.exports = UniversalDApp