diff --git a/.eslinttsconfigrc b/.eslinttsconfigrc index 2a6524fc..13355640 100644 --- a/.eslinttsconfigrc +++ b/.eslinttsconfigrc @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "include": ["deploy", "hardhat.config.ts", "subgraphs"] + "include": ["deploy", "hardhat.config.ts", "subgraphs", "type-extensions.ts"] } diff --git a/hardhat.config.ts b/hardhat.config.ts index 3a5ad62f..83d61d4d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -3,7 +3,11 @@ import 'hardhat-deploy'; import "@nomicfoundation/hardhat-chai-matchers"; import "@nomiclabs/hardhat-ethers"; import 'hardhat-dependency-compiler'; -import { HardhatUserConfig } from 'hardhat/config'; +import { HardhatUserConfig, extendEnvironment } from "hardhat/config"; + +extendEnvironment(hre => { + hre.getNetworkName = () => process.env.HARDHAT_FORK_NETWORK || hre.network.name; +}); const compilers = { compilers: [ diff --git a/tsconfig.json b/tsconfig.json index 03778313..a9f048eb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,5 +10,5 @@ "esModuleInterop": true, "resolveJsonModule": true }, - "include": ["subgraphs", "hardhat.config.ts"] + "include": ["subgraphs", "hardhat.config.ts", "type-extensions.ts"] } diff --git a/type-extensions.ts b/type-extensions.ts new file mode 100644 index 00000000..389caaa7 --- /dev/null +++ b/type-extensions.ts @@ -0,0 +1,9 @@ +import 'hardhat/types/runtime'; + +declare module 'hardhat/types/runtime' { + // This is an example of an extension to the Hardhat Runtime Environment. + // This new field will be available in tasks' actions, scripts, and tests. + export interface HardhatRuntimeEnvironment { + getNetworkName: () => string; + } +}