From c4987bef735826ab2633795fcb05ae3bacbd6f4f Mon Sep 17 00:00:00 2001 From: aapsi Date: Mon, 20 Oct 2025 19:37:13 +0530 Subject: [PATCH 1/2] ERC20: return bool from transfer/transferFrom/approve (EIP-20) --- src/ERC20/ERC20/ERC20Facet.sol | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ERC20/ERC20/ERC20Facet.sol b/src/ERC20/ERC20/ERC20Facet.sol index 366eea28..56809f6a 100644 --- a/src/ERC20/ERC20/ERC20Facet.sol +++ b/src/ERC20/ERC20/ERC20Facet.sol @@ -140,13 +140,14 @@ contract ERC20Facet { * @param _spender The address approved to spend tokens. * @param _value The number of tokens to approve. */ - function approve(address _spender, uint256 _value) external { + function approve(address _spender, uint256 _value) external returns (bool) { ERC20Storage storage s = getStorage(); if (_spender == address(0)) { revert ERC20InvalidSpender(address(0)); } s.allowances[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); + return true; } /** @@ -155,7 +156,7 @@ contract ERC20Facet { * @param _to The address to receive the tokens. * @param _value The amount of tokens to transfer. */ - function transfer(address _to, uint256 _value) external { + function transfer(address _to, uint256 _value) external returns (bool) { ERC20Storage storage s = getStorage(); if (_to == address(0)) { revert ERC20InvalidReceiver(address(0)); @@ -169,6 +170,7 @@ contract ERC20Facet { s.balanceOf[_to] += _value; } emit Transfer(msg.sender, _to, _value); + return true; } /** @@ -178,7 +180,7 @@ contract ERC20Facet { * @param _to The address to transfer tokens to. * @param _value The amount of tokens to transfer. */ - function transferFrom(address _from, address _to, uint256 _value) external { + function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { ERC20Storage storage s = getStorage(); if (_from == address(0)) { revert ERC20InvalidSender(address(0)); @@ -200,6 +202,7 @@ contract ERC20Facet { s.balanceOf[_to] += _value; } emit Transfer(_from, _to, _value); + return true; } /** From d89ec9e18df4c30b2d8cc8f6e53a42c949f00276 Mon Sep 17 00:00:00 2001 From: aapsi Date: Mon, 20 Oct 2025 20:14:54 +0530 Subject: [PATCH 2/2] update the NatSpec comments to incorporate the bool return --- src/ERC20/ERC20/ERC20Facet.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ERC20/ERC20/ERC20Facet.sol b/src/ERC20/ERC20/ERC20Facet.sol index 56809f6a..d6dfaca7 100644 --- a/src/ERC20/ERC20/ERC20Facet.sol +++ b/src/ERC20/ERC20/ERC20Facet.sol @@ -139,6 +139,7 @@ contract ERC20Facet { * @dev Emits an {Approval} event. * @param _spender The address approved to spend tokens. * @param _value The number of tokens to approve. + * @return True if the approval was successful. */ function approve(address _spender, uint256 _value) external returns (bool) { ERC20Storage storage s = getStorage(); @@ -155,6 +156,7 @@ contract ERC20Facet { * @dev Emits a {Transfer} event. * @param _to The address to receive the tokens. * @param _value The amount of tokens to transfer. + * @return True if the transfer was successful. */ function transfer(address _to, uint256 _value) external returns (bool) { ERC20Storage storage s = getStorage(); @@ -179,6 +181,7 @@ contract ERC20Facet { * @param _from The address to transfer tokens from. * @param _to The address to transfer tokens to. * @param _value The amount of tokens to transfer. + * @return True if the transfer was successful. */ function transferFrom(address _from, address _to, uint256 _value) external returns (bool) { ERC20Storage storage s = getStorage();