diff --git a/src/facets/NaymsTokenFacet.sol b/src/facets/NaymsTokenFacet.sol index 28fdfcd..2fa8e9b 100644 --- a/src/facets/NaymsTokenFacet.sol +++ b/src/facets/NaymsTokenFacet.sol @@ -3,7 +3,6 @@ pragma solidity 0.8.24; 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"; @@ -92,18 +91,7 @@ contract NaymsTokenFacet is Modifiers { } function approve(address spender, uint256 amount) external returns (bool) { - AppStorage storage s = LibAppStorage.diamondStorage(); - - if (msg.sender == address(0)) { - revert ERC20InvalidApprover(address(0)); - } - if (spender == address(0)) { - revert ERC20InvalidSpender(address(0)); - } - - s.allowance[msg.sender][spender] = amount; - - emit Approval(msg.sender, spender, amount); + _approve(msg.sender, spender, amount, true); return true; } @@ -266,6 +254,9 @@ contract NaymsTokenFacet is Modifiers { } } + /** + * @dev Returns the address who has permissions to mint. + */ function minter() external view returns (address) { AppStorage storage s = LibAppStorage.diamondStorage(); return s.minter; diff --git a/src/shared/AppStorage.sol b/src/shared/AppStorage.sol index 1530a17..475588e 100644 --- a/src/shared/AppStorage.sol +++ b/src/shared/AppStorage.sol @@ -3,24 +3,14 @@ pragma solidity 0.8.24; /// @notice storage for NAYM coin -// solhint-disable no-global-import -import "./FreeStructs.sol"; - struct AppStorage { - // Has this diamond been initialized? + //// Has this diamond been initialized? //// bool diamondInitialized; - //// EIP712 domain separator //// - uint256 initialChainId; - bytes32 initialDomainSeparator; - //// Reentrancy guard //// - uint256 reentrancyStatus; //// NAYMS ERC20 TOKEN //// - string name; mapping(address account => mapping(address spender => uint256)) allowance; uint256 totalSupply; - mapping(bytes32 objectId => bool isInternalToken) internalToken; mapping(address account => uint256) balances; - /// Simple two phase upgrade scheme + //// Simple two phase upgrade scheme //// mapping(bytes32 upgradeId => uint256 timestamp) upgradeScheduled; // id of the upgrade => the time that the upgrade // is valid until. uint256 upgradeExpiration; // the period of time that an upgrade is valid until. @@ -31,10 +21,10 @@ struct AppStorage { } library LibAppStorage { - bytes32 internal constant NAYMS_DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.nayms.storage"); + bytes32 internal constant NAYM_DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.naym.storage"); function diamondStorage() internal pure returns (AppStorage storage ds) { - bytes32 position = NAYMS_DIAMOND_STORAGE_POSITION; + bytes32 position = NAYM_DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } diff --git a/test/NaymToken.t.sol b/test/NaymToken.t.sol index 9f79d9e..08fceb6 100644 --- a/test/NaymToken.t.sol +++ b/test/NaymToken.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPLv3 -pragma solidity ^0.8.20; +pragma solidity 0.8.24; import { Test, console as c, Vm } from "forge-std/Test.sol"; @@ -12,12 +12,9 @@ import { IDiamondProxy } from "src/generated/IDiamondProxy.sol"; import { LibDiamondHelper } from "src/generated/LibDiamondHelper.sol"; import { LibGovernance } from "src/libs/LibGovernance.sol"; import { LibACL } from "src/libs/LibACL.sol"; -import { LibHelpers } from "src/libs/LibHelpers.sol"; import { InitDiamond } from "src/init/InitDiamond.sol"; -import { NaymsTokenFacet } from "src/facets/NaymsTokenFacet.sol"; import { Modifiers } from "src/shared/Modifiers.sol"; import { StdStyle } from "forge-std/StdStyle.sol"; -import { LibConstants as LC } from "src/libs/LibConstants.sol"; contract NaymTokenTest is Test { using StdStyle for *;