Skip to content

Commit

Permalink
refactor: remove user parent relationship code
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-fruitful committed Mar 13, 2024
1 parent 05774fb commit 5d44750
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
19 changes: 15 additions & 4 deletions src/facets/NaymsTokenFacet.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import { LibNaymsToken } from "../libs/LibNaymsToken.sol";
import { AppStorage, LibAppStorage } from "../shared/AppStorage.sol";
import { Modifiers } from "../shared/Modifiers.sol";
import { LibConstants as LC } from "src/libs/LibConstants.sol";
import { LibHelpers } from "../libs/LibHelpers.sol";
import { LibNaymsToken } from "../libs/LibNaymsToken.sol";

/**
* @title Nayms token facet.
* @notice Use it to access and manipulate Nayms token.
* @dev Use it to access and manipulate Nayms token.
*/

contract NaymsTokenFacet {
contract NaymsTokenFacet is Modifiers {
using LibHelpers for *;
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/

error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

/**
Expand Down Expand Up @@ -117,7 +122,13 @@ contract NaymsTokenFacet {
* @param _to The address to which the minted tokens will be sent.
* @param _amount The amount of tokens to mint.
*/
function mint(address _to, uint256 _amount) external /*onlyMinter*/ {
function mint(
address _to,
uint256 _amount
)
external
assertPrivilege(LC.ROLE_MINTER._stringToBytes32(), LC.GROUP_MINTERS)
{
_mint(_to, _amount);
}

Expand Down
7 changes: 0 additions & 7 deletions src/libs/LibACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.20;
import { AppStorage, LibAppStorage } from "../shared/AppStorage.sol";
import { LibDiamond } from "lib/diamond-2-hardhat/contracts/libraries/LibDiamond.sol";
import { LibHelpers } from "./LibHelpers.sol";
import { LibObject } from "./LibObject.sol";
import { LibConstants as LC } from "./LibConstants.sol";

library LibACL {
Expand Down Expand Up @@ -101,11 +100,6 @@ library LibACL {
return false;
}

function _isParentInGroup(bytes32 _objectId, bytes32 _contextId, bytes32 _groupId) internal view returns (bool) {
bytes32 parentId = LibObject._getParent(_objectId);
return _isInGroup(parentId, _contextId, _groupId);
}

/**
* @notice Checks if assigner has the authority to assign object to a role in given context
* @dev Any object ID can be a context, system is a special context with highest priority
Expand Down Expand Up @@ -142,7 +136,6 @@ library LibACL {
}

function _hasGroupPrivilege(bytes32 _userId, bytes32 _contextId, bytes32 _groupId) internal view returns (bool) {
if (_isParentInGroup(_userId, _contextId, _groupId)) return true;
if (_isInGroup(_userId, _contextId, _groupId)) return true;
if (_isInGroup(_userId, LC.SYSTEM_IDENTIFIER_BYTES32, _groupId)) return true;
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/libs/LibConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ library LibConstants {
string internal constant ROLE_ENTITY_COMPTROLLER_CLAIM = "Comptroller Claim";
string internal constant ROLE_ENTITY_COMPTROLLER_DIVIDEND = "Comptroller Dividend";

string internal constant ROLE_MINTER = "Minter";

/// old roles

string internal constant ROLE_SPONSOR = "Sponsor";
Expand Down Expand Up @@ -101,4 +103,5 @@ library LibConstants {
string internal constant GROUP_SERVICE_PROVIDERS = "Service Providers";
string internal constant GROUP_ONBOARDING_APPROVERS = "Onboarding Approvers";
string internal constant GROUP_TOKEN_HOLDERS = "Token Holders";
string internal constant GROUP_MINTERS = "Minters";
}

0 comments on commit 5d44750

Please sign in to comment.