0xFable icon indicating copy to clipboard operation
0xFable copied to clipboard

Bring custom decks onchain

Open eviterin opened this issue 1 year ago • 2 comments

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 avatar Jan 14 '24 17:01 eviterin

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.

eviterin avatar Jan 14 '24 17:01 eviterin

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!

norswap avatar Jan 14 '24 23:01 norswap