Skip to content

feat(store,world): replace ResourceType table with ResourceId table and corresponding checks#1557

Merged
alvrs merged 5 commits intoalvrs/namespace-idfrom
alvrs/resource-checks
Sep 20, 2023
Merged

feat(store,world): replace ResourceType table with ResourceId table and corresponding checks#1557
alvrs merged 5 commits intoalvrs/namespace-idfrom
alvrs/resource-checks

Conversation

@alvrs
Copy link
Copy Markdown
Member

@alvrs alvrs commented Sep 20, 2023

Fixes #1553

TODO:

  • update deploy script to encode ids correctly

@changeset-bot
Copy link
Copy Markdown

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
Comment thread packages/store/src/StoreCore.sol Outdated
string[] memory fieldNames
) internal {
// Verify the table ID is of type RESOURCE_TABLE
if (!tableId.isType(RESOURCE_TABLE)) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 force-pushed the alvrs/resource-checks branch from 6574e1f to f89b5c8 Compare September 20, 2023 19:50
@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 frolic 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
Copy Markdown
Member

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

2 participants