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(cli,recs,std-client): update RECS components with v2 key/value schemas #1195

Merged
merged 10 commits into from
Jul 27, 2023

Conversation

holic
Copy link
Member

@holic holic commented Jul 27, 2023

and move custom RECS schema type default from undefined to unknown

pulled out of #1113

@changeset-bot
Copy link

changeset-bot bot commented Jul 27, 2023

🦋 Changeset detected

Latest commit: b3c16ab

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

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

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

@holic holic marked this pull request as ready for review July 27, 2023 13:20
@holic holic requested a review from alvrs as a code owner July 27, 2023 13:20
alvrs
alvrs previously approved these changes Jul 27, 2023
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.

Lgtm, just small nits/questions. Is this a breaking change in any way?

@@ -27,8 +29,24 @@ export function getRecsV1TableOptions(config: StoreConfig): RecsV1TableOptions {
name: tableData.name,
};

// TODO: move user type -> abi type into our config expanding step rather than sprinkled everywhere
Copy link
Member

Choose a reason for hiding this comment

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

let's create an issue for this to keep track of the TODO

Comment on lines +27 to +30
id: ${JSON.stringify(tableId.toHex())},
metadata: {
componentName: ${JSON.stringify(name)},
tableName: ${JSON.stringify([namespace, name].join(":"))},
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to run JSON.stringify on these? Aren't they already strings?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is generating JS code and namespace/name are technically user generated, so it's a bit safer to encode to string with JSON.stringify rather than wrapping it in quotes

} else {
mappings[keccak256(contractId)] = key;
mappings[
keccak256(typeof component.metadata?.contractId === "string" ? component.metadata.contractId : component.id)
Copy link
Member

Choose a reason for hiding this comment

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

would this be equivalent?

Suggested change
keccak256(typeof component.metadata?.contractId === "string" ? component.metadata.contractId : component.id)
keccak256(component.metadata?.contractId ?? component.id)

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 had this before, but TS complained about the contractId value being {} or something? Might be related to Metadata default being Record<string, unknown>

@@ -26,7 +26,7 @@ export type DecodedSystemCall<
updates: DecodedNetworkComponentUpdate[];
};

export type ContractComponent = Component<Schema, { contractId: string; tableId?: string }>;
export type ContractComponent = Component<Schema>;
Copy link
Member

Choose a reason for hiding this comment

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

does this break any assumptions of existing code? maybe the ecs browser, i believe it's still in use by sky strife? (cc @Kooshaba)

Copy link
Member Author

Choose a reason for hiding this comment

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

ECS browser got inlined into sky strife and I fixed a couple of those things in my PR over there: https://github.com/latticexyz/skystrife/pull/167

@holic
Copy link
Member Author

holic commented Jul 27, 2023

Is this a breaking change in any way?

I don't think so? If you're using plain RECS, this shouldn't have any impact. You'll just need to bump RECS + CLI versions together and rebuild component definitions. It was only Sky Strife (they overloaded component.id and other things) that would break.

alvrs
alvrs previously approved these changes Jul 27, 2023
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