Skip to content

Commit df8c19d

Browse files
committed
fix: update verification script path and enhance error handling
1 parent 6190635 commit df8c19d

File tree

3 files changed

+44
-23
lines changed

3 files changed

+44
-23
lines changed

scripts/sponsoring/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ npx hardhat --network bellecour etherscan-verify
5151
```
5252
and embedded `hardhat-verify` plugin of `hardhat` (v2.22.12):
5353
```
54-
npx hardhat run ./scripts/sponsoring/verify.ts --network bellecour
54+
npx hardhat run ./scripts/verify.ts --network bellecour
5555
```
5656
by previously modifiying the `.json` file produced by:
5757
```

scripts/sponsoring/verify.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

scripts/verify.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import fs from 'fs';
5+
import hre, { deployments } from 'hardhat';
6+
import path from 'path';
7+
8+
(async () => {
9+
const jsonExtension = '.json';
10+
const contractNames = fs
11+
.readdirSync(path.resolve(__dirname, `../deployments/${hre.network.name}`))
12+
.filter((file) => file.endsWith(jsonExtension))
13+
.map((filePath) => filePath.replace(jsonExtension, ''));
14+
15+
console.log(`Contracts to verify: ${contractNames}`);
16+
17+
for (const contractName of contractNames) {
18+
try {
19+
console.log(`Verifying ${contractName}..`);
20+
const deployment = await deployments.get(contractName);
21+
const address = deployment.address;
22+
const constructorArguments = deployment.args || [];
23+
await hre.run('verify:verify', {
24+
address,
25+
constructorArguments,
26+
});
27+
28+
console.log(`${contractName} verified successfully`);
29+
} catch (error: any) {
30+
console.error(`Error verifying ${contractName}:`, error.message || error);
31+
if (
32+
typeof error.message === 'string' &&
33+
error.message.includes('has') &&
34+
error.message.includes('parameters but') &&
35+
error.message.includes('arguments were provided')
36+
) {
37+
console.error(
38+
`${contractName} requires constructor arguments. Please add them to the deployment artifact.`,
39+
);
40+
}
41+
}
42+
}
43+
})();

0 commit comments

Comments
 (0)