From c382f96e114d9c9fc966622846e75bb6b65bcea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wei=C3=9Fer=20Hase?= Date: Thu, 16 May 2024 15:07:44 +0200 Subject: [PATCH] feat: adding deployment script --- foundry.toml | 2 +- package.json | 4 ++-- script/Deploy.s.sol | 19 +++++++++++++++++++ script/Params.s.sol | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 script/Deploy.s.sol create mode 100644 script/Params.s.sol diff --git a/foundry.toml b/foundry.toml index bd346497..f0268bcd 100644 --- a/foundry.toml +++ b/foundry.toml @@ -11,7 +11,7 @@ sort_imports = true [profile.default] solc_version = '0.8.23' libs = ["node_modules", "lib"] -optimizer_runs = 10_000 +optimizer_runs = 50 # TODO: increase for production and add via-ir [profile.optimized] via_ir = true diff --git a/package.json b/package.json index eb4e08f9..be8b9a06 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "build": "forge build", "build:optimized": "FOUNDRY_PROFILE=optimized forge build", "coverage": "forge coverage --match-contract Unit", - "deploy:mainnet": "bash -c 'source .env && forge script Deploy --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK'", - "deploy:sepolia": "bash -c 'source .env && forge script Deploy --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK'", + "deploy:mainnet": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $MAINNET_RPC --broadcast --chain mainnet --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'", + "deploy:testnet": "bash -c 'source .env && forge script Deploy -vvvvv --rpc-url $SEPOLIA_RPC --broadcast --chain sepolia --private-key $SEPOLIA_DEPLOYER_PK --verify --etherscan-api-key $ETHERSCAN_API_KEY'", "lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check", "lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix", "lint:natspec": "npx @defi-wonderland/natspec-smells --config natspec-smells.config.js", diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol new file mode 100644 index 00000000..d2c1dc00 --- /dev/null +++ b/script/Deploy.s.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.23; + +import {BFactory} from 'contracts/BFactory.sol'; +import {Params} from 'script/Params.s.sol'; + +import {Script} from 'forge-std/Script.sol'; +import {IERC20} from 'forge-std/interfaces/IERC20.sol'; + +contract Deploy is Script, Params { + function run() public { + DeploymentParams memory _params = _deploymentParams[block.chainid]; + + vm.startBroadcast(); + BFactory bFactory = new BFactory(); + bFactory.setBLabs(_params.bLabs); + vm.stopBroadcast(); + } +} diff --git a/script/Params.s.sol b/script/Params.s.sol new file mode 100644 index 00000000..c943cf24 --- /dev/null +++ b/script/Params.s.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.23; + +contract Params { + struct DeploymentParams { + address bLabs; + } + + /// @notice Deployment parameters for each chain + mapping(uint256 _chainId => DeploymentParams _params) internal _deploymentParams; + + constructor() { + // Mainnet + _deploymentParams[1] = DeploymentParams(address(this)); + + // Sepolia + _deploymentParams[11_155_111] = DeploymentParams(address(this)); + } +}