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(config,store,world): add namespaceLabel to table config #3039

Merged
merged 9 commits into from
Aug 16, 2024

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Aug 15, 2024

Ripped out from #2944

Copy link

changeset-bot bot commented Aug 15, 2024

🦋 Changeset detected

Latest commit: 7119805

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

This PR includes changesets to release 25 packages
Name Type
@latticexyz/config Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/world Patch
@latticexyz/cli Patch
@latticexyz/protocol-parser Patch
@latticexyz/query Patch
@latticexyz/world-modules Patch
@latticexyz/dev-tools Patch
@latticexyz/store-indexer Patch
ts-benchmarks Patch
@latticexyz/react Patch
@latticexyz/world-module-metadata Patch
mock-game-contracts Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
create-mud Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/utils 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

@alvrs alvrs marked this pull request as ready for review August 15, 2024 14:50
@alvrs alvrs requested a review from holic as a code owner August 15, 2024 14:50
@@ -159,13 +164,15 @@ export function resolveTable<input extends TableInput, scope extends Scope = Abi
const label = input.label;
const type = input.type ?? TABLE_DEFAULTS.type;
const namespace = input.namespace ?? TABLE_DEFAULTS.namespace;
const namespaceLabel = input.namespaceLabel ?? input.namespace ?? TABLE_DEFAULTS.namespace;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const namespaceLabel = input.namespaceLabel ?? input.namespace ?? TABLE_DEFAULTS.namespace;
const namespaceLabel = input.namespaceLabel ?? namespace;

for names, this is actually the other way around: user defines the name or it defaults to the label

I wonder if we should do the same here: allow specifying namespace label, default it if not set, then derive the actual namespace from either the input or the namespace label (and validate length?)

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, switched the logic around

const label = input.label;
const namespace = input.namespace ?? label.slice(0, 14);
const namespaceLabel = input.label;
const namespace = input.namespace ?? namespaceLabel.slice(0, 14);
Copy link
Member

@holic holic Aug 15, 2024

Choose a reason for hiding this comment

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

I think we may wanna throw here instead of truncating?

I ran into this at some point where it's unclear if its okay to throw in resolve step, like as if it should happen in the validate step. But maybe its fine because its a "resolve error" because we're filling in and inferring info? Or maybe in this case, we can validate the namespaceLabel is <= 14 chars only if namespace isn't supplied too.

Copy link
Member Author

Choose a reason for hiding this comment

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

added the validation logic including throwing to validateTable. Could throw here for sanity but we should be able to assume the input to resolveX is sufficiently validated

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah hadn't pushed yet. Opted for not throwing here for now and putting all validation in validateTable (we weren't throwing if namespace is too long here either)

@alvrs alvrs merged commit 57bf8c3 into main Aug 16, 2024
13 checks passed
@alvrs alvrs deleted the alvrs/namespace-label branch August 16, 2024 08:38
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