Skip to main content

_configureIntrinsicPropertiesFor

Contract: JBFundingCycleStore

Updates the configurable funding cycle for this project if it exists, otherwise creates one.

Definition

function _configureIntrinsicPropertiesFor(
uint256 _projectId,
uint256 _configuration,
uint256 _weight,
uint256 _mustStartAtOrAfter
) private { ... }
  • Arguments:
    • _projectId is the ID of the project to find a configurable funding cycle for.
    • _configuration is the time at which the funding cycle was configured.
    • _weight is the weight to store in the configured funding cycle.
    • _mustStartAtOrAfter is the time before which the initialized funding cycle can't start.
  • The function is private to this contract.
  • The function doesn't return anything.

Body

  1. If the project does not yet have a funding cycle, initialize a new one.

    // If there's not yet a funding cycle for the project, initialize one.
    if (latestConfigurationOf[_projectId] == 0)
    // Use an empty funding cycle as the base.
    return
    _initFor(_projectId, _getStructFor(0, 0), _configuration, _mustStartAtOrAfter, _weight);

    Internal references:

  2. If there's no standby funding cycle, get a reference to the project's eligible funding cycle. The configurable funding cycle will have to be initialized based on the eligible cycle.

    // Get the active funding cycle's configuration.
    uint256 _currentConfiguration = _eligibleOf(_projectId);

    Internal references:

  3. If there is no eligible funding cycle for the project, get a reference instead to the project's latest funding cycle configuration, which may have been initialized long into the past.

    // If an eligible funding cycle does not exist, get a reference to the latest funding cycle configuration for the project.
    if (_currentConfiguration == 0)
    // Get the latest funding cycle's configuration.
    _currentConfiguration = latestConfigurationOf[_projectId];

    Internal references:

  4. Resolve the funding cycle struct for the currently referenced configuration.

    // Get a reference to the funding cycle.
    JBFundingCycle memory _baseFundingCycle = _getStructFor(_projectId, _currentConfiguration);

    Internal references:

  5. If the configuration isn't approved, get a reference to the configuration it's based on which must be the latest approved configuration.

    if (!_isApproved(_projectId, _baseFundingCycle) || block.timestamp < _baseFundingCycle.start)
    // If it hasn't been approved or hasn't yet started, set the ID to be the funding cycle it's based on,
    // which carries the latest approved configuration.
    _baseFundingCycle = _getStructFor(_projectId, _baseFundingCycle.basedOn;

    Internal references:

  6. Make sure the configuration isn't the same as the base configuration. Only one configuration can be made to a project's funding cycles per block.

    // The configuration can't be the same as the base configuration.
    if (_baseFundingCycle.configuration == _configuration) revert NO_SAME_BLOCK_RECONFIGURATION();
  7. Get a reference to the time after which the base funding cycle's ballot will be resolved. The funding cycle that will be initialized can start any time after the base funding cycle's ballot's duration is up.

    // The time after the ballot of the provided funding cycle has expired.
    // If the provided funding cycle has no ballot, return the current timestamp.
    uint256 _timestampAfterBallot = _baseFundingCycle.ballot == IJBFundingCycleBallot(address(0))
    ? 0
    : _configuration + _baseFundingCycle.ballot.duration();

    Internal references:

  8. Initialize a funding cycle with the correct configuration. Make sure it can only start after the base cycle's ballot has resolved.

    _initFor(
    _projectId,
    _baseFundingCycle,
    _configuration,
    // Can only start after the ballot.
    _timestampAfterBallot > _mustStartAtOrAfter ? _timestampAfterBallot : _mustStartAtOrAfter,
    _weight
    );

    Internal references: