Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity'

export class ContractVerificationPluginClient extends PluginClient {
public internalEvents: EventManager
private _isActivated: boolean = false

constructor() {
super()
Expand All @@ -19,9 +20,14 @@ export class ContractVerificationPluginClient extends PluginClient {
}

onActivation(): void {
this._isActivated = true
this.internalEvents.emit('verification_activated')
}

isActivated(): boolean {
return this._isActivated
}

async lookupAndSave(verifierId: string, chainId: string, contractAddress: string): Promise<LookupResponse> {
const canonicalVerifierId = VERIFIERS.find((id) => id.toLowerCase() === verifierId.toLowerCase())
if (!canonicalVerifierId) {
Expand Down
15 changes: 13 additions & 2 deletions apps/contract-verification/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const App = () => {
const timer = useRef(null)

useEffect(() => {
plugin.internalEvents.on('verification_activated', () => {
const initializePlugin = () => {
// @ts-ignore
plugin.call('locale', 'currentLocale').then((locale: any) => {
setLocale(locale)
Expand All @@ -51,6 +51,7 @@ const App = () => {
plugin.on('locale', 'localeChanged', (locale: any) => {
setLocale(locale)
})

// Fetch compiler artefacts initially
plugin.call('compilerArtefacts' as any, 'getAllCompilerAbstracts').then((obj: any) => {
setCompilationOutput(obj)
Expand All @@ -60,7 +61,17 @@ const App = () => {
plugin.on('compilerArtefacts' as any, 'compilationSaved', (compilerAbstracts: { [key: string]: CompilerAbstract }) => {
setCompilationOutput((prev) => ({ ...(prev || {}), ...compilerAbstracts }))
})
})
}

// Check if plugin is already activated
if (plugin.isActivated()) {
initializePlugin()
} else {
// Listen for activation event if not yet activated
plugin.internalEvents.once('verification_activated', () => {
initializePlugin()
})
}

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