Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Jan 29, 2025
1 parent 8b48398 commit 2b07298
Show file tree
Hide file tree
Showing 10 changed files with 1,136 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ contract HatsHatCreatorModule is HatsModule, Ownable, IHatsHatCreatorModule {
*/
function _setUp(bytes calldata _initData) internal override {
address _owner = abi.decode(_initData, (address));
_grantCreateHatAuthority(_owner);
_transferOwnership(_owner);
createHatAuthorities[_owner] = true;
}

/**
Expand All @@ -45,22 +45,15 @@ contract HatsHatCreatorModule is HatsModule, Ownable, IHatsHatCreatorModule {
* @param authority The address to grant authority to
*/
function grantCreateHatAuthority(address authority) external onlyOwner {
require(authority != address(0), "Invalid address");
require(!hasCreateHatAuthority(authority), "Already granted");

createHatAuthorities[authority] = true;
emit CreateHatAuthorityGranted(authority);
_grantCreateHatAuthority(authority);
}

/**
* @notice Revokes hat creation authority from an address
* @param authority The address to revoke authority from
*/
function revokeCreateHatAuthority(address authority) external onlyOwner {
require(hasCreateHatAuthority(authority), "Not granted");

createHatAuthorities[authority] = false;
emit CreateHatAuthorityRevoked(authority);
_revokeCreateHatAuthority(authority);
}

/**
Expand Down Expand Up @@ -96,4 +89,29 @@ contract HatsHatCreatorModule is HatsModule, Ownable, IHatsHatCreatorModule {
_imageURI
);
}

// Internal Functions

/**
* @dev Grants hat creation authority to an address
* @param authority The address to grant authority to
*/
function _grantCreateHatAuthority(address authority) internal {
require(authority != address(0), "Invalid address");
require(!hasCreateHatAuthority(authority), "Already granted");

createHatAuthorities[authority] = true;
emit CreateHatAuthorityGranted(authority);
}

/**
* @dev Revokes hat creation authority from an address
* @param authority The address to revoke authority from
*/
function _revokeCreateHatAuthority(address authority) internal {
require(hasCreateHatAuthority(authority), "Not granted");

createHatAuthorities[authority] = false;
emit CreateHatAuthorityRevoked(authority);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract HatsTimeFrameModule is HatsModule, Ownable, IHatsTimeFrameModule {
*/
function _setUp(bytes calldata _initData) internal override {
address _owner = abi.decode(_initData, (address));
_grantOperationAuthority(_owner);
_transferOwnership(_owner);
operationAuthorities[_owner] = true;
}

/**
Expand All @@ -56,22 +56,15 @@ contract HatsTimeFrameModule is HatsModule, Ownable, IHatsTimeFrameModule {
* @param authority The address to grant authority to
*/
function grantOperationAuthority(address authority) external onlyOwner {
require(authority != address(0), "Invalid address");
require(!hasOperationAuthority(authority), "Already granted");

operationAuthorities[authority] = true;
emit OperationAuthorityGranted(authority);
_grantOperationAuthority(authority);
}

/**
* @notice Revokes hat creation authority from an address
* @param authority The address to revoke authority from
*/
function revokeOperationAuthority(address authority) external onlyOwner {
require(hasOperationAuthority(authority), "Not granted");

operationAuthorities[authority] = false;
emit OperationAuthorityRevoked(authority);
_revokeOperationAuthority(authority);
}

/**
Expand Down Expand Up @@ -190,4 +183,29 @@ contract HatsTimeFrameModule is HatsModule, Ownable, IHatsTimeFrameModule {

return activeTime;
}

// internal functions

/**
* @dev Grants hat creation authority to an address
* @param authority The address to grant authority to
*/
function _grantOperationAuthority(address authority) internal {
require(authority != address(0), "Invalid address");
require(!hasOperationAuthority(authority), "Already granted");

operationAuthorities[authority] = true;
emit OperationAuthorityGranted(authority);
}

/**
* @dev Revokes hat creation authority from an address
* @param authority The address to revoke authority from
*/
function _revokeOperationAuthority(address authority) internal {
require(hasOperationAuthority(authority), "Not granted");

operationAuthorities[authority] = false;
emit OperationAuthorityRevoked(authority);
}
}
Empty file.
Loading

0 comments on commit 2b07298

Please sign in to comment.