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

refactor: combine name and namespace to resource selector in World methods #1208

Merged
merged 16 commits into from
Aug 17, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Jul 28, 2023

  • remove separate function selectors for namespace/name in World and instead align with Store interfaces on only using bytes32 resourceSelector

  • side effect: saving some byte code in the world contract:

before (contract/size/margin) after (contract/size/margin)
CleanShot 2023-08-11 at 16 34 12@2x CleanShot 2023-08-17 at 00 02 16@2x

@changeset-bot
Copy link

changeset-bot bot commented Jul 28, 2023

🦋 Changeset detected

Latest commit: 28a0268

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

This PR includes changesets to release 27 packages
Name Type
@latticexyz/cli Major
@latticexyz/world Major
@latticexyz/std-client Major
@latticexyz/dev-tools Major
@latticexyz/store-sync Major
@latticexyz/ecs-browser Major
@latticexyz/store-indexer Major
@latticexyz/block-logs-stream Major
@latticexyz/common Major
@latticexyz/config Major
create-mud 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-contracts Major
@latticexyz/store-cache Major
@latticexyz/store Major
@latticexyz/utils 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

@alvrs alvrs changed the title wip: combine name and namespace to resource selector in function signature refactor: combine name and namespace to resource selector in World methods Aug 16, 2023
@alvrs alvrs marked this pull request as ready for review August 16, 2023 22:33
@alvrs alvrs requested a review from holic as a code owner August 16, 2023 22:33
@alvrs alvrs requested a review from dk1a August 16, 2023 22:33
@@ -1,5 +1,6 @@
import { Hex, stringToHex, concatHex } from "viem";

// TODO: rename to `resourceIdToHex` or `resourceSelectorToHex` since it can be used with other resources than tables
Copy link
Member

Choose a reason for hiding this comment

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

but this is specific to tables (namespace+name), not all resources follow that same naming scheme, right?

Copy link
Member

Choose a reason for hiding this comment

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

I see now that we've sprinkled this throughout our deploy process etc.

Maybe worth renaming this but still exposing a table ID variant/wrapper that does ~the same thing for clarity when working with tables.

dk1a
dk1a previously approved these changes Aug 17, 2023
Copy link
Contributor

@dk1a dk1a 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 some nits
virtual/override look inconsistent in World (u're not using virtual in some places, and using override for interfaces)

.changeset/grumpy-geckos-raise.md Outdated Show resolved Hide resolved
packages/world/src/AccessControl.sol Outdated Show resolved Hide resolved
packages/world/src/World.sol Outdated Show resolved Hide resolved
packages/world/src/World.sol Outdated Show resolved Hide resolved
packages/world/src/World.sol Outdated Show resolved Hide resolved
packages/world/src/World.sol Outdated Show resolved Hide resolved
@holic holic merged commit c32a926 into main Aug 17, 2023
9 checks passed
@holic holic deleted the alvrs/resource-selector branch August 17, 2023 11:45
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