_eligibleOf
Contract: JBFundingCycleStore
- Step by step
- Code
- Bug bounty
The project's stored funding cycle that has started and hasn't yet expired.
A value of 0 is returned if no funding cycle was found.
Assumes the project has a latest configuration.
Definition
function _eligibleOf(uint256 _projectId) private view returns (uint256 configuration) { ... }
- Arguments:
- _projectIdis the ID of the project to look through.
 
- The view function is private to this contract.
- The view function does not alter state on the blockchain.
- The function returns the configuration of an eligible funding cycle if one exists, or 0 if one doesn't exist.
Body
- 
Get a reference to the latest funding cycle for the project. // Get a reference to the project's latest funding cycle.
 configuration = latestConfigurationOf[_projectId];Internal references: 
- 
Get the struct for the latest funding cycle. // Get the latest funding cycle.
 JBFundingCycle memory _fundingCycle = _getStructFor(_projectId, configuration);Internal references: 
- 
If the latest is expired, return an empty funding cycle since there can't be a stored eligible cycle. // If the latest is expired, return an empty funding cycle.
 // A duration of 0 cannot be expired.
 if (
 _fundingCycle.duration > 0 && block.timestamp >= _fundingCycle.start + _fundingCycle.duration
 ) return 0;
- 
If the funding cycle has started, it must be eligible. // Return the funding cycle's configuration if it has started.
 if (block.timestamp >= _fundingCycle.start) return _fundingCycle.configuration;
- 
Get a reference to the funding cycle that the current cycle is based on. // Get a reference to the cycle's base configuration.
 JBFundingCycle memory _baseFundingCycle = _getStructFor(_projectId, _fundingCycle.basedOn);Internal references: 
- 
If the base is expired, return an empty funding cycle since there can't be a stored eligible cycle. // If the base cycle isn't eligible, the project has no eligible cycle.
 // A duration of 0 is always eligible.
 if (
 _baseFundingCycle.duration > 0 &&
 block.timestamp >= _baseFundingCycle.start + _baseFundingCycle.duration
 ) return 0;
- 
Return the configuration that the latest funding cycle is based on. // Return the configuration that the latest funding cycle is based on.
 configuration = _fundingCycle.basedOn;
/**
  @notice
  The project's stored funding cycle that has started and hasn't yet expired.
  @dev
  A value of 0 is returned if no funding cycle was found.
  @dev
  Assumes the project has a latest configuration.
  @param _projectId The ID of the project to look through.
  @return configuration The configuration of an eligible funding cycle if one exists, or 0 if one doesn't exist.
*/
function _eligibleOf(uint256 _projectId) private view returns (uint256 configuration) {
  // Get a reference to the project's latest funding cycle.
  configuration = latestConfigurationOf[_projectId];
  // Get the latest funding cycle.
  JBFundingCycle memory _fundingCycle = _getStructFor(_projectId, configuration);
  // If the latest is expired, return an empty funding cycle.
  // A duration of 0 can not be expired.
  if (
    _fundingCycle.duration > 0 && block.timestamp >= _fundingCycle.start + _fundingCycle.duration
  ) return 0;
  // Return the funding cycle's configuration if it has started.
  if (block.timestamp >= _fundingCycle.start) return _fundingCycle.configuration;
  // Get a reference to the cycle's base configuration.
  JBFundingCycle memory _baseFundingCycle = _getStructFor(_projectId, _fundingCycle.basedOn);
  // If the base cycle isn't eligible, the project has no eligible cycle.
  // A duration of 0 is always eligible.
  if (
    _baseFundingCycle.duration > 0 &&
    block.timestamp >= _baseFundingCycle.start + _baseFundingCycle.duration
  ) return 0;
  // Return the configuration that the latest funding cycle is based on.
  configuration = _fundingCycle.basedOn;
}
| 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 |