diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 63faf345af..60432ac944 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -52,7 +52,7 @@ class CompileTab extends ViewPlugin { eventHandlers: {}, loading: false } - this.compileTabLogic = new CompileTabLogic( + this.compileTabLogic = new CompileTabLogic(this, this.queryParams, this.fileManager, this.config, @@ -277,6 +277,14 @@ class CompileTab extends ViewPlugin { , this.el) } + getParameters () { + return this.queryParams.get() + } + + setParameters (params) { + this.queryParams.update(params) + } + onActivation () { this.call('manager', 'activatePlugin', 'solidity-logic') this.listenToEvents() 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 98ec8e8c11..cf6ceba0dc 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -18,7 +18,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line + const { api, config, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -65,7 +65,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { useEffect(() => { if (compileTabLogic && compileTabLogic.compiler) { setState(prevState => { - const params = queryParams.get() + const params = api.getParameters() const optimize = params.optimize === 'false' ? false : params.optimize === 'true' ? true : null const runs = params.runs const evmVersion = params.evmVersion @@ -152,7 +152,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { allVersions = [...allVersions, ...versions] selectedVersion = state.defaultVersion - if (queryParams.get().version) selectedVersion = queryParams.get().version + if (api.getParameters().version) selectedVersion = api.getParameters().version // Check if version is a URL and corresponding filename starts with 'soljson' if (selectedVersion.startsWith('https://')) { const urlArr = selectedVersion.split('/') @@ -321,7 +321,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) } updateCurrentVersion(selectedVersion) - queryParams.update({ version: selectedVersion }) + api.setParameters({ version: selectedVersion }) let url if (customUrl !== '') { @@ -331,7 +331,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) updateCurrentVersion(selectedVersion) url = customUrl - queryParams.update({ version: selectedVersion }) + api.setParameters({ version: selectedVersion }) } else if (selectedVersion === 'builtin') { let location: string | Location = window.document.location let path = location.pathname 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 7ec31b31c1..cded031940 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -18,46 +18,46 @@ export class CompileTab extends Plugin { public compilerImport public event - constructor (public queryParams, public fileManager, public config, public fileProvider, public contentImport) { + constructor (public api, public fileManager, public config, public fileProvider, 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))) } init () { - this.optimize = this.queryParams.get().optimize + this.optimize = this.api.getParameters().optimize this.optimize = this.optimize === 'true' - this.queryParams.update({ optimize: this.optimize }) + this.api.setParameters({ optimize: this.optimize }) this.compiler.set('optimize', this.optimize) - this.runs = this.queryParams.get().runs + this.runs = this.api.getParameters().runs this.runs = this.runs && this.runs !== 'undefined' ? this.runs : 200 - this.queryParams.update({ runs: this.runs }) + this.api.setParameters({ runs: this.runs }) this.compiler.set('runs', this.runs) - this.evmVersion = this.queryParams.get().evmVersion + this.evmVersion = this.api.getParameters().evmVersion if (this.evmVersion === 'undefined' || this.evmVersion === 'null' || !this.evmVersion) { this.evmVersion = null } - this.queryParams.update({ evmVersion: this.evmVersion }) + this.api.setParameters({ evmVersion: this.evmVersion }) this.compiler.set('evmVersion', this.evmVersion) } setOptimize (newOptimizeValue) { this.optimize = newOptimizeValue - this.queryParams.update({ optimize: this.optimize }) + this.api.setParameters({ optimize: this.optimize }) this.compiler.set('optimize', this.optimize) } setRuns (runs) { this.runs = runs - this.queryParams.update({ runs: this.runs }) + this.api.setParameters({ runs: this.runs }) this.compiler.set('runs', this.runs) } setEvmVersion (newEvmVersion) { this.evmVersion = newEvmVersion - this.queryParams.update({ evmVersion: this.evmVersion }) + this.api.setParameters({ evmVersion: this.evmVersion }) this.compiler.set('evmVersion', this.evmVersion) } 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 83f05d6409..35b96ee48e 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: { config, queryParams, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { config, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -78,7 +78,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>