fix: should be able to run tests without .env
This commit is contained in:
parent
299f2b0f1b
commit
538783027d
|
@ -4,20 +4,22 @@ import { HardhatUserConfig, task } from "hardhat/config";
|
|||
import "@nomiclabs/hardhat-waffle";
|
||||
import "hardhat-gas-reporter";
|
||||
import "solidity-coverage";
|
||||
import { NetworksUserConfig } from "hardhat/types";
|
||||
|
||||
dotenv.config();
|
||||
const {GOERLI_URL,PRIVATE_KEY} = process.env;
|
||||
|
||||
|
||||
// This is a sample Hardhat task. To learn how to create your own go to
|
||||
// https://hardhat.org/guides/create-task.html
|
||||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
|
||||
const accounts = await hre.ethers.getSigners();
|
||||
|
||||
for (const account of accounts) {
|
||||
console.log(account.address);
|
||||
}
|
||||
});
|
||||
const getNetworkConfig = (): NetworksUserConfig | undefined => {
|
||||
if (GOERLI_URL && PRIVATE_KEY) {
|
||||
return {
|
||||
goerli: {
|
||||
url: GOERLI_URL,
|
||||
accounts: [PRIVATE_KEY],
|
||||
}
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// You need to export an object to set up your config
|
||||
// Go to https://hardhat.org/config/ to learn more
|
||||
|
@ -30,12 +32,7 @@ const config: HardhatUserConfig = {
|
|||
version: "0.8.15"
|
||||
}],
|
||||
},
|
||||
networks: {
|
||||
goerli: {
|
||||
url: GOERLI_URL,
|
||||
accounts: [`${PRIVATE_KEY}`]
|
||||
}
|
||||
}
|
||||
networks: getNetworkConfig()
|
||||
};
|
||||
|
||||
export default config;
|
Loading…
Reference in New Issue