@@ -21,8 +21,9 @@ contract ZamaERC20 is ERC20, ERC20Permit, ERC1363, ERC20Burnable, AccessControl,
2121 event ERC20Recovered (address indexed token , address indexed recipient , uint256 amount );
2222 event ERC721Recovered (address indexed token , uint256 tokenId , address indexed recipient );
2323
24- error FailedToSendEther ();
2524 error AmountsReceiversLengthMismatch ();
25+ error FailedToSendEther ();
26+ error InvalidNullRecipient ();
2627
2728 /**
2829 * @param name Name of the token.
@@ -79,10 +80,11 @@ contract ZamaERC20 is ERC20, ERC20Permit, ERC1363, ERC20Burnable, AccessControl,
7980 /**
8081 * @dev Allows the sender to recover Ether held by the contract.
8182 * @param amount Amount of recovered ETH.
82- * @param recipient Receiver of the recovered ETH.
83+ * @param recipient Receiver of the recovered ETH, should be non-null .
8384 * @dev Emits an EtherRecovered event upon success.
8485 */
8586 function recoverEther (uint256 amount , address recipient ) external onlyRole (DEFAULT_ADMIN_ROLE) {
87+ if (recipient == address (0 )) revert InvalidNullRecipient ();
8688 (bool success , ) = recipient.call { value: amount }("" );
8789 if (! success) {
8890 revert FailedToSendEther ();
@@ -94,10 +96,11 @@ contract ZamaERC20 is ERC20, ERC20Permit, ERC1363, ERC20Burnable, AccessControl,
9496 * @dev Allows the sender to recover ERC20 tokens held by the contract.
9597 * @param token The address of the ERC20 token to recover.
9698 * @param amount The amount of the ERC20 token to recover.
97- * @param recipient Receiver of the recovered tokens.
99+ * @param recipient Receiver of the recovered tokens, should be non-null .
98100 * @dev Emits an ERC20Recovered event upon success.
99101 */
100102 function recoverERC20 (address token , uint256 amount , address recipient ) external onlyRole (DEFAULT_ADMIN_ROLE) {
103+ if (recipient == address (0 )) revert InvalidNullRecipient ();
101104 IERC20 (token).safeTransfer (recipient, amount);
102105 emit ERC20Recovered (token, recipient, amount);
103106 }
@@ -106,10 +109,11 @@ contract ZamaERC20 is ERC20, ERC20Permit, ERC1363, ERC20Burnable, AccessControl,
106109 * @dev Allows the sender to recover ERC721 tokens held by the contract.
107110 * @param token The address of the ERC721 token to recover.
108111 * @param tokenId The token ID of the ERC721 token to recover.
109- * @param recipient Receiver of the recovered ERC721 token.
112+ * @param recipient Receiver of the recovered ERC721 token, should be non-null .
110113 * @dev Emits an ERC721Recovered event upon success.
111114 */
112115 function recoverERC721 (address token , uint256 tokenId , address recipient ) external onlyRole (DEFAULT_ADMIN_ROLE) {
116+ if (recipient == address (0 )) revert InvalidNullRecipient ();
113117 IERC721 (token).safeTransferFrom (address (this ), recipient, tokenId);
114118 emit ERC721Recovered (token, tokenId, recipient);
115119 }
0 commit comments