-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from decentdao/add-contract/DecentAutonomousA…
…dminHat `New Feature` Termed Roles
- Loading branch information
Showing
20 changed files
with
2,156 additions
and
30 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
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); | ||
} | ||
} |
Oops, something went wrong.