You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some pattern require an Ownable contract to change its owner under specific condition. This would for example be necessary to implement an OwnableClaimable contract for #2369 on top of the existing Ownable.
However, the current implmentation of Ownable can only be transfered using the public transferOwnership, which has the modifier onlyOwner.
I believe it would be better to have two function, one internal that does the change, and one public that gives restricted access to the internal.
abstract contract Ownable is Context {
...
function renounceOwnership() public virtual onlyOwner {
_setOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwnership(newOwner);
}
function _setOwnership(address newOwner) internal {
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
The text was updated successfully, but these errors were encountered:
Good point! What do you think about completely removing constructor in favor of internal function? My struggle is that contracts with constructor can't be used with proxy pattern. So I should create custom Ownable to use it in implementation contract.
Some pattern require an Ownable contract to change its owner under specific condition. This would for example be necessary to implement an
OwnableClaimable
contract for #2369 on top of the existingOwnable
.However, the current implmentation of
Ownable
can only be transfered using the publictransferOwnership
, which has the modifier onlyOwner.I believe it would be better to have two function, one internal that does the change, and one public that gives restricted access to the internal.
The text was updated successfully, but these errors were encountered: