diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-10 04:23:25 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-12 18:52:48 +0800 |
commit | eb89926cee2c50ef657b3c033b5637f527d73c6a (patch) | |
tree | 6a4ece7902c860bfa48ac53033baf86ba25683d0 /packages/sol-cov/src | |
parent | 7923ff4ac6d03adf3787a2a3e6f7deb6aa38fc73 (diff) | |
download | dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.tar dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.tar.gz dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.tar.bz2 dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.tar.lz dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.tar.xz dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.tar.zst dexon-sol-tools-eb89926cee2c50ef657b3c033b5637f527d73c6a.zip |
Implement the resolver
Diffstat (limited to 'packages/sol-cov/src')
-rw-r--r-- | packages/sol-cov/src/collect_contract_data.ts | 22 | ||||
-rw-r--r-- | packages/sol-cov/src/types.ts | 1 |
2 files changed, 6 insertions, 17 deletions
diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts index e4a13695a..da56e8d0d 100644 --- a/packages/sol-cov/src/collect_contract_data.ts +++ b/packages/sol-cov/src/collect_contract_data.ts @@ -6,27 +6,17 @@ import * as path from 'path'; import { ContractData } from './types'; export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => { - const sourcesGlob = `${sourcesPath}/**/*.sol`; - const sourceFileNames = glob.sync(sourcesGlob, { absolute: true }); - const contractsDataIfExists: Array<ContractData | {}> = _.map(sourceFileNames, sourceFileName => { - const baseName = path.basename(sourceFileName, '.sol'); - const artifactFileName = path.join(artifactsPath, `${baseName}.json`); - if (!fs.existsSync(artifactFileName)) { - // If the contract isn't directly compiled, but is imported as the part of the other contract - we don't - // have an artifact for it and therefore can't do anything useful with it - return {}; - } + const artifactsGlob = `${artifactsPath}/**/*.json`; + const artifactFileNames = glob.sync(artifactsGlob, { absolute: true }); + const contractsDataIfExists: Array<ContractData | {}> = _.map(artifactFileNames, artifactFileName => { const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString()); const sources = artifact.networks[networkId].sources; - const sourceCodes = _.map(sources, (source: string) => { - const includedSourceCode = fs.readFileSync(source).toString(); - return includedSourceCode; - }); + const contractName = artifact.contract_name; + const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); if (_.isUndefined(artifact.networks[networkId])) { - throw new Error(`No ${baseName} artifacts found for networkId ${networkId}`); + throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`); } const contractData = { - baseName, sourceCodes, sources, sourceMap: artifact.networks[networkId].source_map, diff --git a/packages/sol-cov/src/types.ts b/packages/sol-cov/src/types.ts index d6491100b..01359d858 100644 --- a/packages/sol-cov/src/types.ts +++ b/packages/sol-cov/src/types.ts @@ -79,7 +79,6 @@ export interface ContractData { runtimeBytecode: string; sourceMapRuntime: string; sourceCodes: string[]; - baseName: string; sources: string[]; } |