diff --git a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol index 3d19010..8bc5e81 100644 --- a/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol +++ b/packages/zevm-app-contracts/contracts/instant-rewards/InstantRewards.sol @@ -30,6 +30,7 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { error InvalidSigner(); error InvalidAddress(); error TaskAlreadyClaimed(); + error TransferFailed(); constructor(address signerAddress_, address owner) Ownable() { if (signerAddress_ == address(0)) revert InvalidAddress(); @@ -37,28 +38,6 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { signerAddress = signerAddress_; } - // Helper function to convert uint to string - function _uint2str(uint _i) internal pure returns (string memory _uintAsString) { - if (_i == 0) { - return "0"; - } - uint j = _i; - uint len; - while (j != 0) { - len++; - j /= 10; - } - bytes memory bstr = new bytes(len); - uint k = len; - while (_i != 0) { - k = k - 1; - uint8 temp = (uint8(48 + (_i % 10))); - bstr[k] = bytes1(temp); - _i /= 10; - } - return string(bstr); - } - function _verify(ClaimData memory claimData) private view { bytes32 payloadHash = _calculateHash(claimData); @@ -89,7 +68,8 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { taskCompletedByUser[claimData.to][claimData.taskId] = true; - payable(claimData.to).transfer(claimData.amount); + (bool success, ) = claimData.to.call{value: claimData.amount}(""); + if (!success) revert TransferFailed(); emit Claimed(claimData.to, claimData.taskId, claimData.amount); } @@ -100,6 +80,7 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { } function withdraw(address wallet) external onlyOwner { + if (wallet == address(0)) revert InvalidAddress(); payable(wallet).transfer(address(this).balance); }