From 4be7550dcb2685f42fadad7949cd52698b9e400d Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 3 Sep 2021 12:38:43 +0200 Subject: [PATCH 01/30] do not show undefined property in details --- libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx index 7b85038aa6..efac0765ec 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx @@ -115,7 +115,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { let node if (propertyName === 'web3Deploy' || propertyName === 'name' || propertyName === 'Assembly') { node =
{ details[propertyName] }
- } else if (propertyName === 'abi' || propertyName === 'metadata') { + } else if (details[propertyName] && (propertyName === 'abi' || propertyName === 'metadata')) { if (details[propertyName] !== '') { try { node =
From e3324c9ddf5e7f618b05b8d30935d7dc63fc5740 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 10 Sep 2021 19:33:29 +0200 Subject: [PATCH 02/30] fix gasUsed in the receipt (#1542) Make sure the receipt `gasUsed` is the actual amount of gas used, not the `gasLimit`. --- libs/remix-lib/src/web3Provider/web3VmProvider.ts | 5 +++-- libs/remix-simulator/src/methods/transactions.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.ts b/libs/remix-lib/src/web3Provider/web3VmProvider.ts index ff2c5ac9e8..f29e225e5a 100644 --- a/libs/remix-lib/src/web3Provider/web3VmProvider.ts +++ b/libs/remix-lib/src/web3Provider/web3VmProvider.ts @@ -144,8 +144,9 @@ export class Web3VmProvider { if (lastOp) { lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'DESTRUCT' } - this.vmTraces[this.processingHash].gas = '0x' + data.gasUsed.toString(16) - + const gasUsed = '0x' + data.gasUsed.toString(16) + this.vmTraces[this.processingHash].gas = gasUsed + this.txsReceipt[this.processingHash].gasUsed = gasUsed const logs = [] for (const l in data.execResult.logs) { const log = data.execResult.logs[l] diff --git a/libs/remix-simulator/src/methods/transactions.ts b/libs/remix-simulator/src/methods/transactions.ts index 90e3df270f..44786c6f62 100644 --- a/libs/remix-simulator/src/methods/transactions.ts +++ b/libs/remix-simulator/src/methods/transactions.ts @@ -102,8 +102,8 @@ export class Transactions { transactionIndex: '0x00', blockHash: '0x' + txBlock.hash().toString('hex'), blockNumber: '0x' + txBlock.header.number.toString('hex'), - gasUsed: Web3.utils.toHex(receipt.gas), - cumulativeGasUsed: Web3.utils.toHex(receipt.gas), + gasUsed: receipt.gasUsed, + cumulativeGasUsed: receipt.gasUsed, // only 1 tx per block contractAddress: receipt.contractAddress, logs: receipt.logs, status: receipt.status, From f7e97c88fd2c451d493bf61fb0367cc557462529 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 18 Aug 2021 17:50:51 +0200 Subject: [PATCH 03/30] create solidity web app --- apps/remix-ide/src/app.js | 8 +- apps/remix-ide/src/app/tabs/compile-tab.js | 210 +++------------ .../src/app/tabs/styles/compile-tab-styles.js | 238 +---------------- apps/solidity-compiler/.babelrc | 4 + apps/solidity-compiler/.browserslistrc | 16 ++ apps/solidity-compiler/src/app/app.tsx | 17 ++ .../solidity-compiler/src/app/compiler-api.ts | 248 ++++++++++++++++++ apps/solidity-compiler/src/app/compiler.ts | 40 +++ apps/solidity-compiler/src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 + .../src/environments/environment.ts | 6 + apps/solidity-compiler/src/favicon.ico | Bin 0 -> 15086 bytes apps/solidity-compiler/src/index.html | 14 + apps/solidity-compiler/src/index.ts | 1 + apps/solidity-compiler/src/main.tsx | 11 + apps/solidity-compiler/src/polyfills.ts | 7 + apps/solidity-compiler/src/styles.css | 1 + apps/solidity-compiler/tsconfig.app.json | 9 + apps/solidity-compiler/tsconfig.json | 16 ++ apps/solidity-compiler/tsconfig.spec.json | 15 ++ apps/solidity-compiler/webpack.config.js | 17 ++ libs/remix-ui/debugger-ui/src/index.ts | 1 - libs/remix-ui/solidity-compiler/src/index.ts | 1 + .../src/lib/icompiler-api.ts | 28 ++ .../src/lib/logic/compileTabLogic.ts | 10 +- .../src/lib/solidity-compiler.tsx | 40 ++- .../solidity-compiler/src/lib/types/index.ts | 11 +- nx.json | 5 +- tsconfig.base.json | 1 + workspace.json | 70 +++++ 30 files changed, 621 insertions(+), 427 deletions(-) create mode 100644 apps/solidity-compiler/.babelrc create mode 100644 apps/solidity-compiler/.browserslistrc create mode 100644 apps/solidity-compiler/src/app/app.tsx create mode 100644 apps/solidity-compiler/src/app/compiler-api.ts create mode 100644 apps/solidity-compiler/src/app/compiler.ts create mode 100644 apps/solidity-compiler/src/assets/.gitkeep create mode 100644 apps/solidity-compiler/src/environments/environment.prod.ts create mode 100644 apps/solidity-compiler/src/environments/environment.ts create mode 100644 apps/solidity-compiler/src/favicon.ico create mode 100644 apps/solidity-compiler/src/index.html create mode 100644 apps/solidity-compiler/src/index.ts create mode 100644 apps/solidity-compiler/src/main.tsx create mode 100644 apps/solidity-compiler/src/polyfills.ts create mode 100644 apps/solidity-compiler/src/styles.css create mode 100644 apps/solidity-compiler/tsconfig.app.json create mode 100644 apps/solidity-compiler/tsconfig.json create mode 100644 apps/solidity-compiler/tsconfig.spec.json create mode 100644 apps/solidity-compiler/webpack.config.js create mode 100644 libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index da6aaaf976..76087eb176 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -425,13 +425,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } // CONTENT VIEWS & DEFAULT PLUGINS - const compileTab = new CompileTab( - editor, - registry.get('config').api, - registry.get('fileproviders/browser').api, - registry.get('filemanager').api, - contentImport - ) + const compileTab = new CompileTab() const run = new RunTab( blockchain, registry.get('config').api, diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 2276d759e1..a77ccb4737 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -2,7 +2,7 @@ import React from 'react' // eslint-disable-line import ReactDOM from 'react-dom' import { SolidityCompiler, CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line -import { compile } from '@remix-project/remix-solidity' +import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' import { ViewPlugin } from '@remixproject/engine-web' import * as packageJson from '../../../../../package.json' @@ -13,6 +13,8 @@ var QueryParams = require('../../lib/query-params') const addTooltip = require('../ui/tooltip') const globalRegistry = require('../../global/registry') +const css = require('./styles/compile-tab-styles') + const profile = { name: 'solidity', displayName: 'Solidity compiler', @@ -30,51 +32,19 @@ const profile = { // - events: ['compilationFinished'], // - methods: ['getCompilationResult'] -class CompileTab extends ViewPlugin { - constructor (editor, config, fileProvider, fileManager, contentImport) { +class CompileTab extends CompilerApiMixin(ViewPlugin) { + constructor () { super(profile) - this.events = new EventEmitter() - this._view = { - el: null, - warnCompilationSlow: null, - errorContainer: null, - contractEl: null - } - this.contentImport = contentImport - this.queryParams = new QueryParams() - this.fileProvider = fileProvider - // dependencies - this.editor = editor - this.config = config - this.fileManager = fileManager - this.contractsDetails = {} - this.data = { - eventHandlers: {}, - loading: false - } - this.compileTabLogic = new CompileTabLogic(this, this.contentImport) - this.compiler = this.compileTabLogic.compiler - this.compileTabLogic.init() - this.contractMap = {} - this.isHardHatProject = false - this.compileErrors = {} - this.compiledFileName = '' - this.selectedVersion = '' - this.configurationSettings = null - - this.el = document.createElement('div') - this.el.setAttribute('id', 'compileTabView') + this.initCompilerApi() } - resetResults () { - this.currentFile = '' - this.contractsDetails = {} - this.emit('statusChanged', { key: 'none' }) - this.renderComponent() + renderComponent () { + ReactDOM.render( + + , this.el) } - setCompileErrors (data) { - this.compileErrors = data + onCurrentFileChanged () { this.renderComponent() } @@ -191,6 +161,10 @@ class CompileTab extends ViewPlugin { }) } + onResetResults () { + this.renderComponent() + } + setHardHatCompilation (value) { this.hhCompilation = value } @@ -199,46 +173,27 @@ class CompileTab extends ViewPlugin { this.selectedVersion = version } - getCompilationResult () { - return this.compileTabLogic.compiler.state.lastCompilationResult + onSetWorkspace () { + this.renderComponent() } - addExternalFile (fileName, content) { - this.fileProvider.addExternal(fileName, content) + onNoFileSelected () { + this.renderComponent() } - /** - * compile using @arg fileName. - * The module UI will be updated accordingly to the new compilation result. - * This function is used by remix-plugin compiler API. - * @param {string} fileName to compile - */ - compile (fileName) { - addTooltip(yo`
${this.currentRequest.from} is requiring to compile ${fileName}
`) - return this.compileTabLogic.compileFile(fileName) + onCompilationFinished () { + this.renderComponent() } - /** - * compile using @arg compilationTargets and @arg settings - * The module UI will *not* be updated, the compilation result is returned - * This function is used by remix-plugin compiler API. - * @param {object} map of source files. - * @param {object} settings {evmVersion, optimize, runs, version, language} - */ - async compileWithParameters (compilationTargets, settings) { - settings.version = settings.version || this.selectedVersion - const res = await compile(compilationTargets, settings) - return res - } + render () { + if (this.el) return this.el + this.el = yo` +
+
+
` + this.renderComponent() - // This function is used for passing the compiler configuration to 'remix-tests' - getCurrentCompilerConfig () { - return { - currentVersion: this.selectedVersion, - evmVersion: this.compileTabLogic.evmVersion, - optimize: this.compileTabLogic.optimize, - runs: this.compileTabLogic.runs - } + return this.el } /** @@ -246,89 +201,20 @@ class CompileTab extends ViewPlugin { * This function is used by remix-plugin compiler API. * @param {object} settings {evmVersion, optimize, runs, version, language} */ - setCompilerConfig (settings) { - this.configurationSettings = settings + setCompilerConfig (settings) { + super.setCompilerConfig(settings) this.renderComponent() // @todo(#2875) should use loading compiler return value to check whether the compiler is loaded instead of "setInterval" addTooltip(yo`
${this.currentRequest.from} is updating the Solidity compiler configuration.
${JSON.stringify(settings, null, '\t')}
`) } - // TODO : Add success alert when compilation succeed - contractCompiledSuccess () { - return yo`
` - } - - // TODO : Add error alert when compilation failed - contractCompiledError () { - return yo`
` - } - - /************ - * METHODS - */ - - selectContract (contractName) { - this.selectedContract = contractName - } - - render () { - this.renderComponent() - return this.el - } - - renderComponent () { - ReactDOM.render( - - , this.el) - } - - getParameters () { - return this.queryParams.get() - } - - setParameters (params) { - this.queryParams.update(params) - } - - getConfiguration (name) { - return this.config.get(name) - } - - setConfiguration (name, value) { - this.config.set(name, value) - } - - fileProviderOf (fileName) { - return this.fileManager.fileProviderOf(fileName) - } - - getFileManagerMode () { - return this.fileManager.mode - } - - fileExists (fileName) { - return this.call('fileManager', 'exists', fileName) - } - - writeFile (fileName, content) { - return this.call('fileManager', 'writeFile', fileName, content) - } - - readFile (fileName) { - return this.call('fileManager', 'readFile', fileName) - } - - saveCurrentFile () { - return this.fileManager.saveCurrentFile() - } - - open (fileName) { - return this.call('fileManager', 'open', fileName) + compile (fileName) { + addTooltip(yo`
${this.currentRequest.from} is requiring to compile ${fileName}
`) + super.compile(fileName) } onActivation () { - this.call('manager', 'activatePlugin', 'solidity-logic') - this.listenToEvents() + super.onActivation() this.call('filePanel', 'registerContextMenuItem', { id: 'solidity', name: 'compileFile', @@ -339,32 +225,6 @@ class CompileTab extends ViewPlugin { pattern: [] }) } - - // Returns if the compilation was successfull - async compileFile (event) { - if (event.path.length > 0) { - try { - return await this.compileTabLogic.compileFile(event.path[0]) - } catch (error) { - return false - } - } - return false - } - - onDeactivation () { - this.editor.event.unregister('contentChanged') - this.editor.event.unregister('sessionSwitched') - this.editor.event.unregister('contentChanged', this.data.eventHandlers.onContentChanged) - this.compiler.event.unregister('loadingCompiler', this.data.eventHandlers.onLoadingCompiler) - this.compiler.event.unregister('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) - this.compileTabLogic.event.removeListener('startingCompilation', this.data.eventHandlers.onStartingCompilation) - this.fileManager.events.removeListener('currentFileChanged', this.data.eventHandlers.onCurrentFileChanged) - this.fileManager.events.removeListener('noFileSelected', this.data.eventHandlers.onNoFileSelected) - this.compiler.event.unregister('compilationFinished', this.data.eventHandlers.onCompilationFinished) - globalRegistry.get('themeModule').api.events.removeListener('themeChanged', this.data.eventHandlers.onThemeChanged) - this.call('manager', 'deactivatePlugin', 'solidity-logic') - } } module.exports = CompileTab diff --git a/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js b/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js index b80f46bdec..6ab95aed8c 100644 --- a/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js +++ b/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js @@ -1,239 +1,11 @@ -const csjs = require('csjs-inject') +var csjs = require('csjs-inject') const css = csjs` - .title { - font-size: 1.1em; - font-weight: bold; - margin-bottom: 1em; + .compilerTabView { + padding: 2%; } - .panicError { - color: red; - font-size: 20px; - } - .crow { - display: flex; - overflow: auto; - clear: both; - padding: .2em; - } - .checkboxText { - font-weight: normal; - } - .crow label { - cursor:pointer; - } - .crowNoFlex { - overflow: auto; - clear: both; - } - .info { - padding: 10px; - word-break: break-word; - } - .contract { - display: block; - margin: 3% 0; - } - .nightlyBuilds { - display: flex; - flex-direction: row; - align-items: center; - } - .autocompileContainer { - display: flex; - align-items: center; - } - .runs { - width: 40%; - } - .hideWarningsContainer { - display: flex; - align-items: center; - } - .autocompile {} - .autocompileTitle { - font-weight: bold; - margin: 1% 0; - } - .autocompileText { - margin: 1% 0; - font-size: 12px; - overflow: hidden; - word-break: normal; - line-height: initial; - } - .warnCompilationSlow { - margin-left: 1%; - } - .compilerConfig { - display: flex; - align-items: center; - } - .compilerConfig label { - margin: 0; - } - .compilerSection { - padding: 12px 24px 16px; - } - .compilerLabel { - margin-bottom: 2px; - font-size: 11px; - line-height: 12px; - text-transform: uppercase; - } - .copyButton { - padding: 6px; - font-weight: bold; - font-size: 11px; - line-height: 15px; - } - .name { - display: flex; - } - .size { - display: flex; - } - .checkboxes { - display: flex; - width: 100%; - justify-content: space-between; - flex-wrap: wrap; - } - .compileButton { - width: 100%; - margin: 15px 0 10px 0; - font-size: 12px; - } - .container { - margin: 0; - margin-bottom: 2%; - } - .optimizeContainer { - display: flex; - } - .noContractAlert { - display: flex; - justify-content: center; - align-items: center; - } - .contractHelperButtons { - margin-top: 6px; - display: flex; - align-items: center; - justify-content: space-between; - float: right; - } - .copyToClipboard { - font-size: 1rem; - } - .copyIcon { - margin-right: 5px; - } - .log { - display: flex; - flex-direction: column; - margin-bottom: 5%; - overflow: visible; - } - .key { - margin-right: 5px; - text-transform: uppercase; - width: 100%; - } - .value { - display: flex; - width: 100%; - margin-top: 1.5%; - } - .questionMark { - margin-left: 2%; - cursor: pointer; - } - .questionMark:hover { - } - .detailsJSON { - padding: 8px 0; - border: none; - } - .icon { - margin-right: 0.3em; - } - .errorBlobs { - padding-left: 5px; - padding-right: 5px; - word-break: break-word; - } - .storageLogo { - width: 20px; - height: 20px; - } - .spinningIcon { - display: inline-block; - position: relative; - animation: spin 2s infinite linear; - -moz-animation: spin 2s infinite linear; - -o-animation: spin 2s infinite linear; - -webkit-animation: spin 2s infinite linear; - } - @keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } - } - @-webkit-keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } - } - @-moz-keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } - } - @-o-keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } - } - @-ms-keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } - } - - .bouncingIcon { - display: inline-block; - position: relative; - -moz-animation: bounce 2s infinite linear; - -o-animation: bounce 2s infinite linear; - -webkit-animation: bounce 2s infinite linear; - animation: bounce 2s infinite linear; - } - - @-webkit-keyframes bounce { - 0% { top: 0; } - 50% { top: -0.2em; } - 70% { top: -0.3em; } - 100% { top: 0; } - } - @-moz-keyframes bounce { - 0% { top: 0; } - 50% { top: -0.2em; } - 70% { top: -0.3em; } - 100% { top: 0; } - } - @-o-keyframes bounce { - 0% { top: 0; } - 50% { top: -0.2em; } - 70% { top: -0.3em; } - 100% { top: 0; } - } - @-ms-keyframes bounce { - 0% { top: 0; } - 50% { top: -0.2em; } - 70% { top: -0.3em; } - 100% { top: 0; } - } - @keyframes bounce { - 0% { top: 0; } - 50% { top: -0.2em; } - 70% { top: -0.3em; } - 100% { top: 0; } + .compiler { + margin-bottom: 1%; } ` diff --git a/apps/solidity-compiler/.babelrc b/apps/solidity-compiler/.babelrc new file mode 100644 index 0000000000..09d67939cc --- /dev/null +++ b/apps/solidity-compiler/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["@nrwl/react/babel"], + "plugins": [] +} diff --git a/apps/solidity-compiler/.browserslistrc b/apps/solidity-compiler/.browserslistrc new file mode 100644 index 0000000000..f1d12df4fa --- /dev/null +++ b/apps/solidity-compiler/.browserslistrc @@ -0,0 +1,16 @@ +# This file is used by: +# 1. autoprefixer to adjust CSS to support the below specified browsers +# 2. babel preset-env to adjust included polyfills +# +# For additional information regarding the format and rule options, please see: +# https://github.com/browserslist/browserslist#queries +# +# If you need to support different browsers in production, you may tweak the list below. + +last 1 Chrome version +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major version +last 2 iOS major versions +Firefox ESR +not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file diff --git a/apps/solidity-compiler/src/app/app.tsx b/apps/solidity-compiler/src/app/app.tsx new file mode 100644 index 0000000000..3f3e32eb11 --- /dev/null +++ b/apps/solidity-compiler/src/app/app.tsx @@ -0,0 +1,17 @@ +import React, { useState, useEffect } from 'react'; + +import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line + +import { CompilerClientApi } from './compiler' + +const remix = new CompilerClientApi() + +export const App = () => { + return ( +
+ +
+ ); +}; + +export default App; diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts new file mode 100644 index 0000000000..d85d05da66 --- /dev/null +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -0,0 +1,248 @@ +import { compile } from '@remix-project/remix-solidity' +import { CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line + +export const CompilerApiMixin = (Base) => class extends Base { + initCompilerApi () { + this.configurationSettings = null + + this._view = { + warnCompilationSlow: null, + errorContainer: null, + contractEl: null + } + + this.contractsDetails = {} + this.data = { + eventHandlers: {}, + loading: false + } + this.compileTabLogic = new CompileTabLogic(this, this.contentImport) + this.compiler = this.compileTabLogic.compiler + this.compileTabLogic.init() + + this.contractMap = {} + this.contractsDetails = {} + + this.compileErrors = {} + this.compiledFileName = '' + this.selectedVersion = '' + this.currentFile = '' + } + + onActivation () { + this.call('manager', 'activatePlugin', 'solidity-logic') + this.listenToEvents() + } + + onDeactivation () { + this.call('manager', 'deactivatePlugin', 'solidity-logic') + } + + setHardHatCompilation (value) { + this.hhCompilation = value + } + + setSelectedVersion (version) { + this.selectedVersion = version + } + + getCompilationResult () { + return this.compileTabLogic.compiler.state.lastCompilationResult + } + + addExternalFile (fileName, content) { + this.fileProvider.addExternal(fileName, content) + } + + /** + * compile using @arg fileName. + * The module UI will be updated accordingly to the new compilation result. + * This function is used by remix-plugin compiler API. + * @param {string} fileName to compile + */ + compile (fileName) { + return this.compileTabLogic.compileFile(fileName) + } + + compileFile (event) { + if (event.path.length > 0) { + this.compileTabLogic.compileFile(event.path[0]) + } + } + + /** + * compile using @arg compilationTargets and @arg settings + * The module UI will *not* be updated, the compilation result is returned + * This function is used by remix-plugin compiler API. + * @param {object} map of source files. + * @param {object} settings {evmVersion, optimize, runs, version, language} + */ + async compileWithParameters (compilationTargets, settings) { + settings.version = settings.version || this.selectedVersion + const res = await compile(compilationTargets, settings, (url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) + return res + } + + // This function is used for passing the compiler configuration to 'remix-tests' + getCurrentCompilerConfig () { + return { + currentVersion: this.selectedVersion, + evmVersion: this.compileTabLogic.evmVersion, + optimize: this.compileTabLogic.optimize, + runs: this.compileTabLogic.runs + } + } + + + /** + * set the compiler configuration + * This function is used by remix-plugin compiler API. + * @param {object} settings {evmVersion, optimize, runs, version, language} + */ + setCompilerConfig (settings) { + this.configurationSettings = settings + } + + getParameters () { + return {} + } + + setParameters (params) {} + + getConfiguration (name) { + const conf = { + 'currentFile': () => this.currentFile, + 'hideWarnings': () => false, + 'autoCompile': () => false, + 'includeNightlies': () => false, + 'optimise': () => false + } + return conf[name]() + } + + setConfiguration (name, value) {} + + getFileManagerMode () { + return 'browser' + } + + fileExists (fileName) { + return this.call('fileManager', 'exists', fileName) + } + + writeFile (fileName, content) { + return this.call('fileManager', 'writeFile', fileName, content) + } + + readFile (fileName) { + return this.call('fileManager', 'readFile', fileName) + } + + open (fileName) { + return this.call('fileManager', 'open', fileName) + } + + resetResults () { + this.currentFile = '' + this.contractsDetails = {} + this.emit('statusChanged', { key: 'none' }) + if (this.onResetResults()) this.onResetResults() + } + + listenToEvents () { + this.data.eventHandlers.onContentChanged = () => { + this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' }) + } + this.on('editor', 'contentChanged', this.data.eventHandlers.onContentChanged) + + this.data.eventHandlers.onLoadingCompiler = () => { + this.data.loading = true + this.emit('statusChanged', { key: 'loading', title: 'loading compiler...', type: 'info' }) + } + this.compiler.event.register('loadingCompiler', this.data.eventHandlers.onLoadingCompiler) + + this.data.eventHandlers.onCompilerLoaded = () => { + this.data.loading = false + this.emit('statusChanged', { key: 'none' }) + } + this.compiler.event.register('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) + + this.data.eventHandlers.onStartingCompilation = () => { + this.emit('statusChanged', { key: 'loading', title: 'compiling...', type: 'info' }) + } + + this.data.eventHandlers.onRemoveAnnotations = () => { + this.call('editor', 'clearAnnotations') + } + + this.on('filePanel', 'setWorkspace', (workspace) => { + this.resetResults() + if (this.onSetWorkspace) this.onSetWorkspace(workspace) + }) + + this.compileTabLogic.event.on('startingCompilation', this.data.eventHandlers.onStartingCompilation) + this.compileTabLogic.event.on('removeAnnotations', this.data.eventHandlers.onRemoveAnnotations) + + this.data.eventHandlers.onCurrentFileChanged = (name) => { + this.currentFile = name + if (this.onCurrentFileChanged) this.onCurrentFileChanged(name) + } + this.on('fileManager', 'currentFileChanged', this.data.eventHandlers.onCurrentFileChanged) + + this.data.eventHandlers.onNoFileSelected = () => { + this.currentFile = '' + if (this.onNoFileSelected) this.onNoFileSelected() + } + this.on('fileManager', 'noFileSelected', this.data.eventHandlers.onNoFileSelected) + + this.data.eventHandlers.onCompilationFinished = (success, data, source) => { + this.compileErrors = data + if (success) { + // forwarding the event to the appManager infra + this.emit('compilationFinished', source.target, source, 'soljson', data) + if (data.errors && data.errors.length > 0) { + this.emit('statusChanged', { + key: data.errors.length, + title: `compilation finished successful with warning${data.errors.length > 1 ? 's' : ''}`, + type: 'warning' + }) + } else this.emit('statusChanged', { key: 'succeed', title: 'compilation successful', type: 'success' }) + // Store the contracts + this.contractsDetails = {} + this.compiler.visitContracts((contract) => { + this.contractsDetails[contract.name] = parseContracts( + contract.name, + contract.object, + this.compiler.getSource(contract.file) + ) + }) + } else { + const count = (data.errors ? data.errors.filter(error => error.severity === 'error').length : 0 + data.error ? 1 : 0) + this.emit('statusChanged', { key: count, title: `compilation failed with ${count} error${count.length > 1 ? 's' : ''}`, type: 'error' }) + } + // Update contract Selection + this.contractMap = {} + if (success) this.compiler.visitContracts((contract) => { this.contractMap[contract.name] = contract }) + if (this.onCompilationFinished) this.onCompilationFinished(this.contractsDetails, this.contractMap) + } + this.compiler.event.register('compilationFinished', this.data.eventHandlers.onCompilationFinished) + + this.data.eventHandlers.onThemeChanged = (theme) => { + const invert = theme.quality === 'dark' ? 1 : 0 + const img = document.getElementById('swarmLogo') + if (img) { + img.style.filter = `invert(${invert})` + } + } + this.on('themeModule', 'themeChanged', this.data.eventHandlers.onThemeChanged) + + // Run the compiler instead of trying to save the website + window.document.addEventListener('keydown', (e) => { + // ctrl+s or command+s + if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { + e.preventDefault() + this.compileTabLogic.runCompiler(this.hhCompilation) + } + }) + } +} diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts new file mode 100644 index 0000000000..d16c6a5740 --- /dev/null +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -0,0 +1,40 @@ +import { PluginClient } from "@remixproject/plugin"; +import { createClient } from "@remixproject/plugin-webview"; +import { CompilerApiMixin } from './compiler-api' + +export interface ConfigurationSettings { + version: string, + evmVersion: string, + language: string, + optimize: boolean, + runs: string +} + +export class CompilerClientApi extends CompilerApiMixin(PluginClient) { + contractMap: { + file: string + } | Record + compileErrors: any + compileTabLogic: any + contractsDetails: Record + contentImport: any + call: (...args) => void + on: (...args) => void + setSelectedVersion: (value: string) => void + configurationSettings: ConfigurationSettings + getConfiguration: (value: string) => string + setConfiguration: (name: string, value: string) => void + currentFile: string + + onCurrentFileChanged: (fileName: string) => void + onResetResults: () => void + onSetWorkspace: (workspace: any) => void + onNoFileSelected: () => void + onCompilationFinished: (contractsDetails: any, contractMap: any) => void + + constructor () { + super() + createClient(this as any) + this.initCompilerApi() + } +} diff --git a/apps/solidity-compiler/src/assets/.gitkeep b/apps/solidity-compiler/src/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/solidity-compiler/src/environments/environment.prod.ts b/apps/solidity-compiler/src/environments/environment.prod.ts new file mode 100644 index 0000000000..3612073bc3 --- /dev/null +++ b/apps/solidity-compiler/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/apps/solidity-compiler/src/environments/environment.ts b/apps/solidity-compiler/src/environments/environment.ts new file mode 100644 index 0000000000..d9370e924b --- /dev/null +++ b/apps/solidity-compiler/src/environments/environment.ts @@ -0,0 +1,6 @@ +// This file can be replaced during build by using the `fileReplacements` array. +// When building for production, this file is replaced with `environment.prod.ts`. + +export const environment = { + production: false +}; diff --git a/apps/solidity-compiler/src/favicon.ico b/apps/solidity-compiler/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..317ebcb2336e0833a22dddf0ab287849f26fda57 GIT binary patch literal 15086 zcmeI332;U^%p|z7g|#(P)qFEA@4f!_@qOK2 z_lJl}!lhL!VT_U|uN7%8B2iKH??xhDa;*`g{yjTFWHvXn;2s{4R7kH|pKGdy(7z!K zgftM+Ku7~24TLlh(!g)gz|foI94G^t2^IO$uvX$3(OR0<_5L2sB)lMAMy|+`xodJ{ z_Uh_1m)~h?a;2W{dmhM;u!YGo=)OdmId_B<%^V^{ovI@y`7^g1_V9G}*f# zNzAtvou}I!W1#{M^@ROc(BZ! z+F!!_aR&Px3_reO(EW+TwlW~tv*2zr?iP7(d~a~yA|@*a89IUke+c472NXM0wiX{- zl`UrZC^1XYyf%1u)-Y)jj9;MZ!SLfd2Hl?o|80Su%Z?To_=^g_Jt0oa#CT*tjx>BI z16wec&AOWNK<#i0Qd=1O$fymLRoUR*%;h@*@v7}wApDl^w*h}!sYq%kw+DKDY)@&A z@9$ULEB3qkR#85`lb8#WZw=@})#kQig9oqy^I$dj&k4jU&^2(M3q{n1AKeGUKPFbr z1^<)aH;VsG@J|B&l>UtU#Ejv3GIqERzYgL@UOAWtW<{p#zy`WyJgpCy8$c_e%wYJL zyGHRRx38)HyjU3y{-4z6)pzb>&Q1pR)B&u01F-|&Gx4EZWK$nkUkOI|(D4UHOXg_- zw{OBf!oWQUn)Pe(=f=nt=zkmdjpO^o8ZZ9o_|4tW1ni+Un9iCW47*-ut$KQOww!;u z`0q)$s6IZO!~9$e_P9X!hqLxu`fpcL|2f^I5d4*a@Dq28;@2271v_N+5HqYZ>x;&O z05*7JT)mUe&%S0@UD)@&8SmQrMtsDfZT;fkdA!r(S=}Oz>iP)w=W508=Rc#nNn7ym z1;42c|8($ALY8#a({%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sKK9lbVK&Lo734x7SIFJ9V_}2$@q?zm^7?*XH94w5Qae{7zOMUF z^?%F%)c1Y)Q?Iy?I>knw*8gYW#ok|2gdS=YYZLiD=CW|Nj;n^x!=S#iJ#`~Ld79+xXpVmUK^B(xO_vO!btA9y7w3L3-0j-y4 z?M-V{%z;JI`bk7yFDcP}OcCd*{Q9S5$iGA7*E1@tfkyjAi!;wP^O71cZ^Ep)qrQ)N z#wqw0_HS;T7x3y|`P==i3hEwK%|>fZ)c&@kgKO1~5<5xBSk?iZV?KI6&i72H6S9A* z=U(*e)EqEs?Oc04)V-~K5AUmh|62H4*`UAtItO$O(q5?6jj+K^oD!04r=6#dsxp?~}{`?&sXn#q2 zGuY~7>O2=!u@@Kfu7q=W*4egu@qPMRM>(eyYyaIE<|j%d=iWNdGsx%c!902v#ngNg z@#U-O_4xN$s_9?(`{>{>7~-6FgWpBpqXb`Ydc3OFL#&I}Irse9F_8R@4zSS*Y*o*B zXL?6*Aw!AfkNCgcr#*yj&p3ZDe2y>v$>FUdKIy_2N~}6AbHc7gA3`6$g@1o|dE>vz z4pl(j9;kyMsjaw}lO?(?Xg%4k!5%^t#@5n=WVc&JRa+XT$~#@rldvN3S1rEpU$;XgxVny7mki3 z-Hh|jUCHrUXuLr!)`w>wgO0N%KTB-1di>cj(x3Bav`7v z3G7EIbU$z>`Nad7Rk_&OT-W{;qg)-GXV-aJT#(ozdmnA~Rq3GQ_3mby(>q6Ocb-RgTUhTN)))x>m&eD;$J5Bg zo&DhY36Yg=J=$Z>t}RJ>o|@hAcwWzN#r(WJ52^g$lh^!63@hh+dR$&_dEGu&^CR*< z!oFqSqO@>xZ*nC2oiOd0eS*F^IL~W-rsrO`J`ej{=ou_q^_(<$&-3f^J z&L^MSYWIe{&pYq&9eGaArA~*kA + + + + SolidityCompiler + + + + + + +
+ + diff --git a/apps/solidity-compiler/src/index.ts b/apps/solidity-compiler/src/index.ts new file mode 100644 index 0000000000..776e9a33df --- /dev/null +++ b/apps/solidity-compiler/src/index.ts @@ -0,0 +1 @@ +export * from './app/compiler-api'; diff --git a/apps/solidity-compiler/src/main.tsx b/apps/solidity-compiler/src/main.tsx new file mode 100644 index 0000000000..89c91fbb14 --- /dev/null +++ b/apps/solidity-compiler/src/main.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; + +import App from './app/app'; + +ReactDOM.render( + + + , + document.getElementById('root') +); diff --git a/apps/solidity-compiler/src/polyfills.ts b/apps/solidity-compiler/src/polyfills.ts new file mode 100644 index 0000000000..2adf3d05b6 --- /dev/null +++ b/apps/solidity-compiler/src/polyfills.ts @@ -0,0 +1,7 @@ +/** + * Polyfill stable language features. These imports will be optimized by `@babel/preset-env`. + * + * See: https://github.com/zloirock/core-js#babel + */ +import 'core-js/stable'; +import 'regenerator-runtime/runtime'; diff --git a/apps/solidity-compiler/src/styles.css b/apps/solidity-compiler/src/styles.css new file mode 100644 index 0000000000..90d4ee0072 --- /dev/null +++ b/apps/solidity-compiler/src/styles.css @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/apps/solidity-compiler/tsconfig.app.json b/apps/solidity-compiler/tsconfig.app.json new file mode 100644 index 0000000000..2151bb6497 --- /dev/null +++ b/apps/solidity-compiler/tsconfig.app.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts", "**/*.spec.tsx"], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/apps/solidity-compiler/tsconfig.json b/apps/solidity-compiler/tsconfig.json new file mode 100644 index 0000000000..7c6fcde8f2 --- /dev/null +++ b/apps/solidity-compiler/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "jsx": "react", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "types": ["node", "jest"], + "resolveJsonModule": true + }, + "files": [ + "../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/apps/solidity-compiler/tsconfig.spec.json b/apps/solidity-compiler/tsconfig.spec.json new file mode 100644 index 0000000000..559410b96a --- /dev/null +++ b/apps/solidity-compiler/tsconfig.spec.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "**/*.spec.ts", + "**/*.spec.tsx", + "**/*.spec.js", + "**/*.spec.jsx", + "**/*.d.ts" + ] +} diff --git a/apps/solidity-compiler/webpack.config.js b/apps/solidity-compiler/webpack.config.js new file mode 100644 index 0000000000..bacc6e251e --- /dev/null +++ b/apps/solidity-compiler/webpack.config.js @@ -0,0 +1,17 @@ +const nxWebpack = require('@nrwl/react/plugins/webpack') + +module.exports = config => { + const nxWebpackConfig = nxWebpack(config) + + return { + ...nxWebpackConfig, + node: { + fs: 'empty', + tls: 'empty', + readline: 'empty', + net: 'empty', + module: 'empty', + child_process: 'empty' + } + } +} diff --git a/libs/remix-ui/debugger-ui/src/index.ts b/libs/remix-ui/debugger-ui/src/index.ts index bc404baa76..840763d2ef 100644 --- a/libs/remix-ui/debugger-ui/src/index.ts +++ b/libs/remix-ui/debugger-ui/src/index.ts @@ -1,3 +1,2 @@ export * from './lib/debugger-ui' export * from './lib/idebugger-api' -export * from './lib/idebugger-api' diff --git a/libs/remix-ui/solidity-compiler/src/index.ts b/libs/remix-ui/solidity-compiler/src/index.ts index 317c79cefa..073b7eeacc 100644 --- a/libs/remix-ui/solidity-compiler/src/index.ts +++ b/libs/remix-ui/solidity-compiler/src/index.ts @@ -1,2 +1,3 @@ export * from './lib/solidity-compiler' export * from './lib/logic' +export * from './lib/icompiler-api' diff --git a/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts b/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts new file mode 100644 index 0000000000..8ff1df432e --- /dev/null +++ b/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts @@ -0,0 +1,28 @@ +export type onCurrentFileChanged = (fileName: string) => void + +export interface ICompilerApi { + contractMap: { + file: string + } | Record + + compileErrors:any + + currentFile: string + configurationSettings: any + setHardHatCompilation(value: boolean): void + setSelectedVersion(version: string): void + getCompilationResult(): any + setCompilerConfig: (settings: any) => void + getParameters: () => any + setParameters: (params) => void + getConfiguration: (name: string) => string + setConfiguration: (name: string, value: string) => void + fileProviderOf: (file: string) => string + getFileManagerMode: () => string + fileExists: (file: string) => Promise + writeFile: (file: string, content: string) => Promise + readFile: (file: string) => Promise + open: (file: string) => void + addExternalFile: (file: string, content: string) => void + onCurrentFileChanged: (listener: onCurrentFileChanged) => void +} diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index eaba281abe..09aa9ad66f 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -87,15 +87,14 @@ export class CompileTab extends Plugin { */ compileFile (target) { if (!target) throw new Error('No target provided for compiliation') - const provider = this.api.fileProviderOf(target) - if (!provider) throw new Error(`cannot compile ${target}. Does not belong to any explorer`) return new Promise((resolve, reject) => { - provider.get(target, (error, content) => { - if (error) return reject(error) + this.api.readFile(target).then((content) => { const sources = { [target]: { content } } this.event.emit('startingCompilation') // setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation') setTimeout(() => { this.compiler.compile(sources, target); resolve(true) }, 100) + }).catch((error) => { + reject(error) }) }) } @@ -131,7 +130,8 @@ export class CompileTab extends Plugin { }) } } - this.api.saveCurrentFile() + // TODO readd saving current file + // this.api.saveCurrentFile() this.event.emit('removeAnnotations') var currentFile = this.api.getConfiguration('currentFile') return this.compileFile(currentFile) diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 46c032d582..57acbbd18b 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,10 +9,12 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props + const { plugin, plugin: { currentFile, compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props const [state, setState] = useState({ + isHardhatProject: false, + currentFile, contractsDetails: {}, - eventHandlers: {}, + contractMap: {}, loading: false, compileTabLogic: null, compiler: null, @@ -30,6 +32,37 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { }) const [currentVersion, setCurrentVersion] = useState('') + plugin.onCurrentFileChanged = (currentFile: string) => { + setState(prevState => { + return { ...prevState, currentFile } + }) + } + + plugin.onResetResults = () => { + setState(prevState => { + return { ...prevState, currentFile: '', contractsDetails: {}, contractMap: {} } + }) + } + + plugin.onSetWorkspace = async (workspace: any) => { + const isHardhat = workspace.isLocalhost && await compileTabLogic.isHardhatProject() + setState(prevState => { + return { ...prevState, currentFile, isHardhatProject: isHardhat } + }) + } + + plugin.onNoFileSelected = () => { + setState(prevState => { + return { ...prevState, currentFile: '' } + }) + } + + plugin.onCompilationFinished = (contractsDetails: any, contractMap: any) => { + setState(prevState => { + return { ...prevState, contractsDetails, contractMap } + }) + } + const toast = (message: string) => { setState(prevState => { return { ...prevState, toasterMsg: message } @@ -75,11 +108,10 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
) - const currentFile = plugin.getConfiguration('currentFile') return ( <>
- +
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index a2106e2205..5aae51ab93 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -1,5 +1,8 @@ +export type onCurrentFileChanged = (fileName: string) => void + export interface SolidityCompilerProps { plugin: { + currentFile: string contractMap: { file: string } | Record @@ -12,13 +15,19 @@ export interface SolidityCompilerProps { setSelectedVersion: (value: string) => void, configurationSettings: ConfigurationSettings, getConfiguration: (value: string) => string, - setConfiguration: (name: string, value: string) => void + setConfiguration: (name: string, value: string) => void, + onCurrentFileChanged: (fileName: string) => void, + onResetResults: () => void, + onSetWorkspace: (workspace: any) => void, + onNoFileSelected: () => void, + onCompilationFinished: (contractsDetails: any, contractMap: any) => void }, } export interface CompilerContainerProps { api: any, compileTabLogic: any, + isHardhatProject: boolean, tooltip: (message: string | JSX.Element) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, compiledFileName: string, diff --git a/nx.json b/nx.json index 62fadd942e..b1c4b6de08 100644 --- a/nx.json +++ b/nx.json @@ -98,7 +98,7 @@ "tags": [] }, "remix-ui-settings": { - "tags": [] + "tags": [] }, "remix-ui-static-analyser": { "tags": [] @@ -120,6 +120,9 @@ }, "remix-ui-renderer": { "tags": [] + }, + "solidity-compiler": { + "tags": [] } } } diff --git a/tsconfig.base.json b/tsconfig.base.json index 3efbbce238..541c18c889 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -25,6 +25,7 @@ "@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"], "@remix-project/remix-url-resolver": ["dist/libs/remix-url-resolver/index.js"], "@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"], + "@remixproject/solidity-compiler-plugin": ["apps/solidity-compiler/src/index.ts"], "@remix-project/remixd": ["dist/libs/remixd/index.js"], "@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"], "@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"], diff --git a/workspace.json b/workspace.json index 54bf6be2c5..5a885656d1 100644 --- a/workspace.json +++ b/workspace.json @@ -875,6 +875,76 @@ } } } + }, + "solidity-compiler": { + "root": "apps/solidity-compiler", + "sourceRoot": "apps/solidity-compiler/src", + "projectType": "application", + "schematics": {}, + "architect": { + "build": { + "builder": "@nrwl/web:build", + "options": { + "outputPath": "dist/apps/solidity-compiler", + "index": "apps/solidity-compiler/src/index.html", + "main": "apps/solidity-compiler/src/main.tsx", + "polyfills": "apps/solidity-compiler/src/polyfills.ts", + "tsConfig": "apps/solidity-compiler/tsconfig.app.json", + "assets": [ + "apps/solidity-compiler/src/favicon.ico", + "apps/solidity-compiler/src/assets", + "apps/solidity-compiler/src/index.html" + ], + "styles": ["apps/solidity-compiler/src/styles.css"], + "scripts": [], + "webpackConfig": "apps/solidity-compiler/webpack.config.js", + "maxWorkers": 2 + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "apps/solidity-compiler/src/environments/environment.ts", + "with": "apps/solidity-compiler/src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ] + } + } + }, + "serve": { + "builder": "@nrwl/web:dev-server", + "options": { + "buildTarget": "solidity-compiler:build" + }, + "configurations": { + "production": { + "buildTarget": "solidity-compiler:build:production" + } + } + }, + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": ["apps/solidity-compiler/tsconfig.app.json"], + "exclude": ["**/node_modules/**", "!apps/solidity-compiler/**/*"] + } + } + } } }, "cli": { From eb38865e42decdc66c70c2d715ea70f9e419c44d Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Aug 2021 15:25:54 +0200 Subject: [PATCH 04/30] make sure compile-logic do not use call directly --- apps/solidity-compiler/src/app/compiler-api.ts | 12 ++++++++++++ .../src/lib/logic/compileTabLogic.ts | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index d85d05da66..3f1c13779f 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -38,6 +38,18 @@ export const CompilerApiMixin = (Base) => class extends Base { this.call('manager', 'deactivatePlugin', 'solidity-logic') } + resolveContentAndSave (url) { + return this.call('contentImport', 'resolveAndSave', url) + } + + compileWithHardhat (configFile) { + return this.call('hardhat', 'compile', configFile) + } + + logToTerminal (content) { + return this.call('terminal', 'log', content) + } + setHardHatCompilation (value) { this.hhCompilation = value } diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 09aa9ad66f..f28a1b8988 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -29,7 +29,7 @@ export class CompileTab extends Plugin { constructor (public api, public contentImport) { super(profile) this.event = new EventEmitter() - this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) + this.compiler = new Compiler((url, cb) => api.resolveContentAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message))) } init () { @@ -123,10 +123,10 @@ export class CompileTab extends Plugin { const configFilePath = 'remix-compiler.config.js' this.api.writeFile(configFilePath, fileContent) _paq.push(['trackEvent', 'compiler', 'compileWithHardhat']) - this.call('hardhat', 'compile', configFilePath).then((result) => { - this.call('terminal', 'log', { type: 'info', value: result }) + this.api.compileWithHardhat(configFilePath).then((result) => { + this.api.logToTerminal({ type: 'info', value: result }) }).catch((error) => { - this.call('terminal', 'log', { type: 'error', value: error }) + this.api.logToTerminal({ type: 'error', value: error }) }) } } From 42220cfda02a2998a10f2adc220903792ed72adc Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Aug 2021 15:34:43 +0200 Subject: [PATCH 05/30] ensure API is public --- apps/remix-ide/src/app/tabs/compile-tab.js | 14 +++++++++++++- apps/solidity-compiler/src/app/compiler.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index a77ccb4737..037a14492f 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -196,12 +196,20 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { return this.el } + async compileWithParameters (compilationTargets, settings) { + return await super.compileWithParameters(compilationTargets, settings) + } + + getCompilationResult () { + return super.getCompilationResult() + } + /** * set the compiler configuration * This function is used by remix-plugin compiler API. * @param {object} settings {evmVersion, optimize, runs, version, language} */ - setCompilerConfig (settings) { + setCompilerConfig (settings) { super.setCompilerConfig(settings) this.renderComponent() // @todo(#2875) should use loading compiler return value to check whether the compiler is loaded instead of "setInterval" @@ -213,6 +221,10 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { super.compile(fileName) } + compileFile (event) { + return super.compileFile(event) + } + onActivation () { super.onActivation() this.call('filePanel', 'registerContextMenuItem', { diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index d16c6a5740..f42d2f88bd 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -2,6 +2,19 @@ import { PluginClient } from "@remixproject/plugin"; import { createClient } from "@remixproject/plugin-webview"; import { CompilerApiMixin } from './compiler-api' +const profile = { + name: 'solidity', + displayName: 'Solidity compiler', + icon: 'assets/img/solidity.webp', + description: 'Compile solidity contracts', + kind: 'compiler', + permission: true, + location: 'sidePanel', + documentation: 'https://remix-ide.readthedocs.io/en/latest/solidity_editor.html', + version: '0.0.1', + methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile'] +} + export interface ConfigurationSettings { version: string, evmVersion: string, From ab12707703d2f1c22861640a4933a56f0bfe8d91 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Aug 2021 15:56:34 +0200 Subject: [PATCH 06/30] fix usage of solidity logic --- apps/remix-ide/src/app.js | 1 - apps/remix-ide/src/app/tabs/compile-tab.js | 2 +- apps/solidity-compiler/src/app/compiler-api.ts | 9 +++------ apps/solidity-compiler/src/app/compiler.ts | 2 +- .../src/lib/publish-to-storage.tsx | 4 ++-- .../solidity-compiler/src/lib/icompiler-api.ts | 1 - .../src/lib/logic/compileTabLogic.ts | 13 +------------ .../src/lib/remix-ui-static-analyser.tsx | 2 +- 8 files changed, 9 insertions(+), 25 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 76087eb176..2668dff15c 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -450,7 +450,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org engine.register([ compileTab, - compileTab.compileTabLogic, run, debug, analysis, diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 037a14492f..6a69f99ad9 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -25,7 +25,7 @@ const profile = { location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/solidity_editor.html', version: packageJson.version, - methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile'] + methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile', 'getCompilerState'] } // EditorApi: diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index 3f1c13779f..e29981c14e 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -30,13 +30,10 @@ export const CompilerApiMixin = (Base) => class extends Base { } onActivation () { - this.call('manager', 'activatePlugin', 'solidity-logic') this.listenToEvents() } - onDeactivation () { - this.call('manager', 'deactivatePlugin', 'solidity-logic') - } + onDeactivation () {} resolveContentAndSave (url) { return this.call('contentImport', 'resolveAndSave', url) @@ -62,8 +59,8 @@ export const CompilerApiMixin = (Base) => class extends Base { return this.compileTabLogic.compiler.state.lastCompilationResult } - addExternalFile (fileName, content) { - this.fileProvider.addExternal(fileName, content) + getCompilerState () { + return this.compileTabLogic.getCompilerState() } /** diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index f42d2f88bd..201a680085 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -12,7 +12,7 @@ const profile = { location: 'sidePanel', documentation: 'https://remix-ide.readthedocs.io/en/latest/solidity_editor.html', version: '0.0.1', - methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile'] + methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile' ,'getCompilerState'] } export interface ConfigurationSettings { diff --git a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx index f8f5878aa0..ed8ca6a65f 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx +++ b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx @@ -29,7 +29,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) // triggered each time there's a new verified publish (means hash correspond) - api.addExternalFile('swarm/' + result.item.hash, result.item.content) + api.writeFile('swarm/' + result.item.hash, result.item.content) } catch (err) { let parseError = err try { @@ -43,7 +43,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) // triggered each time there's a new verified publish (means hash correspond) - api.addExternalFile('ipfs/' + result.item.hash, result.item.content) + api.writeFile('ipfs/' + result.item.hash, result.item.content) } catch (err) { modal('IPFS Publish Failed', publishMessageFailed(storage, err)) } diff --git a/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts b/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts index 8ff1df432e..7bac190abe 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts @@ -23,6 +23,5 @@ export interface ICompilerApi { writeFile: (file: string, content: string) => Promise readFile: (file: string) => Promise open: (file: string) => void - addExternalFile: (file: string, content: string) => void onCurrentFileChanged: (listener: onCurrentFileChanged) => void } diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index f28a1b8988..ea0f5c5425 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -1,15 +1,5 @@ -import { Plugin } from '@remixproject/engine' - -const packageJson = require('../../../../../../package.json') const Compiler = require('@remix-project/remix-solidity').Compiler const EventEmitter = require('events') -const profile = { - name: 'solidity-logic', - displayName: 'Solidity compiler logic', - description: 'Compile solidity contracts - Logic', - methods: ['getCompilerState'], - version: packageJson.version -} declare global { interface Window { @@ -18,7 +8,7 @@ declare global { } const _paq = window._paq = window._paq || [] //eslint-disable-line -export class CompileTab extends Plugin { +export class CompileTab { public compiler public optimize public runs @@ -27,7 +17,6 @@ export class CompileTab extends Plugin { public event constructor (public api, public contentImport) { - super(profile) this.event = new EventEmitter() this.compiler = new Compiler((url, cb) => api.resolveContentAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message))) } diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 2f45e44830..bd88dad856 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -217,7 +217,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }) // Slither Analysis if (slitherEnabled) { - props.analysisModule.call('solidity-logic', 'getCompilerState').then(async (compilerState) => { + props.analysisModule.call('solidity', 'getCompilerState').then((compilerState) => { const { currentVersion, optimize, evmVersion } = compilerState props.analysisModule.call('terminal', 'log', { type: 'info', value: '[Slither Analysis]: Running...' }) _paq.push(['trackEvent', 'solidityStaticAnalyzer', 'analyzeWithSlither']) From 0e7f088fc39ad32782f4a499d378cee0e5b6c09f Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 19 Aug 2021 16:33:07 +0200 Subject: [PATCH 07/30] fix index.html --- apps/solidity-compiler/src/index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/solidity-compiler/src/index.html b/apps/solidity-compiler/src/index.html index 20d2fdd17f..45be468da6 100644 --- a/apps/solidity-compiler/src/index.html +++ b/apps/solidity-compiler/src/index.html @@ -2,11 +2,12 @@ - SolidityCompiler - + Solidity Compiler + +
From 1aff58dbfbfb4ed6e15b8a778611aa258b34d862 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 23 Aug 2021 18:36:19 +0200 Subject: [PATCH 08/30] fix iframe plugin api --- apps/remix-ide/src/app/tabs/compile-tab.js | 113 ------------------ .../solidity-compiler/src/app/compiler-api.ts | 22 +++- apps/solidity-compiler/src/app/compiler.ts | 26 +++- libs/remix-ui/solidity-compiler/src/index.ts | 3 +- .../src/lib/actions/compiler.ts | 10 +- .../src/lib/compiler-container.tsx | 2 +- .../src/lib/icompiler-api.ts | 27 ----- .../src/lib/solidity-compiler.tsx | 6 +- .../solidity-compiler/src/lib/types/index.ts | 56 +++++---- 9 files changed, 82 insertions(+), 183 deletions(-) delete mode 100644 libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 6a69f99ad9..39c66d3ec6 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -48,119 +48,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { this.renderComponent() } - /************ - * EVENTS - */ - - listenToEvents () { - this.data.eventHandlers.onContentChanged = () => { - this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' }) - } - this.editor.event.register('contentChanged', this.data.eventHandlers.onContentChanged) - - this.data.eventHandlers.onLoadingCompiler = () => { - this.data.loading = true - this.emit('statusChanged', { key: 'loading', title: 'loading compiler...', type: 'info' }) - } - this.compiler.event.register('loadingCompiler', this.data.eventHandlers.onLoadingCompiler) - - this.data.eventHandlers.onCompilerLoaded = () => { - this.data.loading = false - this.emit('statusChanged', { key: 'none' }) - } - this.compiler.event.register('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) - - this.data.eventHandlers.onStartingCompilation = () => { - this.emit('statusChanged', { key: 'loading', title: 'compiling...', type: 'info' }) - } - - this.data.eventHandlers.onRemoveAnnotations = () => { - this.call('editor', 'clearAnnotations') - } - - const resetView = (isLocalhost) => { - this.compileTabLogic.isHardhatProject().then((result) => { - if (result && isLocalhost) this.isHardHatProject = true - else this.isHardHatProject = false - this.renderComponent() - }) - this.resetResults() - } - - this.on('filePanel', 'setWorkspace', (workspace) => { - resetView(workspace.isLocalhost) - }) - - this.on('remixd', 'rootFolderChanged', () => { - resetView(true) - }) - - this.compileTabLogic.event.on('startingCompilation', this.data.eventHandlers.onStartingCompilation) - this.compileTabLogic.event.on('removeAnnotations', this.data.eventHandlers.onRemoveAnnotations) - - this.data.eventHandlers.onCurrentFileChanged = (name) => { - this.currentFile = name - this.renderComponent() - } - this.fileManager.events.on('currentFileChanged', this.data.eventHandlers.onCurrentFileChanged) - - this.data.eventHandlers.onNoFileSelected = () => { - this.currentFile = '' - this.renderComponent() - } - this.fileManager.events.on('noFileSelected', this.data.eventHandlers.onNoFileSelected) - - this.data.eventHandlers.onCompilationFinished = (success, data, source) => { - this.setCompileErrors(data) - if (success) { - // forwarding the event to the appManager infra - this.emit('compilationFinished', source.target, source, 'soljson', data) - if (data.errors && data.errors.length > 0) { - this.emit('statusChanged', { - key: data.errors.length, - title: `compilation finished successful with warning${data.errors.length > 1 ? 's' : ''}`, - type: 'warning' - }) - } else this.emit('statusChanged', { key: 'succeed', title: 'compilation successful', type: 'success' }) - // Store the contracts - this.contractsDetails = {} - this.compiler.visitContracts((contract) => { - this.contractsDetails[contract.name] = parseContracts( - contract.name, - contract.object, - this.compiler.getSource(contract.file) - ) - }) - } else { - const count = (data.errors ? data.errors.filter(error => error.severity === 'error').length : 0) + data.error ? 1 : 0 - this.emit('statusChanged', { key: count, title: `compilation failed with ${count} error${count.length > 1 ? 's' : ''}`, type: 'error' }) - } - // Update contract Selection - this.contractMap = {} - if (success) this.compiler.visitContracts((contract) => { this.contractMap[contract.name] = contract }) - this.renderComponent() - } - this.compiler.event.register('compilationFinished', this.data.eventHandlers.onCompilationFinished) - - this.data.eventHandlers.onThemeChanged = (theme) => { - const invert = theme.quality === 'dark' ? 1 : 0 - const img = document.getElementById('swarmLogo') - if (img) { - img.style.filter = `invert(${invert})` - } - } - globalRegistry.get('themeModule').api.events.on('themeChanged', this.data.eventHandlers.onThemeChanged) - - // Run the compiler instead of trying to save the website - $(window).keydown((e) => { - // ctrl+s or command+s - if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { - e.preventDefault() - this.compileTabLogic.runCompiler(this.hhCompilation) - } - }) - } - onResetResults () { this.renderComponent() } diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index e29981c14e..edc69528cd 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -123,8 +123,7 @@ export const CompilerApiMixin = (Base) => class extends Base { 'currentFile': () => this.currentFile, 'hideWarnings': () => false, 'autoCompile': () => false, - 'includeNightlies': () => false, - 'optimise': () => false + 'includeNightlies': () => false } return conf[name]() } @@ -186,7 +185,20 @@ export const CompilerApiMixin = (Base) => class extends Base { this.on('filePanel', 'setWorkspace', (workspace) => { this.resetResults() - if (this.onSetWorkspace) this.onSetWorkspace(workspace) + if (this.onSetWorkspace) this.onSetWorkspace(workspace.isLocalhost) + }) + + this.on('remixd', 'rootFolderChanged', () => { + this.resetResults() + if (this.onSetWorkspace) this.onSetWorkspace(true) + }) + + this.on('editor', 'sessionSwitched', () => { + if (this.onSessionSwitched) this.onSessionSwitched() + }) + + this.on('editor', 'contentChanged', () => { + if (this.onContentChanged) this.onContentChanged() }) this.compileTabLogic.event.on('startingCompilation', this.data.eventHandlers.onStartingCompilation) @@ -226,8 +238,8 @@ export const CompilerApiMixin = (Base) => class extends Base { ) }) } else { - const count = (data.errors ? data.errors.filter(error => error.severity === 'error').length : 0 + data.error ? 1 : 0) - this.emit('statusChanged', { key: count, title: `compilation failed with ${count} error${count.length > 1 ? 's' : ''}`, type: 'error' }) + const count = (data.errors ? data.errors.filter(error => error.severity === 'error').length : 0) + data.error ? 1 : 0 + this.emit('statusChanged', { key: count, title: `compilation failed with ${count} error${count > 1 ? 's' : ''}`, type: 'error' }) } // Update contract Selection this.contractMap = {} diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 201a680085..7e6deb8c98 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -24,26 +24,40 @@ export interface ConfigurationSettings { } export class CompilerClientApi extends CompilerApiMixin(PluginClient) { + // interface matches libs/remix-ui/solidity-compiler/types/index.ts : ICompilerApi + currentFile: string contractMap: { file: string } | Record compileErrors: any compileTabLogic: any contractsDetails: Record - contentImport: any - call: (...args) => void - on: (...args) => void - setSelectedVersion: (value: string) => void configurationSettings: ConfigurationSettings + + setHardHatCompilation: (value: boolean) => void + getParameters: () => ConfigurationSettings + setParameters: (params: Partial) => void + setCompilerConfig: (settings: ConfigurationSettings) => void + getConfiguration: (value: string) => string setConfiguration: (name: string, value: string) => void - currentFile: string + getFileManagerMode: () => string + + + getCompilationResult: () => any onCurrentFileChanged: (fileName: string) => void onResetResults: () => void - onSetWorkspace: (workspace: any) => void + onSetWorkspace: (isLocalhost: boolean) => void onNoFileSelected: () => void onCompilationFinished: (contractsDetails: any, contractMap: any) => void + onSessionSwitched: () => void + onContentChanged: () => void + + fileExists: (file: string) => Promise + writeFile: (file: string, content: string) => Promise + readFile: (file: string) => Promise + open: (file: string) => void constructor () { super() diff --git a/libs/remix-ui/solidity-compiler/src/index.ts b/libs/remix-ui/solidity-compiler/src/index.ts index 073b7eeacc..30a13c42f4 100644 --- a/libs/remix-ui/solidity-compiler/src/index.ts +++ b/libs/remix-ui/solidity-compiler/src/index.ts @@ -1,3 +1,2 @@ export * from './lib/solidity-compiler' -export * from './lib/logic' -export * from './lib/icompiler-api' +export * from './lib/logic' \ No newline at end of file diff --git a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts index e0e2a46498..96316c8bd5 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -27,9 +27,9 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch) => { } export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatch) => { - api.on('editor', 'sessionSwitched', () => { + api.onSessionSwitched = () => { dispatch(setEditorMode('sessionSwitched')) - }) + } compileTabLogic.event.on('startingCompilation', () => { dispatch(setCompilerMode('startingCompilation')) @@ -39,10 +39,10 @@ export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatc dispatch(setCompilerMode('compilationDuration', speed)) }) - api.on('editor', 'contentChanged', () => { + api.onContentChanged = () => { dispatch(setEditorMode('contentChanged')) - }) - + } + compileTabLogic.compiler.event.register('loadingCompiler', () => { dispatch(setCompilerMode('loadingCompiler')) }) diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 80b1004ab6..3bd1032c76 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -76,7 +76,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { hideWarnings: api.getConfiguration('hideWarnings') || false, autoCompile: typeof autoCompile === 'boolean' ? autoCompile : api.getConfiguration('autoCompile') || false, includeNightlies: api.getConfiguration('includeNightlies') || false, - optimise: typeof optimize === 'boolean' ? optimize : api.getConfiguration('optimise') || false, + optimize: (optimize !== null) && (optimize !== undefined) ? optimize : false, runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200, evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' } diff --git a/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts b/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts deleted file mode 100644 index 7bac190abe..0000000000 --- a/libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts +++ /dev/null @@ -1,27 +0,0 @@ -export type onCurrentFileChanged = (fileName: string) => void - -export interface ICompilerApi { - contractMap: { - file: string - } | Record - - compileErrors:any - - currentFile: string - configurationSettings: any - setHardHatCompilation(value: boolean): void - setSelectedVersion(version: string): void - getCompilationResult(): any - setCompilerConfig: (settings: any) => void - getParameters: () => any - setParameters: (params) => void - getConfiguration: (name: string) => string - setConfiguration: (name: string, value: string) => void - fileProviderOf: (file: string) => string - getFileManagerMode: () => string - fileExists: (file: string) => Promise - writeFile: (file: string, content: string) => Promise - readFile: (file: string) => Promise - open: (file: string) => void - onCurrentFileChanged: (listener: onCurrentFileChanged) => void -} diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 57acbbd18b..792beb8829 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -44,8 +44,8 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { }) } - plugin.onSetWorkspace = async (workspace: any) => { - const isHardhat = workspace.isLocalhost && await compileTabLogic.isHardhatProject() + plugin.onSetWorkspace = async (isLocalhost: boolean) => { + const isHardhat = isLocalhost && await compileTabLogic.isHardhatProject() setState(prevState => { return { ...prevState, currentFile, isHardhatProject: isHardhat } }) @@ -71,7 +71,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { const updateCurrentVersion = (value) => { setCurrentVersion(value) - plugin.setSelectedVersion(value) + plugin.setParameters({ version: value }) } const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => { diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 5aae51ab93..b477a8df85 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -1,27 +1,41 @@ export type onCurrentFileChanged = (fileName: string) => void export interface SolidityCompilerProps { - plugin: { - currentFile: string - contractMap: { - file: string - } | Record - compileErrors: any, - compileTabLogic: any, - contractsDetails: Record, - contentImport: any, - call: (...args) => void - on: (...args) => void, - setSelectedVersion: (value: string) => void, - configurationSettings: ConfigurationSettings, - getConfiguration: (value: string) => string, - setConfiguration: (name: string, value: string) => void, - onCurrentFileChanged: (fileName: string) => void, - onResetResults: () => void, - onSetWorkspace: (workspace: any) => void, - onNoFileSelected: () => void, - onCompilationFinished: (contractsDetails: any, contractMap: any) => void - }, + plugin: ICompilerApi +} + +export interface ICompilerApi { + currentFile: string + contractMap: { + file: string + } | Record + compileErrors: any + compileTabLogic: any + contractsDetails: Record + configurationSettings: ConfigurationSettings + + setHardHatCompilation: (value: boolean) => void + getParameters: () => any + setParameters: (params) => void + getConfiguration: (value: string) => string + setConfiguration: (name: string, value: string) => void + getFileManagerMode: () => string + setCompilerConfig: (settings: any) => void + + getCompilationResult: () => any + + onCurrentFileChanged: (fileName: string) => void + onResetResults: () => void, + onSetWorkspace: (isLocalhost: boolean) => void + onNoFileSelected: () => void + onCompilationFinished: (contractsDetails: any, contractMap: any) => void + onSessionSwitched: () => void + onContentChanged: () => void + + fileExists: (file: string) => Promise + writeFile: (file: string, content: string) => Promise + readFile: (file: string) => Promise + open: (file: string) => void } export interface CompilerContainerProps { From 25fc94e2d2d3bebccaad422215a5892beadfb2ad Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 26 Aug 2021 12:13:28 +0200 Subject: [PATCH 09/30] better org of types --- apps/remix-ide/src/app/tabs/compile-tab.js | 3 +- apps/solidity-compiler/src/app/compiler.ts | 3 +- libs/remix-lib/src/index.ts | 55 ++++++++----------- libs/remix-lib/src/types/ICompilerApi.ts | 41 ++++++++++++++ .../src/lib/compiler-container.tsx | 3 +- .../solidity-compiler/src/lib/types/index.ts | 45 +-------------- 6 files changed, 73 insertions(+), 77 deletions(-) create mode 100644 libs/remix-lib/src/types/ICompilerApi.ts diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 39c66d3ec6..61dc9200b4 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -4,6 +4,7 @@ import ReactDOM from 'react-dom' import { SolidityCompiler, CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' import { ViewPlugin } from '@remixproject/engine-web' +import { ICompilerApi } from '@remix-project/remix-lib-ts' import * as packageJson from '../../../../../package.json' const EventEmitter = require('events') @@ -32,7 +33,7 @@ const profile = { // - events: ['compilationFinished'], // - methods: ['getCompilationResult'] -class CompileTab extends CompilerApiMixin(ViewPlugin) { +class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerApi constructor () { super(profile) this.initCompilerApi() diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 7e6deb8c98..0d1cd1e620 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -1,6 +1,7 @@ import { PluginClient } from "@remixproject/plugin"; import { createClient } from "@remixproject/plugin-webview"; import { CompilerApiMixin } from './compiler-api' +import { ICompilerApi } from '@remix-project/remix-lib-ts' const profile = { name: 'solidity', @@ -23,7 +24,7 @@ export interface ConfigurationSettings { runs: string } -export class CompilerClientApi extends CompilerApiMixin(PluginClient) { +export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi { // interface matches libs/remix-ui/solidity-compiler/types/index.ts : ICompilerApi currentFile: string contractMap: { diff --git a/libs/remix-lib/src/index.ts b/libs/remix-lib/src/index.ts index d3d37231f1..20e192bf9b 100644 --- a/libs/remix-lib/src/index.ts +++ b/libs/remix-lib/src/index.ts @@ -18,36 +18,29 @@ import * as typeConversion from './execution/typeConversion' import { TxRunnerVM } from './execution/txRunnerVM' import { TxRunnerWeb3 } from './execution/txRunnerWeb3' import * as txResultHelper from './helpers/txResultHelper' +export { ICompilerApi, ConfigurationSettings} from './types/ICompilerApi' -export = modules() - -function modules () { - return { - EventManager: EventManager, - helpers: { - ui: uiHelper, - compiler: compilerHelper, - txResultHelper - }, - vm: { - Web3Providers: Web3Providers, - DummyProvider: DummyProvider, - Web3VMProvider: Web3VmProvider - }, - Storage: Storage, - util: util, - execution: { - EventsDecoder: EventsDecoder, - txExecution: txExecution, - txHelper: txHelper, - txFormat: txFormat, - txListener: TxListener, - TxRunner: TxRunner, - TxRunnerWeb3: TxRunnerWeb3, - TxRunnerVM: TxRunnerVM, - typeConversion: typeConversion, - LogsManager, - forkAt - } - } +const helpers = { + ui: uiHelper, + compiler: compilerHelper, + txResultHelper +} +const vm = { + Web3Providers: Web3Providers, + DummyProvider: DummyProvider, + Web3VMProvider: Web3VmProvider +} +const execution = { + EventsDecoder: EventsDecoder, + txExecution: txExecution, + txHelper: txHelper, + txFormat: txFormat, + txListener: TxListener, + TxRunner: TxRunner, + TxRunnerWeb3: TxRunnerWeb3, + TxRunnerVM: TxRunnerVM, + typeConversion: typeConversion, + LogsManager, + forkAt } +export { EventManager, helpers, vm, Storage, util, execution } diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts new file mode 100644 index 0000000000..89dd12c6e6 --- /dev/null +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -0,0 +1,41 @@ +export interface ICompilerApi { + currentFile: string + contractMap: { + file: string + } | Record + compileErrors: any + compileTabLogic: any + contractsDetails: Record + configurationSettings: ConfigurationSettings + + setHardHatCompilation: (value: boolean) => void + getParameters: () => any + setParameters: (params) => void + getConfiguration: (value: string) => string + setConfiguration: (name: string, value: string) => void + getFileManagerMode: () => string + setCompilerConfig: (settings: any) => void + + getCompilationResult: () => any + + onCurrentFileChanged: (fileName: string) => void + onResetResults: () => void, + onSetWorkspace: (workspace: any) => void + onNoFileSelected: () => void + onCompilationFinished: (contractsDetails: any, contractMap: any) => void + onSessionSwitched: () => void + onContentChanged: () => void + + fileExists: (file: string) => Promise + writeFile: (file: string, content: string) => Promise + readFile: (file: string) => Promise + open: (file: string) => void + } + +export interface ConfigurationSettings { + version: string, + evmVersion: string, + language: string, + optimize: boolean, + runs: string +} \ No newline at end of file diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 3bd1032c76..b62525dc1f 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint-disable-line import semver from 'semver' -import { CompilerContainerProps, ConfigurationSettings } from './types' +import { CompilerContainerProps } from './types' +import { ConfigurationSettings } from '@remix-project/remix-lib-ts' import * as helper from '../../../../../apps/remix-ide/src/lib/helper' import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity' import { compilerReducer, compilerInitialState } from './reducers/compiler' diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index b477a8df85..fdb291b66d 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -1,43 +1,10 @@ +import { ICompilerApi, ConfigurationSettings } from '@remix-project/remix-lib-ts' export type onCurrentFileChanged = (fileName: string) => void export interface SolidityCompilerProps { plugin: ICompilerApi } -export interface ICompilerApi { - currentFile: string - contractMap: { - file: string - } | Record - compileErrors: any - compileTabLogic: any - contractsDetails: Record - configurationSettings: ConfigurationSettings - - setHardHatCompilation: (value: boolean) => void - getParameters: () => any - setParameters: (params) => void - getConfiguration: (value: string) => string - setConfiguration: (name: string, value: string) => void - getFileManagerMode: () => string - setCompilerConfig: (settings: any) => void - - getCompilationResult: () => any - - onCurrentFileChanged: (fileName: string) => void - onResetResults: () => void, - onSetWorkspace: (isLocalhost: boolean) => void - onNoFileSelected: () => void - onCompilationFinished: (contractsDetails: any, contractMap: any) => void - onSessionSwitched: () => void - onContentChanged: () => void - - fileExists: (file: string) => Promise - writeFile: (file: string, content: string) => Promise - readFile: (file: string) => Promise - open: (file: string) => void -} - export interface CompilerContainerProps { api: any, compileTabLogic: any, @@ -55,12 +22,4 @@ export interface ContractSelectionProps { } | Record, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, contractsDetails: Record -} - -export interface ConfigurationSettings { - version: string, - evmVersion: string, - language: string, - optimize: boolean, - runs: string -} +} \ No newline at end of file From b109eafbc02d610d2a386b30e24c815dcabb0178 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Aug 2021 10:47:06 +0200 Subject: [PATCH 10/30] linting --- apps/remix-ide/src/app/tabs/compile-tab.js | 6 +----- libs/remix-lib/src/index.ts | 2 +- libs/remix-lib/src/types/ICompilerApi.ts | 10 +++++----- libs/remix-ui/solidity-compiler/src/index.ts | 2 +- .../solidity-compiler/src/lib/actions/compiler.ts | 2 +- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 61dc9200b4..b1d4709cd0 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -4,15 +4,11 @@ import ReactDOM from 'react-dom' import { SolidityCompiler, CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' import { ViewPlugin } from '@remixproject/engine-web' -import { ICompilerApi } from '@remix-project/remix-lib-ts' +// import { ICompilerApi } from '@remix-project/remix-lib-ts' import * as packageJson from '../../../../../package.json' -const EventEmitter = require('events') -const $ = require('jquery') const yo = require('yo-yo') -var QueryParams = require('../../lib/query-params') const addTooltip = require('../ui/tooltip') -const globalRegistry = require('../../global/registry') const css = require('./styles/compile-tab-styles') diff --git a/libs/remix-lib/src/index.ts b/libs/remix-lib/src/index.ts index 20e192bf9b..1ba94fdd21 100644 --- a/libs/remix-lib/src/index.ts +++ b/libs/remix-lib/src/index.ts @@ -18,7 +18,7 @@ import * as typeConversion from './execution/typeConversion' import { TxRunnerVM } from './execution/txRunnerVM' import { TxRunnerWeb3 } from './execution/txRunnerWeb3' import * as txResultHelper from './helpers/txResultHelper' -export { ICompilerApi, ConfigurationSettings} from './types/ICompilerApi' +export { ICompilerApi, ConfigurationSettings } from './types/ICompilerApi' const helpers = { ui: uiHelper, diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts index 89dd12c6e6..6e97840101 100644 --- a/libs/remix-lib/src/types/ICompilerApi.ts +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -7,7 +7,7 @@ export interface ICompilerApi { compileTabLogic: any contractsDetails: Record configurationSettings: ConfigurationSettings - + setHardHatCompilation: (value: boolean) => void getParameters: () => any setParameters: (params) => void @@ -15,9 +15,9 @@ export interface ICompilerApi { setConfiguration: (name: string, value: string) => void getFileManagerMode: () => string setCompilerConfig: (settings: any) => void - + getCompilationResult: () => any - + onCurrentFileChanged: (fileName: string) => void onResetResults: () => void, onSetWorkspace: (workspace: any) => void @@ -25,7 +25,7 @@ export interface ICompilerApi { onCompilationFinished: (contractsDetails: any, contractMap: any) => void onSessionSwitched: () => void onContentChanged: () => void - + fileExists: (file: string) => Promise writeFile: (file: string, content: string) => Promise readFile: (file: string) => Promise @@ -38,4 +38,4 @@ export interface ConfigurationSettings { language: string, optimize: boolean, runs: string -} \ No newline at end of file +} diff --git a/libs/remix-ui/solidity-compiler/src/index.ts b/libs/remix-ui/solidity-compiler/src/index.ts index 30a13c42f4..317c79cefa 100644 --- a/libs/remix-ui/solidity-compiler/src/index.ts +++ b/libs/remix-ui/solidity-compiler/src/index.ts @@ -1,2 +1,2 @@ export * from './lib/solidity-compiler' -export * from './lib/logic' \ No newline at end of file +export * from './lib/logic' diff --git a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts index 96316c8bd5..17f2886625 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -42,7 +42,7 @@ export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatc api.onContentChanged = () => { dispatch(setEditorMode('contentChanged')) } - + compileTabLogic.compiler.event.register('loadingCompiler', () => { dispatch(setCompilerMode('loadingCompiler')) }) diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index fdb291b66d..ac1b4e60ac 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -22,4 +22,4 @@ export interface ContractSelectionProps { } | Record, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, contractsDetails: Record -} \ No newline at end of file +} From 57407ab25f39ba980478b4f66d59f0bd88beb237 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Aug 2021 12:26:46 +0200 Subject: [PATCH 11/30] fix remix-lib reference --- .../solidity-compiler/src/lib/logic/contract-parser.ts | 4 ++-- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts index 3894b01a9d..2b6a23fa5a 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts @@ -1,8 +1,8 @@ 'use strict' import * as solcTranslate from 'solc/translate' -import * as remixLib from '@remix-project/remix-lib' +import { execution } from '@remix-project/remix-lib' -const txHelper = remixLib.execution.txHelper +const txHelper = execution.txHelper export function parseContracts (contractName, contract, source) { const detail: Record = {} diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index bd88dad856..88b7925b5c 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useReducer } from 'react' import Button from './Button/StaticAnalyserButton' // eslint-disable-line -import remixLib from '@remix-project/remix-lib' +import { util } from '@remix-project/remix-lib' import _ from 'lodash' import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line import { RemixUiCheckbox } from '@remix-ui/checkbox' // eslint-disable-line @@ -9,7 +9,6 @@ import { compilation } from './actions/staticAnalysisActions' import { initialState, analysisReducer } from './reducers/staticAnalysisReducer' import { OverlayTrigger, Tooltip } from 'react-bootstrap'// eslint-disable-line const StaticAnalysisRunner = require('@remix-project/remix-analyzer').CodeAnalysis -const utils = remixLib.util declare global { interface Window { @@ -38,7 +37,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { }) } - const groupedModules = utils.groupBy( + const groupedModules = util.groupBy( preProcessModules(runner.modules()), 'categoryId' ) From 63ee352ec42cc8b059eba3755a6460a8a2a6c22c Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Aug 2021 12:51:52 +0200 Subject: [PATCH 12/30] fix registering 'contentChanged' event --- apps/solidity-compiler/src/app/compiler-api.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index edc69528cd..aacd16cb2a 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -158,11 +158,11 @@ export const CompilerApiMixin = (Base) => class extends Base { } listenToEvents () { - this.data.eventHandlers.onContentChanged = () => { + this.on('editor', 'contentChanged', () => { this.emit('statusChanged', { key: 'edited', title: 'the content has changed, needs recompilation', type: 'info' }) - } - this.on('editor', 'contentChanged', this.data.eventHandlers.onContentChanged) - + if (this.onContentChanged) this.onContentChanged() + }) + this.data.eventHandlers.onLoadingCompiler = () => { this.data.loading = true this.emit('statusChanged', { key: 'loading', title: 'loading compiler...', type: 'info' }) @@ -195,11 +195,7 @@ export const CompilerApiMixin = (Base) => class extends Base { this.on('editor', 'sessionSwitched', () => { if (this.onSessionSwitched) this.onSessionSwitched() - }) - - this.on('editor', 'contentChanged', () => { - if (this.onContentChanged) this.onContentChanged() - }) + }) this.compileTabLogic.event.on('startingCompilation', this.data.eventHandlers.onStartingCompilation) this.compileTabLogic.event.on('removeAnnotations', this.data.eventHandlers.onRemoveAnnotations) From c1bdf45d2782b5cc1e3cac722f6726157bc223bc Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 7 Sep 2021 14:45:54 +0200 Subject: [PATCH 13/30] refactor ICompilerAPI --- apps/remix-ide/src/app.js | 2 +- apps/remix-ide/src/app/files/fileManager.js | 2 +- apps/remix-ide/src/app/tabs/compile-tab.js | 39 ++++++++-- apps/solidity-compiler/src/app/app.tsx | 2 +- .../solidity-compiler/src/app/compiler-api.ts | 55 +++++++------- apps/solidity-compiler/src/app/compiler.ts | 71 ++++++++----------- libs/remix-lib/src/types/ICompilerApi.ts | 23 ++++-- libs/remix-ui/renderer/src/lib/renderer.tsx | 4 +- .../src/lib/actions/compiler.ts | 4 +- .../src/lib/compiler-container.tsx | 52 +++++++------- .../src/lib/logic/compileTabLogic.ts | 27 +++---- .../src/lib/solidity-compiler.tsx | 26 +++---- .../solidity-compiler/src/lib/types/index.ts | 9 +-- 13 files changed, 166 insertions(+), 150 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 2668dff15c..c6020f4bae 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -425,7 +425,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } // CONTENT VIEWS & DEFAULT PLUGINS - const compileTab = new CompileTab() + const compileTab = new CompileTab(registry.get('config').api) const run = new RunTab( blockchain, registry.get('config').api, diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index a378c46cb6..99eeb03380 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -398,7 +398,7 @@ class FileManager extends Plugin { } fileChangedEvent (path) { - this.emit('currentFileChanged', path) + this.emit('fileChanged', path) } fileRenamedEvent (oldName, newName, isFolder) { diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index b1d4709cd0..159709c3cd 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -1,9 +1,11 @@ /* global */ import React from 'react' // eslint-disable-line import ReactDOM from 'react-dom' -import { SolidityCompiler, CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line +import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line +import { CompileTabLogic } from '@remix-ui/solidity-compiler' // eslint-disable-line import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' import { ViewPlugin } from '@remixproject/engine-web' +import QueryParams from '../../lib/query-params' // import { ICompilerApi } from '@remix-project/remix-lib-ts' import * as packageJson from '../../../../../package.json' @@ -30,14 +32,19 @@ const profile = { // - methods: ['getCompilationResult'] class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerApi - constructor () { + constructor (config) { super(profile) + this.config = config + this.queryParams = new QueryParams() + this.compileTabLogic = new CompileTabLogic(this, this.contentImport) + this.compiler = this.compileTabLogic.compiler + this.compileTabLogic.init() this.initCompilerApi() } renderComponent () { ReactDOM.render( - + , this.el) } @@ -49,10 +56,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA this.renderComponent() } - setHardHatCompilation (value) { - this.hhCompilation = value - } - setSelectedVersion (version) { this.selectedVersion = version } @@ -121,6 +124,28 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA pattern: [] }) } + + getCompilerParameters () { + const params = this.queryParams.get() + params.optimize = (params.optimize === 'false' || params.optimize === null || params.optimize === undefined) ? false : params.optimize + params.optimize = params.optimize === 'true' ? true : params.optimize + return params + } + + setCompilerParameters (params) { + this.queryParams.update(params) + } + + getAppParameter (name) { + const param = this.config.get(name) + if (param === 'true') return true + if (param === 'false') return false + return param + } + + setAppParameter (name, value) { + this.config.set(name, value) + } } module.exports = CompileTab diff --git a/apps/solidity-compiler/src/app/app.tsx b/apps/solidity-compiler/src/app/app.tsx index 3f3e32eb11..e5ace4d4c8 100644 --- a/apps/solidity-compiler/src/app/app.tsx +++ b/apps/solidity-compiler/src/app/app.tsx @@ -9,7 +9,7 @@ const remix = new CompilerClientApi() export const App = () => { return (
- +
); }; diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index aacd16cb2a..c001df228e 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -1,7 +1,26 @@ import { compile } from '@remix-project/remix-solidity' -import { CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line +import { CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line +import { ConfigurationSettings } from '@remix-project/remix-lib-ts' export const CompilerApiMixin = (Base) => class extends Base { + currentFile: string + contractMap: { + file: string + } | Record + compileErrors: any + compileTabLogic: CompileTabLogic + contractsDetails: Record + + configurationSettings: ConfigurationSettings + + onCurrentFileChanged: (fileName: string) => void + onResetResults: () => void + onSetWorkspace: (workspace: any) => void + onNoFileSelected: () => void + onCompilationFinished: (contractsDetails: any, contractMap: any) => void + onSessionSwitched: () => void + onContentChanged: () => void + initCompilerApi () { this.configurationSettings = null @@ -16,9 +35,6 @@ export const CompilerApiMixin = (Base) => class extends Base { eventHandlers: {}, loading: false } - this.compileTabLogic = new CompileTabLogic(this, this.contentImport) - this.compiler = this.compileTabLogic.compiler - this.compileTabLogic.init() this.contractMap = {} this.contractsDetails = {} @@ -46,11 +62,7 @@ export const CompilerApiMixin = (Base) => class extends Base { logToTerminal (content) { return this.call('terminal', 'log', content) } - - setHardHatCompilation (value) { - this.hhCompilation = value - } - + setSelectedVersion (version) { this.selectedVersion = version } @@ -102,7 +114,6 @@ export const CompilerApiMixin = (Base) => class extends Base { } } - /** * set the compiler configuration * This function is used by remix-plugin compiler API. @@ -110,25 +121,7 @@ export const CompilerApiMixin = (Base) => class extends Base { */ setCompilerConfig (settings) { this.configurationSettings = settings - } - - getParameters () { - return {} - } - - setParameters (params) {} - - getConfiguration (name) { - const conf = { - 'currentFile': () => this.currentFile, - 'hideWarnings': () => false, - 'autoCompile': () => false, - 'includeNightlies': () => false - } - return conf[name]() - } - - setConfiguration (name, value) {} + } getFileManagerMode () { return 'browser' @@ -154,7 +147,7 @@ export const CompilerApiMixin = (Base) => class extends Base { this.currentFile = '' this.contractsDetails = {} this.emit('statusChanged', { key: 'none' }) - if (this.onResetResults()) this.onResetResults() + if (this.onResetResults) this.onResetResults() } listenToEvents () { @@ -258,7 +251,7 @@ export const CompilerApiMixin = (Base) => class extends Base { // ctrl+s or command+s if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { e.preventDefault() - this.compileTabLogic.runCompiler(this.hhCompilation) + this.compileTabLogic.runCompiler(this.getAppParameter('hardhat-compilation')) } }) } diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 0d1cd1e620..924e358a30 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -16,53 +16,38 @@ const profile = { methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile' ,'getCompilerState'] } -export interface ConfigurationSettings { - version: string, - evmVersion: string, - language: string, - optimize: boolean, - runs: string -} export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi { - // interface matches libs/remix-ui/solidity-compiler/types/index.ts : ICompilerApi - currentFile: string - contractMap: { - file: string - } | Record - compileErrors: any - compileTabLogic: any - contractsDetails: Record - configurationSettings: ConfigurationSettings - - setHardHatCompilation: (value: boolean) => void - getParameters: () => ConfigurationSettings - setParameters: (params: Partial) => void - setCompilerConfig: (settings: ConfigurationSettings) => void - - getConfiguration: (value: string) => string - setConfiguration: (name: string, value: string) => void - getFileManagerMode: () => string - - - getCompilationResult: () => any - - onCurrentFileChanged: (fileName: string) => void - onResetResults: () => void - onSetWorkspace: (isLocalhost: boolean) => void - onNoFileSelected: () => void - onCompilationFinished: (contractsDetails: any, contractMap: any) => void - onSessionSwitched: () => void - onContentChanged: () => void - - fileExists: (file: string) => Promise - writeFile: (file: string, content: string) => Promise - readFile: (file: string) => Promise - open: (file: string) => void - constructor () { super() createClient(this as any) + this.compileTabLogic = new CompileTabLogic(this, this.contentImport) + this.compiler = this.compileTabLogic.compiler + this.compileTabLogic.init() this.initCompilerApi() - } + } + + getCompilerParameters () { + return { + runs: '200', + optimize: false, + version: '0.8.7+commit.e28d00a7', + evmVersion: null, // default + language: 'Solidity' + } + } + + setCompilerParameters (params) {} + + getAppParameter (name) { + const conf = { + 'currentFile': () => this.currentFile, + 'hideWarnings': () => false, + 'autoCompile': () => false, + 'includeNightlies': () => false + } + return conf[name]() + } + + setAppParameter (name, value) {} } diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts index 6e97840101..5f709c435e 100644 --- a/libs/remix-lib/src/types/ICompilerApi.ts +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -8,11 +8,12 @@ export interface ICompilerApi { contractsDetails: Record configurationSettings: ConfigurationSettings - setHardHatCompilation: (value: boolean) => void - getParameters: () => any - setParameters: (params) => void - getConfiguration: (value: string) => string - setConfiguration: (name: string, value: string) => void + getCompilerParameters: () => ConfigurationSettings + setCompilerParameters: (ConfigurationSettings?) => void + + getAppParameter: (value: string) => string | boolean + setAppParameter: (name: string, value: string | boolean) => void + getFileManagerMode: () => string setCompilerConfig: (settings: any) => void @@ -26,11 +27,21 @@ export interface ICompilerApi { onSessionSwitched: () => void onContentChanged: () => void + resolveContentAndSave: (url: string) => Promise fileExists: (file: string) => Promise writeFile: (file: string, content: string) => Promise readFile: (file: string) => Promise open: (file: string) => void - } + + logToTerminal: (log: terminalLog) => {} + + compileWithHardhat: (configPath: string) => Promise +} + +export type terminalLog = { + type: 'info' | 'error' | 'warning' + value: string +} export interface ConfigurationSettings { version: string, diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 815a4c85ee..8850c1e5b1 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -69,7 +69,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { } const addAnnotation = (file, error) => { - if (file === plugin.getConfiguration('currentFile')) { + if (file === plugin.getAppParameter('currentFile')) { plugin.call('editor', 'addAnnotation', error, file) } } @@ -87,7 +87,7 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { } const _errorClick = (errFile, errLine, errCol) => { - if (errFile !== plugin.getConfiguration('currentFile')) { + if (errFile !== plugin.getAppParameter('currentFile')) { // TODO: refactor with this._components.contextView.jumpTo const provider = plugin.fileProviderOf(errFile) if (provider) { diff --git a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts index 17f2886625..17e58a0052 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -1,5 +1,5 @@ import React from 'react' - +import { CompileTabLogic } from '../logic/compileTabLogic' export const setEditorMode = (mode: string) => { return { type: 'SET_EDITOR_MODE', @@ -26,7 +26,7 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch) => { }) } -export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatch) => { +export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispatch: React.Dispatch) => { api.onSessionSwitched = () => { dispatch(setEditorMode('sessionSwitched')) } diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index b62525dc1f..09168923cd 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -19,11 +19,11 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { api, compileTabLogic, tooltip, modal, compiledFileName, updateCurrentVersion, configurationSettings } = props // eslint-disable-line + const { api, compileTabLogic, tooltip, modal, compiledFileName, updateCurrentVersion, configurationSettings, isHardhatProject } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, - optimise: false, + optimize: false, compileTimeout: null, timeout: 300, allversions: [], @@ -57,7 +57,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { _updateVersionSelector(selectedVersion) } }) - const currentFileName = api.getConfiguration('currentFile') + const currentFileName = api.getAppParameter('currentFile') as string currentFile(currentFileName) listenToEvents(compileTabLogic, api)(dispatch) @@ -66,19 +66,19 @@ export const CompilerContainer = (props: CompilerContainerProps) => { useEffect(() => { if (compileTabLogic && compileTabLogic.compiler) { setState(prevState => { - const params = api.getParameters() - const optimize = params.optimize === 'false' ? false : params.optimize === 'true' ? true : null - const runs = params.runs + const params = api.getCompilerParameters() + const optimize = params.optimize + const runs = params.runs as string const evmVersion = params.evmVersion const autoCompile = params.autoCompile === 'false' ? false : params.autoCompile === 'true' ? true : null return { ...prevState, - hideWarnings: api.getConfiguration('hideWarnings') || false, - autoCompile: typeof autoCompile === 'boolean' ? autoCompile : api.getConfiguration('autoCompile') || false, - includeNightlies: api.getConfiguration('includeNightlies') || false, - optimize: (optimize !== null) && (optimize !== undefined) ? optimize : false, - runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200, + hideWarnings: api.getAppParameter('hideWarnings') as boolean || false, + autoCompile: api.getAppParameter('autoCompile') as boolean || false, + includeNightlies: api.getAppParameter('includeNightlies') as boolean || false, + optimize: optimize, + runs: runs, evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' } }) @@ -154,7 +154,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { allVersions = [...allVersions, ...versions] selectedVersion = state.defaultVersion - if (api.getParameters().version) selectedVersion = api.getParameters().version + if (api.getCompilerParameters().version) selectedVersion = api.getCompilerParameters().version // Check if version is a URL and corresponding filename starts with 'soljson' if (selectedVersion.startsWith('https://')) { const urlArr = selectedVersion.split('/') @@ -229,8 +229,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) } - const isSolFileSelected = (currentFile = '') => { - if (!currentFile) currentFile = api.getConfiguration('currentFile') + const isSolFileSelected = (currentFile: string = '') => { + if (!currentFile) currentFile = api.getAppParameter('currentFile') as string if (!currentFile) return false const extention = currentFile.substr(currentFile.length - 3, currentFile.length) return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul' @@ -299,7 +299,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } const compile = () => { - const currentFile = api.getConfiguration('currentFile') + const currentFile = api.getAppParameter('currentFile') as string if (!isSolFileSelected()) return @@ -323,7 +323,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) } updateCurrentVersion(selectedVersion) - api.setParameters({ version: selectedVersion }) + api.setCompilerParameters({ version: selectedVersion }) let url if (customUrl !== '') { @@ -333,7 +333,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) updateCurrentVersion(selectedVersion) url = customUrl - api.setParameters({ version: selectedVersion }) + api.setCompilerParameters({ version: selectedVersion }) } else { if (helper.checkSpecialChars(selectedVersion)) { return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') @@ -404,7 +404,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const handleAutoCompile = (e) => { const checked = e.target.checked - api.setConfiguration('autoCompile', checked) + api.setAppParameter('autoCompile', checked) checked && compile() setState(prevState => { return { ...prevState, autoCompile: checked } @@ -414,7 +414,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const handleOptimizeChange = (value) => { const checked = !!value - api.setConfiguration('optimise', checked) + api.setAppParameter('optimize', checked) compileTabLogic.setOptimize(checked) if (compileTabLogic.optimize) { compileTabLogic.setRuns(parseInt(state.runs)) @@ -423,7 +423,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } state.autoCompile && compile() setState(prevState => { - return { ...prevState, optimise: checked } + return { ...prevState, optimize: checked } }) } @@ -440,7 +440,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const handleHideWarningsChange = (e) => { const checked = e.target.checked - api.setConfiguration('hideWarnings', checked) + api.setAppParameter('hideWarnings', checked) state.autoCompile && compile() setState(prevState => { return { ...prevState, hideWarnings: checked } @@ -451,7 +451,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const checked = e.target.checked if (!checked) handleLoadVersion(state.defaultVersion) - api.setConfiguration('includeNightlies', checked) + api.setAppParameter('includeNightlies', checked) setState(prevState => { return { ...prevState, includeNightlies: checked } }) @@ -482,7 +482,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const checked = event.target.checked sethhCompilation(checked) - api.setHardHatCompilation(checked) + api.setAppParameter('hardhat-compilation', checked) } /* @@ -553,7 +553,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
- { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimise} /> + { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimize} /> { type="number" title="Estimated number of times each opcode of the deployed code will be executed across the life-time of the contract." onChange={(e) => onChangeRuns(e.target.value)} - disabled={!state.optimise} + disabled={!state.optimize} />
@@ -574,7 +574,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
{ - api.isHardHatProject && + isHardhatProject &&
diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index ea0f5c5425..66caaf550f 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -1,3 +1,5 @@ +import { ICompilerApi } from '@remix-project/remix-lib-ts' + const Compiler = require('@remix-project/remix-solidity').Compiler const EventEmitter = require('events') @@ -8,7 +10,7 @@ declare global { } const _paq = window._paq = window._paq || [] //eslint-disable-line -export class CompileTab { +export class CompileTabLogic { public compiler public optimize public runs @@ -16,45 +18,44 @@ export class CompileTab { public compilerImport public event - constructor (public api, public contentImport) { + constructor (public api: ICompilerApi, public contentImport) { this.event = new EventEmitter() this.compiler = new Compiler((url, cb) => api.resolveContentAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message))) } init () { - this.optimize = this.api.getParameters().optimize - this.optimize = this.optimize === 'true' - this.api.setParameters({ optimize: this.optimize }) + this.optimize = this.api.getCompilerParameters().optimize + this.api.setCompilerParameters({ optimize: this.optimize }) this.compiler.set('optimize', this.optimize) - this.runs = this.api.getParameters().runs + this.runs = this.api.getCompilerParameters().runs this.runs = this.runs && this.runs !== 'undefined' ? this.runs : 200 - this.api.setParameters({ runs: this.runs }) + this.api.setCompilerParameters({ runs: this.runs }) this.compiler.set('runs', this.runs) - this.evmVersion = this.api.getParameters().evmVersion + this.evmVersion = this.api.getCompilerParameters().evmVersion if (this.evmVersion === 'undefined' || this.evmVersion === 'null' || !this.evmVersion) { this.evmVersion = null } - this.api.setParameters({ evmVersion: this.evmVersion }) + this.api.setCompilerParameters({ evmVersion: this.evmVersion }) this.compiler.set('evmVersion', this.evmVersion) } setOptimize (newOptimizeValue) { this.optimize = newOptimizeValue - this.api.setParameters({ optimize: this.optimize }) + this.api.setCompilerParameters({ optimize: this.optimize }) this.compiler.set('optimize', this.optimize) } setRuns (runs) { this.runs = runs - this.api.setParameters({ runs: this.runs }) + this.api.setCompilerParameters({ runs: this.runs }) this.compiler.set('runs', this.runs) } setEvmVersion (newEvmVersion) { this.evmVersion = newEvmVersion - this.api.setParameters({ evmVersion: this.evmVersion }) + this.api.setCompilerParameters({ evmVersion: this.evmVersion }) this.compiler.set('evmVersion', this.evmVersion) } @@ -122,7 +123,7 @@ export class CompileTab { // TODO readd saving current file // this.api.saveCurrentFile() this.event.emit('removeAnnotations') - var currentFile = this.api.getConfiguration('currentFile') + var currentFile = this.api.getAppParameter('currentFile') return this.compileFile(currentFile) } catch (err) { console.error(err) diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 792beb8829..3a1a59cad6 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { currentFile, compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props + const { api, api: { currentFile, compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props const [state, setState] = useState({ isHardhatProject: false, currentFile, @@ -32,32 +32,32 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { }) const [currentVersion, setCurrentVersion] = useState('') - plugin.onCurrentFileChanged = (currentFile: string) => { + api.onCurrentFileChanged = (currentFile: string) => { setState(prevState => { return { ...prevState, currentFile } }) } - plugin.onResetResults = () => { + api.onResetResults = () => { setState(prevState => { return { ...prevState, currentFile: '', contractsDetails: {}, contractMap: {} } }) } - plugin.onSetWorkspace = async (isLocalhost: boolean) => { + api.onSetWorkspace = async (isLocalhost: boolean) => { const isHardhat = isLocalhost && await compileTabLogic.isHardhatProject() setState(prevState => { return { ...prevState, currentFile, isHardhatProject: isHardhat } }) } - plugin.onNoFileSelected = () => { + api.onNoFileSelected = () => { setState(prevState => { return { ...prevState, currentFile: '' } }) } - plugin.onCompilationFinished = (contractsDetails: any, contractMap: any) => { + api.onCompilationFinished = (contractsDetails: any, contractMap: any) => { setState(prevState => { return { ...prevState, contractsDetails, contractMap } }) @@ -71,7 +71,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { const updateCurrentVersion = (value) => { setCurrentVersion(value) - plugin.setParameters({ version: value }) + api.setCompilerParameters({ version: value }) } const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => { @@ -111,19 +111,19 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>
- - + +
- { compileErrors.error && } + { compileErrors.error && } { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { - if (plugin.getConfiguration('hideWarnings')) { + if (api.getAppParameter('hideWarnings')) { if (err.severity !== 'warning') { - return + return } } else { - return + return } }) }
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index ac1b4e60ac..4932b1456c 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -1,13 +1,14 @@ import { ICompilerApi, ConfigurationSettings } from '@remix-project/remix-lib-ts' +import { CompileTabLogic } from '../logic/compileTabLogic' export type onCurrentFileChanged = (fileName: string) => void export interface SolidityCompilerProps { - plugin: ICompilerApi + api: ICompilerApi } export interface CompilerContainerProps { - api: any, - compileTabLogic: any, + api: ICompilerApi, + compileTabLogic: CompileTabLogic, isHardhatProject: boolean, tooltip: (message: string | JSX.Element) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, @@ -16,7 +17,7 @@ export interface CompilerContainerProps { configurationSettings: ConfigurationSettings } export interface ContractSelectionProps { - api: any, + api: ICompilerApi, contractMap: { file: string } | Record, From 0d53c00fc7a20a688fff42b6c00c6b59a3643c00 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 7 Sep 2021 15:59:52 +0200 Subject: [PATCH 14/30] fix compileWithParameters --- apps/remix-ide/src/app/tabs/compile-tab.js | 4 ---- apps/solidity-compiler/src/app/compiler-api.ts | 17 +++++++---------- .../src/compiler/compiler-utils.ts | 3 ++- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 159709c3cd..4441993d34 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -56,10 +56,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA this.renderComponent() } - setSelectedVersion (version) { - this.selectedVersion = version - } - onSetWorkspace () { this.renderComponent() } diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index c001df228e..502ec33ac4 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -41,7 +41,6 @@ export const CompilerApiMixin = (Base) => class extends Base { this.compileErrors = {} this.compiledFileName = '' - this.selectedVersion = '' this.currentFile = '' } @@ -63,10 +62,6 @@ export const CompilerApiMixin = (Base) => class extends Base { return this.call('terminal', 'log', content) } - setSelectedVersion (version) { - this.selectedVersion = version - } - getCompilationResult () { return this.compileTabLogic.compiler.state.lastCompilationResult } @@ -99,18 +94,20 @@ export const CompilerApiMixin = (Base) => class extends Base { * @param {object} settings {evmVersion, optimize, runs, version, language} */ async compileWithParameters (compilationTargets, settings) { - settings.version = settings.version || this.selectedVersion + const compilerState = this.getCompilerState() + settings.version = settings.version || compilerState.currentVersion const res = await compile(compilationTargets, settings, (url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) return res } // This function is used for passing the compiler configuration to 'remix-tests' getCurrentCompilerConfig () { + const compilerState = this.getCompilerState() return { - currentVersion: this.selectedVersion, - evmVersion: this.compileTabLogic.evmVersion, - optimize: this.compileTabLogic.optimize, - runs: this.compileTabLogic.runs + currentVersion: compilerState.currentVersion, + evmVersion: compilerState.evmVersion, + optimize: compilerState.optimize, + runs: compilerState.runs } } diff --git a/libs/remix-solidity/src/compiler/compiler-utils.ts b/libs/remix-solidity/src/compiler/compiler-utils.ts index 7e19ae7d8a..ef205c3ca8 100644 --- a/libs/remix-solidity/src/compiler/compiler-utils.ts +++ b/libs/remix-solidity/src/compiler/compiler-utils.ts @@ -12,7 +12,7 @@ export const pathToURL = {} * @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix */ export function urlFromVersion (version) { - let url + let url if (version === 'builtin') { let location: string | Location = window.document.location let path = location.pathname @@ -22,6 +22,7 @@ export function urlFromVersion (version) { if (!location.endsWith('/')) location += '/' url = `${location}soljson.js` } else { + version = version.replace('.Emscripten.clang', '') if (!version.startsWith('soljson-v')) version = 'soljson-v' + version if (!version.endsWith('.js')) version = version + '.js' url = `${pathToURL[version]}/${version}` From b4d0b5eb2110f57e29c30aac814174a9b4c68faf Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 7 Sep 2021 16:23:09 +0200 Subject: [PATCH 15/30] remove use of fileProviderOf in compiler UI --- libs/remix-ui/renderer/src/lib/renderer.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 8850c1e5b1..f61695abd5 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -86,17 +86,12 @@ export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { setClose(true) } - const _errorClick = (errFile, errLine, errCol) => { + const _errorClick = async (errFile, errLine, errCol) => { if (errFile !== plugin.getAppParameter('currentFile')) { // TODO: refactor with this._components.contextView.jumpTo - const provider = plugin.fileProviderOf(errFile) - if (provider) { - provider.exists(errFile).then(() => { - plugin.open(errFile) - plugin.call('editor', 'gotoLine', errLine, errCol) - }).catch(error => { - if (error) return console.log(error) - }) + if (await plugin.fileExists(errFile)) { + plugin.open(errFile) + plugin.call('editor', 'gotoLine', errLine, errCol) } } else { plugin.call('editor', 'gotoLine', errLine, errCol) From ae97092466fbc20f6487d2ed3501433dee59bf31 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 8 Sep 2021 10:50:21 +0200 Subject: [PATCH 16/30] fix references & wrong rebasing --- apps/solidity-compiler/src/app/compiler.ts | 1 + apps/solidity-compiler/tsconfig.json | 2 +- libs/remix-solidity/src/compiler/compiler-utils.ts | 2 +- libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx | 1 - tsconfig.base.json | 1 + 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 924e358a30..dd111d9a70 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -2,6 +2,7 @@ import { PluginClient } from "@remixproject/plugin"; import { createClient } from "@remixproject/plugin-webview"; import { CompilerApiMixin } from './compiler-api' import { ICompilerApi } from '@remix-project/remix-lib-ts' +import { CompileTabLogic } from '@remix-ui/solidity-compiler' const profile = { name: 'solidity', diff --git a/apps/solidity-compiler/tsconfig.json b/apps/solidity-compiler/tsconfig.json index 7c6fcde8f2..b2a6956c94 100644 --- a/apps/solidity-compiler/tsconfig.json +++ b/apps/solidity-compiler/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "jsx": "react", "allowJs": true, diff --git a/libs/remix-solidity/src/compiler/compiler-utils.ts b/libs/remix-solidity/src/compiler/compiler-utils.ts index ef205c3ca8..0a90e69adf 100644 --- a/libs/remix-solidity/src/compiler/compiler-utils.ts +++ b/libs/remix-solidity/src/compiler/compiler-utils.ts @@ -12,7 +12,7 @@ export const pathToURL = {} * @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix */ export function urlFromVersion (version) { - let url + let url if (version === 'builtin') { let location: string | Location = window.document.location let path = location.pathname diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 09168923cd..72c997b39f 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -70,7 +70,6 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const optimize = params.optimize const runs = params.runs as string const evmVersion = params.evmVersion - const autoCompile = params.autoCompile === 'false' ? false : params.autoCompile === 'true' ? true : null return { ...prevState, diff --git a/tsconfig.base.json b/tsconfig.base.json index 541c18c889..73709ef68c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -32,6 +32,7 @@ "@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"], "@remix-ui/clipboard": ["libs/remix-ui/clipboard/src/index.ts"], "@remix-project/remix-solidity-ts": ["libs/remix-solidity/src/index.ts"], + "@remix-project/remix-lib-ts": ["libs/remix-lib/src/index.ts"], "@remix-ui/modal-dialog": ["libs/remix-ui/modal-dialog/src/index.ts"], "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], From 1c866004bc60c03c43fcb9955be850ee0d8535a8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 8 Sep 2021 12:07:43 +0200 Subject: [PATCH 17/30] readd saveCurrentFile --- apps/remix-ide/src/app/files/fileManager.js | 2 +- apps/solidity-compiler/src/app/compiler-api.ts | 4 ++++ libs/remix-lib/src/types/ICompilerApi.ts | 1 + .../solidity-compiler/src/lib/logic/compileTabLogic.ts | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index 99eeb03380..3d57afcab3 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -22,7 +22,7 @@ const profile = { icon: 'assets/img/fileManager.webp', permission: true, version: packageJson.version, - methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh', 'getProviderOf', 'getProviderByName', 'getPathFromUrl', 'getUrlFromPath'], + methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh', 'getProviderOf', 'getProviderByName', 'getPathFromUrl', 'getUrlFromPath', 'saveCurrentFile'], kind: 'file-system' } const errorMsg = { diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index 502ec33ac4..297a78b726 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -140,6 +140,10 @@ export const CompilerApiMixin = (Base) => class extends Base { return this.call('fileManager', 'open', fileName) } + saveCurrentFile () { + return this.call('fileManager', 'saveCurrentFile') + } + resetResults () { this.currentFile = '' this.contractsDetails = {} diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts index 5f709c435e..de765327ad 100644 --- a/libs/remix-lib/src/types/ICompilerApi.ts +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -32,6 +32,7 @@ export interface ICompilerApi { writeFile: (file: string, content: string) => Promise readFile: (file: string) => Promise open: (file: string) => void + saveCurrentFile: () => void logToTerminal: (log: terminalLog) => {} diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 66caaf550f..69861c12a1 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -121,7 +121,7 @@ export class CompileTabLogic { } } // TODO readd saving current file - // this.api.saveCurrentFile() + this.api.saveCurrentFile() this.event.emit('removeAnnotations') var currentFile = this.api.getAppParameter('currentFile') return this.compileFile(currentFile) From 3f9f4cd73be4cdc71b7b5bc7682b15e3a46220d1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 8 Sep 2021 21:36:06 +0200 Subject: [PATCH 18/30] use currentFile --- .../solidity-compiler/src/lib/compiler-container.tsx | 6 +++--- .../solidity-compiler/src/lib/logic/compileTabLogic.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 72c997b39f..21d2d7d5cf 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -57,7 +57,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { _updateVersionSelector(selectedVersion) } }) - const currentFileName = api.getAppParameter('currentFile') as string + const currentFileName = api.currentFile currentFile(currentFileName) listenToEvents(compileTabLogic, api)(dispatch) @@ -229,7 +229,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } const isSolFileSelected = (currentFile: string = '') => { - if (!currentFile) currentFile = api.getAppParameter('currentFile') as string + if (!currentFile) currentFile = api.currentFile if (!currentFile) return false const extention = currentFile.substr(currentFile.length - 3, currentFile.length) return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul' @@ -298,7 +298,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } const compile = () => { - const currentFile = api.getAppParameter('currentFile') as string + const currentFile = api.currentFile if (!isSolFileSelected()) return diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 69861c12a1..7d036edf12 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -123,7 +123,7 @@ export class CompileTabLogic { // TODO readd saving current file this.api.saveCurrentFile() this.event.emit('removeAnnotations') - var currentFile = this.api.getAppParameter('currentFile') + var currentFile = this.api.currentFile return this.compileFile(currentFile) } catch (err) { console.error(err) From 160eb44bea6e7b01cd6ffba1e229c5753d82cc0f Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 8 Sep 2021 21:36:29 +0200 Subject: [PATCH 19/30] compiler iframe, load default parameters --- apps/solidity-compiler/src/app/compiler.ts | 53 ++++++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index dd111d9a70..03d54f23f5 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -17,6 +17,25 @@ const profile = { methods: ['getCompilationResult', 'compile', 'compileWithParameters', 'setCompilerConfig', 'compileFile' ,'getCompilerState'] } +const defaultAppParameters = { + 'hideWarnings': () => false, + 'autoCompile': () => false, + 'includeNightlies': () => false +} + +const defaultCompilerParameters = { + runs: '200', + optimize: false, + version: 'soljson-v0.8.7+commit.e28d00a7', + evmVersion: null, // default + language: 'Solidity' +} + +const getOptimize = () => { + let value = localStorage.getItem('optimize') || defaultCompilerParameters['optimize'] + value = (value === 'false' || value === null || value === undefined) ? false : value + value = value === 'true' ? true : false +} export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi { constructor () { @@ -29,26 +48,30 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements } getCompilerParameters () { - return { - runs: '200', - optimize: false, - version: '0.8.7+commit.e28d00a7', - evmVersion: null, // default - language: 'Solidity' + const params = { + runs: localStorage.getItem('runs') || defaultCompilerParameters['runs'], + optimize: localStorage.getItem('optimize') === 'true' ? true : false, + version: localStorage.getItem('version') || defaultCompilerParameters['version'], + evmVersion: localStorage.getItem('evmVersion') || defaultCompilerParameters['evmVersion'], // default + language: localStorage.getItem('language') || defaultCompilerParameters['language'] } + return params } - setCompilerParameters (params) {} + setCompilerParameters (params) { + for (const key in Object.keys(params)) { + localStorage.setItem(key, params[key]) + } + } getAppParameter (name) { - const conf = { - 'currentFile': () => this.currentFile, - 'hideWarnings': () => false, - 'autoCompile': () => false, - 'includeNightlies': () => false - } - return conf[name]() + const param = localStorage.getItem(name) || defaultAppParameters[name] + if (param === 'true') return true + if (param === 'false') return false + return param } - setAppParameter (name, value) {} + setAppParameter (name, value) { + localStorage.setItem(name, value) + } } From d5aaf548bd788fa38fc1f66c27242c7545946228 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 8 Sep 2021 21:36:43 +0200 Subject: [PATCH 20/30] compiler iframe load assets --- apps/solidity-compiler/src/assets/img/ipfs.webp | Bin 0 -> 22016 bytes apps/solidity-compiler/src/assets/js/.gitignore | 4 ++++ package.json | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 apps/solidity-compiler/src/assets/img/ipfs.webp create mode 100644 apps/solidity-compiler/src/assets/js/.gitignore diff --git a/apps/solidity-compiler/src/assets/img/ipfs.webp b/apps/solidity-compiler/src/assets/img/ipfs.webp new file mode 100644 index 0000000000000000000000000000000000000000..9cdfa7380c503f4ccfed36563f44cef6c5f1b082 GIT binary patch literal 22016 zcmd?PgLhnA8}L1`-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G6))ZlFy+s*CWoEGc2@do1}#hr5t{D{%+<^er@|z?2=7! zF>NgX000?ReZ%G>T`ms|Vd;mG)HQ~eCY2dKUF~Ujhgzo1424&sc*tCya%m8leC6II ziAsk$24H08$^P14pK@=yZ!2mR8kKjCt|IGq#nF!eqV}lqF{u~yx|B)PKX2F~4?f{? z%!!TF_7cwN-t-v_H?uQq2!1rr3~@p)&t#O-yhMy{rVd8IbF49F)bTPCvl-&pAy%#q zSHY47DAN43hMfI15yUG>+`0e&02;WwvdhYSl}9{8R;v7E$05e$OCJ;q;F(7Id1wNv za3zL61cGF0&p)QQOeMlr%XU_NpgYrsw&=A|bATXoJWtYri~(sIpc-88VE|jNjr>@BCC-`NTCX mHt7 Date: Thu, 9 Sep 2021 09:26:11 +0200 Subject: [PATCH 21/30] uneeded classname --- apps/solidity-compiler/src/app/app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/solidity-compiler/src/app/app.tsx b/apps/solidity-compiler/src/app/app.tsx index e5ace4d4c8..00ce99f3d7 100644 --- a/apps/solidity-compiler/src/app/app.tsx +++ b/apps/solidity-compiler/src/app/app.tsx @@ -8,7 +8,7 @@ const remix = new CompilerClientApi() export const App = () => { return ( -
+
); From b090cee19d6f0e1749b023180951ff15cb70db03 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 09:26:33 +0200 Subject: [PATCH 22/30] fix linting & remove uneeded classname --- apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js b/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js index 6ab95aed8c..35286b2f80 100644 --- a/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js +++ b/apps/remix-ide/src/app/tabs/styles/compile-tab-styles.js @@ -1,12 +1,9 @@ -var csjs = require('csjs-inject') +const csjs = require('csjs-inject') const css = csjs` .compilerTabView { padding: 2%; } - .compiler { - margin-bottom: 1%; - } ` module.exports = css From 4040818c513c3b18028ba7ad6980ccb61cb23d1b Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 09:51:53 +0200 Subject: [PATCH 23/30] fix unregistering events --- .../solidity-compiler/src/app/compiler-api.ts | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index 297a78b726..d0b30cec64 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -45,10 +45,48 @@ export const CompilerApiMixin = (Base) => class extends Base { } onActivation () { - this.listenToEvents() + this.listenToEvents() } - onDeactivation () {} + onDeactivation () { + this.off('editor', 'contentChanged') + + if (this.data.eventHandlers.onLoadingCompiler) { + this.compiler.event.unregister('loadingCompiler', this.data.eventHandlers.onLoadingCompiler) + } + + if (this.data.eventHandlers.onCompilerLoaded) { + this.compiler.event.unregister('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) + } + + if (this.data.eventHandlers.onCompilationFinished) { + this.compiler.event.unregister('compilationFinished', this.data.eventHandlers.onCompilationFinished) + } + + this.off('filePanel', 'setWorkspace') + + this.off('remixd', 'rootFolderChanged') + + this.off('editor', 'sessionSwitched') + + if (this.data.eventHandlers.onStartingCompilation) { + this.compileTabLogic.event.off('startingCompilation', this.data.eventHandlers.onStartingCompilation) + } + + if (this.data.eventHandlers.onRemoveAnnotations) { + this.compileTabLogic.event.off('removeAnnotations', this.data.eventHandlers.onRemoveAnnotations) + } + + this.off('fileManager', 'currentFileChanged') + + this.off('fileManager', 'noFileSelected') + + this.off('themeModule', 'themeChanged') + + if (this.data.eventHandlers.onKeyDown) { + window.document.removeEventListener('keydown', this.data.eventHandlers.onKeyDown) + } + } resolveContentAndSave (url) { return this.call('contentImport', 'resolveAndSave', url) @@ -248,12 +286,13 @@ export const CompilerApiMixin = (Base) => class extends Base { this.on('themeModule', 'themeChanged', this.data.eventHandlers.onThemeChanged) // Run the compiler instead of trying to save the website - window.document.addEventListener('keydown', (e) => { + this.data.eventHandlers.onKeyDown = (e) => { // ctrl+s or command+s if ((e.metaKey || e.ctrlKey) && e.keyCode === 83) { e.preventDefault() this.compileTabLogic.runCompiler(this.getAppParameter('hardhat-compilation')) } - }) + } + window.document.addEventListener('keydown', this.data.eventHandlers.onKeyDown) } } From 427b885cc64702f305aaf83e3e1156c8ba264fd2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 09:52:15 +0200 Subject: [PATCH 24/30] remove unused code --- apps/solidity-compiler/src/app/compiler.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 03d54f23f5..f003f33c76 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -31,12 +31,6 @@ const defaultCompilerParameters = { language: 'Solidity' } -const getOptimize = () => { - let value = localStorage.getItem('optimize') || defaultCompilerParameters['optimize'] - value = (value === 'false' || value === null || value === undefined) ? false : value - value = value === 'true' ? true : false -} - export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi { constructor () { super() From a938a02b475592478789ee345e343a74c5d70711 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 09:53:21 +0200 Subject: [PATCH 25/30] fix fileManager mode --- apps/remix-ide/src/app.js | 2 +- apps/remix-ide/src/app/tabs/compile-tab.js | 7 ++++++- apps/solidity-compiler/src/app/compiler-api.ts | 6 +----- apps/solidity-compiler/src/app/compiler.ts | 4 ++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index c6020f4bae..03ecc61b55 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -425,7 +425,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } // CONTENT VIEWS & DEFAULT PLUGINS - const compileTab = new CompileTab(registry.get('config').api) + const compileTab = new CompileTab(registry.get('config').api, registry.get('filemanager').api) const run = new RunTab( blockchain, registry.get('config').api, diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 4441993d34..8066128218 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -32,8 +32,9 @@ const profile = { // - methods: ['getCompilationResult'] class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerApi - constructor (config) { + constructor (config, fileManager) { super(profile) + this.fileManager this.config = config this.queryParams = new QueryParams() this.compileTabLogic = new CompileTabLogic(this, this.contentImport) @@ -87,6 +88,10 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA return super.getCompilationResult() } + getFileManagerMode () { + return this.fileManager.mode + } + /** * set the compiler configuration * This function is used by remix-plugin compiler API. diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index d0b30cec64..9a96319e9a 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -1,6 +1,6 @@ import { compile } from '@remix-project/remix-solidity' import { CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line -import { ConfigurationSettings } from '@remix-project/remix-lib-ts' +import type { ConfigurationSettings } from '@remix-project/remix-lib-ts' export const CompilerApiMixin = (Base) => class extends Base { currentFile: string @@ -158,10 +158,6 @@ export const CompilerApiMixin = (Base) => class extends Base { this.configurationSettings = settings } - getFileManagerMode () { - return 'browser' - } - fileExists (fileName) { return this.call('fileManager', 'exists', fileName) } diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index f003f33c76..1080bf6ff3 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -68,4 +68,8 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements setAppParameter (name, value) { localStorage.setItem(name, value) } + + getFileManagerMode () { + return 'browser' + } } From df78375f4ee9da9340960870f5a413851d28e356 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 09:54:19 +0200 Subject: [PATCH 26/30] change comment --- apps/solidity-compiler/src/app/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 1080bf6ff3..223b5e2bc7 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -27,7 +27,7 @@ const defaultCompilerParameters = { runs: '200', optimize: false, version: 'soljson-v0.8.7+commit.e28d00a7', - evmVersion: null, // default + evmVersion: null, // compiler default language: 'Solidity' } From e56f0ca40a7b333eac370d33e357bd08dea24d8b Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 10:02:10 +0200 Subject: [PATCH 27/30] fix assignments --- apps/remix-ide/src/app/tabs/compile-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 8066128218..17f10a504b 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -34,7 +34,7 @@ const profile = { class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerApi constructor (config, fileManager) { super(profile) - this.fileManager + this.fileManager = fileManager this.config = config this.queryParams = new QueryParams() this.compileTabLogic = new CompileTabLogic(this, this.contentImport) From 4dc1a4947dcc24e368ee8ece81a8f52faa50a551 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 10:53:59 +0200 Subject: [PATCH 28/30] set default language --- libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 21d2d7d5cf..f7390446eb 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -30,11 +30,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => { customVersions: [], selectedVersion: null, defaultVersion: 'soljson-v0.8.7+commit.e28d00a7.js', // this default version is defined: in makeMockCompiler (for browser test) - selectedLanguage: '', runs: '', compiledFileName: '', includeNightlies: false, - language: '', + language: 'Solidity', evmVersion: '' }) const [disableCompileButton, setDisableCompileButton] = useState(false) From f5479a2cc5fb16efd2ee9bd6d14b1207b6f1bc9e Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 10:54:09 +0200 Subject: [PATCH 29/30] fix default parameters --- apps/solidity-compiler/src/app/compiler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 223b5e2bc7..6f499103b9 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -18,9 +18,9 @@ const profile = { } const defaultAppParameters = { - 'hideWarnings': () => false, - 'autoCompile': () => false, - 'includeNightlies': () => false + hideWarnings: false, + autoCompile: false, + includeNightlies: false } const defaultCompilerParameters = { From 96dbfb9d8ba7e0d0d29f626186bbf2aaf12cc728 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 9 Sep 2021 11:24:23 +0200 Subject: [PATCH 30/30] fix saving compiler parameters --- apps/solidity-compiler/src/app/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/solidity-compiler/src/app/compiler.ts b/apps/solidity-compiler/src/app/compiler.ts index 6f499103b9..5a6e8eafaa 100644 --- a/apps/solidity-compiler/src/app/compiler.ts +++ b/apps/solidity-compiler/src/app/compiler.ts @@ -53,7 +53,7 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements } setCompilerParameters (params) { - for (const key in Object.keys(params)) { + for (const key of Object.keys(params)) { localStorage.setItem(key, params[key]) } }