Skip to content

Commit

Permalink
remove ediorContent && currentFile
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed May 15, 2018
1 parent eea2aad commit ea30e7f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
11 changes: 3 additions & 8 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
},
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 13 additions & 6 deletions src/app/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,26 +170,33 @@ 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()
}
}

/**
* 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) {
Expand Down
10 changes: 5 additions & 5 deletions src/app/tabs/run-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -319,7 +319,7 @@ function contractDropdown (events, appAPI, appEvents, opts, self) {
${createPanel}
<div class="${css.button}">
${atAddressButtonInput}
<div class="${css.atAddress}" onclick=${function () { loadFromAddress(appAPI) }}>Access</div>
<div class="${css.atAddress}" onclick=${function () { loadFromAddress(opts.editor, opts.config) }}>At Address</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -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]}`)
Expand All @@ -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.')
}
Expand Down

0 comments on commit ea30e7f

Please sign in to comment.