From 18e3d6be91f04ef660a4a4519f6ec9525622466e Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 11 Apr 2018 14:55:29 +0200 Subject: [PATCH 1/5] remove getAccounts from api --- src/app.js | 3 --- src/app/tabs/run-tab.js | 2 +- src/recorder.js | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app.js b/src/app.js index f033514446..6b70816d40 100644 --- a/src/app.js +++ b/src/app.js @@ -705,9 +705,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org document.querySelector(`.${css.dragbar2}`).style.right = delta + 'px' onResize() }, - getAccounts: (cb) => { - udapp.getAccounts(cb) - }, getSource: (fileName) => { return compiler.getSource(fileName) }, diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index ba6b8eafbe..3ba71cdaf0 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -187,7 +187,7 @@ function updateAccountBalances (container, appAPI) { RECORDER ------------------------------------------------ */ function makeRecorder (appAPI, appEvents, opts, self) { - var recorder = new Recorder(opts.compiler, { + var recorder = new Recorder(opts.compiler, opts.udapp, { events: { udapp: appEvents.udapp, executioncontext: executionContext.event, diff --git a/src/recorder.js b/src/recorder.js index 0ba76dbbca..d9298755c4 100644 --- a/src/recorder.js +++ b/src/recorder.js @@ -13,7 +13,7 @@ var modal = require('./app/ui/modal-dialog-custom') * */ class Recorder { - constructor (compiler, opts = {}) { + constructor (compiler, udapp, opts = {}) { var self = this self._api = opts.api self.event = new EventManager() @@ -61,7 +61,7 @@ class Recorder { record.name = payLoad.funAbi.name record.type = payLoad.funAbi.type - self._api.getAccounts((error, accounts) => { + udapp.getAccounts((error, accounts) => { if (error) return console.log(error) record.from = `account{${accounts.indexOf(from)}}` self.data._usedAccounts[record.from] = from From 1182abc7bf56d1f20a2584160238777e16899346 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 11 Apr 2018 15:09:27 +0200 Subject: [PATCH 2/5] remove ediorContent && currentFile --- src/app.js | 11 +++-------- src/app/editor/editor.js | 19 +++++++++++++------ src/app/tabs/run-tab.js | 10 +++++----- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/app.js b/src/app.js index 6b70816d40..b4990bfaaf 100644 --- a/src/app.js +++ b/src/app.js @@ -698,7 +698,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org // ---------------- Righthand-panel -------------------- var rhpAPI = { - config: config, setEditorSize (delta) { $('#righthand-panel').css('width', delta) self._view.centerpanel.style.right = delta + 'px' @@ -708,12 +707,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org getSource: (fileName) => { return compiler.getSource(fileName) }, - editorContent: () => { - return editor.get(editor.current()) - }, - currentFile: () => { - return config.get('currentFile') - }, visitContracts: (cb) => { compiler.visitContracts(cb) }, @@ -772,7 +765,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org udapp: udapp, udappUI: udappUI, compiler: compiler, - renderer: renderer + renderer: renderer, + editor: editor, + config: config } self._components.righthandpanel = new RighthandPanel(rhpAPI, rhpEvents, rhpOpts) diff --git a/src/app/editor/editor.js b/src/app/editor/editor.js index fd96b107a5..a67e5dd4de 100644 --- a/src/app/editor/editor.js +++ b/src/app/editor/editor.js @@ -170,17 +170,25 @@ function Editor (opts = {}) { } /** - * returns the content of the specified session @arg path - * if @arg path is not provided, the content of the current editing session is returned + * returns the content of the current session + * + * @return {String} content of the file referenced by @arg path + */ + this.currentContent = function () { + return this.get(this.current()) + } + + /** + * returns the content of the session targeted by @arg path + * if @arg path is null, the content of the current session is returned * - * @param {String} path - path of th file in edition * @return {String} content of the file referenced by @arg path */ this.get = function (path) { if (!path || currentSession === path) { return editor.getValue() } else if (sessions[path]) { - sessions[path].getValue() + return sessions[path].getValue() } } @@ -188,8 +196,7 @@ function Editor (opts = {}) { * returns the path of the currently editing file * returns `undefined` if no session is being editer * - * @param {String} path - path of th file in edition - * @return {String} content of the file referenced by @arg path + * @return {String} path of the current session */ this.current = function () { if (editor.getSession() === emptySession) { diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 3ba71cdaf0..496a583226 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -240,7 +240,7 @@ function makeRecorder (appAPI, appEvents, opts, self) { update account address in scenario.json popup if scenario.json not open - "Open a file with transactions you want to replay and click play again" */ - var currentFile = appAPI.config.get('currentFile') + var currentFile = opts.config.get('currentFile') appAPI.fileProviderOf(currentFile).get(currentFile, (error, json) => { if (error) { modalDialogCustom.alert('Invalid Scenario File ' + error) @@ -319,7 +319,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) { ${createPanel}
${atAddressButtonInput} -
Access
+
At Address
@@ -384,7 +384,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) { } // ACCESS DEPLOYED INSTANCE - function loadFromAddress (appAPI) { + function loadFromAddress (editor, config) { var noInstancesText = self._view.noInstancesText if (noInstancesText.parentNode) { noInstancesText.parentNode.removeChild(noInstancesText) } var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) @@ -395,11 +395,11 @@ function contractDropdown (events, appAPI, appEvents, opts, self) { if (/[a-f]/.test(address) && /[A-F]/.test(address) && !ethJSUtil.isValidChecksumAddress(address)) { return modalDialogCustom.alert('Invalid checksum address.') } - if (/.(.abi)$/.exec(appAPI.currentFile())) { + if (/.(.abi)$/.exec(config.get('currentFile'))) { modalDialogCustom.confirm(null, 'Do you really want to interact with ' + address + ' using the current ABI definition ?', () => { var abi try { - abi = JSON.parse(appAPI.editorContent()) + abi = JSON.parse(editor.currentContent()) } catch (e) { return modalDialogCustom.alert('Failed to parse the current file as JSON ABI.') } From dae762073d01ade169fb3bd3492186647eab76ee Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 11 Apr 2018 15:11:39 +0200 Subject: [PATCH 3/5] remove getSource from rhpAPI --- src/app.js | 3 --- src/app/tabs/compile-tab.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app.js b/src/app.js index b4990bfaaf..629b950146 100644 --- a/src/app.js +++ b/src/app.js @@ -704,9 +704,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org document.querySelector(`.${css.dragbar2}`).style.right = delta + 'px' onResize() }, - getSource: (fileName) => { - return compiler.getSource(fileName) - }, visitContracts: (cb) => { compiler.visitContracts(cb) }, diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index b83f06ea14..aa8ee69a36 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -191,7 +191,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) { if (success) { contractNames.removeAttribute('disabled') appAPI.visitContracts((contract) => { - contractsDetails[contract.name] = parseContracts(contract.name, contract.object, appAPI.getSource(contract.file)) + contractsDetails[contract.name] = parseContracts(contract.name, contract.object, opts.compiler.getSource(contract.file)) var contractName = yo`