From 5d4475053827a184e7b02510c74c4a637042fa25 Mon Sep 17 00:00:00 2001 From: Kevin Park Date: Wed, 13 Mar 2024 17:58:25 +0700 Subject: [PATCH] refactor: remove user parent relationship code --- src/facets/NaymsTokenFacet.sol | 19 +++++++++++++++---- src/libs/LibACL.sol | 7 ------- src/libs/LibConstants.sol | 3 +++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/facets/NaymsTokenFacet.sol b/src/facets/NaymsTokenFacet.sol index e76ba29..9defc03 100644 --- a/src/facets/NaymsTokenFacet.sol +++ b/src/facets/NaymsTokenFacet.sol @@ -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); /** @@ -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); } diff --git a/src/libs/LibACL.sol b/src/libs/LibACL.sol index 1a3178e..b547e25 100644 --- a/src/libs/LibACL.sol +++ b/src/libs/LibACL.sol @@ -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 { @@ -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 @@ -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; diff --git a/src/libs/LibConstants.sol b/src/libs/LibConstants.sol index dc770d3..25bfbbc 100644 --- a/src/libs/LibConstants.sol +++ b/src/libs/LibConstants.sol @@ -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"; @@ -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"; }