diff options
Diffstat (limited to 'packages/sol-tracing-utils/src/artifact_adapters')
-rw-r--r-- | packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts index 57391abbe..d52587f2c 100644 --- a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts +++ b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts @@ -5,7 +5,7 @@ import * as glob from 'glob'; import * as _ from 'lodash'; import * as path from 'path'; -import { ContractData } from '../types'; +import { ContractData, SourceCodes, Sources } from '../types'; import { AbstractArtifactAdapter } from './abstract_artifact_adapter'; @@ -43,9 +43,14 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { logUtils.warn(`${artifactFileName} doesn't contain bytecode. Skipping...`); continue; } - let sources = _.keys(artifact.sources); - sources = _.map(sources, relativeFilePath => path.resolve(this._sourcesPath, relativeFilePath)); - const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); + const sources: Sources = {}; + const sourceCodes: SourceCodes = {}; + _.map(artifact.sources, (value: { id: number }, relativeFilePath: string) => { + const filePath = path.resolve(this._sourcesPath, relativeFilePath); + const fileContent = fs.readFileSync(filePath).toString(); + sources[value.id] = filePath; + sourceCodes[value.id] = fileContent; + }); const contractData = { sourceCodes, sources, |