changeTokenOf
Contract: JBController
Interface: IJBController
- Step by step
- Code
- Errors
- Bug bounty
Swap the current project's token that is minted and burned for another, and transfer ownership of the current token to another address if needed.
Only a project's owner or operator can change its token.
Definition
function changeTokenOf(
uint256 _projectId,
IJBToken _token,
address _newOwner
)
external
virtual
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.CHANGE_TOKEN) { ... }
- Arguments:
_projectId
is the ID of the project to which the changed token belongs._token
is the new token, which must adhere to theIJBToken
specification._newOwner
is an address to transfer the current token's ownership to. This is optional, but it cannot be done later.
- Through the
requirePermission
modifier, the function is only accessible by the project's owner, or from an operator that has been given theJBOperations.CHANGE_TOKEN
permission by the project owner for the provided_projectId
. - The function can be overriden by inheriting contracts.
- The function overrides a function definition from the
IJBController
interface. - The function doesn't return anything.
Body
-
Get a reference to the project's current funding cycle.
// Get a reference to the project's current funding cycle.
JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);Internal references:
External references:
-
Make sure the current funding cycle for the project allows changing tokens.
// The current funding cycle must not be paused.
if (!_fundingCycle.changeTokenAllowed()) revert CHANGE_TOKEN_NOT_ALLOWED();Library references:
JBFundingCycleMetadataResolver
.changeTokenAllowed(...)
-
Forward the call to the token store.
// Change the token in the store.
tokenStore.changeFor(_projectId, _token, _newOwner);Internal references:
External references:
/**
@notice
Swap the current project's token that is minted and burned for another, and transfer ownership of the current token to another address if needed.
@dev
Only a project's owner or operator can change its token.
@param _projectId The ID of the project to which the changed token belongs.
@param _token The new token.
@param _newOwner An address to transfer the current token's ownership to. This is optional, but it cannot be done later.
*/
function changeTokenOf(
uint256 _projectId,
IJBToken _token,
address _newOwner
)
external
virtual
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.CHANGE_TOKEN)
{
// Get a reference to the project's current funding cycle.
JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);
// The current funding cycle must not be paused.
if (!_fundingCycle.changeTokenAllowed()) revert CHANGE_TOKEN_NOT_ALLOWED();
// Change the token in the store.
tokenStore.changeFor(_projectId, _token, _newOwner);
}
String | Description |
---|---|
CHANGE_TOKEN_NOT_ALLOWED | Thrown if the project doesn't currently allow changing tokens. |
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |