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(store-sync): extra table definitions #1840

Merged
merged 8 commits into from
Oct 31, 2023
Merged

Conversation

holic
Copy link
Member

@holic holic commented Oct 30, 2023

before

image

after

image

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2023

🦋 Changeset detected

Latest commit: b9e8c6f

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

This PR includes changesets to release 30 packages
Name Type
@latticexyz/store-sync Major
@latticexyz/dev-tools Major
@latticexyz/store-indexer Major
@latticexyz/abi-ts Major
@latticexyz/block-logs-stream Major
@latticexyz/cli Major
@latticexyz/common Major
@latticexyz/config Major
create-mud Major
@latticexyz/ecs-browser Major
@latticexyz/faucet Major
@latticexyz/gas-report Major
@latticexyz/network Major
@latticexyz/noise Major
@latticexyz/phaserx Major
@latticexyz/protocol-parser Major
@latticexyz/react Major
@latticexyz/recs Major
@latticexyz/schema-type Major
@latticexyz/services Major
@latticexyz/solecs Major
solhint-config-mud Major
solhint-plugin-mud Major
@latticexyz/std-client Major
@latticexyz/std-contracts Major
@latticexyz/store-cache Major
@latticexyz/store Major
@latticexyz/utils Major
@latticexyz/world-modules Major
@latticexyz/world Major

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

@@ -22,7 +34,7 @@ export type ResolvedTableConfig<
TEnumNames extends StringForUnion,
TNamespace extends string = string,
TName extends string = string
> = Omit<TTableConfig, "keySchema" | "valueSchema"> & {
Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't want to clutter the new resolved config/tables shape with old props that we're gonna rearrange, so I removed em. Can still access em via the old config object and the same table name/key.

@@ -48,7 +60,9 @@ export type ResolvedSchema<
TEnumNames extends StringForUnion
> = {
[key in keyof TSchema]: {
type: TSchema[key] extends keyof TUserTypes
type: TSchema[key] extends SchemaAbiType
? TSchema[key]
Copy link
Member Author

Choose a reason for hiding this comment

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

@alvrs This was the fix. Not sure why only certain ABI types were getting trapped in the TSchema[key] extends TEnumNames check.

@@ -71,7 +71,7 @@ const zShorthandSchemaConfig = zFieldData.transform((fieldData) => {

export const zSchemaConfig = zFullSchemaConfig.or(zShorthandSchemaConfig);

export type ResolvedSchema<
type ResolvedSchema<
Copy link
Member Author

Choose a reason for hiding this comment

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

not used anywhere and the name overlaps with our experimental config types, so I removed this export

Comment on lines 42 to +43
config: mudConfig,
tables: {
Copy link
Member

Choose a reason for hiding this comment

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

so syncToRecs syncs all tables passed mudConfig or in tables correct? What in mudConfig do we need in here besides the resolved tables? If it's only that, should we just pass a tables key (ie syncToRecs({ tables: { ...mudConfig.tables, ...additionalTables } }))? (mostly wondering about longer term when the config is resolved by default, fine to not do that here yet to avoid breaking changes)

Copy link
Member Author

Choose a reason for hiding this comment

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

long term I think we should do that, yep! I just didn't want to encourage the intermediate step of using the experimental resolveConfig in user land

address: networkConfig.worldAddress as Hex,
publicClient,
startBlock: BigInt(networkConfig.initialBlockNumber),
});
} as const);
Copy link
Member

Choose a reason for hiding this comment

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

what would break without as const here? Does this break anything for current users who don't have as const yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

the manually defined tables were missing strong types for namespace/name without this

Comment on lines -26 to +27
export type RecsStorageAdapter<TConfig extends StoreConfig = StoreConfig> = {
export type RecsStorageAdapter<tables extends Record<string, Table>> = {
Copy link
Member

Choose a reason for hiding this comment

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

I'm still not used to tables instead of TTables 😭 Don't you find it confusing not to see on first sight whether you have to use typeof tables vs just tables? I'm just so used to custom types being uppercase and only primitive types being lowercase

alvrs
alvrs previously approved these changes Oct 31, 2023
@holic holic changed the title feat(store-sync): additional table definitions feat(store-sync): extra table definitions Oct 31, 2023
@holic holic merged commit de47d69 into main Oct 31, 2023
9 checks passed
@holic holic deleted the holic/sync-additional-tables branch October 31, 2023 11:14
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.

2 participants