_addTerminalIfNeeded
Contract: JBDirectory
Interface: IJBDirectory
- Step by step
- Code
- Errors
- Events
- Bug bounty
Add a terminal to a project's list of terminals if it hasn't been already.
Definition
function _addTerminalIfNeeded(uint256 _projectId, IJBPaymentTerminal _terminal) private { ... }
- Arguments:
_projectId
is the ID of the project having a terminal added._terminal
is the terminal to add.
- The function is private to this contract.
- The function doesn't return anything.
Body
-
Nothing to do if the terminal is already a terminal of the project.
// Check that the terminal has not already been added.
if (isTerminalOf(_projectId, _terminal)) return;Internal references:
-
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 project's current funding cycle is set to allow setting its terminals, or the request to set the controller is coming from the project's current controller.
// Setting terminals must be allowed if not called from the current controller.
if (
msg.sender != address(controllerOf[_projectId]) && !_fundingCycle.global().allowSetTerminals
) revert SET_TERMINALS_NOT_ALLOWED();Library references:
JBFundingCycleMetadataResolver
.global(...)
Internal references:
-
Add the terminal.
// Add the new terminal.
_terminalsOf[_projectId].push(_terminal);Internal references:
-
Emit a
AddTerminal
event with the relevant parameters.emit AddTerminal(_projectId, _terminal, msg.sender);
Event references:
/**
@notice
Add a terminal to a project's list of terminals if it hasn't been already.
@param _projectId The ID of the project having a terminal added.
@param _terminal The terminal to add.
*/
function _addTerminalIfNeeded(uint256 _projectId, IJBPaymentTerminal _terminal) private {
// Check that the terminal has not already been added.
if (isTerminalOf(_projectId, _terminal)) return;
// Get a reference to the project's current funding cycle.
JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);
// Setting terminals must be allowed if not called from the current controller.
if (
msg.sender != address(controllerOf[_projectId]) && !_fundingCycle.global().allowSetTerminals
) revert SET_TERMINALS_NOT_ALLOWED();
// Add the new terminal.
_terminalsOf[_projectId].push(_terminal);
emit AddTerminal(_projectId, _terminal, msg.sender);
}
String | Description |
---|---|
SET_TERMINALS_NOT_ALLOWED | Thrown if the provided project isn't currently allowed to set its terminals. |
Name | Data |
---|---|
AddTerminal |
|
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 |