From e974e8ed5326bb3c769955be86512b3b3cfa607b Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 13 May 2024 11:51:31 -0400 Subject: [PATCH] Add owner view function to manifest validation list --- src/plugins/owner/SingleOwnerPlugin.sol | 6 +++++- test/account/UpgradeableModularAccount.t.sol | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/owner/SingleOwnerPlugin.sol b/src/plugins/owner/SingleOwnerPlugin.sol index b1d5d5e1..38f16872 100644 --- a/src/plugins/owner/SingleOwnerPlugin.sol +++ b/src/plugins/owner/SingleOwnerPlugin.sol @@ -156,7 +156,7 @@ contract SingleOwnerPlugin is BasePlugin, ISingleOwnerPlugin, IERC1271 { functionId: uint8(FunctionId.VALIDATION_OWNER_OR_SELF), dependencyIndex: 0 // Unused. }); - manifest.validationFunctions = new ManifestAssociatedFunction[](7); + manifest.validationFunctions = new ManifestAssociatedFunction[](8); manifest.validationFunctions[0] = ManifestAssociatedFunction({ executionSelector: this.transferOwnership.selector, associatedFunction: ownerValidationFunction @@ -191,6 +191,10 @@ contract SingleOwnerPlugin is BasePlugin, ISingleOwnerPlugin, IERC1271 { executionSelector: this.isValidSignature.selector, associatedFunction: alwaysAllowRuntime }); + manifest.validationFunctions[7] = ManifestAssociatedFunction({ + executionSelector: this.owner.selector, + associatedFunction: alwaysAllowRuntime + }); return manifest; } diff --git a/test/account/UpgradeableModularAccount.t.sol b/test/account/UpgradeableModularAccount.t.sol index 3ef6f107..c1c0580c 100644 --- a/test/account/UpgradeableModularAccount.t.sol +++ b/test/account/UpgradeableModularAccount.t.sol @@ -419,6 +419,15 @@ contract UpgradeableModularAccountTest is AccountTestBase { assertEq(address(account3), address(uint160(uint256(vm.load(address(account1), slot))))); } + function test_transferOwnership() public { + assertEq(SingleOwnerPlugin(address(account1)).owner(), owner1); + + vm.prank(owner1); + SingleOwnerPlugin(address(account1)).transferOwnership(owner2); + + assertEq(SingleOwnerPlugin(address(account1)).owner(), owner2); + } + // Internal Functions function _printStorageReadsAndWrites(address addr) internal {