diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 50f160a..982e550 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -22,4 +22,4 @@ jobs: uses: foundry-rs/foundry-toolchain@v1 - name: Run Linter - run: yarn lint + run: forge fmt --check diff --git a/README.md b/README.md index 2ef75b2..c95ff8c 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ This behavior is acknowledged and should be considered when designing a strategy An alternative solution is to build a queue mechanism on top of the URD with a 0 timelock distribution. Here, the root updater could be a queue designed as the [Delay Modifier of Zodiac](https://github.com/gnosis/zodiac-modifier-delay/blob/36f56fd2e7a4aeb128971c5567fb8dffb6c6a21b/contracts/Delay.sol). -## Getting Started +## Developers ### Installation @@ -102,35 +102,18 @@ yarn cp .env.example .env ``` -### Development +### Testing Running tests requires forge from [Foundry](https://book.getfoundry.sh/getting-started/installation). ```bash -yarn test +forge test ``` ### Deployment -- Add the desired network key and its corresponding RPC url to `foundry.toml` -- `yarn deploy {network} --broadcast --sender {sender}` followed with appropriate private key management parameters - -> [!NOTE] -> If the provided network's RPC url uses a variable environment (such as `ALCHEMY_KEY`), it should be defined in your `.env` - -For example: - -```bash -yarn deploy goerli --broadcast --ledger --sender 0x7Ef4174aFdF4514F556439fa2822212278151Db6 -``` - -> [!NOTE] -> Broadcast run logs are to be committed to this repository for future reference. - -### Etherscan verification - ```bash -yarn verify --watch --chain-id {chainid} --etherscan-api-key {key} {address} src/UrdFactory.sol:UrdFactory +forge create src/UrdFactory.sol:UrdFactory --broadcast ``` ## Audits diff --git a/foundry.toml b/foundry.toml index 58ce97c..e4a14ea 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,6 +6,8 @@ fs_permissions = [ { access = "read", path = "./script/config/"}, { access = "read", path = "./out/"} ] +optimizer_runs = 200 +via-ir = true [profile.default.fmt] wrap_comments = true @@ -17,17 +19,6 @@ goerli = "https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}" sepolia = "https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_KEY}" -[profile.build] -via-ir = true -test = "/dev/null" -script = "/dev/null" - - -[profile.script] -src = "/dev/null" -test = "/dev/null" - - [profile.test-slow] via-ir = false diff --git a/package.json b/package.json index ff06ba2..8c4a730 100644 --- a/package.json +++ b/package.json @@ -17,17 +17,6 @@ "bugs": { "url": "https://github.com/morpho-org/universal-rewards-distributor/issues" }, - "scripts": { - "prepare": "husky install && forge install", - "script": "FOUNDRY_PROFILE=script forge script", - "build": "FOUNDRY_PROFILE=build forge build", - "deploy": "yarn build && yarn script script/DeployUrdFactory.sol --sig \"run(string memory)\"", - "verify": "FOUNDRY_PROFILE=build forge verify-contract", - "test": "FOUNDRY_PROFILE=test forge test", - "lint": "forge fmt --check", - "lint:fix": "forge fmt", - "clean": "forge clean" - }, "devDependencies": { "@commitlint/cli": "^18.2.0", "@commitlint/config-conventional": "^18.1.0", diff --git a/script/ConfiguredScript.sol b/script/ConfiguredScript.sol deleted file mode 100644 index 1708f52..0000000 --- a/script/ConfiguredScript.sol +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.0; - -import "../lib/forge-std/src/Script.sol"; -import "../lib/forge-std/src/console2.sol"; - -abstract contract ConfiguredScript is Script { - using stdJson for string; - - string internal configPath; - - function _init(string memory network) internal returns (bytes memory) { - vm.createSelectFork(vm.rpcUrl(network)); - - console2.log("Running script on network %s using %s...", network, msg.sender); - - return _loadConfig(network); - } - - function _loadConfig(string memory network) internal returns (bytes memory) { - configPath = string.concat("script/config/", network, ".json"); - - return vm.parseJson(vm.readFile(configPath)); - } - - function _deployCreate2Code(string memory what, bytes memory args, bytes32 salt) internal returns (address addr) { - bytes memory bytecode = abi.encodePacked(vm.getCode(string.concat(what, ".sol")), args); - - vm.broadcast(); - assembly ("memory-safe") { - addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt) - } - - require(addr != address(0), "create2 deployment failed"); - - console2.log("Deployed %s at: %s", what, addr); - } -} diff --git a/script/DeployUrdFactory.sol b/script/DeployUrdFactory.sol deleted file mode 100644 index aea13c4..0000000 --- a/script/DeployUrdFactory.sol +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity ^0.8.0; - -import "./ConfiguredScript.sol"; - -/// @dev Warning: keys must be ordered alphabetically. -struct DeployUrdFactoryConfig { - bytes32 salt; -} - -contract DeployUrdFactory is ConfiguredScript { - function run(string memory network) public returns (DeployUrdFactoryConfig memory config) { - config = abi.decode(_init(network), (DeployUrdFactoryConfig)); - - // Deploy UrdFactory - _deployCreate2Code("UrdFactory", hex"", config.salt); - } -} diff --git a/script/config/ethereum.json b/script/config/ethereum.json deleted file mode 100644 index 8ba9cdd..0000000 --- a/script/config/ethereum.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "salt": "0x0000000000000000000000000000000000000000000000000000000000000000" -} diff --git a/script/config/goerli.json b/script/config/goerli.json deleted file mode 100644 index 8ba9cdd..0000000 --- a/script/config/goerli.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "salt": "0x0000000000000000000000000000000000000000000000000000000000000000" -} diff --git a/script/config/sepolia.json b/script/config/sepolia.json deleted file mode 100644 index 8ba9cdd..0000000 --- a/script/config/sepolia.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "salt": "0x0000000000000000000000000000000000000000000000000000000000000000" -}