Skip to content

Commit d17b720

Browse files
ci-botAniket-Engg
authored andcommitted
patch verification
(cherry picked from commit 4439975)
1 parent 43e0ebf commit d17b720

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity'
99

1010
export class ContractVerificationPluginClient extends PluginClient {
1111
public internalEvents: EventManager
12+
private _isActivated: boolean = false
1213

1314
constructor() {
1415
super()
@@ -19,9 +20,14 @@ export class ContractVerificationPluginClient extends PluginClient {
1920
}
2021

2122
onActivation(): void {
23+
this._isActivated = true
2224
this.internalEvents.emit('verification_activated')
2325
}
2426

27+
isActivated(): boolean {
28+
return this._isActivated
29+
}
30+
2531
async lookupAndSave(verifierId: string, chainId: string, contractAddress: string): Promise<LookupResponse> {
2632
const canonicalVerifierId = VERIFIERS.find((id) => id.toLowerCase() === verifierId.toLowerCase())
2733
if (!canonicalVerifierId) {

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const App = () => {
4141
const timer = useRef(null)
4242

4343
useEffect(() => {
44-
plugin.internalEvents.on('verification_activated', () => {
44+
const initializePlugin = () => {
4545
// @ts-ignore
4646
plugin.call('locale', 'currentLocale').then((locale: any) => {
4747
setLocale(locale)
@@ -51,6 +51,7 @@ const App = () => {
5151
plugin.on('locale', 'localeChanged', (locale: any) => {
5252
setLocale(locale)
5353
})
54+
5455
// Fetch compiler artefacts initially
5556
plugin.call('compilerArtefacts' as any, 'getAllCompilerAbstracts').then((obj: any) => {
5657
setCompilationOutput(obj)
@@ -60,7 +61,17 @@ const App = () => {
6061
plugin.on('compilerArtefacts' as any, 'compilationSaved', (compilerAbstracts: { [key: string]: CompilerAbstract }) => {
6162
setCompilationOutput((prev) => ({ ...(prev || {}), ...compilerAbstracts }))
6263
})
63-
})
64+
}
65+
66+
// Check if plugin is already activated
67+
if (plugin.isActivated()) {
68+
initializePlugin()
69+
} else {
70+
// Listen for activation event if not yet activated
71+
plugin.internalEvents.once('verification_activated', () => {
72+
initializePlugin()
73+
})
74+
}
6475

6576
// Fetch chains.json and update state
6677
fetch('https://chainid.network/chains.json')

0 commit comments

Comments
 (0)