Skip to content

Commit

Permalink
feat: deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan Trenev committed Dec 11, 2023
1 parent dcbf67e commit 1ccd5c4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
16 changes: 11 additions & 5 deletions deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;

const greeter = await deploy("Greeter", {
const safeVault = await deploy("SafeVault", {
from: deployer,
args: ["Bonjour, le monde!"],
args: [
process.env.USDC_ADDRESS,
process.env.BUY_TAX_BPS,
process.env.SELL_TAX_BPS,
process.env.MANAGEMENT_ADDRESS,
process.env.AI_FUND_ADDRESS,
],
log: true,
});

console.log(`Greeter contract: `, greeter.address);
console.log(`SafeVault contract: `, safeVault.address);
};
export default func;
func.id = "deploy_greeter"; // id required to prevent reexecution
func.tags = ["Greeter"];
func.id = "deploy_safe_vault"; // id required to prevent reexecution
func.tags = ["SafeVault"];
19 changes: 12 additions & 7 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ import "hardhat-deploy";
import type { HardhatUserConfig } from "hardhat/config";
import { vars } from "hardhat/config";
import type { NetworkUserConfig } from "hardhat/types";
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";


import "./tasks/accounts";
import "./tasks/greet";
import "./tasks/taskDeploy";

// Run 'npx hardhat vars setup' to see the list of variables that need to be set
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) });

// Ensure that we have all the environment variables we need.
const mnemonic: string | undefined = process.env.MNEMONIC;
if (!mnemonic) {
throw new Error("Please set your MNEMONIC in a .env file");
}

const mnemonic: string = vars.get("MNEMONIC");
const infuraApiKey: string = vars.get("INFURA_API_KEY");

const chainIds = {
Expand Down Expand Up @@ -43,11 +52,7 @@ function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
}
return {
accounts: {
count: 10,
mnemonic,
path: "m/44'/60'/0'/0",
},
accounts: [process.env.WALLET_PK || ""],
chainId: chainIds[chain],
url: jsonRpcUrl,
};
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"ts-generator": "^0.1.1",
"ts-node": "^10.9.1",
"typechain": "^8.2.0",
"typescript": "^4.9.3"
"typescript": "^4.9.3",
"dotenv": "^16.3.1"
},
"dependencies": {
"@openzeppelin/contracts": "5.0.0"
Expand All @@ -67,7 +68,8 @@
"clean": "rimraf ./artifacts ./cache ./coverage ./types ./coverage.json && pnpm typechain",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && pnpm typechain",
"deploy:contracts": "hardhat deploy",
"deploy": "npx hardhat run deploy/deploy.jts --network",
"deploy:contracts": "hardhat deploy --network",
"lint": "pnpm lint:sol && pnpm lint:ts && pnpm prettier:check",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"lint:ts": "eslint --ignore-path ./.eslintignore --ext .js,.ts .",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ccd5c4

Please sign in to comment.