Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-fruitful committed Mar 15, 2024
1 parent a02dacb commit 758fd10
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
17 changes: 4 additions & 13 deletions src/facets/NaymsTokenFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 4 additions & 14 deletions src/shared/AppStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down
5 changes: 1 addition & 4 deletions test/NaymToken.t.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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 *;
Expand Down

0 comments on commit 758fd10

Please sign in to comment.