Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ERC173/ERC173.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract ERC173Facet {
/// @notice Returns a pointer to the ERC-173 storage struct.
/// @dev Uses inline assembly to access the storage slot defined by STORAGE_POSITION.
/// @return s The ERC173Storage struct in storage.
function getStorage() internal pure returns (ERC173Storage storage s) {
function _getStorage() internal pure returns (ERC173Storage storage s) {
bytes32 position = STORAGE_POSITION;
assembly {
s.slot := position
Expand All @@ -29,14 +29,14 @@ contract ERC173Facet {
/// @notice Get the address of the owner
/// @return The address of the owner.
function owner() external view returns (address) {
return getStorage().owner;
return _getStorage().owner;
}

/// @notice Set the address of the new owner of the contract
/// @dev Set _newOwner to address(0) to renounce any ownership.
/// @param _newOwner The address of the new owner of the contract
function transferOwnership(address _newOwner) external {
ERC173Storage storage s = getStorage();
ERC173Storage storage s = _getStorage();
if (msg.sender != s.owner) revert OwnableUnauthorizedAccount();
address previousOwner = s.owner;
s.owner = _newOwner;
Expand Down
10 changes: 5 additions & 5 deletions src/ERC173/libraries/LibERC173.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library LibERC173 {
/// @notice Returns a pointer to the ERC-173 storage struct.
/// @dev Uses inline assembly to access the storage slot defined by STORAGE_POSITION.
/// @return s The ERC173Storage struct in storage.
function getStorage() internal pure returns (ERC173Storage storage s) {
function _getStorage() internal pure returns (ERC173Storage storage s) {
bytes32 position = STORAGE_POSITION;
assembly {
s.slot := position
Expand All @@ -28,15 +28,15 @@ library LibERC173 {

/// @notice Get the address of the owner
/// @return The address of the owner.
function owner() internal view returns (address) {
return getStorage().owner;
function _owner() internal view returns (address) {
return _getStorage().owner;
}

/// @notice Set the address of the new owner of the contract
/// @dev Set _newOwner to address(0) to renounce any ownership.
/// @param _newOwner The address of the new owner of the contract
function transferOwnership(address _newOwner) internal {
ERC173Storage storage s = getStorage();
function _transferOwnership(address _newOwner) internal {
ERC173Storage storage s = _getStorage();
if (s.owner == address(0)) revert OwnableAlreadyRenounced();
address previousOwner = s.owner;
s.owner = _newOwner;
Expand Down
36 changes: 24 additions & 12 deletions src/ERC20/ERC20/ERC20Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract ERC20Facet {
* @dev Uses inline assembly to set the storage slot reference.
* @return s The ERC20 storage struct reference.
*/
function getStorage() internal pure returns (ERC20Storage storage s) {
function _getStorage() internal pure returns (ERC20Storage storage s) {
bytes32 position = STORAGE_POSITION;
assembly {
s.slot := position
Expand All @@ -84,31 +84,31 @@ contract ERC20Facet {
* @return The token name.
*/
function name() external view returns (string memory) {
return getStorage().name;
return _getStorage().name;
}

/**
* @notice Returns the symbol of the token.
* @return The token symbol.
*/
function symbol() external view returns (string memory) {
return getStorage().symbol;
return _getStorage().symbol;
}

/**
* @notice Returns the number of decimals used for token precision.
* @return The number of decimals.
*/
function decimals() external view returns (uint8) {
return getStorage().decimals;
return _getStorage().decimals;
}

/**
* @notice Returns the total supply of tokens.
* @return The total token supply.
*/
function totalSupply() external view returns (uint256) {
return getStorage().totalSupply;
return _getStorage().totalSupply;
}

/**
Expand All @@ -117,7 +117,7 @@ contract ERC20Facet {
* @return The account balance.
*/
function balanceOf(address _account) external view returns (uint256) {
return getStorage().balanceOf[_account];
return _getStorage().balanceOf[_account];
}

/**
Expand All @@ -127,7 +127,7 @@ contract ERC20Facet {
* @return The remaining allowance.
*/
function allowance(address _owner, address _spender) external view returns (uint256) {
return getStorage().allowances[_owner][_spender];
return _getStorage().allowances[_owner][_spender];
}

/**
Expand All @@ -138,7 +138,11 @@ contract ERC20Facet {
* @return True if the approval was successful.
*/
function approve(address _spender, uint256 _value) external returns (bool) {
<<<<<<< HEAD
ERC20Storage storage s = _getStorage();
=======
ERC20Storage storage s = getStorage();
>>>>>>> upstream/main
if (_spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
Expand All @@ -155,7 +159,11 @@ contract ERC20Facet {
* @return True if the transfer was successful.
*/
function transfer(address _to, uint256 _value) external returns (bool) {
<<<<<<< HEAD
ERC20Storage storage s = _getStorage();
=======
ERC20Storage storage s = getStorage();
>>>>>>> upstream/main
if (_to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
Expand All @@ -180,7 +188,11 @@ contract ERC20Facet {
* @return True if the transfer was successful.
*/
function transferFrom(address _from, address _to, uint256 _value) external returns (bool) {
<<<<<<< HEAD
ERC20Storage storage s = _getStorage();
=======
ERC20Storage storage s = getStorage();
>>>>>>> upstream/main
if (_from == address(0)) {
revert ERC20InvalidSender(address(0));
}
Expand Down Expand Up @@ -210,7 +222,7 @@ contract ERC20Facet {
* @param _value The amount of tokens to burn.
*/
function burn(uint256 _value) external {
ERC20Storage storage s = getStorage();
ERC20Storage storage s = _getStorage();
uint256 balance = s.balanceOf[msg.sender];
if (balance < _value) {
revert ERC20InsufficientBalance(msg.sender, balance, _value);
Expand All @@ -229,7 +241,7 @@ contract ERC20Facet {
* @param _value The amount of tokens to burn.
*/
function burnFrom(address _account, uint256 _value) external {
ERC20Storage storage s = getStorage();
ERC20Storage storage s = _getStorage();
uint256 currentAllowance = s.allowances[_account][msg.sender];
if (currentAllowance < _value) {
revert ERC20InsufficientAllowance(msg.sender, currentAllowance, _value);
Expand All @@ -255,7 +267,7 @@ contract ERC20Facet {
* @return The current nonce.
*/
function nonces(address _owner) external view returns (uint256) {
return getStorage().nonces[_owner];
return _getStorage().nonces[_owner];
}

/**
Expand All @@ -267,7 +279,7 @@ contract ERC20Facet {
return keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(getStorage().name)),
keccak256(bytes(_getStorage().name)),
keccak256("1"),
block.chainid,
address(this)
Expand Down Expand Up @@ -302,7 +314,7 @@ contract ERC20Facet {
revert ERC2612InvalidSignature(_owner, _spender, _value, _deadline, _v, _r, _s);
}

ERC20Storage storage s = getStorage();
ERC20Storage storage s = _getStorage();
uint256 currentNonce = s.nonces[_owner];
bytes32 structHash = keccak256(
abi.encode(
Expand Down
26 changes: 17 additions & 9 deletions src/ERC20/ERC20/libraries/LibERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ library LibERC20 {
/// @notice Returns a pointer to the ERC-20 storage struct.
/// @dev Uses inline assembly to bind the storage struct to the fixed storage position.
/// @return s The ERC-20 storage struct.
function getStorage() internal pure returns (ERC20Storage storage s) {
function _getStorage() internal pure returns (ERC20Storage storage s) {
bytes32 position = STORAGE_POSITION;
assembly {
s.slot := position
Expand All @@ -70,8 +70,8 @@ library LibERC20 {
/// @dev Increases both total supply and the recipient's balance.
/// @param _account The address receiving the newly minted tokens.
/// @param _value The number of tokens to mint.
function mint(address _account, uint256 _value) internal {
ERC20Storage storage s = getStorage();
function _mint(address _account, uint256 _value) internal {
ERC20Storage storage s = _getStorage();
if (_account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
Expand All @@ -84,8 +84,8 @@ library LibERC20 {
/// @dev Decreases both total supply and the sender's balance.
/// @param _account The address whose tokens will be burned.
/// @param _value The number of tokens to burn.
function burn(address _account, uint256 _value) internal {
ERC20Storage storage s = getStorage();
function _burn(address _account, uint256 _value) internal {
ERC20Storage storage s = _getStorage();
if (_account == address(0)) {
revert ERC20InvalidSender(address(0));
}
Expand All @@ -105,8 +105,8 @@ library LibERC20 {
/// @param _from The address to send tokens from.
/// @param _to The address to send tokens to.
/// @param _value The number of tokens to transfer.
function transferFrom(address _from, address _to, uint256 _value) internal {
ERC20Storage storage s = getStorage();
function _transferFrom(address _from, address _to, uint256 _value) internal {
ERC20Storage storage s = _getStorage();
if (_from == address(0)) {
revert ERC20InvalidSender(address(0));
}
Expand All @@ -133,8 +133,8 @@ library LibERC20 {
/// @dev Updates balances directly without allowance mechanism.
/// @param _to The address to send tokens to.
/// @param _value The number of tokens to transfer.
function transfer(address _to, uint256 _value) internal {
ERC20Storage storage s = getStorage();
function _transfer(address _to, uint256 _value) internal {
ERC20Storage storage s = _getStorage();
if (_to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
Expand All @@ -153,11 +153,19 @@ library LibERC20 {
/// @dev Sets the allowance for the spender.
/// @param _spender The address to approve for spending.
/// @param _value The amount of tokens to approve.
<<<<<<< HEAD
function _approve(address _spender, uint256 _value) internal {
if ( _spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
ERC20Storage storage s = _getStorage();
=======
function approve(address _spender, uint256 _value) internal {
if (_spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
ERC20Storage storage s = getStorage();
>>>>>>> upstream/main
s.allowances[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
}
Expand Down
Loading