Skip to content

Commit

Permalink
self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Sep 24, 2023
1 parent 26c3b9a commit 5738256
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/world/src/AccessControl.sol
Expand Up @@ -15,11 +15,12 @@ library AccessControl {
*/
function hasAccess(ResourceId resourceId, address caller) internal view returns (bool) {
return
ResourceAccess._get(resourceId.getNamespaceId(), caller) || ResourceAccess._get(resourceId, caller); // First check access based on the namespace // If caller has no namespace access, check access on the name
// First check access based on the namespace. If caller has no namespace access, check access on the resource.
ResourceAccess._get(resourceId.getNamespaceId(), caller) || ResourceAccess._get(resourceId, caller);
}

/**
* Check for access at the given namespace or name.
* Check for access at the given namespace or resource.
* Reverts with World_AccessDenied if the caller has no access.
*/
function requireAccess(ResourceId resourceId, address caller) internal view {
Expand Down
3 changes: 1 addition & 2 deletions packages/world/src/Delegation.sol
Expand Up @@ -2,10 +2,9 @@
pragma solidity >=0.8.21;

import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
import { ROOT_NAMESPACE, UNLIMITED_DELEGATION } from "./constants.sol";
import { UNLIMITED_DELEGATION } from "./constants.sol";
import { IDelegationControl } from "./interfaces/IDelegationControl.sol";
import { SystemCall } from "./SystemCall.sol";
import { RESOURCE_SYSTEM } from "./worldResourceTypes.sol";

library Delegation {
function exists(ResourceId delegationControlId) internal pure returns (bool) {
Expand Down
3 changes: 1 addition & 2 deletions packages/world/test/World.t.sol
Expand Up @@ -25,13 +25,12 @@ import { WORLD_VERSION } from "../src/version.sol";
import { World } from "../src/World.sol";
import { System } from "../src/System.sol";
import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../src/WorldResourceId.sol";
import { ROOT_NAMESPACE, ROOT_NAME, ROOT_NAMESPACE_ID } from "../src/constants.sol";
import { ROOT_NAMESPACE, ROOT_NAME, ROOT_NAMESPACE_ID, UNLIMITED_DELEGATION } from "../src/constants.sol";
import { RESOURCE_TABLE, RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "../src/worldResourceTypes.sol";
import { WorldContextProvider, WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "../src/WorldContext.sol";
import { SystemHook } from "../src/SystemHook.sol";
import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM } from "../src/systemHookTypes.sol";
import { Module, MODULE_INTERFACE_ID } from "../src/Module.sol";
import { UNLIMITED_DELEGATION } from "../src/Delegation.sol";

import { NamespaceOwner, NamespaceOwnerTableId } from "../src/tables/NamespaceOwner.sol";
import { ResourceAccess } from "../src/tables/ResourceAccess.sol";
Expand Down

0 comments on commit 5738256

Please sign in to comment.