@@ -21,7 +21,7 @@ export class CircomPluginClient extends PluginClient {
2121
2222 constructor ( ) {
2323 super ( )
24- this . methods = [ 'init' , 'parse' , 'compile' , 'generateR1cs' ]
24+ this . methods = [ 'init' , 'parse' , 'compile' , 'generateR1cs' , 'resolveDependencies' ]
2525 createClient ( this )
2626 this . internalEvents = new EventManager ( )
2727 this . onload ( )
@@ -123,14 +123,18 @@ export class CircomPluginClient extends PluginClient {
123123
124124 async compile ( path : string , compilationConfig ?: CompilationConfig ) : Promise < void > {
125125 this . internalEvents . emit ( 'circuit_compiling_start' )
126+ // @ts -ignore
127+ this . call ( 'terminal' , 'log' , { type : 'log' , value : 'Compiling ' + path } )
126128 const [ parseErrors , filePathToId ] = await this . parse ( path )
127129
128130 if ( parseErrors && ( parseErrors . length > 0 ) ) {
129131 if ( parseErrors [ 0 ] . type === 'Error' ) {
130132 this . internalEvents . emit ( 'circuit_parsing_errored' , parseErrors , filePathToId )
133+ this . logCompilerReport ( parseErrors )
131134 return
132135 } else if ( parseErrors [ 0 ] . type === 'Warning' ) {
133136 this . internalEvents . emit ( 'circuit_parsing_warning' , parseErrors , filePathToId )
137+ this . logCompilerReport ( parseErrors )
134138 }
135139 } else {
136140 this . internalEvents . emit ( 'circuit_parsing_done' , parseErrors , filePathToId )
@@ -147,6 +151,7 @@ export class CircomPluginClient extends PluginClient {
147151 if ( circuitProgram . length < 1 ) {
148152 const circuitErrors = circuitApi . report ( )
149153
154+ this . logCompilerReport ( circuitErrors )
150155 throw new Error ( circuitErrors )
151156 } else {
152157 this . lastCompiledFile = path
@@ -166,19 +171,28 @@ export class CircomPluginClient extends PluginClient {
166171 } else {
167172 this . internalEvents . emit ( 'circuit_compiling_done' , [ ] )
168173 }
174+ circuitApi . log ( ) . map ( log => {
175+ log && this . call ( 'terminal' , 'log' , { type : 'log' , value : log } )
176+ } )
177+ // @ts -ignore
178+ this . call ( 'terminal' , 'log' , { type : 'typewritersuccess' , value : 'Everything went okay, circom safe' } )
169179 }
170180 }
171181
172182 async generateR1cs ( path : string , compilationConfig ?: CompilationConfig ) : Promise < void > {
173183 this . internalEvents . emit ( 'circuit_generating_r1cs_start' )
184+ // @ts -ignore
185+ this . call ( 'terminal' , 'log' , { type : 'log' , value : 'Generating R1CS for ' + path } )
174186 const [ parseErrors , filePathToId ] = await this . parse ( path )
175187
176188 if ( parseErrors && ( parseErrors . length > 0 ) ) {
177189 if ( parseErrors [ 0 ] . type === 'Error' ) {
178190 this . internalEvents . emit ( 'circuit_parsing_errored' , parseErrors )
191+ this . logCompilerReport ( parseErrors )
179192 return
180193 } else if ( parseErrors [ 0 ] . type === 'Warning' ) {
181194 this . internalEvents . emit ( 'circuit_parsing_warning' , parseErrors )
195+ this . logCompilerReport ( parseErrors )
182196 }
183197 } else {
184198 this . internalEvents . emit ( 'circuit_parsing_done' , parseErrors , filePathToId )
@@ -195,6 +209,7 @@ export class CircomPluginClient extends PluginClient {
195209 if ( r1csProgram . length < 1 ) {
196210 const r1csErrors = r1csApi . report ( )
197211
212+ this . logCompilerReport ( r1csErrors )
198213 throw new Error ( r1csErrors )
199214 } else {
200215 this . internalEvents . emit ( 'circuit_generating_r1cs_done' )
@@ -203,6 +218,11 @@ export class CircomPluginClient extends PluginClient {
203218
204219 // @ts -ignore
205220 await this . call ( 'fileManager' , 'writeFile' , writePath , r1csProgram , true )
221+ r1csApi . log ( ) . map ( log => {
222+ log && this . call ( 'terminal' , 'log' , { type : 'log' , value : log } )
223+ } )
224+ // @ts -ignore
225+ this . call ( 'terminal' , 'log' , { type : 'typewritersuccess' , value : 'Everything went okay, circom safe' } )
206226 }
207227 }
208228
@@ -373,4 +393,10 @@ export class CircomPluginClient extends PluginClient {
373393 }
374394 }
375395 }
396+
397+ async logCompilerReport ( report : CompilerReport [ ] ) : Promise < void > {
398+ this . call ( 'terminal' , 'log' , { type : 'log' , value : JSON . stringify ( report , null , 2 ) } )
399+ if ( report [ 0 ] . type === 'Error' ) this . call ( 'terminal' , 'log' , { type : 'error' , value : 'previous errors were found' } )
400+ if ( report [ 0 ] . type === 'Warning' ) this . call ( 'terminal' , 'log' , { type : 'log' , value : 'previous warnings were found' } )
401+ }
376402}
0 commit comments