Skip to content

Commit

Permalink
remove redundant var; reset redeemables for all tokens
Browse files Browse the repository at this point in the history
Signed-off-by: Pranay Valson <pranay.valson@gmail.com>
  • Loading branch information
noslav committed Dec 3, 2024
1 parent a57269d commit 1241efe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions contracts/EwmNftController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,13 @@ 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];
uint256 redeemable = userReedemable(tokenId);

if (redeemable > 0) {
totalRedeemable += redeemable;
validTokenCount++;
}
}

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/controller/rewardRedeem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1241efe

Please sign in to comment.