From 1241efedc6e16d1d686f950a917b058b63c7a958 Mon Sep 17 00:00:00 2001 From: Pranay Valson Date: Tue, 3 Dec 2024 16:11:06 +0530 Subject: [PATCH] remove redundant var; reset redeemables for all tokens Signed-off-by: Pranay Valson --- contracts/EwmNftController.sol | 7 +------ test/unit/controller/rewardRedeem.js | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/contracts/EwmNftController.sol b/contracts/EwmNftController.sol index a0a86f0..8f6f836 100644 --- a/contracts/EwmNftController.sol +++ b/contracts/EwmNftController.sol @@ -437,7 +437,6 @@ contract EwmNftController is Ownable2StepUpgradeable, ERC721EnumerableUpgradeabl uint256[] memory tokenIds = tokenIdsOfOwnerByAmount(msg.sender, totalTokens); uint256 totalRedeemable = 0; - uint256 validTokenCount = 0; for (uint256 i = 0; i < tokenIds.length; i++) { uint256 tokenId = tokenIds[i]; @@ -445,7 +444,6 @@ contract EwmNftController is Ownable2StepUpgradeable, ERC721EnumerableUpgradeabl if (redeemable > 0) { totalRedeemable += redeemable; - validTokenCount++; } } @@ -464,10 +462,7 @@ contract EwmNftController is Ownable2StepUpgradeable, ERC721EnumerableUpgradeabl ) internal { for (uint256 i = 0; i < tokenIds.length; i++) { UserInfo storage info = _users[tokenIds[i]]; - address currentUser = userOf(tokenIds[i]); - if (currentUser != address(0)) { - info.redeemable = 0; // Reset redeemable amount only for non-expired tokens - } + info.redeemable = 0; // Reset redeemable amount for all tokens } _transferFromContract(owner, totalRedeemable); diff --git a/test/unit/controller/rewardRedeem.js b/test/unit/controller/rewardRedeem.js index 3bcb860..7b5e88c 100644 --- a/test/unit/controller/rewardRedeem.js +++ b/test/unit/controller/rewardRedeem.js @@ -242,7 +242,7 @@ describe('EwmNftController - Redeem Rewards', () => { // Attempt to redeem rewards await expect(controllerContract.connect(holder).redeemRewards()) .to.emit(controllerContract, 'EventRewardsRedeemed') - .withArgs(holder.address, REWARD_REDEEM_THRESHOLD.mul(3)); + .withArgs(holder.address, REWARD_REDEEM_THRESHOLD.mul(1)); const finalUserInfo = await controllerContract.getUserInfo(9); // console.log('Final User Info:', finalUserInfo);