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

feat(create-mud): new react template with stash/entrykit #3439

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

holic
Copy link
Member

@holic holic commented Jan 10, 2025

TODO

  • bump react, viem, wagmi deps
  • move stuff within mud to MUD packages

@holic holic requested a review from alvrs as a code owner January 10, 2025 10:24
Copy link

changeset-bot bot commented Jan 10, 2025

🦋 Changeset detected

Latest commit: d4caba1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 29 packages
Name Type
@latticexyz/entrykit Patch
create-mud Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/cli Patch
@latticexyz/common Patch
@latticexyz/config Patch
@latticexyz/dev-tools Patch
@latticexyz/explorer Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/paymaster Patch
@latticexyz/protocol-parser Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/stash Patch
@latticexyz/store-consumer Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
vite-plugin-mud Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines +32 to +36
"overrides": {
"@tanstack/react-query": "link:../../packages/entrykit/node_modules/@tanstack/react-query",
"@types/react": "link:../../packages/entrykit/node_modules/@types/react",
"wagmi": "link:../../packages/entrykit/node_modules/wagmi"
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is how we work around the linking issue where different instances of Wagmi exist inside the dependency tree (even if pinned to the same version), which leads to things like Rainbowkit inside EntryKit not being able to find the Wagmi config provided the template's app.

The downside is that we need to keep versions aligned in the template + EntryKit to not have failing tests or weird edge cases. But that seems like a reasonable trade-off for having a working local environment for templates.

Some potential solutions we can look into in the future:

  • move templates into the monorepo root workspace (would mean "flattening" the templates to not use workspaces) so the templates can share common pnpm dependencies with MUD packages
  • replace Rainbowkit in EntryKit with our own wallet connection UI (the underlying error seems to be related to transitive deps across linked deps in pnpm workspace)

Comment on lines +15 to +26
const sync = useSync();
const worldContract = useWorldContract();
const onMove = useMemo(
() =>
sync.data && worldContract
? async (direction: Direction) => {
const tx = await worldContract.write.app__move([mudConfig.enums.Direction.indexOf(direction)]);
await sync.data.waitForTransaction(tx);
}
: undefined,
[sync.data, worldContract],
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This still feels a little clunky to me. I tried to streamline this by doing the sync data check inside useWorldContract so that we could have one hook to return both worldContract and waitForTransaction (since you're often doing these together), but I was constantly battling TS depth issues where editing anything in useWorldContract caused it to spin due to the huge world ABI.

A potential next step to improve this would be better utils to call individual systems via their individual ABIs rather than a monolithic world contract, but wagmi doesn't make it easy to call using a separate client (session client, in our case).

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.

1 participant