From ad48bd64dc2220b4f5c634382eea2a11cb47cd4b Mon Sep 17 00:00:00 2001 From: Paul Razvan Berg Date: Wed, 21 Jun 2023 15:05:41 +0300 Subject: [PATCH] fix: use "constructor" instead of "setUp" in "BaseScript" chore: prettier ignore ".github/workflows" ci: polish deploy workflow refactor: remove nested dirs in "script" --- .github/workflows/deploy-test-token.yml | 7 ++++-- .prettierignore | 1 + script/Base.s.sol | 29 +++++++++++++++++++++++ script/{deploy => }/DeployTestToken.s.sol | 4 ++-- script/shared/Base.s.sol | 21 ---------------- 5 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 script/Base.s.sol rename script/{deploy => }/DeployTestToken.s.sol (76%) delete mode 100644 script/shared/Base.s.sol diff --git a/.github/workflows/deploy-test-token.yml b/.github/workflows/deploy-test-token.yml index cb04c29..6d0d4c0 100644 --- a/.github/workflows/deploy-test-token.yml +++ b/.github/workflows/deploy-test-token.yml @@ -10,7 +10,7 @@ on: inputs: chain: default: "goerli" - description: 'Chain name. Defaults to "goerli" if unspecified' + description: "Chain name as defined in the Foundry config." required: false jobs: @@ -27,7 +27,10 @@ jobs: - name: "Deploy a test ERC-20 token contract" run: >- - forge script script/deploy/DeployTestToken.s.sol --broadcast --rpc-url "${{ github.event.inputs.chain }}" + forge script script/DeployTestToken.s.sol + --broadcast + --rpc-url "${{github.event.inputs.chain }}" + --verify -vvvv - name: "Add summary" diff --git a/.prettierignore b/.prettierignore index 839f326..b22ff35 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ # directories +.github/workflows broadcast cache lib diff --git a/script/Base.s.sol b/script/Base.s.sol new file mode 100644 index 0000000..b9c6976 --- /dev/null +++ b/script/Base.s.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.19 <0.9.0; + +import { Script } from "forge-std/Script.sol"; + +abstract contract BaseScript is Script { + /// @dev Included to enable compilation of the script without a $MNEMONIC environment variable. + string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk"; + + /// @dev Needed for the deterministic deployments. + bytes32 internal constant ZERO_SALT = bytes32(0); + + /// @dev The address of the contract deployer. + address internal deployer; + + /// @dev Used to derive the deployer's address. + string internal mnemonic; + + constructor() { + mnemonic = vm.envOr("MNEMONIC", TEST_MNEMONIC); + (deployer,) = deriveRememberKey({ mnemonic: mnemonic, index: 0 }); + } + + modifier broadcaster() { + vm.startBroadcast(deployer); + _; + vm.stopBroadcast(); + } +} diff --git a/script/deploy/DeployTestToken.s.sol b/script/DeployTestToken.s.sol similarity index 76% rename from script/deploy/DeployTestToken.s.sol rename to script/DeployTestToken.s.sol index 6269e4b..5475fe3 100644 --- a/script/deploy/DeployTestToken.s.sol +++ b/script/DeployTestToken.s.sol @@ -3,9 +3,9 @@ pragma solidity >=0.8.19; import { Script } from "forge-std/Script.sol"; -import { ERC20GodMode } from "../../src/token/erc20/ERC20GodMode.sol"; +import { ERC20GodMode } from "../src/token/erc20/ERC20GodMode.sol"; -import { BaseScript } from "../shared/Base.s.sol"; +import { BaseScript } from "./Base.s.sol"; /// @notice Deploys a test ERC-20 token with infinite minting and burning capabilities. contract DeployTestToken is Script, BaseScript { diff --git a/script/shared/Base.s.sol b/script/shared/Base.s.sol deleted file mode 100644 index a9cbefa..0000000 --- a/script/shared/Base.s.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.19; - -import { Script } from "forge-std/Script.sol"; - -abstract contract BaseScript is Script { - bytes32 internal constant ZERO_SALT = bytes32(0); - address internal deployer; - string internal mnemonic; - - function setUp() public virtual { - mnemonic = vm.envString("MNEMONIC"); - (deployer,) = deriveRememberKey(mnemonic, 0); - } - - modifier broadcaster() { - vm.startBroadcast(deployer); - _; - vm.stopBroadcast(); - } -}