|
|
@ -19,11 +19,11 @@ 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, 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({ |
|
|
|
const [state, setState] = useState({ |
|
|
|
hideWarnings: false, |
|
|
|
hideWarnings: false, |
|
|
|
autoCompile: false, |
|
|
|
autoCompile: false, |
|
|
|
optimise: false, |
|
|
|
optimize: false, |
|
|
|
compileTimeout: null, |
|
|
|
compileTimeout: null, |
|
|
|
timeout: 300, |
|
|
|
timeout: 300, |
|
|
|
allversions: [], |
|
|
|
allversions: [], |
|
|
@ -57,7 +57,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
_updateVersionSelector(selectedVersion) |
|
|
|
_updateVersionSelector(selectedVersion) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
const currentFileName = api.getConfiguration('currentFile') |
|
|
|
const currentFileName = api.getAppParameter('currentFile') as string |
|
|
|
|
|
|
|
|
|
|
|
currentFile(currentFileName) |
|
|
|
currentFile(currentFileName) |
|
|
|
listenToEvents(compileTabLogic, api)(dispatch) |
|
|
|
listenToEvents(compileTabLogic, api)(dispatch) |
|
|
@ -66,19 +66,19 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (compileTabLogic && compileTabLogic.compiler) { |
|
|
|
if (compileTabLogic && compileTabLogic.compiler) { |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
const params = api.getParameters() |
|
|
|
const params = api.getCompilerParameters() |
|
|
|
const optimize = params.optimize === 'false' ? false : params.optimize === 'true' ? true : null |
|
|
|
const optimize = params.optimize |
|
|
|
const runs = params.runs |
|
|
|
const runs = params.runs as string |
|
|
|
const evmVersion = params.evmVersion |
|
|
|
const evmVersion = params.evmVersion |
|
|
|
const autoCompile = params.autoCompile === 'false' ? false : params.autoCompile === 'true' ? true : null |
|
|
|
const autoCompile = params.autoCompile === 'false' ? false : params.autoCompile === 'true' ? true : null |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
...prevState, |
|
|
|
...prevState, |
|
|
|
hideWarnings: api.getConfiguration('hideWarnings') || false, |
|
|
|
hideWarnings: api.getAppParameter('hideWarnings') as boolean || false, |
|
|
|
autoCompile: typeof autoCompile === 'boolean' ? autoCompile : api.getConfiguration('autoCompile') || false, |
|
|
|
autoCompile: api.getAppParameter('autoCompile') as boolean || false, |
|
|
|
includeNightlies: api.getConfiguration('includeNightlies') || false, |
|
|
|
includeNightlies: api.getAppParameter('includeNightlies') as boolean || false, |
|
|
|
optimize: (optimize !== null) && (optimize !== undefined) ? optimize : false, |
|
|
|
optimize: optimize, |
|
|
|
runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200, |
|
|
|
runs: runs, |
|
|
|
evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' |
|
|
|
evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -154,7 +154,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
|
|
|
|
|
|
|
|
allVersions = [...allVersions, ...versions] |
|
|
|
allVersions = [...allVersions, ...versions] |
|
|
|
selectedVersion = state.defaultVersion |
|
|
|
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'
|
|
|
|
// Check if version is a URL and corresponding filename starts with 'soljson'
|
|
|
|
if (selectedVersion.startsWith('https://')) { |
|
|
|
if (selectedVersion.startsWith('https://')) { |
|
|
|
const urlArr = selectedVersion.split('/') |
|
|
|
const urlArr = selectedVersion.split('/') |
|
|
@ -229,8 +229,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isSolFileSelected = (currentFile = '') => { |
|
|
|
const isSolFileSelected = (currentFile: string = '') => { |
|
|
|
if (!currentFile) currentFile = api.getConfiguration('currentFile') |
|
|
|
if (!currentFile) currentFile = api.getAppParameter('currentFile') as string |
|
|
|
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' |
|
|
@ -299,7 +299,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const compile = () => { |
|
|
|
const compile = () => { |
|
|
|
const currentFile = api.getConfiguration('currentFile') |
|
|
|
const currentFile = api.getAppParameter('currentFile') as string |
|
|
|
|
|
|
|
|
|
|
|
if (!isSolFileSelected()) return |
|
|
|
if (!isSolFileSelected()) return |
|
|
|
|
|
|
|
|
|
|
@ -323,7 +323,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
updateCurrentVersion(selectedVersion) |
|
|
|
updateCurrentVersion(selectedVersion) |
|
|
|
api.setParameters({ version: selectedVersion }) |
|
|
|
api.setCompilerParameters({ version: selectedVersion }) |
|
|
|
let url |
|
|
|
let url |
|
|
|
|
|
|
|
|
|
|
|
if (customUrl !== '') { |
|
|
|
if (customUrl !== '') { |
|
|
@ -333,7 +333,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
updateCurrentVersion(selectedVersion) |
|
|
|
updateCurrentVersion(selectedVersion) |
|
|
|
url = customUrl |
|
|
|
url = customUrl |
|
|
|
api.setParameters({ version: selectedVersion }) |
|
|
|
api.setCompilerParameters({ version: selectedVersion }) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (helper.checkSpecialChars(selectedVersion)) { |
|
|
|
if (helper.checkSpecialChars(selectedVersion)) { |
|
|
|
return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') |
|
|
|
return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') |
|
|
@ -404,7 +404,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
const handleAutoCompile = (e) => { |
|
|
|
const handleAutoCompile = (e) => { |
|
|
|
const checked = e.target.checked |
|
|
|
const checked = e.target.checked |
|
|
|
|
|
|
|
|
|
|
|
api.setConfiguration('autoCompile', checked) |
|
|
|
api.setAppParameter('autoCompile', checked) |
|
|
|
checked && compile() |
|
|
|
checked && compile() |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, autoCompile: checked } |
|
|
|
return { ...prevState, autoCompile: checked } |
|
|
@ -414,7 +414,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
const handleOptimizeChange = (value) => { |
|
|
|
const handleOptimizeChange = (value) => { |
|
|
|
const checked = !!value |
|
|
|
const checked = !!value |
|
|
|
|
|
|
|
|
|
|
|
api.setConfiguration('optimise', checked) |
|
|
|
api.setAppParameter('optimize', checked) |
|
|
|
compileTabLogic.setOptimize(checked) |
|
|
|
compileTabLogic.setOptimize(checked) |
|
|
|
if (compileTabLogic.optimize) { |
|
|
|
if (compileTabLogic.optimize) { |
|
|
|
compileTabLogic.setRuns(parseInt(state.runs)) |
|
|
|
compileTabLogic.setRuns(parseInt(state.runs)) |
|
|
@ -423,7 +423,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
} |
|
|
|
} |
|
|
|
state.autoCompile && compile() |
|
|
|
state.autoCompile && compile() |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, optimise: checked } |
|
|
|
return { ...prevState, optimize: checked } |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -440,7 +440,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
const handleHideWarningsChange = (e) => { |
|
|
|
const handleHideWarningsChange = (e) => { |
|
|
|
const checked = e.target.checked |
|
|
|
const checked = e.target.checked |
|
|
|
|
|
|
|
|
|
|
|
api.setConfiguration('hideWarnings', checked) |
|
|
|
api.setAppParameter('hideWarnings', checked) |
|
|
|
state.autoCompile && compile() |
|
|
|
state.autoCompile && compile() |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, hideWarnings: checked } |
|
|
|
return { ...prevState, hideWarnings: checked } |
|
|
@ -451,7 +451,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) |
|
|
|
api.setConfiguration('includeNightlies', checked) |
|
|
|
api.setAppParameter('includeNightlies', checked) |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, includeNightlies: checked } |
|
|
|
return { ...prevState, includeNightlies: checked } |
|
|
|
}) |
|
|
|
}) |
|
|
@ -482,7 +482,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
const checked = event.target.checked |
|
|
|
const checked = event.target.checked |
|
|
|
|
|
|
|
|
|
|
|
sethhCompilation(checked) |
|
|
|
sethhCompilation(checked) |
|
|
|
api.setHardHatCompilation(checked) |
|
|
|
api.setAppParameter('hardhat-compilation', checked) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -553,7 +553,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="mt-2 remixui_compilerConfig custom-control custom-checkbox"> |
|
|
|
<div className="mt-2 remixui_compilerConfig custom-control custom-checkbox"> |
|
|
|
<div className="justify-content-between align-items-center d-flex"> |
|
|
|
<div className="justify-content-between align-items-center d-flex"> |
|
|
|
<input onChange={(e) => { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimise} /> |
|
|
|
<input onChange={(e) => { handleOptimizeChange(e.target.checked) }} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimize} /> |
|
|
|
<label className="form-check-label custom-control-label" htmlFor="optimize">Enable optimization</label> |
|
|
|
<label className="form-check-label custom-control-label" htmlFor="optimize">Enable optimization</label> |
|
|
|
<input |
|
|
|
<input |
|
|
|
min="1" |
|
|
|
min="1" |
|
|
@ -564,7 +564,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
type="number" |
|
|
|
type="number" |
|
|
|
title="Estimated number of times each opcode of the deployed code will be executed across the life-time of the contract." |
|
|
|
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)} |
|
|
|
onChange={(e) => onChangeRuns(e.target.value)} |
|
|
|
disabled={!state.optimise} |
|
|
|
disabled={!state.optimize} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -574,7 +574,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{ |
|
|
|
{ |
|
|
|
api.isHardHatProject && |
|
|
|
isHardhatProject && |
|
|
|
<div className="mt-3 remixui_compilerConfig custom-control custom-checkbox"> |
|
|
|
<div className="mt-3 remixui_compilerConfig custom-control custom-checkbox"> |
|
|
|
<input className="remixui_autocompile custom-control-input" onChange={updatehhCompilation} id="enableHardhat" type="checkbox" title="Enable Hardhat Compilation" checked={hhCompilation} /> |
|
|
|
<input className="remixui_autocompile custom-control-input" onChange={updatehhCompilation} id="enableHardhat" type="checkbox" title="Enable Hardhat Compilation" checked={hhCompilation} /> |
|
|
|
<label className="form-check-label custom-control-label" htmlFor="enableHardhat">Enable Hardhat Compilation</label> |
|
|
|
<label className="form-check-label custom-control-label" htmlFor="enableHardhat">Enable Hardhat Compilation</label> |
|
|
|