Skip to content

feat: add two-step Ownable mixin with tests#6

Merged
oliv3rdrt merged 1 commit into
mainfrom
feat/ownable-mixin
May 17, 2026
Merged

feat: add two-step Ownable mixin with tests#6
oliv3rdrt merged 1 commit into
mainfrom
feat/ownable-mixin

Conversation

@oliv3rdrt

Copy link
Copy Markdown
Owner

Summary

  • src/Ownable.sol: abstract base. transferOwnership sets pendingOwner; the new owner must call acceptOwnership for the change to take effect. renounceOwnership is intentionally single-step.
  • Custom errors (NotOwner, NotPendingOwner) save deploy bytes vs. require strings.
  • test/Ownable.t.sol: 7 tests using an OwnableHarness concrete impl. Covers happy path, mid-flight overwrite of pending owner, accept-while-not-pending, renounce, and the access-control guard.

Test plan

  • forge test --match-contract OwnableTest - 7/7
  • forge test - 48/48, no regressions

Pending-owner must accept before ownership transfers - avoids the
classic foot-gun where a typo'd address ends up as owner. Renounce stays
single-step but zeroes pendingOwner too. Custom errors throughout.

Concrete OwnableHarness in the test file lets the abstract base be
deployed for unit tests.
@oliv3rdrt

Copy link
Copy Markdown
Owner Author

Reviewed - two-step is the right default. The 'transfer overwrites pending' test catches the subtle case where a stale pending owner could otherwise still accept after a second transfer. Merging.

@oliv3rdrt oliv3rdrt merged commit bb358aa into main May 17, 2026
@oliv3rdrt oliv3rdrt deleted the feat/ownable-mixin branch May 17, 2026 11:41
oliv3rdrt added a commit that referenced this pull request Jun 27, 2026
Pending-owner must accept before ownership transfers - avoids the
classic foot-gun where a typo'd address ends up as owner. Renounce stays
single-step but zeroes pendingOwner too. Custom errors throughout.

Concrete OwnableHarness in the test file lets the abstract base be
deployed for unit tests.

Co-authored-by: Oliver Anyanwu <oliver.anyanwu@aol.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant