magmo/rps-poc

Challenging on-chain throws error when not the user's turn

Closed this issue · 3 comments

After pressing Challenge on-chain error is: Error: States must have consequetive turn numbers
image

Thanks for taking a look at our app! I'll take a look into this and let you know what I figure out.

@jo-tud I think the issue here is that the app is designed around the idea that a challenge should only be issued when the player is waiting for a bot or another player to respond.

I was able to reproduce this issue by issuing a challenge when it was currently my turn. Challenging while it is the bots turn works ok.

The idea behind Challening on-chain is that if forces the other player to take a move or the game ends. This prevents the other player from stalling / not responding if they don't like how the game is going.

From the application's perspective it doesn't make sense to allow the player to issue a challenge on their turn. Right not we don't handle this gracefully and throw an error when it happens. We should really disable the challenge button (or show a message) when it's not the user's turn.

We're currently working on a major rewrite of the wallet code to make it more robust and handle more of these edge cases. We'll make sure we cover this issue as part of this work. Thanks @jo-tud!