Skip to content

Commit

Permalink
Merge pull request #128 from skalenetwork/bug/SKALE-2353-token
Browse files Browse the repository at this point in the history
SKALE-2353 Change ReentrancyGuard to not allow to delegate burning tokens
  • Loading branch information
DimaStebaev authored Apr 6, 2020
2 parents f8341f1 + c30cafc commit d8f1e9f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions contracts/ERC777/LockableERC777.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract LockableERC777 is IERC777, IERC20 /* Added by SKALE */, ReentrancyGuard
*
* Also emits a `Sent` event.
*/
function transfer(address recipient, uint256 amount) external /* Added by SKALE */ nonReentrant /* End of added by SKALE */ returns (bool) {
function transfer(address recipient, uint256 amount) external returns (bool) {
require(recipient != address(0), "ERC777: transfer to the zero address");

address from = msg.sender;
Expand Down Expand Up @@ -207,7 +207,7 @@ contract LockableERC777 is IERC777, IERC20 /* Added by SKALE */, ReentrancyGuard
*
* Emits `Sent` and `Transfer` events.
*/
function transferFrom(address holder, address recipient, uint256 amount) external /* Added by SKALE */ nonReentrant /*End*/ returns (bool) {
function transferFrom(address holder, address recipient, uint256 amount) external returns (bool) {
require(recipient != address(0), "ERC777: transfer to the zero address");
require(holder != address(0), "ERC777: transfer from the zero address");

Expand Down Expand Up @@ -373,7 +373,6 @@ contract LockableERC777 is IERC777, IERC20 /* Added by SKALE */, ReentrancyGuard
bool requireReceptionAck
)
private
/* Added by SKALE */ nonReentrant /* End of added by SKALE */
{
require(from != address(0), "ERC777: send from the zero address");
require(to != address(0), "ERC777: send to the zero address");
Expand Down Expand Up @@ -409,17 +408,18 @@ contract LockableERC777 is IERC777, IERC20 /* Added by SKALE */, ReentrancyGuard
private
{
require(from != address(0), "ERC777: burn from the zero address");

_callTokensToSend(
operator, from, address(0), amount, data, operatorData
);

// Added by SKALE----------------------------------------------------------
uint locked = _getAndUpdateLockedAmount(from);
if (locked > 0) {
require(_balances[from] >= locked.add(amount), "Token should be unlocked for burning");
}
//-------------------------------------------------------------------------

_callTokensToSend(
operator, from, address(0), amount, data, operatorData
);

// Update state variables
_totalSupply = _totalSupply.sub(amount);
_balances[from] = _balances[from].sub(amount);
Expand Down Expand Up @@ -483,6 +483,7 @@ contract LockableERC777 is IERC777, IERC20 /* Added by SKALE */, ReentrancyGuard
bytes memory operatorData
)
private
/* Added by SKALE */ nonReentrant /* End of added by SKALE */
{
address implementer = _erc1820.getInterfaceImplementer(from, TOKENS_SENDER_INTERFACE_HASH);
if (implementer != address(0)) {
Expand Down Expand Up @@ -513,6 +514,7 @@ contract LockableERC777 is IERC777, IERC20 /* Added by SKALE */, ReentrancyGuard
bool requireReceptionAck
)
private
/* Added by SKALE */ nonReentrant /* End of added by SKALE */
{
address implementer = _erc1820.getInterfaceImplementer(to, TOKENS_RECIPIENT_INTERFACE_HASH);
if (implementer != address(0)) {
Expand Down

0 comments on commit d8f1e9f

Please sign in to comment.