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 force-pushed the alvrs/resource-selector branch from fe0fc1d to eaf16cf Compare July 28, 2023 15:27
@alvrs alvrs force-pushed the alvrs/real-schema branch from 0b8a66d to 7ff27a1 Compare August 9, 2023 17:18
@alvrs alvrs force-pushed the alvrs/resource-selector branch from eaf16cf to 39992b2 Compare August 9, 2023 17:18
@alvrs alvrs force-pushed the alvrs/real-schema branch from 7ff27a1 to 4d918cd Compare August 15, 2023 10:30
@alvrs alvrs force-pushed the alvrs/resource-selector branch from 3658f6d to 3796fec Compare August 15, 2023 10:30
@alvrs alvrs force-pushed the alvrs/real-schema branch from 4d918cd to 4a52c4a Compare August 15, 2023 14:56
@alvrs alvrs force-pushed the alvrs/resource-selector branch from 3796fec to df01ee1 Compare August 15, 2023 14:56
@alvrs alvrs force-pushed the alvrs/real-schema branch from 4a52c4a to c49c11e Compare August 15, 2023 16:16
@alvrs alvrs force-pushed the alvrs/resource-selector branch from df01ee1 to d139d9a Compare August 15, 2023 16:16
@alvrs alvrs force-pushed the alvrs/real-schema branch from c49c11e to 8a2d0d1 Compare August 15, 2023 17:47
@alvrs alvrs force-pushed the alvrs/resource-selector branch from d139d9a to 00f9b9f Compare August 15, 2023 17:47
@alvrs alvrs force-pushed the alvrs/real-schema branch from 8a2d0d1 to 0ca3474 Compare August 16, 2023 10:55
@alvrs alvrs force-pushed the alvrs/resource-selector branch from 00f9b9f to f86e487 Compare August 16, 2023 10:55
@alvrs alvrs force-pushed the alvrs/real-schema branch from 0ca3474 to 2dc150b Compare August 16, 2023 11:38
@alvrs alvrs force-pushed the alvrs/resource-selector branch from f86e487 to 79b0e0d Compare August 16, 2023 11:38
@alvrs alvrs force-pushed the alvrs/resource-selector branch from b307f55 to 57beee8 Compare August 16, 2023 22:01
@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
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