From bebc6376d92e2bbc1a4d460f293f176d7199ee5f Mon Sep 17 00:00:00 2001 From: kopy-kat Date: Wed, 28 Aug 2024 12:59:33 +0200 Subject: [PATCH 1/2] feat: add module registration helper --- src/deployment/RegistryDeployer.sol | 26 ++++++++++++++++++++++---- test/RegistryDeployer.t.sol | 17 +++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/deployment/RegistryDeployer.sol b/src/deployment/RegistryDeployer.sol index b25daa74..22aa5ed9 100644 --- a/src/deployment/RegistryDeployer.sol +++ b/src/deployment/RegistryDeployer.sol @@ -81,6 +81,28 @@ contract RegistryDeployer { return registry.calcModuleAddress(salt, initCode); } + // <---- REGISTRATION ----> + + function registerModule( + address module, + bytes memory metadata, + bytes memory resolverContext + ) + public + { + ResolverUID _resolverUID = findResolver(); + registry.registerModule({ + resolverUID: _resolverUID, + moduleAddress: module, + metadata: metadata, + resolverContext: resolverContext + }); + } + + function findModule(address moduleAddress) public view returns (ModuleRecord memory) { + return registry.findModule(moduleAddress); + } + // <---- ATTESTATIONS ----> function mockAttestToModule( @@ -153,10 +175,6 @@ contract RegistryDeployer { }); } - function findModule(address moduleAddress) public view returns (ModuleRecord memory) { - return registry.findModule(moduleAddress); - } - function setRegistry(address _registry) public { registry = IRegistry(_registry); } diff --git a/test/RegistryDeployer.t.sol b/test/RegistryDeployer.t.sol index c465048b..5fecdc3d 100644 --- a/test/RegistryDeployer.t.sol +++ b/test/RegistryDeployer.t.sol @@ -71,6 +71,23 @@ contract RegistryDeployerTest is RegistryDeployer, BaseTest { assertEq(moduleRecord.metadata, metadata); } + function testRegisterModule() public onMainnet { + address module = address(new MockValidator()); + + ModuleRecord memory moduleRecord = findModule(module); + assertEq(ResolverUID.unwrap(moduleRecord.resolverUID), bytes32(0)); + assertEq(moduleRecord.metadata, ""); + + bytes memory metadata = hex"41414141414141"; + bytes memory resolverContext = ""; + + registerModule({ module: module, metadata: metadata, resolverContext: resolverContext }); + + moduleRecord = findModule(module); + assertEq(ResolverUID.unwrap(moduleRecord.resolverUID), ResolverUID.unwrap(resolverUID)); + assertEq(moduleRecord.metadata, metadata); + } + function testMockAttestModule() public onTestnet { deployModule(); From 3ddfd8719e17cc78fb119bb59b30dd12c28335d6 Mon Sep 17 00:00:00 2001 From: kopy-kat Date: Wed, 28 Aug 2024 12:59:49 +0200 Subject: [PATCH 2/2] chore: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f7416e80..fd56b1dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rhinestone/modulekit", - "version": "0.4.12", + "version": "0.4.13", "description": "A development kit for building and testing smart account modules.", "license": "GPL-3.0", "author": {