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

add ownerCount method #60

Merged
merged 2 commits into from
Apr 19, 2024
Merged

add ownerCount method #60

merged 2 commits into from
Apr 19, 2024

Conversation

wilsoncusack
Copy link
Contributor

src/MultiOwnable.sol Outdated Show resolved Hide resolved
@@ -137,8 +136,7 @@ contract MultiOwnable {
/// @param index The index of the owner to be removed.
/// @param owner The ABI encoded bytes of the owner to be removed.
function removeLastOwner(uint256 index, bytes calldata owner) external virtual onlyOwner {
MultiOwnableStorage storage $ = _getMultiOwnableStorage();
uint256 ownersRemaining = $.nextOwnerIndex - $.removedOwnersCount;
uint256 ownersRemaining = ownerCount();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get rid of this stack variable and do the same thing as in `removeOwnerAtIndex():

if (ownerCount() > 1) {
    revert NotLastOwner(ownersRemaining);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then I would need to call ownerCount again here revert NotLastOwner(ownersRemaining);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be revert NotLastOwner(ownerCount());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes right, I missed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah could debate: do we penalize gas on the non revert path in order to save on revert?

@cb-heimdall
Copy link
Collaborator

Review Error for xenoliss @ 2024-04-19 17:06:50 UTC
User failed mfa authentication, see go/mfa-help

@wilsoncusack wilsoncusack merged commit adab965 into main Apr 19, 2024
6 of 9 checks passed
@wilsoncusack wilsoncusack deleted the wilson/ownerCount branch April 19, 2024 17:47
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants