From 634f3b3e0d8aadcb770e64ff56977112d5650122 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Sat, 28 May 2022 11:04:27 +0200 Subject: [PATCH] rm save option --- .../src/lib/editor-context-listener.ts | 7 ++++++- libs/remix-solidity/src/compiler/compiler-input.ts | 4 ++-- .../remix-solidity/src/compiler/compiler-worker.ts | 14 +++++++------- libs/remix-solidity/src/compiler/compiler.ts | 1 + .../src/lib/compiler-container.tsx | 1 + .../src/lib/logic/compileTabLogic.ts | 9 +-------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/editor-context-listener.ts b/libs/remix-core-plugin/src/lib/editor-context-listener.ts index d9af0546ee..b4e1607e48 100644 --- a/libs/remix-core-plugin/src/lib/editor-context-listener.ts +++ b/libs/remix-core-plugin/src/lib/editor-context-listener.ts @@ -2,6 +2,7 @@ import { Plugin } from '@remixproject/engine' import { sourceMappingDecoder } from '@remix-project/remix-debug' import { CompilerAbstract } from '@remix-project/remix-solidity' +import { getValidLanguage, Compiler} from '@remix-project/remix-solidity' const profile = { name: 'contextualListener', @@ -41,6 +42,7 @@ export class EditorContextListener extends Plugin { lastCompilationResult: any lastAST: any + compiler: any constructor(astWalker) { super(profile) @@ -60,6 +62,9 @@ export class EditorContextListener extends Plugin { this._stopHighlighting() }) + this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url, undefined, false).then((result) => cb(null, result)).catch((error) => cb(error.message))) + this.compiler.loadVersion(true,'https://binaries.soliditylang.org/wasm/soljson-v0.8.7+commit.e28d00a7.js') + this.on('solidity', 'astFinished', async (file, source, languageVersion, data, input, version) => { // console.log('compilation result', Object.keys(data.sources)) if (languageVersion.indexOf('soljson') !== 0 || !data.sources) return @@ -76,7 +81,7 @@ export class EditorContextListener extends Plugin { }) setInterval(async () => { - await this.compile() + //await this.compile() }, 5000) diff --git a/libs/remix-solidity/src/compiler/compiler-input.ts b/libs/remix-solidity/src/compiler/compiler-input.ts index 92934e5649..0b214b5201 100644 --- a/libs/remix-solidity/src/compiler/compiler-input.ts +++ b/libs/remix-solidity/src/compiler/compiler-input.ts @@ -16,9 +16,9 @@ export default (sources: Source, opts: CompilerInputOptions): string => { outputSelection: { '*': { '': ['ast'], - '*': [] + //'*': [] //'*' : ['abi', 'metadata'] - // '*': ['abi', 'metadata', 'devdoc', 'userdoc', 'storageLayout', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates', 'evm.assembly'] + '*': ['abi', 'metadata', 'devdoc', 'userdoc', 'storageLayout', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates', 'evm.assembly'] } } } diff --git a/libs/remix-solidity/src/compiler/compiler-worker.ts b/libs/remix-solidity/src/compiler/compiler-worker.ts index db8bfc9000..ab86666ef0 100644 --- a/libs/remix-solidity/src/compiler/compiler-worker.ts +++ b/libs/remix-solidity/src/compiler/compiler-worker.ts @@ -44,13 +44,13 @@ export default function (self) { // eslint-disable-line @typescript-eslint/expli case 'compile': missingInputs.length = 0 if (data.input && compileJSON) { - self.postMessage({ - cmd: 'compiled', - job: data.job, - data: compileJSON(data.input), - input: data.input, - missingInputs: missingInputs - }) + self.postMessage({ + cmd: 'compiled', + job: data.job, + data: compileJSON(data.input), + input: data.input, + missingInputs: missingInputs + }) } break } diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index 97f307504d..8d4dc8b2f0 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -272,6 +272,7 @@ export class Compiler { const jobs: Record<'sources', SourceWithTarget> [] = [] this.state.worker.addEventListener('message', (msg: Record <'data', MessageFromWorker>) => { + console.log(msg) const data: MessageFromWorker = msg.data switch (data.cmd) { case 'versionLoaded': 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 d5d3ff9f5b..a8facf0761 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -478,6 +478,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { console.log('VERSION', selectedVersion) if (selectedVersion === 'builtin') selectedVersion = state.defaultVersion if (selectedVersion !== 'builtin' && canUseWorker(selectedVersion)) { + console.log('loading ' + url + ' with worker') compileTabLogic.compiler.loadVersion(true, url) } else { compileTabLogic.compiler.loadVersion(false, url) 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 203426b0da..e4c2565d48 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -99,8 +99,7 @@ export class CompileTabLogic { * Compile a specific file of the file manager * @param {string} target the path to the file to compile */ - compileFile (target: string, settings: any = {save: true}) { - console.log(settings) + compileFile (target: string) { if (!target) throw new Error('No target provided for compiliation') return new Promise((resolve, reject) => { this.api.readFile(target).then((content) => { @@ -110,12 +109,6 @@ export class CompileTabLogic { this.api.readFile(this.configFilePath).then( contentConfig => { this.compiler.set('configFileContent', contentConfig) }) - if(settings.save) { - this.compiler.handleImportCall = (url, cb) => this.api.resolveContentAndSave(url).then((result) => cb(null, result)).catch((error) => cb(error.message)) - }else{ - this.compiler.handleImportCall = (url, cb) => this.api.resolveContent(url).then((result) => cb(null, result)).catch((error) => cb(error.message)) - } - console.log(this.compiler) // setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation') setTimeout(() => { this.compiler.compile(sources, target); resolve(true) }, 100) }).catch((error) => {