|
| 1 | +import type { HardhatRuntimeEnvironment } from 'hardhat/types'; |
| 2 | + |
| 3 | +// Note: getDeploymentName is not strictly needed here as there are no constructor args, |
| 4 | +// but kept for potential future consistency if desired. For no-arg singletons, |
| 5 | +// using the contract name directly as the deployment name is often simplest. |
| 6 | +// import { getDeploymentName } from '../src/deployment'; |
| 7 | + |
| 8 | +const CONTRACT_NAME = 'WstETHApi3ReaderProxyV1'; |
| 9 | + |
| 10 | +module.exports = async (hre: HardhatRuntimeEnvironment) => { |
| 11 | + const { getUnnamedAccounts, deployments, network, run } = hre; |
| 12 | + const { deploy, log } = deployments; |
| 13 | + |
| 14 | + const [deployerAddress] = await getUnnamedAccounts(); |
| 15 | + if (!deployerAddress) { |
| 16 | + throw new Error('No deployer address found.'); |
| 17 | + } |
| 18 | + log(`Deployer address: ${deployerAddress}`); |
| 19 | + |
| 20 | + const isLocalNetwork = network.name === 'hardhat' || network.name === 'localhost'; |
| 21 | + |
| 22 | + const confirmations = isLocalNetwork ? 1 : 5; |
| 23 | + log(`Deployment confirmations: ${confirmations}`); |
| 24 | + |
| 25 | + // For contracts with no constructor args, using the contract name directly is common. |
| 26 | + log(`Deployment name for this instance: ${CONTRACT_NAME}`); |
| 27 | + |
| 28 | + const deployment = await deploy(CONTRACT_NAME, { |
| 29 | + contract: CONTRACT_NAME, |
| 30 | + from: deployerAddress, |
| 31 | + log: true, |
| 32 | + waitConfirmations: confirmations, |
| 33 | + }); |
| 34 | + |
| 35 | + if (isLocalNetwork) { |
| 36 | + log('Skipping verification on local network.'); |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + log(`Attempting verification of ${CONTRACT_NAME} at ${deployment.address} (already waited for confirmations)...`); |
| 41 | + await run('verify:verify', { |
| 42 | + address: deployment.address, |
| 43 | + }); |
| 44 | +}; |
| 45 | +module.exports.tags = [CONTRACT_NAME]; |
0 commit comments