diff --git a/.circleci/config.yml b/.circleci/config.yml index 61aba18604..c419e2f4db 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,10 +26,10 @@ jobs: - checkout - restore_cache: keys: - - dep-bundle-21-{{ checksum "package.json" }} + - dep-bundle-22-{{ checksum "package.json" }} - run: npm install - save_cache: - key: dep-bundle-21-{{ checksum "package.json" }} + key: dep-bundle-22-{{ checksum "package.json" }} paths: - ~/repo/node_modules - run: npm run lint && npm run test && npm run make-mock-compiler && npm run build @@ -46,10 +46,10 @@ jobs: - checkout - restore_cache: keys: - - dep-bundle-16-{{ checksum "package.json" }} + - dep-bundle-17-{{ checksum "package.json" }} - run: npm install - save_cache: - key: dep-bundle-16-{{ checksum "package.json" }} + key: dep-bundle-17-{{ checksum "package.json" }} paths: - ~/repo/node_modules - run: npm run build_debugger diff --git a/ci/browser_tests.sh b/ci/browser_tests.sh index eb1e358e8b..abae1828e9 100755 --- a/ci/browser_tests.sh +++ b/ci/browser_tests.sh @@ -19,7 +19,7 @@ else OS="linux" FILEFORMAT="tar.gz" fi -SC_VERSION="4.4.11" +SC_VERSION="4.5.1" SAUCECONNECT_URL="https://saucelabs.com/downloads/sc-$SC_VERSION-$OS.$FILEFORMAT" SAUCECONNECT_USERNAME="chriseth" SAUCECONNECT_ACCESSKEY="b781828a-9e9c-43d8-89d4-2fbb879595ca" diff --git a/ci/browser_tests_debugger.sh b/ci/browser_tests_debugger.sh index 2aa54fb53b..145e154925 100755 --- a/ci/browser_tests_debugger.sh +++ b/ci/browser_tests_debugger.sh @@ -10,7 +10,7 @@ else OS="linux" FILEFORMAT="tar.gz" fi -SC_VERSION="4.4.11" +SC_VERSION="4.5.1" SAUCECONNECT_URL="https://saucelabs.com/downloads/sc-$SC_VERSION-$OS.$FILEFORMAT" SAUCECONNECT_USERNAME="yanneth" SAUCECONNECT_ACCESSKEY="1f5a4560-b02b-41aa-b52b-f033aad30870" diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js index 6cd6eb1cc9..2cf969d405 100644 --- a/src/app/debugger/debugger.js +++ b/src/app/debugger/debugger.js @@ -39,7 +39,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { this.isActive = false this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, (sourceLocation) => { - return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources) + return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, this._deps.compiler.lastCompilationResult.source.sources, this._deps.compiler.lastCompilationResult.data.sources) }, (step) => { this.debugger_ui.stepManager.jumpTo(step) }) @@ -80,7 +80,7 @@ function Debugger (container, sourceHighlighter, localRegistry) { if (error) return console.log(error) self.debugger.callTree.sourceLocationTracker.getSourceLocationFromVMTraceIndex(address, index, self._deps.compiler.lastCompilationResult.data.contracts, function (error, rawLocation) { if (!error && self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) } else { self._components.sourceHighlighter.currentSourceLocation(null) diff --git a/src/app/editor/contextView.js b/src/app/editor/contextView.js index e4781f6b68..68f861681b 100644 --- a/src/app/editor/contextView.js +++ b/src/app/editor/contextView.js @@ -98,7 +98,7 @@ class ContextView { } } if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) var filename = self._deps.compiler.getSourceName(position.file) // TODO: refactor with rendererAPI.errorClick if (filename !== self._deps.config.get('currentFile')) { diff --git a/src/app/editor/contextualListener.js b/src/app/editor/contextualListener.js index d55965fd49..0b6848b3b4 100644 --- a/src/app/editor/contextualListener.js +++ b/src/app/editor/contextualListener.js @@ -114,7 +114,7 @@ class ContextualListener { _highlightInternal (position, node) { var self = this if (self._deps.compiler.lastCompilationResult && self._deps.compiler.lastCompilationResult.data) { - var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumn = self._deps.offsetToLineColumnConverter.offsetToLineColumn(position, position.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) var css = 'highlightreference' if (node.children && node.children.length) { // If node has children, highlight the entire line. if not, just highlight the current source position of the node. diff --git a/src/app/plugin/pluginAPI.js b/src/app/plugin/pluginAPI.js index a6c8f8dd54..99a738e168 100644 --- a/src/app/plugin/pluginAPI.js +++ b/src/app/plugin/pluginAPI.js @@ -127,6 +127,10 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) => highlighter.currentSourceLocation(null) highlighter.currentSourceLocationFromfileName(position, filePath, hexColor) cb() + }, + discardHighlight: (mod, cb) => { + highlighter.currentSourceLocation(null) + cb() } } } diff --git a/src/app/staticanalysis/staticAnalysisView.js b/src/app/staticanalysis/staticAnalysisView.js index 6bb5b56398..e12d161d49 100644 --- a/src/app/staticanalysis/staticAnalysisView.js +++ b/src/app/staticanalysis/staticAnalysisView.js @@ -97,7 +97,7 @@ staticAnalysisView.prototype.run = function () { start: parseInt(split[0]), length: parseInt(split[1]) } - location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, file, self.lastCompilationSource.sources) + location = self._deps.offsetToLineColumnConverter.offsetToLineColumn(location, parseInt(file), self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) location = Object.keys(self.lastCompilationResult.contracts)[file] + ':' + (location.start.line + 1) + ':' + (location.start.column + 1) + ':' } warningCount++ diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index e4a90efa85..ef83cf1f27 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -615,7 +615,7 @@ const css = csjs` color: ${styles.rightPanel.modalDialog_text_Secondary}; } .icon { - margin-right: 3%; + margin-right: 0.3em; } .spinningIcon { margin-right: .3em; diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 377e953b68..ed540c2ed4 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -292,6 +292,7 @@ function contractDropdown (events, self) { instanceContainer.appendChild(instanceContainerTitle) instanceContainer.appendChild(self._view.noInstancesText) var compFails = yo`` + var info = yo`` self._deps.compiler.event.register('compilationFinished', function (success, data, source) { getContractNames(success, data) if (success) { @@ -303,6 +304,25 @@ function contractDropdown (events, self) { } }) + var deployAction = (value) => { + self._view.createPanel.style.display = value + self._view.orLabel.style.display = value + } + + self._deps.fileManager.event.register('currentFileChanged', (currentFile) => { + document.querySelector(`.${css.contractNames}`).classList.remove(css.contractNamesError) + var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) + contractNames.innerHTML = '' + if (/.(.abi)$/.exec(currentFile)) { + deployAction('none') + compFails.style.display = 'none' + contractNames.appendChild(yo``) + selectContractNames.setAttribute('disabled', true) + } else if (/.(.sol)$/.exec(currentFile)) { + deployAction('block') + } + }) + var atAddressButtonInput = yo`` var selectContractNames = yo`` @@ -317,15 +337,16 @@ function contractDropdown (events, self) { return null } - var createPanel = yo`
` - + self._view.createPanel = yo`
` + self._view.orLabel = yo`
or
` var el = yo`
- ${selectContractNames} ${compFails} + ${selectContractNames} ${compFails} ${info}
-
- ${createPanel} +
+ ${self._view.createPanel} + ${self._view.orLabel}
At Address
${atAddressButtonInput} @@ -335,17 +356,17 @@ function contractDropdown (events, self) { ` function setInputParamsPlaceHolder () { - createPanel.innerHTML = '' + self._view.createPanel.innerHTML = '' if (self._deps.compiler.getContract && selectContractNames.selectedIndex >= 0 && selectContractNames.children.length > 0) { var ctrabi = txHelper.getConstructorInterface(getSelectedContract().contract.object.abi) var ctrEVMbc = getSelectedContract().contract.object.evm.bytecode.object var createConstructorInstance = new MultiParamManager(0, ctrabi, (valArray, inputsValues) => { createInstance(inputsValues) }, txHelper.inputParametersDeclarationToString(ctrabi.inputs), 'Deploy', ctrEVMbc) - createPanel.appendChild(createConstructorInstance.render()) + self._view.createPanel.appendChild(createConstructorInstance.render()) return } else { - createPanel.innerHTML = 'No compiled contracts' + self._view.createPanel.innerHTML = 'No compiled contracts' } } @@ -624,7 +645,6 @@ function settings (container, self) { function newAccount () { self._deps.udapp.newAccount('', (error, address) => { if (!error) { - container.querySelector('#txorigin').appendChild(yo``) addTooltip(`account ${address} created`) } else { addTooltip('Cannot create an account: ' + error) diff --git a/src/app/tabs/styles/run-tab-styles.js b/src/app/tabs/styles/run-tab-styles.js index 02493e9926..1850cd9454 100644 --- a/src/app/tabs/styles/run-tab-styles.js +++ b/src/app/tabs/styles/run-tab-styles.js @@ -124,7 +124,7 @@ var css = csjs` .button { display: flex; align-items: center; - margin-top: 2%; + margin-top: 13px; } .transaction { ${styles.rightPanel.runTab.button_transaction} @@ -140,6 +140,9 @@ var css = csjs` border-bottom-right-radius: 0; border-right: 0; } + .atAddressSect { + margin-top: 6px; + } .atAddressSect input { border-top-left-radius: 0; border-bottom-left-radius: 0; @@ -148,7 +151,8 @@ var css = csjs` ${styles.rightPanel.runTab.button_Create} } .input { - ${styles.rightPanel.runTab.input_RunTab} + ${styles.rightPanel.runTab.input_RunTab}; + font-size: 10px; } .noInstancesText { ${styles.rightPanel.runTab.box_Instance} @@ -233,7 +237,14 @@ var css = csjs` justify-content: space-evenly; ${styles.rightPanel.runTab.box_Info_RunTab}; width: 145px; -} + } + .orLabel { + margin-left: 44px; + } + .infoDeployAction { + margin-left: 5px; + font-size: 13px; + } ` module.exports = css diff --git a/src/lib/cmdInterpreterAPI.js b/src/lib/cmdInterpreterAPI.js index cef5a05579..5f6d8bbe8f 100644 --- a/src/lib/cmdInterpreterAPI.js +++ b/src/lib/cmdInterpreterAPI.js @@ -28,6 +28,7 @@ class CmdInterpreterAPI { offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api } self.commandHelp = { + 'remix.getFile(path)': 'Returns te content of the file located at the given path', 'remix.debug(hash)': 'Start debugging a transaction.', 'remix.loadgist(id)': 'Load a gist in the file explorer.', 'remix.loadurl(url)': 'Load the given url in the file explorer. The url can be of type github, swarm, ipfs or raw http', @@ -45,7 +46,7 @@ class CmdInterpreterAPI { self._components.sourceHighlighter.currentSourceLocation(null) return } - var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) } debug (hash, cb) { @@ -106,7 +107,7 @@ class CmdInterpreterAPI { self.d.goTo = (row) => { if (self._deps.editor.current()) { var breakPoint = new remixLib.code.BreakpointManager(self.d, (sourceLocation) => { - return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, self._deps.compiler.lastCompilationResult.source.sources) + return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, self._deps.compiler.lastCompilationResult.source.sources, self._deps.compiler.lastCompilationResult.data.sources) }) breakPoint.event.register('breakpointHit', (sourceLocation, currentStep) => { self.log(null, 'step index ' + currentStep) @@ -163,6 +164,14 @@ class CmdInterpreterAPI { exeCurrent (cb) { return this.execute(undefined, cb) } + getFile (path, cb) { + var provider = this._deps.fileManager.fileProviderOf(path) + if (provider) { + provider.get(path, cb) + } else { + cb('file not found') + } + } execute (file, cb) { const self = this diff --git a/src/lib/offsetToLineColumnConverter.js b/src/lib/offsetToLineColumnConverter.js index 2a73dfbe6f..d85d443f89 100644 --- a/src/lib/offsetToLineColumnConverter.js +++ b/src/lib/offsetToLineColumnConverter.js @@ -10,10 +10,15 @@ function offsetToColumnConverter (compilerEvent) { }) } -offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources) { +offsetToColumnConverter.prototype.offsetToLineColumn = function (rawLocation, file, sources, asts) { if (!this.lineBreakPositionsByContent[file]) { - var filename = Object.keys(sources)[file] - this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) + for (var filename in asts) { + var source = asts[filename] + if (source.id === file) { + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) + break + } + } } return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) } diff --git a/src/multiParamManager.js b/src/multiParamManager.js index dd4e55559d..6600b78381 100644 --- a/src/multiParamManager.js +++ b/src/multiParamManager.js @@ -122,7 +122,6 @@ class MultiParamManager { var onClick = (domEl) => { this.clickCallBack(this.funABI.inputs, this.basicInputField.value) - this.emptyInputs() } this.contractActionsContainerSingle = yo`
@@ -138,7 +137,6 @@ class MultiParamManager { } else { this.clickCallBack(this.funABI.inputs, '') } - this.emptyInputs() } var button = yo``