@@ -44,7 +44,7 @@ export async function verify(packageRef: string, cliSettings: CliSettings, chain
4444 getMainLoader ( cliSettings )
4545 ) ;
4646
47- const etherscanApi = cliSettings . etherscanApiUrl || getChainById ( chainId ) ?. blockExplorers ?. default . apiUrl ;
47+ const etherscanApi = cliSettings . etherscanApiUrl || 'https://api.etherscan.io/api' ;
4848
4949 if ( ! etherscanApi ) {
5050 throw new Error (
@@ -60,6 +60,8 @@ export async function verify(packageRef: string, cliSettings: CliSettings, chain
6060
6161 const guids : { [ c : string ] : string } = { } ;
6262
63+ const verifiedAddresses = new Set < string > ( ) ;
64+
6365 const verifyPackage = async ( deployData : DeploymentInfo ) => {
6466 const miscData = await runtime . readBlob ( deployData . miscUrl ) ;
6567
@@ -74,6 +76,13 @@ export async function verify(packageRef: string, cliSettings: CliSettings, chain
7476 for ( const c in outputs . contracts ) {
7577 const contractInfo = outputs . contracts [ c ] ;
7678
79+ // simple safeguard to ensure we dont keep trying to verify the same contract multiple times
80+ if ( verifiedAddresses . has ( contractInfo . address ) ) {
81+ continue ;
82+ } else {
83+ verifiedAddresses . add ( contractInfo . address ) ;
84+ }
85+
7786 // contracts can either be imported by just their name, or by a full path.
7887 // technically it may be more correct to just load by the actual name of the `artifact` property used, but that is complicated
7988 debug ( 'finding contract:' , contractInfo . sourceName , contractInfo . contractName ) ;
@@ -92,7 +101,7 @@ export async function verify(packageRef: string, cliSettings: CliSettings, chain
92101 continue ;
93102 }
94103
95- if ( await isVerified ( contractInfo . address , etherscanApi , cliSettings . etherscanApiKey ) ) {
104+ if ( await isVerified ( contractInfo . address , etherscanApi , cliSettings . etherscanApiKey , chainId ) ) {
96105 log ( `✅ ${ c } : Contract source code already verified` ) ;
97106 await sleep ( 500 ) ;
98107 continue ;
@@ -105,6 +114,7 @@ export async function verify(packageRef: string, cliSettings: CliSettings, chain
105114
106115 const reqData : { [ k : string ] : string } = {
107116 apikey : cliSettings . etherscanApiKey ,
117+ chainid : chainId . toString ( ) ,
108118 module : 'contract' ,
109119 action : 'verifysourcecode' ,
110120 contractaddress : contractInfo . address ,
0 commit comments