Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

In `RapBattle` wrong condition used in `RapBattle::emit Battle()` while emitting the event `<` is used instead of `<=`. Leading to wrong data emitted

Summary

In RapBattle::emit Battle wrong condition is used to check for winner. it uses if less than < which does not include if random is equal to defenderRapperSkills. This does not correspond with the later logic which include less than or equal. cause lets say when random and defenderRapperSkills are equal the winner emitted by the event will be the challenger instead of defender. whereas the logic while transfering the prize will be the _defender .

Impact

Event emission is incorrect, leading to off-chain functions potentially malfunctioning.

Recommendations

emit Battle(msg.sender, tokenId,
- random < defenderRapperSkill ? _defender : msg.sender);
+ random <= defenderRapperSkill ? _defender : msg.sender);
// the logic here incapulates both less than or equal to unlike the event
if (random <= defenderRapperSkill) {
credToken.transferFrom(msg.sender, _defender, _credBet);
} else {
credToken.transfer(msg.sender, _credBet);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Contradictory battle result event

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.