fix using external URL

pull/694/head
yann300 4 years ago
parent 00d55c7c80
commit a7465b5623
  1. 4
      apps/remix-ide/src/app/compiler/compiler-helpers.js
  2. 17
      apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.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)

@ -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) {

Loading…
Cancel
Save