@@ -3,6 +3,7 @@ import { CommonModule, isPlatformBrowser } from '@angular/common';
33import { FormsModule } from '@angular/forms' ;
44import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor' ;
55import { PLATFORM_ID , inject } from '@angular/core' ;
6+ import { CompilerService } from '../../services/compiler' ;
67
78
89const DEFAULT_RUST_CODE = `// Welcome to Soroban Smart Contract Editor
@@ -33,6 +34,7 @@ export class EditorComponent implements OnDestroy {
3334 private timeoutIds = new Set < number > ( ) ;
3435 isLoading = false ;
3536 isBrowser = isPlatformBrowser ( inject ( PLATFORM_ID ) ) ;
37+ private compilerService = inject ( CompilerService ) ;
3638
3739 // Validation and output properties
3840 errorMessage : string = '' ;
@@ -114,6 +116,21 @@ export class EditorComponent implements OnDestroy {
114116 this . outputType = 'info' ;
115117 console . log ( 'Compiling Rust smart contract code:' , this . code ) ;
116118
119+ this . compilerService . compile ( this . code ) . subscribe ( {
120+ next : ( response ) => {
121+ this . isLoading = false ;
122+ this . outputMessage = 'Compilation completed successfully!' ;
123+ this . outputType = 'success' ;
124+ console . log ( 'Compilation response:' , response ) ;
125+ } ,
126+ error : ( error ) => {
127+ this . isLoading = false ;
128+ this . errorMessage = 'Compilation failed: ' + ( error . message || error ) ;
129+ this . outputType = 'error' ;
130+ console . error ( 'Compilation error:' , error ) ;
131+ }
132+ } ) ;
133+
117134 // TODO: Implement API call to backend compiler
118135 const timeoutId = setTimeout ( ( ) => {
119136 this . isLoading = false ;
@@ -140,6 +157,21 @@ export class EditorComponent implements OnDestroy {
140157 this . outputType = 'info' ;
141158 console . log ( 'Testing Rust smart contract code:' , this . code ) ;
142159
160+ this . compilerService . test ( this . code ) . subscribe ( {
161+ next : ( response ) => {
162+ this . isLoading = false ;
163+ this . outputMessage = 'All tests passed successfully!' ;
164+ this . outputType = 'success' ;
165+ console . log ( 'Test response:' , response ) ;
166+ } ,
167+ error : ( error ) => {
168+ this . isLoading = false ;
169+ this . errorMessage = 'Tests failed: ' + ( error . message || error ) ;
170+ this . outputType = 'error' ;
171+ console . error ( 'Test error:' , error ) ;
172+ }
173+ } ) ;
174+
143175 // TODO: Implement API call to backend test runner
144176 const timeoutId = setTimeout ( ( ) => {
145177 this . isLoading = false ;
0 commit comments