Skip to main content

_eligibleOf

Contract: JBFundingCycleStore

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:
    • _projectId is 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

  1. 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:

  2. Get the struct for the latest funding cycle.

    // Get the latest funding cycle.
    JBFundingCycle memory _fundingCycle = _getStructFor(_projectId, configuration);

    Internal references:

  3. 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;
  4. 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;
  5. 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:

  6. 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;
  7. 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;