Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Owned ECDSA Validation Module #151

Merged
merged 6 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface IMultiOwnedECDSAModule {
error NotEOA(address account);
error ZeroAddressNotAllowedAsOwner();
error OwnerAlreadyUsedForSmartAccount(address owner, address smartAccount);
error NotAnOwner(address owner, address smartAccount);

/**
* @dev Initializes the module for a Smart Account.
Expand Down
10 changes: 9 additions & 1 deletion contracts/smart-account/modules/MultiOwnedECDSAModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ contract MultiOwnedECDSAModule is
if (owner == address(0)) revert ZeroAddressNotAllowedAsOwner();
if (owner == newOwner)
revert OwnerAlreadyUsedForSmartAccount(newOwner, msg.sender);
if (!_smartAccountOwners[owner][msg.sender])
revert NotAnOwner(owner, msg.sender);
if (_smartAccountOwners[newOwner][msg.sender])
revert OwnerAlreadyUsedForSmartAccount(newOwner, msg.sender);
_transferOwnership(msg.sender, owner, newOwner);
}

Expand All @@ -84,11 +88,15 @@ contract MultiOwnedECDSAModule is
revert OwnerAlreadyUsedForSmartAccount(owner, msg.sender);

_smartAccountOwners[owner][msg.sender] = true;
numberOfOwners[msg.sender]++;
unchecked {
++numberOfOwners[msg.sender];
}
}

/// @inheritdoc IMultiOwnedECDSAModule
function removeOwner(address owner) external override {
if(!_smartAccountOwners[owner][msg.sender])
revert NotAnOwner(owner, msg.sender);
_transferOwnership(msg.sender, owner, address(0));
--numberOfOwners[msg.sender];
filmakarov marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ describe("MultiOwned ECDSA Module (with Bundler):", async () => {
describe("transferOwnership: ", async () => {
it("Call transferOwnership from userSA and it successfully changes owner ", async () => {
const { multiOwnedECDSAModule, entryPoint, userSA } = await setupTests();
// console.log(await userSA.getImplementation());

// Calldata to set Eve as owner
const txnData1 = multiOwnedECDSAModule.interface.encodeFunctionData(
Expand Down