@@ -61,23 +61,22 @@ export class TruffleClient extends PluginClient {
6161 }
6262
6363 private async processArtifact ( ) {
64- const folderFiles = await fs . readdir ( this . buildPath )
64+ const folderFiles = await fs . readdir ( this . buildPath )
65+ const compilationResult = {
66+ input : { } ,
67+ output : {
68+ contracts : { } ,
69+ sources : { }
70+ } ,
71+ solcVersion : null ,
72+ compilationTarget : null
73+ }
6574 // name of folders are file names
6675 for ( const file of folderFiles ) {
6776 if ( file . endsWith ( '.json' ) ) {
68- const compilationResult = {
69- input : { } ,
70- output : {
71- contracts : { } ,
72- sources : { }
73- } ,
74- solcVersion : null ,
75- compilationTarget : null
76- }
7777 const content = await fs . readFile ( join ( this . buildPath , file ) , { encoding : 'utf-8' } )
7878 await this . feedContractArtifactFile ( file , content , compilationResult )
7979 this . emit ( 'compilationFinished' , compilationResult . compilationTarget , { sources : compilationResult . input } , 'soljson' , compilationResult . output , compilationResult . solcVersion )
80-
8180 }
8281 }
8382 if ( ! this . warnLog ) {
@@ -104,10 +103,12 @@ export class TruffleClient extends PluginClient {
104103 const contentJSON = JSON . parse ( content )
105104 const contractName = basename ( path ) . replace ( '.json' , '' )
106105 compilationResultPart . solcVersion = contentJSON . compiler . version
107- compilationResultPart . compilationTarget = contentJSON . ast . absolutePath
106+ // file name in artifacts starts with `project:/`
107+ const filepath = contentJSON . ast . absolutePath . startsWith ( 'project:/' ) ? contentJSON . ast . absolutePath . replace ( 'project:/' , '' ) : contentJSON . ast . absolutePath
108+ compilationResultPart . compilationTarget = filepath
108109 compilationResultPart . input [ path ] = { content : contentJSON . source }
109110 // extract data
110- const relPath = utils . relativePath ( contentJSON . ast . absolutePath , this . currentSharedFolder )
111+ const relPath = utils . relativePath ( filepath , this . currentSharedFolder )
111112 if ( ! compilationResultPart . output [ 'sources' ] [ relPath ] ) compilationResultPart . output [ 'sources' ] [ relPath ] = { }
112113
113114 const location = contentJSON . ast . src . split ( ':' )
0 commit comments