-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
274227e
commit f605b8f
Showing
5 changed files
with
121 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule ds-spell
deleted from
132420
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
// Copyright (C) 2022 Horsefacts <[email protected]> | ||
// Copyright (C) 2020 Maker Ecosystem Growth Holdings, INC. | ||
// | ||
// 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 <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity 0.5.16; | ||
|
||
interface PauseLike { | ||
function plot(address,bytes32,bytes calldata,uint256) external; | ||
function exec(address,bytes32,bytes calldata,uint256) external; | ||
function delay() external view returns (uint256); | ||
} | ||
|
||
interface ActionLike { | ||
function description() external view returns (string memory); | ||
} | ||
|
||
contract DssSpell { | ||
|
||
PauseLike public pause; | ||
address public action; | ||
bytes32 public tag; | ||
uint256 public eta; | ||
bytes public sig; | ||
uint256 public expiration; | ||
bool public done; | ||
|
||
constructor(address _pause, address _action) public { | ||
pause = PauseLike(_pause); | ||
sig = abi.encodeWithSignature("execute()"); | ||
action = _action; | ||
bytes32 _tag; | ||
assembly { _tag := extcodehash(_action) } | ||
tag = _tag; | ||
expiration = now + 30 days; | ||
} | ||
|
||
function description() public view returns (string memory) { | ||
return ActionLike(action).description(); | ||
} | ||
|
||
function schedule() public { | ||
require(now <= expiration, "This contract has expired"); | ||
require(eta == 0, "This spell has already been scheduled"); | ||
eta = now + pause.delay(); | ||
pause.plot(action, tag, sig, eta); | ||
} | ||
|
||
function cast() public { | ||
require(!done, "spell-already-cast"); | ||
done = true; | ||
pause.exec(action, tag, sig, eta); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters