@ -33,55 +33,32 @@ const App = () => {
const sourcifyVerifier = new SourcifyVerifier ( 'http://localhost:5555/' , 'Sourcify Localhost' )
setSourcifyVerifiers ( [ sourcifyVerifier ] )
// TODO: Fix 'compilationFinished' event types. The interface is outdated at https://github.com/ethereum/remix-plugin/blob/master/packages/api/src/lib/compiler/api.ts. It does not include data, input, or version. See the current parameters: https://github.com/ethereum/remix-project/blob/9f6c5be882453a555055f07171701459e4ae88a4/libs/remix-solidity/src/compiler/compiler.ts#L189
// Because of this reason we use @ts-expect-error for the next line
// // @ts-expect-error:next-line
// plugin.on('solidity', 'compilationFinished', (fileName: string, source: CompilationFileSources, languageVersion: string, data: CompilationResult, input: string, version: string) => {
// console.log('Compilation output')
// console.log(data)
// console.log('File Name:', fileName)
// console.log('Source:', source)
// console.log('Language Version:', languageVersion)
// console.log('Compilation Result:', data)
// // console.log('Input:', input)
// console.log('Compiler Version:', version)
// console.log('contractNames')
// console.log(Object.keys(data.contracts[fileName]))
// setTargetFileName(fileName)
// setCompilationOutput(data)
// })
// plugin.call('compilerArtefacts', 'getAllContractDatas').then((allContractDatas: any) => {
// console.log('compilerArtefacts.getAllContractDatas')
// console.log(allContractDatas)
// const files = Object.keys(allContractDatas)
// files.forEach((file) => {
// //
// plugin.call('compilerArtefacts' as any, 'getCompilerAbstract', file).then((data: any) => {
// console.log('compilerArtefacts.getCompilerAbstract ' + file)
// console.log(data)
// })
// })
// })
// // TODO: why "as any" needed here
// plugin.call('compilerArtefacts' as any, 'getLastCompilationResult').then((data: any) => {
// console.log('compilerArtefacts.getLastCompilationResult')
// console.log(data)
// })
// Fetch compiler artefacts initially
plugin . call ( 'compilerArtefacts' as any , 'getAllCompilerAbstracts' ) . then ( ( obj : any ) = > {
console . log ( 'compilerArtefacts.getAllCompilerAbstracts' )
console . log ( obj )
setCompilationOutput ( obj )
} )
// Subscribe to compilations
plugin . on ( 'compilerArtefacts' as any , 'compilationSaved' , ( compilerAbstract : { [ key : string ] : CompilerAbstract } ) = > {
console . log ( 'compilerArtefacts.compilationSaved' )
console . log ( compilerAbstract )
setCompilationOutput ( ( prev ) = > ( { . . . ( prev || { } ) , . . . compilerAbstract } ) )
} )
// TODO: Is there a way to get all compilations from the `build-info` files without having to compile again?
// Fetch chains.json and update state
fetch ( 'https://chainid.network/chains.json' )
. then ( ( response ) = > response . json ( ) )
. then ( ( data ) = > setChains ( data ) )
. catch ( ( error ) = > console . error ( 'Failed to fetch chains.json:' , error ) )
// Clean up on unmount
return ( ) = > {
plugin . off ( 'solidity' , 'compilationFinished' ) // Clean up on unmount
plugin . off ( 'compilerArtefacts' as any , 'compilationSaved' )
}
} , [ ] )