diff --git a/src/DataTypes.sol b/src/DataTypes.sol index d5e95e07..d8464e78 100644 --- a/src/DataTypes.sol +++ b/src/DataTypes.sol @@ -34,7 +34,7 @@ struct SchemaRecord { } struct ResolverRecord { - IExternalResolver resolver; // Optional resolver. + IExternalResolver resolver; // resolver. address resolverOwner; // The address of the account used to register the resolver. } diff --git a/src/Registry.sol b/src/Registry.sol index 25e3b0d2..3beeb228 100644 --- a/src/Registry.sol +++ b/src/Registry.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.24; -import { SignedAttestation } from "./core/SignedAttestation.sol"; import { IRegistry } from "./IRegistry.sol"; +import { SignedAttestation } from "./core/SignedAttestation.sol"; /** * @author zeroknots */ diff --git a/src/core/ModuleManager.sol b/src/core/ModuleManager.sol index 4da58042..12558f1f 100644 --- a/src/core/ModuleManager.sol +++ b/src/core/ModuleManager.sol @@ -131,8 +131,6 @@ abstract contract ModuleManager is IRegistry, ResolverManager { internal returns (ModuleRecord memory moduleRegistration) { - // ensure that non-zero resolverUID was provided - if (resolverUID == EMPTY_RESOLVER_UID) revert InvalidDeployment(); // ensure moduleAddress is not already registered if ($moduleAddrToRecords[moduleAddress].resolverUID != EMPTY_RESOLVER_UID) { revert AlreadyRegistered(moduleAddress); diff --git a/src/core/ResolverManager.sol b/src/core/ResolverManager.sol index f4e4f065..4c84e7d9 100644 --- a/src/core/ResolverManager.sol +++ b/src/core/ResolverManager.sol @@ -12,6 +12,11 @@ abstract contract ResolverManager is IRegistry { mapping(ResolverUID uid => ResolverRecord resolver) internal $resolvers; + constructor() { + ResolverRecord storage $resolver = $resolvers[ResolverUID.wrap(bytes32(0))]; + $resolver.resolverOwner = address(this); + } + /** * @dev Modifier to require that the caller is the owner of a resolver * diff --git a/src/lib/ModuleDeploymentLib.sol b/src/lib/ModuleDeploymentLib.sol index b9b41b8b..ab9b70da 100644 --- a/src/lib/ModuleDeploymentLib.sol +++ b/src/lib/ModuleDeploymentLib.sol @@ -71,6 +71,4 @@ library ModuleDeploymentLib { ) ); } - - error InvalidDeployment(); } diff --git a/src/lib/StubLib.sol b/src/lib/StubLib.sol index a79a6db7..4c87e9bc 100644 --- a/src/lib/StubLib.sol +++ b/src/lib/StubLib.sol @@ -108,7 +108,7 @@ library StubLib { { IExternalResolver resolverContract = $resolver.resolver; - if (address(resolverContract) != ZERO_ADDRESS) return; + if (address(resolverContract) == ZERO_ADDRESS) return; if (resolverContract.resolveModuleRegistration({ sender: msg.sender, moduleAddress: moduleAddress, record: moduleRecord }) == false) { diff --git a/test/ModuleRegistration.t.sol b/test/ModuleRegistration.t.sol index ecfad1b7..d819cd4d 100644 --- a/test/ModuleRegistration.t.sol +++ b/test/ModuleRegistration.t.sol @@ -42,7 +42,7 @@ contract ModuleRegistrationTest is BaseTest { function test_WhenRegisteringAModuleOnAnInvalidResolverUID() external prankWithAccount(moduleDev1) { MockModule newModule = new MockModule(); // It should revert. - ResolverUID invalidUID = ResolverUID.wrap(hex"00"); + ResolverUID invalidUID = ResolverUID.wrap(hex"01"); vm.expectRevert(abi.encodeWithSelector(IRegistry.InvalidResolver.selector, address(0))); registry.registerModule(invalidUID, address(newModule), ""); @@ -103,4 +103,15 @@ contract ModuleRegistrationTest is BaseTest { vm.expectRevert(); registry.deployViaFactory(address(registry), "", "", defaultResolverUID); } + + function test_WhenUsingDefaultResolverUID() public prankWithAccount(moduleDev1) { + bytes32 salt = bytes32(abi.encodePacked(address(moduleDev1.addr), bytes12(0))); + + bytes memory bytecode = type(MockModule).creationCode; + + ResolverUID nullUID = ResolverUID.wrap(bytes32(0)); + address moduleAddr = registry.deployModule(salt, nullUID, bytecode, ""); + ModuleRecord memory record = registry.findModule(moduleAddr); + assertTrue(record.resolverUID == nullUID); + } }