From 311fd0827e7bd701c58bf32c84a732f8667e4b68 Mon Sep 17 00:00:00 2001 From: "Shiv Bhonde | shivbhonde.eth" Date: Wed, 4 Dec 2024 09:45:35 +0530 Subject: [PATCH] move 99_deployScript as hardhat task (#1005) --- packages/hardhat/hardhat.config.ts | 10 ++++++++++ .../99_generateTsAbis.ts => scripts/generateTsAbis.ts} | 8 +------- 2 files changed, 11 insertions(+), 7 deletions(-) rename packages/hardhat/{deploy/99_generateTsAbis.ts => scripts/generateTsAbis.ts} (93%) diff --git a/packages/hardhat/hardhat.config.ts b/packages/hardhat/hardhat.config.ts index 9cdbc8be1..fd4a6d41a 100644 --- a/packages/hardhat/hardhat.config.ts +++ b/packages/hardhat/hardhat.config.ts @@ -9,6 +9,8 @@ import "solidity-coverage"; import "@nomicfoundation/hardhat-verify"; import "hardhat-deploy"; import "hardhat-deploy-ethers"; +import { task } from "hardhat/config"; +import generateTsAbis from "./scripts/generateTsAbis"; // If not set, it uses the hardhat account 0 private key. const deployerPrivateKey = @@ -173,4 +175,12 @@ const config: HardhatUserConfig = { }, }; +// Extend the deploy task +task("deploy").setAction(async (args, hre, runSuper) => { + // Run the original deploy task + await runSuper(args); + // Force run the generateTsAbis script + await generateTsAbis(hre); +}); + export default config; diff --git a/packages/hardhat/deploy/99_generateTsAbis.ts b/packages/hardhat/scripts/generateTsAbis.ts similarity index 93% rename from packages/hardhat/deploy/99_generateTsAbis.ts rename to packages/hardhat/scripts/generateTsAbis.ts index b916d1b26..b794e1add 100644 --- a/packages/hardhat/deploy/99_generateTsAbis.ts +++ b/packages/hardhat/scripts/generateTsAbis.ts @@ -87,7 +87,7 @@ function getContractDataFromDeployments() { const { abi, address, metadata } = JSON.parse( fs.readFileSync(`${DEPLOYMENTS_DIR}/${chainName}/${contractName}.json`).toString(), ); - const inheritedFunctions = getInheritedFunctions(JSON.parse(metadata).sources, contractName); + const inheritedFunctions = metadata ? getInheritedFunctions(JSON.parse(metadata).sources, contractName) : {}; contracts[contractName] = { address, abi, inheritedFunctions }; } output[chainId] = contracts; @@ -125,9 +125,3 @@ const generateTsAbis: DeployFunction = async function () { }; export default generateTsAbis; - -// Tags are useful if you have multiple deploy files and only want to run one of them. -// e.g. yarn deploy --tags generateTsAbis -generateTsAbis.tags = ["generateTsAbis"]; - -generateTsAbis.runAtTheEnd = true;