forked from midas-apps/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_contracts.ts
More file actions
44 lines (37 loc) · 1.24 KB
/
verify_contracts.ts
File metadata and controls
44 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { readFileSync } from 'fs';
import { join } from 'path';
import { DeployFunction } from './deploy/common/types';
import { chainIds } from '../config';
import {
logDeployProxy,
tryEtherscanVerifyImplementation,
} from '../helpers/utils';
interface OpenZeppelinArtifact {
proxies: { address: string }[];
}
const fileNameOverrides = {
[chainIds.sepolia]: 'sepolia',
[chainIds.main]: 'mainnet',
[chainIds.arbitrum]: 'arbitrum-one',
[chainIds.bsc]: 'bsc',
};
const getFileName = (chainId: number) => {
const name = fileNameOverrides[chainId] ?? `unknown-${chainId}`;
return name + '.json';
};
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const artifactPath = join(
process.cwd(),
'.openzeppelin',
getFileName(hre.network.config.chainId!),
);
const artifactContent = readFileSync(artifactPath, 'utf-8');
const artifact: OpenZeppelinArtifact = JSON.parse(artifactContent);
console.log(`Verifying proxy contracts ${artifact.proxies.length}...`);
for (const { address } of artifact.proxies) {
await logDeployProxy(hre, 'Contract', address);
await tryEtherscanVerifyImplementation(hre, address);
}
};
export default func;