|
|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
|
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
import { compile } from '@remix-project/remix-solidity' |
|
|
|
import { compile } from '@remix-project/remix-solidity' |
|
|
|
import { util } from '@remix-project/remix-lib' |
|
|
|
import { util } from '@remix-project/remix-lib' |
|
|
@ -8,7 +7,7 @@ import { fetchContractFromSourcify } from './helpers/fetch-sourcify' |
|
|
|
|
|
|
|
|
|
|
|
const profile = { |
|
|
|
const profile = { |
|
|
|
name: 'fetchAndCompile', |
|
|
|
name: 'fetchAndCompile', |
|
|
|
methods: ['resolve'], |
|
|
|
methods: ['resolve', 'clearCache'], |
|
|
|
version: '0.0.1' |
|
|
|
version: '0.0.1' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -21,6 +20,14 @@ export class FetchAndCompile extends Plugin { |
|
|
|
this.sourceVerifierNetWork = ['Main', 'Rinkeby', 'Ropsten', 'Goerli'] |
|
|
|
this.sourceVerifierNetWork = ['Main', 'Rinkeby', 'Ropsten', 'Goerli'] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Clear the cache |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
async clearCache () { |
|
|
|
|
|
|
|
this.unresolvedAddresses = [] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Fetch compiliation metadata from source-Verify from a given @arg contractAddress - https://github.com/ethereum/source-verify
|
|
|
|
* Fetch compiliation metadata from source-Verify from a given @arg contractAddress - https://github.com/ethereum/source-verify
|
|
|
|
* Put the artifacts in the file explorer |
|
|
|
* Put the artifacts in the file explorer |
|
|
@ -68,6 +75,7 @@ export class FetchAndCompile extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
targetPath = `${targetPath}/${network.id}/${contractAddress}` |
|
|
|
let data |
|
|
|
let data |
|
|
|
try { |
|
|
|
try { |
|
|
|
data = await fetchContractFromSourcify(this, network, contractAddress, targetPath) |
|
|
|
data = await fetchContractFromSourcify(this, network, contractAddress, targetPath) |
|
|
@ -100,7 +108,15 @@ export class FetchAndCompile extends Plugin { |
|
|
|
const compData = await compile( |
|
|
|
const compData = await compile( |
|
|
|
compilationTargets, |
|
|
|
compilationTargets, |
|
|
|
settings, |
|
|
|
settings, |
|
|
|
async (url, cb) => await this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) |
|
|
|
async (url, cb) => { |
|
|
|
|
|
|
|
// we first try to resolve the content from the compilation target using a more appropiate path
|
|
|
|
|
|
|
|
const path = `${targetPath}/${url}` |
|
|
|
|
|
|
|
if (compilationTargets[path] && compilationTargets[path].content) { |
|
|
|
|
|
|
|
return cb(null, compilationTargets[path].content) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
await this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compData) |
|
|
|
await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compData) |
|
|
|
return compData |
|
|
|
return compData |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|