Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add low funds warn + update game init flow #16

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

rccsousa
Copy link
Collaborator

@rccsousa rccsousa commented Nov 6, 2024

Why

Builds up on #15 , which mentions the required player workflow:

  1. if the user has enough credits and can play; (TBA);
  2. if the user has already played today; (TBA);
  3. if the user has approved Wordle3 to spend WDT on his/her behalf;

How

By implementing 2 new modals/warns: LowFunds and AlreadyPlayed.

  • AlreadyPlayed just shows up to mention the player cannot init more games today.
  • LowFunds warns the player that more funds are required to play Wordle3 and prompts the user to use the faucet.

This PR also includes changes to the rendering logic, completely hiding the game board if the player is not actively playing and once the game initializes, omits the Play button.

Demo

demo.mp4


// Gets the current account's WDT balance, eligibility to play, player attempts, guesses and alphabet.
// this is constantly pinging the network, so i'm unsure if this is the right way to go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by constantly do you mean whenever the account changes or a user makes a guess, right? If so, that's ok, you need to refetch some data when that happens. It would be an issue if it was fetching on every single state update

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When useEffect is checking for changes on playerGuesses, the eth.call requests start pouring.
It makes sense but does not seem the best option, I'm considering moving the guess checking to the guess handler so it refreshes only on guess submission instead of having a useEffect hook.

@rccsousa rccsousa merged commit 08ca013 into rs/add-approval-workflow Nov 7, 2024
2 checks passed
@rccsousa rccsousa deleted the rs/add-low-funds-warn branch November 7, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants