@@ -12,7 +12,7 @@ export class ContractVerificationPluginClient extends PluginClient {
1212
1313 constructor ( ) {
1414 super ( )
15- this . methods = [ 'lookupAndSave' , 'verifyOnDeploy' ]
15+ this . methods = [ 'lookupAndSave' , 'verifyOnDeploy' , 'isVerificationSupportedForChain' ]
1616 this . internalEvents = new EventManager ( )
1717 createClient ( this )
1818 this . onload ( )
@@ -120,24 +120,15 @@ export class ContractVerificationPluginClient extends PluginClient {
120120 const chainSettings = mergeChainSettingsWithDefaults ( chainId , userSettings )
121121
122122 const verificationPromises = [ ]
123+ const verifiers : VerifierIdentifier [ ] = [ 'Sourcify' , 'Etherscan' , 'Blockscout' , 'Routescan' ]
123124
124- if ( validConfiguration ( chainSettings , 'Sourcify' ) ) {
125- verificationPromises . push ( this . _verifyWithProvider ( 'Sourcify' , submittedContract , compilerAbstract , chainId , chainSettings ) )
126- }
127-
128- if ( currentChain . explorers && currentChain . explorers . some ( explorer => explorer . name . toLowerCase ( ) . includes ( 'routescan' ) ) ) {
129- verificationPromises . push ( this . _verifyWithProvider ( 'Routescan' , submittedContract , compilerAbstract , chainId , chainSettings ) )
130- }
131-
132- if ( currentChain . explorers && currentChain . explorers . some ( explorer => explorer . url . includes ( 'blockscout' ) ) ) {
133- verificationPromises . push ( this . _verifyWithProvider ( 'Blockscout' , submittedContract , compilerAbstract , chainId , chainSettings ) )
134- }
135-
136- if ( currentChain . explorers && currentChain . explorers . some ( explorer => explorer . name . includes ( 'etherscan' ) ) ) {
137- if ( etherscanApiKey ) {
138- verificationPromises . push ( this . _verifyWithProvider ( 'Etherscan' , submittedContract , compilerAbstract , chainId , chainSettings ) )
139- } else {
140- await this . call ( 'terminal' , 'log' , { type : 'warn' , value : 'Etherscan verification skipped: API key not found in global Settings.' } )
125+ for ( const verifier of verifiers ) {
126+ if ( validConfiguration ( chainSettings , verifier ) ) {
127+ if ( verifier === 'Etherscan' && ! etherscanApiKey ) {
128+ this . call ( 'terminal' , 'log' , { type : 'warn' , value : 'Etherscan verification skipped: API key not provided for auto-verification.' } )
129+ continue
130+ }
131+ verificationPromises . push ( this . _verifyWithProvider ( verifier , submittedContract , compilerAbstract , chainId , chainSettings ) )
141132 }
142133 }
143134
@@ -152,6 +143,23 @@ export class ContractVerificationPluginClient extends PluginClient {
152143 }
153144 }
154145
146+ async isVerificationSupportedForChain ( chainId : string ) : Promise < boolean > {
147+ try {
148+ const userSettings = this . getUserSettingsFromLocalStorage ( )
149+ const chainSettings = mergeChainSettingsWithDefaults ( chainId , userSettings )
150+
151+ for ( const verifierId of VERIFIERS ) {
152+ if ( validConfiguration ( chainSettings , verifierId as VerifierIdentifier ) ) {
153+ return true
154+ }
155+ }
156+ return false
157+ } catch ( e ) {
158+ console . error ( e )
159+ return false
160+ }
161+ }
162+
155163 private _verifyWithProvider = async (
156164 providerName : VerifierIdentifier ,
157165 submittedContract : SubmittedContract ,
0 commit comments