latticexyz / mud

MUD is a framework for building autonomous worlds
https://mud.dev
MIT License
758 stars 189 forks source link

Solidity watcher/runner package #1217

Open holic opened 1 year ago

holic commented 1 year ago

Chatted with @0xOlias about the need for a generic way to watch Solidity contracts and run some redeploy script/command.

Might be nice to separate our deploy pipeline into a more generic package that has hooks, and then build the MUD-specific stuff on top of it.

typedarray commented 1 year ago

+1. I've observed several folks building full-stack apps using Foundry (usually in a monorepo), and the experience has some rough edges.

Without any additional tooling, the most common workflow seems to be:

  1. Manually reset the anvil instance (ctrl+c)
  2. Run a forge script command to deploy the contracts, e.g. forge script script/01_Deploy.s.sol:Deploy --rpc-url http://127.0.0.1:8545 --broadcast
  3. (Sometimes) Run another forge script command to add some test/seed data
  4. Reload and continue development of downstream services (frontend or indexer)

Haven't given it much thought, but perhaps Foundry could support a forge dev command which:

This way, you can just save changes to Foundry project files and your downstream services should "just work".

One remaining question (important for Ponder, maybe less important for MUD) is some mechanism for the Anvil node to announce that a reload has occurred, so that downstream services know to invalidate any data that was previously fetched from this RPC URL.

See also @wagmi/cli which solves some related problems in this domain.