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(store,world): replace ResourceType table with ResourceId table and corresponding checks #1557

Merged
merged 5 commits into from Sep 20, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Sep 20, 2023

Fixes #1553

TODO:

  • update deploy script to encode ids correctly

@changeset-bot
Copy link

changeset-bot bot commented Sep 20, 2023

🦋 Changeset detected

Latest commit: 3e1c724

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

This PR includes changesets to release 29 packages
Name Type
@latticexyz/world Patch
@latticexyz/store Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/store-sync Patch
@latticexyz/react 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/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/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 changed the base branch from main to alvrs/namespace-id September 20, 2023 15:42
@@ -134,6 +131,11 @@ library StoreCore {
string[] memory keyNames,
string[] memory fieldNames
) internal {
// Verify the table ID is of type RESOURCE_TABLE
if (!tableId.isType(RESOURCE_TABLE)) {
Copy link
Member

Choose a reason for hiding this comment

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

should this also include offchain tables?

Copy link
Member

Choose a reason for hiding this comment

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

is it worth including a free function in storeResourceTypes.sol something like

function isTable(ResourceId resourceId) { ... }

that we can use here? or is the indirection too gassy?

Copy link
Member Author

Choose a reason for hiding this comment

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

increases gas by 40, see ef89c43 - not super significant, but still don't think it's worth the small increase in ergonomics (agree it would read nicer, sad that the Solidity compiler doesn't just optimize this away)

@alvrs alvrs marked this pull request as ready for review September 20, 2023 19:57
@alvrs alvrs requested a review from dk1a as a code owner September 20, 2023 19:57
@alvrs alvrs requested a review from holic September 20, 2023 19:57
@alvrs alvrs marked this pull request as draft September 20, 2023 20:08
@@ -7,6 +7,7 @@ interface IStoreErrors {
// Errors include a stringified version of the tableId for easier debugging if cleartext tableIds are used
error StoreCore_TableAlreadyExists(ResourceId tableId, string tableIdString);
error StoreCore_TableNotFound(ResourceId tableId, string tableIdString);
Copy link
Member

@holic holic Sep 20, 2023

Choose a reason for hiding this comment

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

nice, we already had this pattern for table errors (ID + human readable string)

@alvrs alvrs marked this pull request as ready for review September 20, 2023 22:28
@alvrs alvrs merged commit dec9af7 into alvrs/namespace-id Sep 20, 2023
10 checks passed
@alvrs alvrs deleted the alvrs/resource-checks branch September 20, 2023 22:29
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.

None yet

2 participants