Skip to content

Commit b9686be

Browse files
committed
Merge remote-tracking branch 'origin/main' into dev
2 parents 51f831c + ee826da commit b9686be

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

examples/router-architecture/src/Greeter.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ contract Greeter {
1616
emit NewGreeting(_greeting);
1717
}
1818
}
19+
# some extra comment

packages/cli/src/commands/verify.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

packages/cli/src/util/verify.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ export type EtherscanGetSourceCodeResponse = EtherscanGetSourceCodeNotOkResponse
3737
* @returns True if the contract is verified, false otherwise.
3838
*/
3939

40-
export async function isVerified(address: string, apiUrl: string, apiKey: string): Promise<boolean> {
40+
export async function isVerified(address: string, apiUrl: string, apiKey: string, chainId: number): Promise<boolean> {
4141
const parameters = new URLSearchParams({
4242
apikey: apiKey,
43+
chainid: chainId.toString(),
4344
module: 'contract',
4445
action: 'getsourcecode',
4546
address,

0 commit comments

Comments
 (0)