Skip to content

Commit

Permalink
Merge pull request #102 from decentdao/add-contract/DecentAutonomousA…
Browse files Browse the repository at this point in the history
…dminHat

`New Feature` Termed Roles
  • Loading branch information
adamgall authored Oct 30, 2024
2 parents 1f2a615 + 302c147 commit 3dfd2c6
Show file tree
Hide file tree
Showing 20 changed files with 2,156 additions and 30 deletions.
48 changes: 48 additions & 0 deletions contracts/DecentAutonomousAdmin.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {IHats} from "./interfaces/hats/full/IHats.sol";
import {IHatsElectionsEligibility} from "./interfaces/hats/full/modules/IHatsElectionsEligibility.sol";
import {FactoryFriendly} from "@gnosis.pm/zodiac/contracts/factory/FactoryFriendly.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IDecentAutonomousAdmin} from "./interfaces/IDecentAutonomousAdmin.sol";

contract DecentAutonomousAdmin is
IDecentAutonomousAdmin,
ERC165,
FactoryFriendly
{
// //////////////////////////////////////////////////////////////
// initializer
// //////////////////////////////////////////////////////////////
function setUp(bytes memory initializeParams) public override initializer {}

// //////////////////////////////////////////////////////////////
// Public Functions
// //////////////////////////////////////////////////////////////
function triggerStartNextTerm(TriggerStartArgs calldata args) public {
if (
args.hatsProtocol.isWearerOfHat(args.currentWearer, args.hatId) ==
false
) revert NotCurrentWearer();

IHatsElectionsEligibility hatsElectionModule = IHatsElectionsEligibility(
args.hatsProtocol.getHatEligibilityModule(args.hatId)
);

hatsElectionModule.startNextTerm();

// This will burn the hat since wearer is no longer eligible
args.hatsProtocol.checkHatWearerStatus(args.hatId, args.currentWearer);
// This will mint the hat to the nominated wearer
args.hatsProtocol.mintHat(args.hatId, args.nominatedWearer);
}

function supportsInterface(
bytes4 interfaceId
) public view override returns (bool) {
return
interfaceId == type(IDecentAutonomousAdmin).interfaceId ||
super.supportsInterface(interfaceId);
}
}
Loading

0 comments on commit 3dfd2c6

Please sign in to comment.