Open skosito opened 4 months ago
Here we're assuming token is an ERC20 compliant address always. To code this defensively we'd check always if it's a token contract.
Also we need to check if to != address(0).
function isERC20(address token) internal view returns (bool) { return token.code.length > 0 && IERC20(token).totalSupply() > 0; } function withdrawAndRevert(address token, address to, uint256 amount, bytes calldata data) public nonReentrant { require(isERC20(token), "Provided address is not an ERC20 token"); require(token != address(0), "Provided address is invalid"); IERC20(token).safeTransfer(address(gateway), amount);
_Originally posted by @fbac in https://github.com/zeta-chain/protocol-contracts/pull/217#discussion_r1682561476_
Also we need to check if to != address(0).
_Originally posted by @fbac in https://github.com/zeta-chain/protocol-contracts/pull/217#discussion_r1682561476_