// SPDX-License-Identifier: None// Super Champs Foundation 2024pragmasolidity ^0.8.24;/// @title Interface for protocol permissions registry/// @author Chance Santana-Wees (Coelacanth/Coel.eth)interfaceIPermissionsManager{
///@notice All available roles.///@dev EXT roles are available for future application.enumRole {
ANY,
GLOBAL_ADMIN,
MINT_ADMIN,
TRANSFER_ADMIN,
SYSTEMS_ADMIN,
EXT1,
EXT2,
EXT3,
EXT4,
EXT5,
EXT6,
EXT7,
EXT8,
EXT9,
EXT10
}
/**
* @param role_ ISCPermissionsManager.Role to query
* @param account_ Address to check for role_
*/functionhasRole(Role role_, address account_) externalviewreturns(bool);
/**
* @param role_ ISCPermissionsManager.Role to add
* @param account_ Address to add role_ on
*/functionaddRole(Role role_, address account_) external;
/**
* @param role_ ISCPermissionsManager.Role to remove
* @param account_ Address to remove role_ from
*/functionremoveRole(Role role_, address account_) external;
}
Contract Source Code
File 2 of 3: SCPermissionedAccess.sol
// SPDX-License-Identifier: None// Super Champs Foundation 2024pragmasolidity ^0.8.24;import"../../interfaces/IPermissionsManager.sol";
contractSCPermissionedAccess{
IPermissionsManager publicimmutable permissions;
/// @notice Function modifier which requires the sender to possess the global admin permission as recorded in "permissions"modifierisGlobalAdmin() {
require(permissions.hasRole(IPermissionsManager.Role.GLOBAL_ADMIN, msg.sender), "Not a Global Admin");
_;
}
/// @notice Function modifier which requires the sender to possess the systems admin permission as recorded in "permissions"modifierisSystemsAdmin() {
require(permissions.hasRole(IPermissionsManager.Role.SYSTEMS_ADMIN, msg.sender), "Not a Systems Admin");
_;
}
constructor(address _permissions){
permissions = IPermissionsManager(_permissions);
}
}
Contract Source Code
File 3 of 3: SCVirtualAssetEvents.sol
// SPDX-License-Identifier: None// Super Champs Foundation 2024pragmasolidity ^0.8.24;import"../Utils/SCPermissionedAccess.sol";
/// @title SuperChamps Game Events Logger/// @author Chance Santana-Wees (Coelacanth/Coel.eth)/// @notice A permissioned events logger. Used for tracking virtual asset transactions on chain, via events only.contractSCVirtualAssetEvents{
ISCVirtualAssetEventsFactory _factory;
stringpublic game;
eventGameUserAsset(string user_id, string asset_id, int256 delta, string data);
eventGameUserActivity(string user_id, string data);
modifierisPermissionedUser() {
require(_factory.permissions_users(msg.sender), "NOT PERMISSIONED USER");
_;
}
constructor(ISCVirtualAssetEventsFactory factory_, stringmemory game_) {
_factory = factory_;
game = game_;
}
functionEmitGameUserAsset(stringmemory user_id, stringmemory asset_id, int256 delta, stringmemory data) externalisPermissionedUser{
emit GameUserAsset(user_id, asset_id, delta, data);
}
functionEmitGameUserActivity(stringmemory user_id, stringmemory data) externalisPermissionedUser{
emit GameUserActivity(user_id, data);
}
}
interfaceISCVirtualAssetEventsFactory{
functionpermissions_users(address user) externalviewreturns (bool);
}
/// @title SuperChamps Game Events Logger Factory/// @author Chance Santana-Wees (Coelacanth/Coel.eth)/// @notice Used to deploy game specific events loggers. Tracks users who are permissioned to emit events.contractSCVirtualAssetEventsFactoryisSCPermissionedAccess, ISCVirtualAssetEventsFactory{
mapping(address=>bool) public permissions_users;
mapping(string=> SCVirtualAssetEvents) public game_events;
string[] private _games;
constructor(address permissions_) SCPermissionedAccess(permissions_) { }
functionpermissionUser(address[] memory users, bool state) externalisSystemsAdmin{
uint256 len = users.length;
for(uint256 i =0; i < len; i++) {
permissions_users[users[i]] = state;
}
}
functiondeployGameEvents(stringmemory game_id) externalisSystemsAdmin{
require(game_events[game_id] == SCVirtualAssetEvents(address(0)), "GAME EXISTS");
game_events[game_id] =new SCVirtualAssetEvents(this, game_id);
_games.push(game_id);
}
functiongames() externalviewreturns (string[] memory _games_) {
uint len = _games.length;
_games_ =newstring[](len);
for(uint i =0; i < len; i++) {
_games_[i] = _games[i];
}
}
}