import { HardhatRuntimeEnvironment } from "hardhat/types"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; import { confirm } from "."; const accountNumber = Number(process.env.DEPLOYER_ACCOUNT) || 0; export const getDeployer = async ( hre: HardhatRuntimeEnvironment, log?: boolean, manualConfirm?: boolean ): Promise => { const deployer = accountNumber == 0 ? await SignerWithAddress.create(hre.ethers.provider.getSigner()) : (await hre.ethers.getSigners())[accountNumber]; if (log || manualConfirm) { console.log(` *** Deployer *********************** using deployer: ${deployer.address} balance: ${hre.ethers.utils.formatUnits( await deployer.getBalance(), "ether" )} eth ************************************ `); } if (manualConfirm) { await confirm(); } return deployer; }; export const logHre = async ( hre: HardhatRuntimeEnvironment, log?: boolean, manualConfirm?: boolean ): Promise => { const feeData = await hre.ethers.provider.getFeeData(); const maxFeePerGas = feeData.maxFeePerGas ? hre.ethers.utils.formatUnits(feeData.maxFeePerGas, "gwei") : "unknown"; const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ? hre.ethers.utils.formatUnits(feeData.maxPriorityFeePerGas, "gwei") : "unknown"; if (log || manualConfirm) { console.log(` *** HRE LOGS *********************** chainId: ${await hre.getChainId()} network: ${hre.network.name}, maxFeePerGas: ${maxFeePerGas} gwei (maximum price per unit of gas, includes base fee and priority fee), maxPriorityFeePerGas: ${maxPriorityFeePerGas} gwei (maximum priority fee per unit of gas) ************************************ `); } if (manualConfirm) { await confirm(); } };