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: add Factories plugin #749

Closed
wants to merge 27 commits into from
Closed

feat: add Factories plugin #749

wants to merge 27 commits into from

Conversation

yonadaa
Copy link
Contributor

@yonadaa yonadaa commented May 7, 2023

Solves #704.

This PR adds Factories into MUD. Users define a template.config (which is strongly typed based via codegen on mud.config), like so:

const factoryConfig = templateConfig({
  templates: {
    Example: {
      Statics: {
        v1: 1n,
        v2: 1,
        v3: "wasd",
        v4: "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
        v5: true,
        v6: "E1",
        v7: "E1",
      },
      Counter: { value: 2n },
    },
  },
});

The templates are created in PostDeploy. Once the world is deployed, a method can be used to create instances from the template data.

Outstanding issues

  • This could perhaps be more cleanly implemented as some plugin.
  • We should replace the type codegen by deriving the types from the config in Typescript.
  • Tables can have different composite keys, so it's unclear how to generate a new unique key for each, per instance.

@vercel
Copy link

vercel bot commented May 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mud ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2023 11:14am
mud-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2023 11:14am
mud-example-minimal-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2023 11:14am

@yonadaa yonadaa changed the title WIP: add Factories feat: add Factories plugin May 15, 2023
@alvrs
Copy link
Member

alvrs commented Jun 16, 2023

Very much like this, but we should wait until the plugin foundation is done. Will close for now, but we should reopen and update this once plugins are ready.

@alvrs alvrs closed this Jun 16, 2023
@holic holic deleted the add-factories branch June 23, 2023 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants