@@ -360,7 +360,7 @@ contract SuperToken is
360360 if (spender != holder) {
361361 require (amount <= _allowances[holder][spender], "SuperToken: transfer amount exceeds allowance " );
362362 // TODO: this triggers an `Approval` event, which shouldn't happen for transfers.
363- _approve (holder, spender, _allowances[holder][spender] - amount);
363+ _approve (holder, spender, _allowances[holder][spender] - amount, false );
364364 }
365365
366366 return true ;
@@ -504,7 +504,17 @@ contract SuperToken is
504504 * - `account` cannot be the zero address.
505505 * - `spender` cannot be the zero address.
506506 */
507- function _approve (address account , address spender , uint256 amount )
507+ function _approve (address owner , address spender , uint256 value ) internal {
508+ _approve (owner, spender, value, true );
509+ }
510+
511+ /**
512+ * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
513+ *
514+ * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made
515+ * during the `transferFrom` operation set the flag to false.
516+ */
517+ function _approve (address account , address spender , uint256 amount , bool emitEvent )
508518 internal
509519 {
510520 if (account == address (0 )) {
@@ -515,7 +525,10 @@ contract SuperToken is
515525 }
516526
517527 _allowances[account][spender] = amount;
518- emit Approval (account, spender, amount);
528+
529+ if (emitEvent) {
530+ emit Approval (account, spender, amount);
531+ }
519532 }
520533
521534 /**
0 commit comments