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(store-consumer): adapt WithWorld to be a System #3546

Merged
merged 10 commits into from
Feb 5, 2025

Conversation

vdrg
Copy link
Contributor

@vdrg vdrg commented Jan 30, 2025

Now WithWorld is also a System, and we modify the onlyNamespace modifier so that protected functions can only be called by calling the system through the world.

Copy link

changeset-bot bot commented Jan 30, 2025

🦋 Changeset detected

Latest commit: 46645e3

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

This PR includes changesets to release 30 packages
Name Type
@latticexyz/store-consumer Patch
@latticexyz/store Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/entrykit Patch
@latticexyz/explorer Patch
@latticexyz/react Patch
@latticexyz/stash Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/world-module-callwithsignature Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/paymaster Patch
@latticexyz/protocol-parser Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/utils Patch
vite-plugin-mud 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

@@ -4,7 +4,7 @@ pragma solidity >=0.8.24;
// @dev Provides information about the current execution context
// We only use it in these contracts in case we want to extend it in the future
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
function _msgSender() public view virtual returns (address) {
Copy link
Member

@holic holic Jan 30, 2025

Choose a reason for hiding this comment

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

ooc why public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because _msgSender in WorldContext.sol is public so we need to be able to override

Copy link
Member

Choose a reason for hiding this comment

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

for context: it's public to have a unique interface id we can check for in supportsInterface so only contracts that are intended to be used as systems can be registered as systems

@dhvanipa
Copy link
Contributor

This means you can use stuff like batchCall and account delegation all works right? Since it'd be a system instead of a standalone contract?

@vdrg
Copy link
Contributor Author

vdrg commented Jan 30, 2025

This means you can use stuff like batchCall and account delegation all works right? Since it'd be a system instead of a standalone contract?

Yeah I think those should work, but also so that you can restrict access to systems within the same namespace.

Comment on lines +32 to +33
// We use WorldContextConsumer directly as we already know the world is the caller
if (!_callerIsWorld() || !ResourceAccess.get(getNamespaceId(), WorldContextConsumer._msgSender())) {
Copy link
Member

Choose a reason for hiding this comment

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

so if my EOA has access to the namespace I still have to call the token system through the world correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I thought about checking for supporting it for both EOAs and world, but I felt it was more consistent this way.

@vdrg vdrg marked this pull request as ready for review February 4, 2025 14:25
@vdrg vdrg requested a review from ludns as a code owner February 4, 2025 14:25
alvrs
alvrs previously approved these changes Feb 4, 2025
@vercel vercel bot temporarily deployed to Preview – explorer February 5, 2025 20:04 Inactive
@vdrg vdrg merged commit 5d6fb1b into main Feb 5, 2025
16 checks passed
@vdrg vdrg deleted the vdrg/store-consumer-only-world-modifier branch February 5, 2025 20:15
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.

4 participants