remove config parameter

pull/1487/head
yann300 4 years ago
parent 4a7b6c08d4
commit 8a83cc35aa
  1. 8
      apps/remix-ide/src/app/tabs/compile-tab.js
  2. 7
      libs/remix-ui/renderer/src/lib/renderer.tsx
  3. 24
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  4. 2
      libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts
  5. 12
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx
  6. 6
      libs/remix-ui/solidity-compiler/src/lib/types/index.ts

@ -284,6 +284,14 @@ class CompileTab extends ViewPlugin {
this.queryParams.update(params) this.queryParams.update(params)
} }
getConfiguration (name) {
return this.config.get(name)
}
setConfiguration (name, value) {
this.config.set(name, value)
}
onActivation () { onActivation () {
this.call('manager', 'activatePlugin', 'solidity-logic') this.call('manager', 'activatePlugin', 'solidity-logic')
this.listenToEvents() this.listenToEvents()

@ -4,11 +4,10 @@ interface RendererProps {
message: any; message: any;
opt?: any, opt?: any,
plugin: any, plugin: any,
config: any,
fileManager: any fileManager: any
} }
export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: RendererProps) => { export const Renderer = ({ message, opt = {}, fileManager, plugin }: RendererProps) => {
const [messageText, setMessageText] = useState(null) const [messageText, setMessageText] = useState(null)
const [editorOptions, setEditorOptions] = useState({ const [editorOptions, setEditorOptions] = useState({
useSpan: false, useSpan: false,
@ -76,7 +75,7 @@ export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: Ren
} }
const addAnnotation = (file, error) => { const addAnnotation = (file, error) => {
if (file === config.get('currentFile')) { if (file === plugin.getConfiguration('currentFile')) {
plugin.call('editor', 'addAnnotation', error, file) plugin.call('editor', 'addAnnotation', error, file)
} }
} }
@ -94,7 +93,7 @@ export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: Ren
} }
const _errorClick = (errFile, errLine, errCol) => { const _errorClick = (errFile, errLine, errCol) => {
if (errFile !== config.get('currentFile')) { if (errFile !== plugin.getConfiguration('currentFile')) {
// TODO: refactor with this._components.contextView.jumpTo // TODO: refactor with this._components.contextView.jumpTo
const provider = fileManager.fileProviderOf(errFile) const provider = fileManager.fileProviderOf(errFile)
if (provider) { if (provider) {

@ -18,7 +18,7 @@ declare global {
const _paq = window._paq = window._paq || [] //eslint-disable-line const _paq = window._paq = window._paq || [] //eslint-disable-line
export const CompilerContainer = (props: CompilerContainerProps) => { export const CompilerContainer = (props: CompilerContainerProps) => {
const { api, config, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line const { api, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line
const [state, setState] = useState({ const [state, setState] = useState({
hideWarnings: false, hideWarnings: false,
autoCompile: false, autoCompile: false,
@ -56,7 +56,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
_updateVersionSelector(selectedVersion) _updateVersionSelector(selectedVersion)
} }
}) })
const currentFileName = config.get('currentFile') const currentFileName = api.getConfiguration('currentFile')
currentFile(currentFileName) currentFile(currentFileName)
listenToEvents(compileTabLogic)(dispatch) listenToEvents(compileTabLogic)(dispatch)
@ -72,10 +72,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
return { return {
...prevState, ...prevState,
hideWarnings: config.get('hideWarnings') || false, hideWarnings: api.getConfiguration('hideWarnings') || false,
autoCompile: config.get('autoCompile') || false, autoCompile: api.getConfiguration('autoCompile') || false,
includeNightlies: config.get('includeNightlies') || false, includeNightlies: api.getConfiguration('includeNightlies') || false,
optimise: (optimize !== null) && (optimize !== undefined) ? optimize : config.get('optimise') || false, optimise: (optimize !== null) && (optimize !== undefined) ? optimize : api.getConfiguration('optimise') || false,
runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200, runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200,
evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default'
} }
@ -228,7 +228,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
} }
const isSolFileSelected = (currentFile = '') => { const isSolFileSelected = (currentFile = '') => {
if (!currentFile) currentFile = config.get('currentFile') if (!currentFile) currentFile = api.getConfiguration('currentFile')
if (!currentFile) return false if (!currentFile) return false
const extention = currentFile.substr(currentFile.length - 3, currentFile.length) const extention = currentFile.substr(currentFile.length - 3, currentFile.length)
return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul' return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul'
@ -297,7 +297,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
} }
const compile = () => { const compile = () => {
const currentFile = config.get('currentFile') const currentFile = api.getConfiguration('currentFile')
if (!isSolFileSelected()) return if (!isSolFileSelected()) return
@ -406,7 +406,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const handleAutoCompile = (e) => { const handleAutoCompile = (e) => {
const checked = e.target.checked const checked = e.target.checked
config.set('autoCompile', checked) api.setConfiguration('autoCompile', checked)
setState(prevState => { setState(prevState => {
return { ...prevState, autoCompile: checked } return { ...prevState, autoCompile: checked }
}) })
@ -415,7 +415,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const handleOptimizeChange = (value) => { const handleOptimizeChange = (value) => {
const checked = !!value const checked = !!value
config.set('optimise', checked) api.setConfiguration('optimise', checked)
compileTabLogic.setOptimize(checked) compileTabLogic.setOptimize(checked)
if (compileTabLogic.optimize) { if (compileTabLogic.optimize) {
compileTabLogic.setRuns(parseInt(state.runs)) compileTabLogic.setRuns(parseInt(state.runs))
@ -441,7 +441,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const handleHideWarningsChange = (e) => { const handleHideWarningsChange = (e) => {
const checked = e.target.checked const checked = e.target.checked
config.set('hideWarnings', checked) api.setConfiguration('hideWarnings', checked)
state.autoCompile && compile() state.autoCompile && compile()
setState(prevState => { setState(prevState => {
return { ...prevState, hideWarnings: checked } return { ...prevState, hideWarnings: checked }
@ -452,7 +452,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const checked = e.target.checked const checked = e.target.checked
if (!checked) handleLoadVersion(state.defaultVersion) if (!checked) handleLoadVersion(state.defaultVersion)
config.set('includeNightlies', checked) api.setConfiguration('includeNightlies', checked)
setState(prevState => { setState(prevState => {
return { ...prevState, includeNightlies: checked } return { ...prevState, includeNightlies: checked }
}) })

@ -124,7 +124,7 @@ export class CompileTab extends Plugin {
} }
this.fileManager.saveCurrentFile() this.fileManager.saveCurrentFile()
this.event.emit('removeAnnotations') this.event.emit('removeAnnotations')
var currentFile = this.config.get('currentFile') var currentFile = this.api.getConfiguration('currentFile')
return this.compileFile(currentFile) return this.compileFile(currentFile)
} catch (err) { } catch (err) {
console.error(err) console.error(err)

@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line
import './css/style.css' import './css/style.css'
export const SolidityCompiler = (props: SolidityCompilerProps) => { export const SolidityCompiler = (props: SolidityCompilerProps) => {
const { plugin, plugin: { config, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const { plugin, plugin: { compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props
const [state, setState] = useState({ const [state, setState] = useState({
contractsDetails: {}, contractsDetails: {},
eventHandlers: {}, eventHandlers: {},
@ -78,19 +78,19 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
return ( return (
<> <>
<div id="compileTabView"> <div id="compileTabView">
<CompilerContainer api={plugin} config={config} compileTabLogic={compileTabLogic} tooltip={toast} modal={modal} compiledFileName={currentFile} setHardHatCompilation={setHardHatCompilation.bind(plugin)} updateCurrentVersion={updateCurrentVersion} isHardHatProject={isHardHatProject} configurationSettings={configurationSettings} /> <CompilerContainer api={plugin} compileTabLogic={compileTabLogic} tooltip={toast} modal={modal} compiledFileName={currentFile} setHardHatCompilation={setHardHatCompilation.bind(plugin)} updateCurrentVersion={updateCurrentVersion} isHardHatProject={isHardHatProject} configurationSettings={configurationSettings} />
<ContractSelection contractMap={contractMap} fileProvider={fileProvider} fileManager={fileManager} contractsDetails={contractsDetails} modal={modal} /> <ContractSelection contractMap={contractMap} fileProvider={fileProvider} fileManager={fileManager} contractsDetails={contractsDetails} modal={modal} />
<div className="remixui_errorBlobs p-4" data-id="compiledErrors"> <div className="remixui_errorBlobs p-4" data-id="compiledErrors">
<span data-id={`compilationFinishedWith_${currentVersion}`}></span> <span data-id={`compilationFinishedWith_${currentVersion}`}></span>
{ compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} config={config} fileManager={fileManager} /> } { compileErrors.error && <Renderer message={compileErrors.error.formattedMessage || compileErrors.error} plugin={plugin} opt={{ type: compileErrors.error.severity || 'error', errorType: compileErrors.error.type }} fileManager={fileManager} /> }
{ compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) }
{ compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => {
if (config.get('hideWarnings')) { if (plugin.getConfiguration('hideWarnings')) {
if (err.severity !== 'warning') { if (err.severity !== 'warning') {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} fileManager={fileManager} /> return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} fileManager={fileManager} />
} }
} else { } else {
return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} config={config} fileManager={fileManager} /> return <Renderer key={index} message={err.formattedMessage} plugin={plugin} opt={{ type: err.severity, errorType: err.type }} fileManager={fileManager} />
} }
}) } }) }
</div> </div>

@ -8,7 +8,6 @@ export interface SolidityCompilerProps {
compileTabLogic: any, compileTabLogic: any,
currentFile: string, currentFile: string,
contractsDetails: Record<string, any>, contractsDetails: Record<string, any>,
config: any,
fileProvider: any, fileProvider: any,
fileManager: any, fileManager: any,
contentImport: any, contentImport: any,
@ -16,13 +15,14 @@ export interface SolidityCompilerProps {
on: (...args) => void, on: (...args) => void,
setHardHatCompilation: (value: boolean) => void, setHardHatCompilation: (value: boolean) => void,
setSelectedVersion: (value: string) => void, setSelectedVersion: (value: string) => void,
configurationSettings: ConfigurationSettings configurationSettings: ConfigurationSettings,
getConfiguration: (value: string) => string,
setConfiguration: (name: string, value: string) => void
}, },
} }
export interface CompilerContainerProps { export interface CompilerContainerProps {
api: any, api: any,
config: any,
compileTabLogic: any, compileTabLogic: any,
tooltip: (message: string | JSX.Element) => void, tooltip: (message: string | JSX.Element) => void,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,

Loading…
Cancel
Save