-
Notifications
You must be signed in to change notification settings - Fork 184
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-indexer,store-sync): filter findAll by tableIds #1572
Changes from all commits
5d06ad2
a5655ab
4f4c7e7
004b0c4
72033de
941c863
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./common"; | ||
export * from "./createStoreSync"; | ||
export * from "./internalTableIds"; | ||
export * from "./SyncStep"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { resourceIdToHex } from "@latticexyz/common"; | ||
import storeConfig from "@latticexyz/store/mud.config"; | ||
import worldConfig from "@latticexyz/world/mud.config"; | ||
|
||
// TODO: refactor config to include table IDs (https://github.com/latticexyz/mud/pull/1561) | ||
|
||
export const storeTableIds = Object.keys(storeConfig.tables).map((name) => | ||
resourceIdToHex({ | ||
type: storeConfig.tables[name as keyof typeof storeConfig.tables].offchainOnly ? "offchainTable" : "table", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed! I think lodash has a thing for this, just waiting for them to finish their TS rewrite |
||
namespace: storeConfig.namespace, | ||
name, | ||
}) | ||
); | ||
|
||
const worldTableIds = Object.keys(worldConfig.tables).map((name) => | ||
resourceIdToHex({ | ||
type: worldConfig.tables[name as keyof typeof worldConfig.tables].offchainOnly ? "offchainTable" : "table", | ||
namespace: worldConfig.namespace, | ||
name, | ||
}) | ||
); | ||
|
||
export const internalTableIds = [...storeTableIds, ...worldTableIds]; |
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.
it looks like we actively pass
internalTableIds
here, but also always include it internally in the query adapter - doesn't really hurt bc it's a set, but feels like it could be confusing (e.g. someone removinginternalTableIds
here and then wondering why they still show up in the results). What are your thoughts on only putting it in one of the two places and making it an explicit assumption? (e.g. "findAll
always returns internal tables", or "findAll
returns only the tables passed in the query, it is recommended internal tables are always included in the query")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.
I think making the indexer dumber (uses whatever you pass in for table IDs) makes sense, and only the store-sync includes internal table IDs.