Эх сурвалжийг харах

Deprecate SafeERC20.safeApprove (#2268)

* Deprecate SafeERC20.safeApprove

* Add changelog entry
Nicolás Venturo 5 жил өмнө
parent
commit
d3ef93a9a5

+ 3 - 0
CHANGELOG.md

@@ -10,6 +10,9 @@
  * `AccessControl`: added a `RoleAdminChanged` event to `_setAdminRole`. ([#2214](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2214))
  * Made all `public` functions in the token preset contracts `virtual`. ([#2257](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2257))
 
+### Deprecations
+ * `SafeERC20`: deprecated `safeApprove`. ([#2268](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2268))
+
 ## 3.0.1 (2020-04-27)
 
 ### Bugfixes

+ 7 - 0
contracts/token/ERC20/SafeERC20.sol

@@ -27,6 +27,13 @@ library SafeERC20 {
         _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
     }
 
+    /**
+     * @dev Deprecated. This function has issues similar to the ones found in
+     * {IERC20-approve}, and its usage is discouraged.
+     *
+     * Whenever possible, use {safeIncreaseAllowance} and
+     * {safeDecreaseAllowance} instead.
+     */
     function safeApprove(IERC20 token, address spender, uint256 value) internal {
         // safeApprove should only be called when setting an initial allowance,
         // or when resetting it to zero. To increase and decrease it, use