Skip to content

Commit

Permalink
chore: remove unregisterSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaa committed Jan 19, 2024
1 parent 0d23f3b commit c7e270b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 48 deletions.
10 changes: 5 additions & 5 deletions packages/world-modules/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"file": "test/StandardDelegationsModule.t.sol",
"test": "testCallFromCallboundDelegation",
"name": "register a callbound delegation",
"gasUsed": 118210
"gasUsed": 118198
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand All @@ -279,7 +279,7 @@
"file": "test/StandardDelegationsModule.t.sol",
"test": "testCallFromSystemDelegation",
"name": "register a systembound delegation",
"gasUsed": 115763
"gasUsed": 115751
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand All @@ -291,7 +291,7 @@
"file": "test/StandardDelegationsModule.t.sol",
"test": "testCallFromTimeboundDelegation",
"name": "register a timebound delegation",
"gasUsed": 112686
"gasUsed": 112674
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand All @@ -303,7 +303,7 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstall",
"name": "install unique entity module",
"gasUsed": 704190
"gasUsed": 704155
},
{
"file": "test/UniqueEntityModule.t.sol",
Expand All @@ -315,7 +315,7 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstallRoot",
"name": "installRoot unique entity module",
"gasUsed": 673093
"gasUsed": 673081
},
{
"file": "test/UniqueEntityModule.t.sol",
Expand Down
6 changes: 3 additions & 3 deletions packages/world/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"file": "test/Factories.t.sol",
"test": "testWorldFactory",
"name": "deploy world via WorldFactory",
"gasUsed": 12708436
"gasUsed": 12642897
},
{
"file": "test/World.t.sol",
Expand Down Expand Up @@ -117,13 +117,13 @@
"file": "test/World.t.sol",
"test": "testRegisterRootFunctionSelector",
"name": "Register a root function selector",
"gasUsed": 80468
"gasUsed": 80445
},
{
"file": "test/World.t.sol",
"test": "testRegisterSystem",
"name": "register a system",
"gasUsed": 164375
"gasUsed": 164363
},
{
"file": "test/World.t.sol",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/world/src/modules/core/CoreModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ contract CoreModule is Module {
_registerRootFunctionSelector(BATCH_CALL_SYSTEM_ID, functionSignaturesBatchCall[i]);
}

string[15] memory functionSignaturesCoreRegistration = [
string[14] memory functionSignaturesCoreRegistration = [
// --- ModuleInstallationSystem ---
"installModule(address,bytes)",
// --- StoreRegistrationSystem ---
Expand All @@ -182,7 +182,6 @@ contract CoreModule is Module {
"registerSystemHook(bytes32,address,uint8)",
"unregisterSystemHook(bytes32,address)",
"registerSystem(bytes32,address,bool)",
"unregisterSystem(bytes32)",
"registerFunctionSelector(bytes32,string)",
"registerRootFunctionSelector(bytes32,string,bytes4)",
"registerDelegation(address,bytes32,bytes)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,40 +171,6 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext {
ResourceAccess._set(namespaceId, address(system), true);
}

/**
* @notice Unregisters a system
* @dev Unregisters the system at the given ID
* @param systemId The unique identifier for the system
*/
function unregisterSystem(ResourceId systemId) public virtual {
// Require the provided system ID to have type RESOURCE_SYSTEM
if (systemId.getType() != RESOURCE_SYSTEM) {
revert World_InvalidResourceType(RESOURCE_SYSTEM, systemId, systemId.toString());
}

// Require the system's namespace to exist
ResourceId namespaceId = systemId.getNamespaceId();
AccessControl.requireExistence(namespaceId);

// Require the caller to own the namespace
AccessControl.requireOwner(namespaceId, _msgSender());

// Require the name to not be the namespace's root name
if (systemId.getName() == ROOT_NAME) revert World_InvalidResourceId(systemId, systemId.toString());

// Get the system at this system ID
address existingSystem = Systems._getSystem(systemId);

// Systems = mapping from system ID to system address and public access flag
Systems._deleteRecord(systemId);

// SystemRegistry = mapping from system address to system ID
SystemRegistry._deleteRecord(address(existingSystem));

// Delete the system access to its namespace
ResourceAccess._deleteRecord(namespaceId, address(existingSystem));
}

/**
* @notice Registers a new World function selector
* @dev Creates a mapping between a World function and its associated system function
Expand Down
3 changes: 1 addition & 2 deletions packages/world/test/World.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ contract WorldTest is Test, GasReporter {
CoreRegistrationSystem coreRegistrationSystem = CoreRegistrationSystem(
Systems.getSystem(CORE_REGISTRATION_SYSTEM_ID)
);
bytes4[23] memory coreFunctionSignatures = [
bytes4[22] memory coreFunctionSignatures = [
// --- AccessManagementSystem ---
AccessManagementSystem.grantAccess.selector,
AccessManagementSystem.revokeAccess.selector,
Expand All @@ -248,7 +248,6 @@ contract WorldTest is Test, GasReporter {
coreRegistrationSystem.registerSystemHook.selector,
coreRegistrationSystem.unregisterSystemHook.selector,
coreRegistrationSystem.registerSystem.selector,
coreRegistrationSystem.unregisterSystem.selector,
coreRegistrationSystem.registerFunctionSelector.selector,
coreRegistrationSystem.registerRootFunctionSelector.selector,
coreRegistrationSystem.registerDelegation.selector,
Expand Down

0 comments on commit c7e270b

Please sign in to comment.