diff --git a/apps/remix-ide/src/app/compiler/compiler-helpers.js b/apps/remix-ide/src/app/compiler/compiler-helpers.js index d1f8399607..e8af5f465a 100644 --- a/apps/remix-ide/src/app/compiler/compiler-helpers.js +++ b/apps/remix-ide/src/app/compiler/compiler-helpers.js @@ -3,10 +3,10 @@ import { canUseWorker, urlFromVersion } from './compiler-utils' import { Compiler } from '@remix-project/remix-solidity' import CompilerAbstract from './compiler-abstract' -export const compile = async (compilationTargets, settings) => { +export const compile = async (compilationTargets, settings, contentResolverCallback) => { const res = await (() => { return new Promise((resolve, reject) => { - const compiler = new Compiler(() => {}) + const compiler = new Compiler(contentResolverCallback || (() => {})) compiler.set('evmVersion', settings.evmVersion) compiler.set('optimize', settings.optimize) compiler.set('language', settings.language) diff --git a/apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js b/apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js index 60b8cacc78..94eb4fcaf0 100644 --- a/apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js +++ b/apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js @@ -92,10 +92,14 @@ export default class FetchAndCompile extends Plugin { if (url.includes('ipfs')) { const stdUrl = `ipfs://${url.split('/')[2]}` const source = await this.call('contentImport', 'resolve', stdUrl) - file = file.replace('browser/', '') // should be fixed in the remix IDE end. - const path = `${targetPath}/${name}/${contractAddress}/${file}` - await this.call('fileManager', 'setFile', path, source.content) - compilationTargets[path] = { content: source.content } + if (await this.call('contentImport', 'isExternalUrl', file)) { + // nothing to do, the compiler callback will handle those + } else { + file = file.replace('browser/', '') // should be fixed in the remix IDE end. + const path = `${targetPath}/${name}/${contractAddress}/${file}` + await this.call('fileManager', 'setFile', path, source.content) + compilationTargets[path] = { content: source.content } + } break } } @@ -111,7 +115,10 @@ export default class FetchAndCompile extends Plugin { } try { setTimeout(_ => this.emit('compiling', settings), 0) - const compData = await compile(compilationTargets, settings) + const compData = await compile( + compilationTargets, + settings, + (url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) compilersartefacts.addResolvedContract(contractAddress, compData) return compData } catch (e) {