The `call` function calculates the dealer's hand, then compares it to the player's to determine the winner. After getting the winner, the function calls `endGame` which resets the state variables and transfers ether to the player if they win. If this transfer fails, the entire transaction would revert including the player's win, causing them to miss out on their payout.
Proof of Concept:
A player starts a game and gets their cards.
They choose to call immediately. They are lucky and win.
Due to unknown circumstances the transfer of their payout fails.
The entire transaction reverts, including their win.
The player has to call again and bear the risk of losing.
Place the below code into TwentyOneTest
in TwentyOne.t.sol
Players would lose their win if endGame
reverts, causing them to have to risk losing again by re-calling call
.
Foundry
Consider using a mapping to track player wins separately and use a different function for players to claim their wins manually.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.