-
Notifications
You must be signed in to change notification settings - Fork 196
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(store,world): replace ResourceType
table with ResourceId
table and corresponding checks
#1557
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f89b5c8
feat(store,world): replace ResourceType table with ResourceId table a…
alvrs 1ffd4ac
prettier
holic 2631a85
allow registering offchain tables
holic 56742fc
Merge branch 'alvrs/namespace-id' into alvrs/resource-checks
holic 3e1c724
gas report
holic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
"@latticexyz/world": patch | ||
"@latticexyz/store": patch | ||
--- | ||
|
||
The `ResourceType` table is removed. | ||
It was previously used to store the resource type for each resource ID in a `World`. This is no longer necessary as the [resource type is now encoded in the resource ID](https://github.com/latticexyz/mud/pull/1544). | ||
|
||
To still be able to determine whether a given resource ID exists, a `ResourceIds` table has been added. | ||
The previous `ResourceType` table was part of `World` and missed tables that were registered directly via `StoreCore.registerTable` instead of via `World.registerTable` (e.g. when a table was registered as part of a root module). | ||
This problem is solved by the new table `ResourceIds` being part of `Store`. | ||
|
||
`StoreCore`'s `hasTable` function was removed in favor of using `ResourceIds.getExists(tableId)` directly. | ||
|
||
```diff | ||
- import { ResourceType } from "@latticexyz/world/src/tables/ResourceType.sol"; | ||
- import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; | ||
+ import { ResourceIds } from "@latticexyz/store/src/codegen/tables/ResourceIds.sol"; | ||
|
||
- bool tableExists = StoreCore.hasTable(tableId); | ||
+ bool tableExists = ResourceIds.getExists(tableId); | ||
|
||
- bool systemExists = ResourceType.get(systemId) != Resource.NONE; | ||
+ bool systemExists = ResourceIds.getExists(systemId); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, we already had this pattern for table errors (ID + human readable string)