Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add DecentHatsModificationModule #121

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions contracts/DecentHatsModificationModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {IERC6551Registry} from "./interfaces/IERC6551Registry.sol";
import {IHats} from "./interfaces/hats/full/IHats.sol";
import {IHatsModuleFactory} from "./interfaces/hats/full/IHatsModuleFactory.sol";
import {DecentHatsUtils} from "./DecentHatsUtils.sol";

contract DecentHatsModificationModule is DecentHatsUtils {
struct CreateTermedOrUntermedRoleHatParams {
IHats hatsProtocol;
IERC6551Registry registry;
address topHatAccount;
address hatsAccountImplementation;
uint256 adminHatId;
uint256 topHatId;
HatParams hat;
address hatsElectionsEligibilityImplementation;
IHatsModuleFactory hatsModuleFactory;
}

/**
* @notice Creates a new termed or untermed role hat and any streams on it.
*
* @notice This contract should be enabled a module on the Safe for which the role is to be created, and disabled after.
*
* @dev Stream funds on untermed Roles are targeted at the hat's smart account. In order to withdraw funds from the stream, the
* hat's smart account must be the one call to `withdraw-` on the Sablier contract, setting the recipient arg to its wearer.
*
* @dev Stream funds on termed Roles are targeted directly at the nominated wearer.
* The wearer should directly call `withdraw-` on the Sablier contract.
*
* @dev Role hat creation, minting, smart account creation and stream creation are handled here in order
* to avoid a race condition where not more than one active proposal to create a new role can exist at a time.
* See: https://github.com/decentdao/decent-interface/issues/2402
*/
function createRoleHat(
CreateTermedOrUntermedRoleHatParams calldata params
) external {
_processHat(
params.hatsProtocol,
params.registry,
params.hatsAccountImplementation,
params.topHatId,
params.topHatAccount,
params.hatsModuleFactory,
params.hatsElectionsEligibilityImplementation,
params.adminHatId,
params.hat
);
}
}
9 changes: 9 additions & 0 deletions deploy/core/021_deploy_DecentHatsModificationModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { deployNonUpgradeable } from '../helpers/deployNonUpgradeable';

const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
await deployNonUpgradeable(hre, 'DecentHatsModificationModule');
};

export default func;
Loading