@@ -13,7 +13,7 @@ export class ContractVerificationPluginClient extends PluginClient {
1313
1414 constructor ( ) {
1515 super ( )
16- this . methods = [ 'lookupAndSave' , 'verifyOnDeploy' ]
16+ this . methods = [ 'lookupAndSave' , 'verifyOnDeploy' , 'isVerificationSupportedForChain' ]
1717 this . internalEvents = new EventManager ( )
1818 createClient ( this )
1919 this . onload ( )
@@ -126,24 +126,15 @@ export class ContractVerificationPluginClient extends PluginClient {
126126 const chainSettings = mergeChainSettingsWithDefaults ( chainId , userSettings )
127127
128128 const verificationPromises = [ ]
129+ const verifiers : VerifierIdentifier [ ] = [ 'Sourcify' , 'Etherscan' , 'Blockscout' , 'Routescan' ]
129130
130- if ( validConfiguration ( chainSettings , 'Sourcify' ) ) {
131- verificationPromises . push ( this . _verifyWithProvider ( 'Sourcify' , submittedContract , compilerAbstract , chainId , chainSettings ) )
132- }
133-
134- if ( currentChain . explorers && currentChain . explorers . some ( explorer => explorer . name . toLowerCase ( ) . includes ( 'routescan' ) ) ) {
135- verificationPromises . push ( this . _verifyWithProvider ( 'Routescan' , submittedContract , compilerAbstract , chainId , chainSettings ) )
136- }
137-
138- if ( currentChain . explorers && currentChain . explorers . some ( explorer => explorer . url . includes ( 'blockscout' ) ) ) {
139- verificationPromises . push ( this . _verifyWithProvider ( 'Blockscout' , submittedContract , compilerAbstract , chainId , chainSettings ) )
140- }
141-
142- if ( currentChain . explorers && currentChain . explorers . some ( explorer => explorer . name . includes ( 'etherscan' ) ) ) {
143- if ( etherscanApiKey ) {
144- verificationPromises . push ( this . _verifyWithProvider ( 'Etherscan' , submittedContract , compilerAbstract , chainId , chainSettings ) )
145- } else {
146- await this . call ( 'terminal' , 'log' , { type : 'warn' , value : 'Etherscan verification skipped: API key not found in global Settings.' } )
131+ for ( const verifier of verifiers ) {
132+ if ( validConfiguration ( chainSettings , verifier ) ) {
133+ if ( verifier === 'Etherscan' && ! etherscanApiKey ) {
134+ this . call ( 'terminal' , 'log' , { type : 'warn' , value : 'Etherscan verification skipped: API key not provided for auto-verification.' } )
135+ continue
136+ }
137+ verificationPromises . push ( this . _verifyWithProvider ( verifier , submittedContract , compilerAbstract , chainId , chainSettings ) )
147138 }
148139 }
149140
@@ -158,6 +149,23 @@ export class ContractVerificationPluginClient extends PluginClient {
158149 }
159150 }
160151
152+ async isVerificationSupportedForChain ( chainId : string ) : Promise < boolean > {
153+ try {
154+ const userSettings = this . getUserSettingsFromLocalStorage ( )
155+ const chainSettings = mergeChainSettingsWithDefaults ( chainId , userSettings )
156+
157+ for ( const verifierId of VERIFIERS ) {
158+ if ( validConfiguration ( chainSettings , verifierId as VerifierIdentifier ) ) {
159+ return true
160+ }
161+ }
162+ return false
163+ } catch ( e ) {
164+ console . error ( e )
165+ return false
166+ }
167+ }
168+
161169 private _verifyWithProvider = async (
162170 providerName : VerifierIdentifier ,
163171 submittedContract : SubmittedContract ,
0 commit comments