Merge branch 'master' into walkT

pull/5370/head
Liana Husikyan 2 years ago committed by GitHub
commit 751ddc6d48
  1. 4
      apps/solidity-compiler/src/app/compiler-api.ts
  2. 3
      libs/remix-solidity/src/compiler/compiler-worker.ts
  3. 14
      libs/remix-solidity/src/compiler/compiler.ts
  4. 2
      libs/remix-solidity/src/compiler/types.ts
  5. 4
      libs/remix-tests/src/compiler.ts
  6. 1
      libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.css
  7. 4
      libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
  8. 22
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  9. 2
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx
  10. 4
      libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx

@ -222,10 +222,10 @@ export const CompilerApiMixin = (Base) => class extends Base {
} }
this.compiler.event.register('loadingCompiler', this.data.eventHandlers.onLoadingCompiler) this.compiler.event.register('loadingCompiler', this.data.eventHandlers.onLoadingCompiler)
this.data.eventHandlers.onCompilerLoaded = (version) => { this.data.eventHandlers.onCompilerLoaded = (version, license) => {
this.data.loading = false this.data.loading = false
this.statusChanged({ key: 'none' }) this.statusChanged({ key: 'none' })
this.emit('compilerLoaded', version) this.emit('compilerLoaded', version, license)
} }
this.compiler.event.register('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) this.compiler.event.register('compilerLoaded', this.data.eventHandlers.onCompilerLoaded)

@ -33,7 +33,8 @@ export default function (self) { // eslint-disable-line @typescript-eslint/expli
} }
self.postMessage({ self.postMessage({
cmd: 'versionLoaded', cmd: 'versionLoaded',
data: compiler.version() data: compiler.version(),
license: compiler.license()
}) })
break break
} }

@ -25,6 +25,7 @@ export class Compiler {
compileJSON: null, compileJSON: null,
worker: null, worker: null,
currentVersion: null, currentVersion: null,
compilerLicense: null,
optimize: false, optimize: false,
runs: 200, runs: 200,
evmVersion: null, evmVersion: null,
@ -94,9 +95,10 @@ export class Compiler {
* @param version compiler version * @param version compiler version
*/ */
onCompilerLoaded (version: string): void { onCompilerLoaded (version: string, license: string): void {
this.state.currentVersion = version this.state.currentVersion = version
this.event.trigger('compilerLoaded', [version]) this.state.compilerLicense = license
this.event.trigger('compilerLoaded', [version, license])
} }
/** /**
@ -131,7 +133,7 @@ export class Compiler {
} }
this.onCompilationFinished(result, missingInputs, source, input, this.state.currentVersion) this.onCompilationFinished(result, missingInputs, source, input, this.state.currentVersion)
} }
this.onCompilerLoaded(compiler.version()) this.onCompilerLoaded(compiler.version(), compiler.license())
} }
} }
@ -184,6 +186,7 @@ export class Compiler {
if (err) { if (err) {
console.error('Error in loading remote solc compiler: ', err) console.error('Error in loading remote solc compiler: ', err)
} else { } else {
let license
this.state.compileJSON = (source: SourceWithTarget) => { this.state.compileJSON = (source: SourceWithTarget) => {
const missingInputs: string[] = [] const missingInputs: string[] = []
const missingInputsCallback = (path: string) => { const missingInputsCallback = (path: string) => {
@ -203,13 +206,14 @@ export class Compiler {
} }
result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback })) result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback }))
license = remoteCompiler.license()
} }
} catch (exception) { } catch (exception) {
result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } } result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } }
} }
this.onCompilationFinished(result, missingInputs, source, input, version) this.onCompilationFinished(result, missingInputs, source, input, version)
} }
this.onCompilerLoaded(version) this.onCompilerLoaded(version, license)
} }
}) })
} }
@ -273,7 +277,7 @@ export class Compiler {
const data: MessageFromWorker = msg.data const data: MessageFromWorker = msg.data
switch (data.cmd) { switch (data.cmd) {
case 'versionLoaded': case 'versionLoaded':
if (data.data) this.onCompilerLoaded(data.data) if (data.data && data.license) this.onCompilerLoaded(data.data, data.license)
break break
case 'compiled': case 'compiled':
{ {

@ -158,6 +158,7 @@ export interface CompilerState {
compileJSON: ((input: SourceWithTarget) => void) | null, compileJSON: ((input: SourceWithTarget) => void) | null,
worker: any, worker: any,
currentVersion: string| null| undefined, currentVersion: string| null| undefined,
compilerLicense: string| null
optimize: boolean, optimize: boolean,
runs: number runs: number
evmVersion: EVMVersion| null, evmVersion: EVMVersion| null,
@ -186,6 +187,7 @@ export interface MessageToWorker {
export interface MessageFromWorker { export interface MessageFromWorker {
cmd: string, cmd: string,
license?: string,
job?: number, job?: number,
missingInputs?: string[], missingInputs?: string[],
input?: any, input?: any,

@ -134,7 +134,7 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts
if (runs) compiler.set('runs', runs) if (runs) compiler.set('runs', runs)
if (currentCompilerUrl) { if (currentCompilerUrl) {
compiler.loadRemoteVersion(currentCompilerUrl) compiler.loadRemoteVersion(currentCompilerUrl)
compiler.event.register('compilerLoaded', this, function (version) { compiler.event.register('compilerLoaded', this, function (version, license) {
next() next()
}) })
} else { } else {
@ -198,7 +198,7 @@ export function compileContractSources (sources: SrcIfc, newCompConfig: any, imp
compiler.set('runs', runs) compiler.set('runs', runs)
compiler.loadVersion(usingWorker, currentCompilerUrl) compiler.loadVersion(usingWorker, currentCompilerUrl)
// @ts-ignore // @ts-ignore
compiler.event.register('compilerLoaded', this, (version) => { compiler.event.register('compilerLoaded', this, (version, license) => {
next() next()
}) })
} else { } else {

@ -8,6 +8,7 @@
.remixModalBody { .remixModalBody {
overflow-y: auto; overflow-y: auto;
max-height: 600px; max-height: 600px;
white-space: pre-line;
} }
@-webkit-keyframes animatetop { @-webkit-keyframes animatetop {
from {top: -300px; opacity: 0} from {top: -300px; opacity: 0}

@ -46,8 +46,8 @@ export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispat
dispatch(setCompilerMode('loadingCompiler')) dispatch(setCompilerMode('loadingCompiler'))
}) })
compileTabLogic.compiler.event.register('compilerLoaded', () => { compileTabLogic.compiler.event.register('compilerLoaded', (version, license) => {
dispatch(setCompilerMode('compilerLoaded')) dispatch(setCompilerMode('compilerLoaded', version, license))
}) })
compileTabLogic.compiler.event.register('compilationFinished', (success, data, source, input, version) => { compileTabLogic.compiler.event.register('compilationFinished', (success, data, source, input, version) => {

@ -48,6 +48,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
timeout: 300, timeout: 300,
allversions: [], allversions: [],
customVersions: [], customVersions: [],
compilerLicense: null,
selectedVersion: null, selectedVersion: null,
defaultVersion: 'soljson-v0.8.7+commit.e28d00a7.js', // this default version is defined: in makeMockCompiler (for browser test) defaultVersion: 'soljson-v0.8.7+commit.e28d00a7.js', // this default version is defined: in makeMockCompiler (for browser test)
runs: '', runs: '',
@ -185,7 +186,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
loadingCompiler() loadingCompiler()
break break
case 'compilerLoaded': case 'compilerLoaded':
compilerLoaded() compilerLoaded(compilerContainer.compiler.args[1])
break break
case 'compilationFinished': case 'compilationFinished':
compilationFinished() compilationFinished()
@ -432,14 +433,20 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
if (!compileIcon.current) return if (!compileIcon.current) return
compileIcon.current.setAttribute('title', 'compiler is loading, please wait a few moments.') compileIcon.current.setAttribute('title', 'compiler is loading, please wait a few moments.')
compileIcon.current.classList.add('remixui_spinningIcon') compileIcon.current.classList.add('remixui_spinningIcon')
setState(prevState => {
return { ...prevState, compilerLicense: 'Compiler is loading. License will be displayed once compiler is loaded'}
})
_updateLanguageSelector() _updateLanguageSelector()
setDisableCompileButton(true) setDisableCompileButton(true)
} }
const compilerLoaded = () => { const compilerLoaded = (license) => {
if (!compileIcon.current) return if (!compileIcon.current) return
compileIcon.current.setAttribute('title', '') compileIcon.current.setAttribute('title', '')
compileIcon.current.classList.remove('remixui_spinningIcon') compileIcon.current.classList.remove('remixui_spinningIcon')
setState(prevState => {
return { ...prevState, compilerLicense: license ? license : 'Could not retreive license for selected compiler version' }
})
if (state.autoCompile) compile() if (state.autoCompile) compile()
const isDisabled = !compiledFileName || (compiledFileName && !isSolFileSelected(compiledFileName)) const isDisabled = !compiledFileName || (compiledFileName && !isSolFileSelected(compiledFileName))
@ -554,6 +561,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
modal('Add a custom compiler', promptMessage('URL'), 'OK', addCustomCompiler, 'Cancel', () => {}) modal('Add a custom compiler', promptMessage('URL'), 'OK', addCustomCompiler, 'Cancel', () => {})
} }
const showCompilerLicense = () => {
modal('Compiler License', state.compilerLicense ? state.compilerLicense : 'License not available', 'OK', () => {})
}
const promptMessage = (message) => { const promptMessage = (message) => {
return ( return (
<> <>
@ -701,10 +712,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<article> <article>
<div className='pt-0 remixui_compilerSection'> <div className='pt-0 remixui_compilerSection'>
<div className="mb-1"> <div className="mb-1">
<label className="remixui_compilerLabel form-check-label" htmlFor="versionSelector"> <label className="remixui_compilerLabel form-check-label" htmlFor="versionSelector">Compiler</label>
Compiler <span className="far fa-plus border-0 p-0 ml-3" onClick={() => promptCompiler()} title="Add a custom compiler with URL"></span>
<button className="far fa-plus btn-light border-0 p-0 mx-2 btn-sm" onClick={promptCompiler} title="Add a custom compiler with URL"></button> <span className="fa fa-file-text-o border-0 p-0 ml-2" onClick={() => showCompilerLicense()} title="See compiler license"></span>
</label>
<select value={ state.selectedVersion || state.defaultVersion } onChange={(e) => handleLoadVersion(e.target.value) } className="custom-select" id="versionSelector" disabled={state.allversions.length <= 0}> <select value={ state.selectedVersion || state.defaultVersion } onChange={(e) => handleLoadVersion(e.target.value) } className="custom-select" id="versionSelector" disabled={state.allversions.length <= 0}>
{ state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === state.defaultVersion ? 'selected' : ''}>{ state.defaultVersion }</option> } { state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === state.defaultVersion ? 'selected' : ''}>{ state.defaultVersion }</option> }
{ state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === 'builtin' ? 'selected' : ''}>builtin</option> } { state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === 'builtin' ? 'selected' : ''}>builtin</option> }

@ -164,7 +164,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
testTab.fileManager.events.on('currentFileChanged', async (file: string) => { testTab.fileManager.events.on('currentFileChanged', async (file: string) => {
await updateForNewCurrent(file) await updateForNewCurrent(file)
}) })
testTab.on('solidity', 'compilerLoaded', async (version: string) => { testTab.on('solidity', 'compilerLoaded', async (version: string, license: string) => {
const { currentVersion } = testTab.compileTab.getCurrentCompilerConfig() const { currentVersion } = testTab.compileTab.getCurrentCompilerConfig()
if (!semver.gt(truncateVersion(currentVersion), '0.4.12')) { if (!semver.gt(truncateVersion(currentVersion), '0.4.12')) {

@ -140,8 +140,8 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => {
setSlitherEnabled(false) setSlitherEnabled(false)
} }
}) })
// eslint-disable-next-line @typescript-eslint/no-unused-vars
props.analysisModule.on('solidity', 'compilerLoaded', async (version: string) => { props.analysisModule.on('solidity', 'compilerLoaded', async (version: string, license: string) => {
setDisableForRun(version) setDisableForRun(version)
}) })
return () => { } return () => { }

Loading…
Cancel
Save