Skip to content

feat(create-mud): add worlds.json types#1430

Merged
frolic merged 1 commit intomainfrom
holic/worlds-d-ts
Sep 11, 2023
Merged

feat(create-mud): add worlds.json types#1430
frolic merged 1 commit intomainfrom
holic/worlds-d-ts

Conversation

@frolic
Copy link
Member

@frolic frolic commented Sep 9, 2023

fixes #1428

@changeset-bot
Copy link

changeset-bot bot commented Sep 9, 2023

⚠️ No Changeset found

Latest commit: 0856b15

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

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

is the world.d.ts file generated or manually created? Should we automatically create it when world.json is written (i believe in the deploy script)? Could even make it strongly typed like the abi types (might be useful to have type safety for which chains there is a deployment?)

@frolic
Copy link
Member Author

frolic commented Sep 11, 2023

is the world.d.ts file generated or manually created? Should we automatically create it when world.json is written (i believe in the deploy script)? Could even make it strongly typed like the abi types (might be useful to have type safety for which chains there is a deployment?)

We intentionally check in an initial worlds.json to avoid import/type issues when building the client, otherwise Vite throws up unless you deploy contracts first.

And we intentionally don't use stronger types/downcast it because we do a look up based on a dynamic chain ID, which fails type checks if it's a strict object with only specific keys included.

We could have a union of the strongly typed definition + more generic one like below, but not sure it helps much right now:

declare const worlds: {
  31337: {
    address: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
  }
} & Partial<Record<string, { address: string; blockNumber?: number }>>;

@frolic
Copy link
Member Author

frolic commented Sep 11, 2023

All that said, I still don't love the current approach for tracking deploys and using the contract addresses and would like to rethink it in the future but this is an 80%+ solution for now.

@frolic frolic merged commit d3049a2 into main Sep 11, 2023
@frolic frolic deleted the holic/worlds-d-ts branch September 11, 2023 10:44
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.

add worlds.json.d.ts file

2 participants