Skip to content

Commit

Permalink
adjust spells with suggestions from @amusingaxl
Browse files Browse the repository at this point in the history
  • Loading branch information
spengrah committed Feb 8, 2023
1 parent c8069ab commit f764afb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 46 deletions.
69 changes: 37 additions & 32 deletions src/CreateHatSpell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,34 @@ pragma solidity ^0.8.13;

import { DssExec } from "dss-exec-lib/DssExec.sol";
import { DssAction } from "dss-exec-lib/DssAction.sol";
import { IHats } from "hats-protocol/Interfaces/IHats.sol";
import { DSPauseProxy } from "ds-pause/pause.sol";

contract CreateHatAction is DssAction {
DSPauseProxy public immutable pauseHatsProxy;
interface DSPauseProxyLike {
function exec(address usr, bytes memory fax) external returns (bytes memory out);
}

interface HatsLike {
function createHat(
uint256 _admin,
string memory _details,
uint32 _maxSupply,
address _eligibility,
address _toggle,
bool _mutable,
string memory _imageURI
) external returns (uint256 newHatId);
}

IHats public immutable hats;
uint256 public immutable tophat;
contract DssSpellAction is DssAction {
address public constant HATS = address(0); // TODO: fill with the hats contract instance
address public constant HATS_PAUSE_PROXY = address(0); // TODO: fill with the hats pause proxy instance
uint256 public constant TOP_HAT_ID = 0; // TODO: fill with the top hat ID created before

constructor(IHats _hats, DSPauseProxy _pauseHatsProxy, uint256 _tophat) {
hats = _hats;
pauseHatsProxy = _pauseHatsProxy;
tophat = _tophat;
}
string public HAT_DETAILS = ""; // TODO: fill with the details of the new hat
uint32 public constant HAT_MAX_SUPPLY = 0; // TODO: fill with the max supply of the new hat
address public constant HAT_ELIGIBILITY = address(0); // TODO: fill with the eligibility module address of the new hat
address public constant HAT_TOGGLE = address(0); // TODO: fill with the toggle module address of the new hat
bool public constant HAT_MUTABLE = false; // TODO: fill with the mutability of the new hat
string public HAT_IMAGE_URI = ""; // TODO: fill with the imageURI of the new hat

function officeHours() public override returns (bool) {
// TODO: Decide whether office hours should be on
Expand Down Expand Up @@ -46,33 +60,24 @@ contract CreateHatAction is DssAction {
*
* This will execute the Hats tx from the execution context of the pauseHatsProxy.
*/
// 0. define new hat parameters
string memory details;
uint32 maxSupply;
address eligibility;
address toggle;
bool mutable_;
string memory imageURI;

// 1. generate the abi-encoded bytes for the createHat transaction to be called against Hats.sol
bytes memory fax = abi.encodeWithSelector(
IHats.CreateHat.selector,
tophat, // admin
details,
maxSupply,
eligibility,
toggle,
mutable_,
imageURI
HatsLike(0).createHat.selector,
TOP_HAT_ID, // admin
HAT_DETAILS,
HAT_MAX_SUPPLY,
HAT_ELIGIBILITY,
HAT_ELIGIBILITY,
HAT_MUTABLE,
HAT_IMAGE_URI
);

// 2. pass the fax as a payload to pauseHatsProxy
pauseHatsProxy.exec(hats, fax);
// 2. pass the fax as a payload to pauseHatsProxy to execute against Hats.sol
DSPauseProxyLike(HATS_PAUSE_PROXY).exec(hats, fax);
}
}

contract CreateHatSpell is DssExec {
constructor(IHats _hats, DSPauseProxy _pauseHatsProxy, uint256 _tophat)
DssExec(block.timestamp + 30 days, address(new DssSpellAction(_hats, _pauseHatsProxy, _tophat)))
{ }
contract DssSpell is DssExec {
constructor() DssExec(block.timestamp + 30 days, address(new DssSpellAction())) { }
}
31 changes: 17 additions & 14 deletions src/MintTopHatSpell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ pragma solidity ^0.8.13;

import { DssExec } from "dss-exec-lib/DssExec.sol";
import { DssAction } from "dss-exec-lib/DssAction.sol";
import { IHats } from "hats-protocol/Interfaces/IHats.sol";
import { DSPauseProxy } from "ds-pause/pause.sol";

contract MintTopHatAction is DssAction {
interface HatsLike {
function mintTopHat(address _target, string memory _details, string memory _imageURI)
external
returns (uint256 topHatId);
}

contract DssSpellAction is DssAction {
// https://etherscan.io/address/0xbe8e3e3618f7474f8cb1d074a26affef007e98fb
// DSPauseProxy public constant pauseProxy = 0xBE8E3e3618f7474F8cB1d074A26afFef007E98FB;

IHats public immutable hats;

constructor(IHats _hats) {
hats = _hats;
}
address public constant HATS = address(0); // TODO: fill with the hats contract instance;

function officeHours() public override returns (bool) {
// TODO: Decide whether office hours should be on
Expand All @@ -32,6 +33,8 @@ contract MintTopHatAction is DssAction {
// The DssExec function will call this subject to the officeHours limiter
// By keeping this function public we allow simulations of `execute()` on the actions outside of the cast time.
function actions() public override {
// https://vote.makerdao.com/polling/TODO#poll-detail TODO: UPDATE THIS ONCE THERE'S A POLL

/* For security & separation of concerns reasons, we create a new proxy to wear
* the tophat. The new proxy is owned/controlled by the original pauseProxy.
Expand All @@ -51,16 +54,16 @@ contract MintTopHatAction is DssAction {
// deploy a new DSPauseProxy that will be owned by the original pauseProxy
DSPauseProxy pauseHatsProxy = new DSPauseProxy(); // owner == msg.sender == pauseProxy

// mint a tophat to the pauseHatsProxy
hats.mintTopHat(
pauseHatsProxy,
// mint a tophat to the hatsPauseProxy
uint256 topHatId = HatsLike(HATS).mintTopHat(
address(hatsPauseProxy),
// the tophat's details and imageURI can both be updated later
_details, // TODO MakerDAO to decide which details to use initially
_imageURI // TODO MakerDAO to decide which image to use initially
"", // TODO MakerDAO to decide which details to use initially
"" // TODO MakerDAO to decide which image to use initially
);
}
}

contract MintTopHatSpell is DssExec {
constructor(IHats _hats) DssExec(block.timestamp + 30 days, address(new DssSpellAction(_hats))) { }
contract DssSpell is DssExec {
constructor() DssExec(block.timestamp + 30 days, address(new DssSpellAction())) { }
}

0 comments on commit f764afb

Please sign in to comment.