Skip to content

Commit

Permalink
Remove forceTransferOwnership
Browse files Browse the repository at this point in the history
  • Loading branch information
heldersepu committed Aug 31, 2022
1 parent ff44765 commit 84f3b9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
7 changes: 0 additions & 7 deletions contracts/access/Ownable2Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ abstract contract Ownable2Step is Ownable {
emit OwnershipTransferStarted(owner(), newOwner);
}

/**
* @dev Make the direct ownership transfer available as a fallback when the receiver cannot accept.
*/
function forceTransferOwnership(address newOwner) public virtual {
super.transferOwnership(newOwner);
}

/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
Expand Down
14 changes: 8 additions & 6 deletions test/access/Ownable2Step.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ contract('Ownable2Step', function (accounts) {
expect(await this.ownable2Step.pendingOwner()).to.not.equal(accountA);
});

it('changes owner after force transfer', async function () {
await this.ownable2Step.forceTransferOwnership(accountA, { from: owner });
expect(await this.ownable2Step.owner()).to.equal(accountA);
expect(await this.ownable2Step.pendingOwner()).to.not.equal(accountA);
it('changes owner after renouncing ownership', async function () {
await this.ownable2Step.renounceOwnership({ from: owner });
// If renounceOwnership is removed from parent an alternative is needed ...
// without it is difficult to cleanly renounce with the two step process
// see: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3620#discussion_r957930388
expect(await this.ownable2Step.owner()).to.equal(ZERO_ADDRESS);
});

it('pending owner resets on force transfer', async function () {
it('pending owner resets after renouncing ownership', async function () {
await this.ownable2Step.transferOwnership(accountA, { from: owner });
expect(await this.ownable2Step.pendingOwner()).to.equal(accountA);
await this.ownable2Step.forceTransferOwnership(accountB, { from: owner });
await this.ownable2Step.renounceOwnership({ from: owner });
expect(await this.ownable2Step.pendingOwner()).to.equal(ZERO_ADDRESS);
await expectRevert(
this.ownable2Step.acceptOwnership({ from: accountA }),
Expand Down

0 comments on commit 84f3b9f

Please sign in to comment.