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

Bring custom decks onchain #103

Open
eviterin opened this issue Jan 14, 2024 · 2 comments
Open

Bring custom decks onchain #103

eviterin opened this issue Jan 14, 2024 · 2 comments
Assignees

Comments

@eviterin
Copy link
Collaborator

Right now, the deck editor is saving the deck locally in-memory - see webdev/src/_app.tsx. Instead, we would like to save the deck on-chain. There seems to be functionality already in place for this that is being used by contracts/src/DeckAirdrop.sol & webapp/src/hooks/useFableWrite.ts.

It also makes sense for the player to be able to name their decks, but the data structure for a deck is just a set of card - not including a name.

This is done when:

  • The player is able to save their deck onchain from the deck editor.
  • The deck data structure is updated to include a name.
  • The deck is no longer saved locally in _app.tsx and the related "todo" is removed.
  • All the player's decks are loaded and displayed when they navigate to the collection view.
@eviterin
Copy link
Collaborator Author

If someone could assist on the contract side and give some directions on how to hook on to that from the front-end I'd be happy to collab.

@norswap
Copy link
Member

norswap commented Jan 14, 2024

There's two parts: reads and writes.

For writes, you can follow the patterns in the actions package and use libContractWrite.ts to make calls.

For reads, we could a bit of architecturing to avoid excessive data fetches, but let's keep things simple for now. You can use the wagmi autogenerated React hooks, here's an example of such from the collection page.

Regarding which contract functions to call, it's all in the Inventory contract., it should be pretty self-explanatory (addCard, getDeck, etc)

You might need to modify those and the Deck structure to add deck names saved on the blockchain.

Don't hesitate to hit me up if you have any question!

@eviterin eviterin mentioned this issue Mar 8, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants