diff --git a/script/deploy.s.sol b/script/dss.s.sol similarity index 95% rename from script/deploy.s.sol rename to script/dss.s.sol index 9770a7c..1ccf3cb 100644 --- a/script/deploy.s.sol +++ b/script/dss.s.sol @@ -26,9 +26,9 @@ import {Dipper} from "../src/dip.sol"; import {Nil} from "../src/nil.sol"; import {Spy} from "../src/spy.sol"; -contract Deploy is Script { +contract DeployDSS is Script { - function deployCore() public { + function deployDSS() public { Sum sum = new Sum(); Use use = new Use(address(sum)); Nil nil = new Nil(address(sum)); @@ -50,7 +50,7 @@ contract Deploy is Script { function run() external { vm.startBroadcast(); - deployCore(); + deployDSS(); vm.stopBroadcast(); } diff --git a/script/gov.s.sol b/script/gov.s.sol new file mode 100644 index 0000000..415484a --- /dev/null +++ b/script/gov.s.sol @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + +// Copyright (C) 2022 Horsefacts +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +pragma solidity 0.5.16; + +import {CTR} from "../src/gov/ctr.sol"; +import {DssSpell} from "../src/gov/spell.sol"; +import {DSChief, DSChiefFab} from "ds-chief/chief.sol"; +import {DSPause, DSPauseProxy} from "ds-pause/pause.sol"; + +interface VmLike { + function startBroadcast() external; + function stopBroadcast() external; + function envAddress(string calldata key) external returns (address value); +} + +interface SumLike { + function rely(address) external; + function deny(address) external; +} + +contract DeployGov { + + // Can't use forge-std Script here + address private constant VM_ADDRESS = address(bytes20(uint160(uint256(keccak256('hevm cheat code'))))); + VmLike public constant vm = VmLike(VM_ADDRESS); + + uint256 public constant MAX_YAYS = 5; + uint256 public constant DELAY = 172_800; + + function deployGov(address sum) public { + address me = address(this); + CTR ctr = new CTR(); + DSChiefFab fab = new DSChiefFab(); + DSChief chief = fab.newChief(ctr, MAX_YAYS); + DSPause pause = new DSPause(DELAY, address(0), address(chief)); + DSPauseProxy proxy = pause.proxy(); + + SumLike(sum).rely(address(proxy)); + SumLike(sum).deny(me); + } + + event Sum(address sum); + + function run() external { + vm.startBroadcast(); + + address sum = vm.envAddress("DSS_SUM_ADDRESS"); + deployGov(sum); + + vm.stopBroadcast(); + } +} diff --git a/src/gov/spell.sol b/src/gov/spell.sol index 73de208..2203605 100644 --- a/src/gov/spell.sol +++ b/src/gov/spell.sol @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -pragma solidity 0.5.16; +pragma solidity >=0.5.16; interface PauseLike { function plot(address,bytes32,bytes calldata,uint256) external; @@ -45,7 +45,7 @@ contract DssSpell { bytes32 _tag; assembly { _tag := extcodehash(_action) } tag = _tag; - expiration = now + 30 days; + expiration = block.timestamp + 30 days; } function description() public view returns (string memory) { @@ -53,9 +53,9 @@ contract DssSpell { } function schedule() public { - require(now <= expiration, "This contract has expired"); + require(block.timestamp <= expiration, "This contract has expired"); require(eta == 0, "This spell has already been scheduled"); - eta = now + pause.delay(); + eta = block.timestamp + pause.delay(); pause.plot(action, tag, sig, eta); }