JBOwnableOverrides
Inherits: Context, JBPermissioned, IJBOwnable
An abstract base for JBOwnable
, which restricts functions so they can only be called by a Juicebox
project's owner or a specific owner address. The owner can give access permission to other addresses with
JBPermissions
.
State Variables
PROJECTS
Mints ERC-721s that represent project ownership and transfers.
IJBProjects public immutable override PROJECTS;
jbOwner
This contract's owner information.
JBOwner public override jbOwner;
Functions
constructor
To restrict access to a Juicebox project's owner, pass that project's ID as the initialProjectIdOwner
and
the zero address as the initialOwner
.
To restrict access to a specific address, pass that address as the initialOwner
and 0
as the
initialProjectIdOwner
.
The owner can give owner access to other addresses through the permissions
contract.
constructor(
IJBPermissions permissions,
IJBProjects projects,
address initialOwner,
uint88 initialProjectIdOwner
)
JBPermissioned(permissions);
Parameters
Name | Type | Description |
---|---|---|
permissions | IJBPermissions | A contract storing permissions. |
projects | IJBProjects | Mints ERC-721s that represent project ownership and transfers. |
initialOwner | address | The owner if the intialProjectIdOwner is 0 (until ownership is transferred). |
initialProjectIdOwner | uint88 | The ID of the Juicebox project whose owner is this contract's owner (until ownership is transferred). |
owner
Returns the owner's address based on this contract's JBOwner
.
function owner() public view virtual returns (address);
_checkOwner
Reverts if the sender is not the owner.
function _checkOwner() internal view virtual;
renounceOwnership
Gives up ownership of this contract, making it impossible to call onlyOwner
and _checkOwner
functions.
This can only be called by the current owner.
function renounceOwnership() public virtual override;
setPermissionId
Sets the permission ID the owner can use to give other addresses owner access.
This can only be called by the current owner.
function setPermissionId(uint8 permissionId) public virtual override;
Parameters
Name | Type | Description |
---|---|---|
permissionId | uint8 | The permission ID to use for onlyOwner . |
transferOwnership
Transfers ownership of this contract to a new address (the newOwner
). Can only be called by the
current owner.
This can only be called by the current owner.
function transferOwnership(address newOwner) public virtual override;
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | The address to transfer ownership to. |
transferOwnershipToProject
Transfer ownership of this contract to a new Juicebox project.
This can only be called by the current owner.
The projectId
must fit within a uint88
.
function transferOwnershipToProject(uint256 projectId) public virtual override;
Parameters
Name | Type | Description |
---|---|---|
projectId | uint256 | The ID of the project to transfer ownership to. |
_emitTransferEvent
Either newOwner
or newProjectId
is non-zero or both are zero. But they can never both be non-zero.
This function exists because some contracts will try to deploy contracts for a project before
function _emitTransferEvent(address previousOwner, address newOwner, uint88 newProjectId) internal virtual;
_setPermissionId
Sets the permission ID the owner can use to give other addresses owner access.
Internal function without access restriction.
function _setPermissionId(uint8 permissionId) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
permissionId | uint8 | The permission ID to use for onlyOwner . |
_transferOwnership
Helper to allow for drop-in replacement of OpenZeppelin Ownable
.
function _transferOwnership(address newOwner) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | The address that should receive ownership of this contract. |
_transferOwnership
Transfers this contract's ownership to an address (newOwner
) OR a Juicebox project (projectId
).
Updates this contract's JBOwner
owner information and resets the JBOwner.permissionId
.
If both newOwner
and projectId
are set, this will revert.
Internal function without access restriction.
function _transferOwnership(address newOwner, uint88 projectId) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | The address that should become this contract's owner. |
projectId | uint88 | The ID of the project whose owner should become this contract's owner. |
Errors
JBOwnableOverrides_InvalidNewOwner
error JBOwnableOverrides_InvalidNewOwner();