k26dr / ethereum-games

The official code repo for the book Building Games with Ethereum Smart Contracts
64 stars 35 forks source link

CasinoRoulette issues #9

Open ferencdg opened 3 years ago

ferencdg commented 3 years ago

I think there are 2 smaller problems with this contract:

  1. it seems you allow 38 different numbers, but a roulette only has 37 numbers: https://github.com/k26dr/ethereum-games/blob/3128272012f7dc6678332533aa97bad29411ba62/contracts/Gambling.sol#L114

  2. you don't have any checks on the type of the bet here: https://github.com/k26dr/ethereum-games/blob/3128272012f7dc6678332533aa97bad29411ba62/contracts/Gambling.sol#L113

however you do check the type here: https://github.com/k26dr/ethereum-games/blob/3128272012f7dc6678332533aa97bad29411ba62/contracts/Gambling.sol#L133

this can cause bets accidentally submitted invalid BetTypes like 3 or 4 to be permanently stuck

Anyway, it was a great book overal, thank you!