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

fix(world): prevent namespace from ending with underscore [M-05] #2182

Merged
merged 11 commits into from
Feb 2, 2024

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Jan 24, 2024

follows #2169

Copy link

changeset-bot bot commented Jan 24, 2024

🦋 Changeset detected

Latest commit: 6881655

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

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

@holic
Copy link
Member

holic commented Jan 24, 2024

I know I suggested otherwise before, but given the gas report, I wonder if we should split validateNamespace from requireNamespace where

  • requireNamespace checks if a resource ID is a namespace type and has an empty name
  • validateNamespace checks if the namespace does not have invalid chars

We only need to requireNamespace+validateNamespace on registration, the rest of the functions can just use requireNamespace and save gas

(I don't love the naming of these, maybe validateNamespace renames to requireValidNamespace to more closely match requireNamespace and the intent of each?)

@holic holic marked this pull request as ready for review January 30, 2024 15:08
@holic holic self-requested a review as a code owner January 30, 2024 15:08
@holic holic changed the title fix(world): prevent namespace from ending with underscore fix(world): prevent namespace from ending with underscore [M-05] Jan 30, 2024
packages/world/src/requireNamespace.sol Outdated Show resolved Hide resolved
using WorldResourceIdInstance for ResourceId;

/**
* @notice Checks if a given `resourceId` is a valid namespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

requireNamespace and requireValidNamespace have the same notice comment, maybe they could be more specific?

Copy link
Member

Choose a reason for hiding this comment

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

whoops, that was a copy pasta issue on my part

Copy link
Member

@holic holic Jan 30, 2024

Choose a reason for hiding this comment

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

wait no, they're different

@notice Checks if a given `resourceId` is a namespace.
@notice Checks if a given `resourceId` is a valid namespace.

and the @dev section describes the difference in more detail

Copy link
Member Author

@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.

✅ approved

@holic holic merged commit 17f9872 into main Feb 2, 2024
11 checks passed
@holic holic deleted the alvrs/namespace-validation-2 branch February 2, 2024 19: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.

3 participants