-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Test on Granted events * remove useless argument
- Loading branch information
1 parent
27f5b65
commit 14f395a
Showing
2 changed files
with
43 additions
and
24 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "./Albums.sol"; | ||
/// @custom:security-contact [email protected] | ||
/** | ||
* @title Admins Contract | ||
|
@@ -67,12 +68,6 @@ contract Admins is Ownable{ | |
* @return bool Returns true if the address is not a super admin, false if it already exists as a super admin. | ||
*/ | ||
function ensureSuperAdminDoNotExist(address _addr) internal view returns (bool){ | ||
// for (uint256 i = 0; i < superAdminsAccounts.length; i++) { | ||
// if (superAdminsAccounts[i] == _addr) { | ||
// return false; | ||
// } | ||
// } | ||
// return true; | ||
return uint(adminRoles[_addr]) == uint(Role.None); | ||
} | ||
|
||
|
@@ -118,15 +113,30 @@ contract Admins is Ownable{ | |
* @notice Only existing superadmins can add new admins. | ||
//TODO newContract will be removed to be used after deploy | ||
*/ | ||
function addAdmin(address newAdmin, address newContract) external { | ||
function addAdmin(address newAdmin) external { | ||
require(ensureAdminDoNotExist(newAdmin), "admin exists"); | ||
require(ensureSuperAdmin(msg.sender), "not super admin"); | ||
require(adminRoles[newAdmin] == Role.None, "role already set"); | ||
// todo factory call to deploy the contract and get the deployment address deployment address | ||
adminRoles[newAdmin] = Role.Admin; | ||
adminsContracts[newAdmin] = newAdmin; // change this with deployed adress | ||
adminsAccounts.push(newAdmin); | ||
emit Granted(msg.sender,newAdmin, Role.Admin , newContract); | ||
bytes memory collectionBytecode = type(Albums).creationCode; | ||
bytes32 salt = keccak256(abi.encodePacked(newAdmin, block.timestamp)); | ||
address collectionAddress; | ||
// assembly { | ||
// collectionAddress := create2( | ||
// 0, | ||
// add(collectionBytecode, 0x20), | ||
// mload(collectionBytecode), | ||
// salt | ||
// ) | ||
// if iszero(extcodesize(collectionAddress)) { | ||
// // revert if something gone wrong (collectionAddress doesn't contain an address) | ||
// revert(0, 0) | ||
// } | ||
// } | ||
adminsContracts[newAdmin] = collectionAddress; // change this with deployed address | ||
adminsAccounts.push(collectionAddress); | ||
emit Granted(msg.sender,newAdmin, Role.Admin, collectionAddress); | ||
} | ||
|
||
function removeAdmin(address oldAdmin) external { | ||
|
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