diff --git a/apps/solidity-compiler/src/app/compiler-api.ts b/apps/solidity-compiler/src/app/compiler-api.ts index 74eec1d57f..f7eb97442c 100644 --- a/apps/solidity-compiler/src/app/compiler-api.ts +++ b/apps/solidity-compiler/src/app/compiler-api.ts @@ -222,10 +222,10 @@ export const CompilerApiMixin = (Base) => class extends Base { } 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.statusChanged({ key: 'none' }) - this.emit('compilerLoaded', version) + this.emit('compilerLoaded', version, license) } this.compiler.event.register('compilerLoaded', this.data.eventHandlers.onCompilerLoaded) diff --git a/libs/remix-solidity/src/compiler/compiler-worker.ts b/libs/remix-solidity/src/compiler/compiler-worker.ts index 662a03ec06..313d1b0119 100644 --- a/libs/remix-solidity/src/compiler/compiler-worker.ts +++ b/libs/remix-solidity/src/compiler/compiler-worker.ts @@ -33,7 +33,8 @@ export default function (self) { // eslint-disable-line @typescript-eslint/expli } self.postMessage({ cmd: 'versionLoaded', - data: compiler.version() + data: compiler.version(), + license: compiler.license() }) break } diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index f728748a9e..20aa8880a2 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -25,6 +25,7 @@ export class Compiler { compileJSON: null, worker: null, currentVersion: null, + compilerLicense: null, optimize: false, runs: 200, evmVersion: null, @@ -94,9 +95,10 @@ export class Compiler { * @param version compiler version */ - onCompilerLoaded (version: string): void { + onCompilerLoaded (version: string, license: string): void { 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.onCompilerLoaded(compiler.version()) + this.onCompilerLoaded(compiler.version(), compiler.license()) } } @@ -184,6 +186,7 @@ export class Compiler { if (err) { console.error('Error in loading remote solc compiler: ', err) } else { + let license this.state.compileJSON = (source: SourceWithTarget) => { const missingInputs: string[] = [] const missingInputsCallback = (path: string) => { @@ -203,13 +206,14 @@ export class Compiler { } result = JSON.parse(remoteCompiler.compile(input, { import: missingInputsCallback })) + license = remoteCompiler.license() } } catch (exception) { result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } } } 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 switch (data.cmd) { case 'versionLoaded': - if (data.data) this.onCompilerLoaded(data.data) + if (data.data && data.license) this.onCompilerLoaded(data.data, data.license) break case 'compiled': { diff --git a/libs/remix-solidity/src/compiler/types.ts b/libs/remix-solidity/src/compiler/types.ts index c4e48dd2ff..9f3cfb4b54 100644 --- a/libs/remix-solidity/src/compiler/types.ts +++ b/libs/remix-solidity/src/compiler/types.ts @@ -158,6 +158,7 @@ export interface CompilerState { compileJSON: ((input: SourceWithTarget) => void) | null, worker: any, currentVersion: string| null| undefined, + compilerLicense: string| null optimize: boolean, runs: number evmVersion: EVMVersion| null, @@ -186,6 +187,7 @@ export interface MessageToWorker { export interface MessageFromWorker { cmd: string, + license?: string, job?: number, missingInputs?: string[], input?: any, diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index b399f7376e..7fedf9c830 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -134,7 +134,7 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts if (runs) compiler.set('runs', runs) if (currentCompilerUrl) { compiler.loadRemoteVersion(currentCompilerUrl) - compiler.event.register('compilerLoaded', this, function (version) { + compiler.event.register('compilerLoaded', this, function (version, license) { next() }) } else { @@ -198,7 +198,7 @@ export function compileContractSources (sources: SrcIfc, newCompConfig: any, imp compiler.set('runs', runs) compiler.loadVersion(usingWorker, currentCompilerUrl) // @ts-ignore - compiler.event.register('compilerLoaded', this, (version) => { + compiler.event.register('compilerLoaded', this, (version, license) => { next() }) } else { 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 c67aee6ddb..b1c0b686de 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -46,8 +46,8 @@ export const listenToEvents = (compileTabLogic: CompileTabLogic, api) => (dispat dispatch(setCompilerMode('loadingCompiler')) }) - compileTabLogic.compiler.event.register('compilerLoaded', () => { - dispatch(setCompilerMode('compilerLoaded')) + compileTabLogic.compiler.event.register('compilerLoaded', (version, license) => { + dispatch(setCompilerMode('compilerLoaded', version, license)) }) compileTabLogic.compiler.event.register('compilationFinished', (success, data, source, input, version) => { 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 069377d045..001e446f54 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -185,7 +185,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { loadingCompiler() break case 'compilerLoaded': - compilerLoaded() + compilerLoaded(compilerContainer.compiler.args[1]) break case 'compilationFinished': compilationFinished() @@ -436,7 +436,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => { setDisableCompileButton(true) } - const compilerLoaded = () => { + const compilerLoaded = (license) => { + console.log('inside compilerLoaded----->', license) if (!compileIcon.current) return compileIcon.current.setAttribute('title', '') compileIcon.current.classList.remove('remixui_spinningIcon') diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index e580a9448b..947eae4dac 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -164,7 +164,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d testTab.fileManager.events.on('currentFileChanged', async (file: string) => { await updateForNewCurrent(file) }) - testTab.on('solidity', 'compilerLoaded', async (version: string) => { + testTab.on('solidity', 'compilerLoaded', async (version: string, license: string) => { const { currentVersion } = testTab.compileTab.getCurrentCompilerConfig() if (!semver.gt(truncateVersion(currentVersion), '0.4.12')) { 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 5e143dec1f..2afc377d15 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 @@ -141,7 +141,7 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { } }) - props.analysisModule.on('solidity', 'compilerLoaded', async (version: string) => { + props.analysisModule.on('solidity', 'compilerLoaded', async (version: string, license: string) => { setDisableForRun(version) }) return () => { }