setPrimaryTerminalOf
Contract: JBDirectory
Interface: IJBDirectory
- Step by step
- Code
- Errors
- Events
- Bug bounty
Project's can set which terminal should be their primary for a particular token.
This is useful in case a project has several terminals connected for a particular token.
The terminal will be set as the primary terminal where ecosystem contracts should route tokens.
If setting a newly added terminal and the funding cycle doesn't allow new terminals, the caller must be the current controller.
Definitionβ
function setPrimaryTerminalOf(
uint256 _projectId,
address _token,
IJBPaymentTerminal _terminal
)
external
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.SET_PRIMARY_TERMINAL) { ... }
- Arguments:
_projectId
is the ID of the project for which a primary token is being set._token
is the token to set the primary terminal of._terminal
is the terminal to make primary.
- Through the
requirePermission
modifier, the function is only accessible by the project's owner, or from an operator that has been given theJBOperations.SET_PRIMARY_TERMINAL
permission by the project owner for the provided_projectId
. - The function overrides a function definition from the
IJBDirectory
interface. - The function doesn't return anything.
Bodyβ
-
Make sure the provided terminal accepts to provided token.
// Can't set the primary terminal for a token if it doesn't accept the token.
if (!_terminal.acceptsToken(_token, _projectId)) revert TOKEN_NOT_ACCEPTED();External references:
-
Make sure the project's current funding cycle is set to allow setting terminals, or the request to set the terminals is coming from the project's current controller.
// Add the terminal to the project if it hasn't been already.
_addTerminalIfNeeded(_projectId, _terminal);Internal references:
-
Store the new terminal as the primary.
// Store the terminal as the primary for the particular token.
_primaryTerminalOf[_projectId][_token] = _terminal;Internal references:
-
Emit a
SetPrimaryTerminal
event with the relevant parameters.emit SetPrimaryTerminal(_projectId, _token, _terminal, msg.sender);
Event references:
/**
@notice
Project's can set which terminal should be their primary for a particular token.
This is useful in case a project has several terminals connected for a particular token.
@dev
The terminal will be set as the primary terminal where ecosystem contracts should route tokens.
@dev
If setting a newly added terminal and the funding cycle doesn't allow new terminals, the caller must be the current controller.
@param _projectId The ID of the project for which a primary token is being set.
@param _token The token to set the primary terminal of.
@param _terminal The terminal to make primary.
*/
function setPrimaryTerminalOf(
uint256 _projectId,
address _token,
IJBPaymentTerminal _terminal
)
external
override
requirePermission(projects.ownerOf(_projectId), _projectId, JBOperations.SET_PRIMARY_TERMINAL)
{
// Can't set the primary terminal for a token if it doesn't accept the token.
if (!_terminal.acceptsToken(_token, _projectId)) revert TOKEN_NOT_ACCEPTED();
// Add the terminal to the project if it hasn't been already.
_addTerminalIfNeeded(_projectId, _terminal);
// Store the terminal as the primary for the particular token.
_primaryTerminalOf[_projectId][_token] = _terminal;
emit SetPrimaryTerminal(_projectId, _token, _terminal, msg.sender);
}
String | Description |
---|---|
TOKEN_NOT_ACCEPTED | Thrown if the provided terminal doesn't accept the provided token. |
Name | Data |
---|---|
SetPrimaryTerminal |
|
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 |