Skip to content

Commit 24fdbc1

Browse files
committed
Add verification_activated event
1 parent 0ff7f42 commit 24fdbc1

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

apps/contract-verification/src/app/ContractVerificationPluginClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ export class ContractVerificationPluginClient extends PluginClient {
1111
createClient(this)
1212
this.onload()
1313
}
14+
15+
onActivation(): void {
16+
this.internalEvents.emit('verification_activated')
17+
}
1418
}

apps/contract-verification/src/app/app.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@ const App = () => {
3636
const timer = useRef(null)
3737

3838
useEffect(() => {
39-
// Fetch compiler artefacts initially
40-
plugin.call('compilerArtefacts' as any, 'getAllCompilerAbstracts').then((obj: any) => {
41-
setCompilationOutput(obj)
39+
plugin.internalEvents.on('verification_activated', () => {
40+
// Fetch compiler artefacts initially
41+
plugin.call('compilerArtefacts' as any, 'getAllCompilerAbstracts').then((obj: any) => {
42+
setCompilationOutput(obj)
43+
})
44+
45+
// Subscribe to compilations
46+
plugin.on('compilerArtefacts' as any, 'compilationSaved', (compilerAbstracts: { [key: string]: CompilerAbstract }) => {
47+
setCompilationOutput((prev) => ({ ...(prev || {}), ...compilerAbstracts }))
48+
})
49+
50+
// Fetch chains.json and update state
51+
fetch('https://chainid.network/chains.json')
52+
.then((response) => response.json())
53+
.then((data) => setChains(data))
54+
.catch((error) => console.error('Failed to fetch chains.json:', error))
4255
})
4356

44-
// Subscribe to compilations
45-
plugin.on('compilerArtefacts' as any, 'compilationSaved', (compilerAbstracts: { [key: string]: CompilerAbstract }) => {
46-
setCompilationOutput((prev) => ({ ...(prev || {}), ...compilerAbstracts }))
47-
})
48-
49-
// TODO: Is there a way to get all compilations from the `build-info` files without having to compile again?
50-
51-
// Fetch chains.json and update state
52-
fetch('https://chainid.network/chains.json')
53-
.then((response) => response.json())
54-
.then((data) => setChains(data))
55-
.catch((error) => console.error('Failed to fetch chains.json:', error))
56-
5757
// Clean up on unmount
5858
return () => {
5959
plugin.off('compilerArtefacts' as any, 'compilationSaved')

0 commit comments

Comments
 (0)