finalize
Contract: JBReconfigurationBufferBallot
Interface: IJBReconfigurationBufferBallot
- Step by step
- Code
- Events
- Bug bounty
Finalizes a configuration state if the current state has settled.
Definitionβ
function finalize(uint256 _projectId, uint256 _configured)
external
override
returns (JBBallotState ballotState) { ... }
- Arguments:
_projectId
is the ID of the project to which the funding cycle being checked belongs._configured
is the configuration of the funding cycle to check the state of.
- The function overrides a function definition from the
IJBReconfigurationBufferBallot
interface. - The function returns the state of the finalized ballot. If
Active
, the ballot can still later be finalized when it's state resolves.
Bodyβ
-
Get a reference to the project's currency funding cycle.
// Get the funding cycle for the configuration.
JBFundingCycle memory _fundingCycle = fundingCycleStore.get(_projectId, _configured);Internal references:
External references:
-
Get a reference to the current finalized ballot state.
// Get the current ballot state.
ballotState = finalState[_projectId][_configured];Internal references:
-
If the currency final state is still unresolved, store the updated value it if it has now resolved and emit a
Finalize
event with the relevant parameters.// If the final ballot skate is still `Active`.
if (ballotState == JBBallotState.Active) {
ballotState = stateOf(_projectId, _configured, _fundingCycle.start);
// If the ballot is active after the cycle has started, it should be finalized as failed.
if (ballotState != JBBallotState.Active) {
// Store the updated value.
finalState[_projectId][_configured] = ballotState;
emit Finalize(_projectId, _configured, ballotState, msg.sender);
}
}Enums used:
JBBallotState
.Active
Internal references:
Event references:
/**
@notice
Finalizes a configuration state if the current state has settled.
@param _projectId The ID of the project to which the funding cycle being checked belongs.
@param _configured The configuration of the funding cycle to check the state of.
@return ballotState The state of the finalized ballot. If `Active`, the ballot can still later be finalized when it's state resolves.
*/
function finalize(uint256 _projectId, uint256 _configured)
external
override
returns (JBBallotState ballotState)
{
// Get the funding cycle for the configuration in question.
JBFundingCycle memory _fundingCycle = fundingCycleStore.get(_projectId, _configured);
// Get the current ballot state.
ballotState = finalState[_projectId][_configured];
// If the final ballot skate is still `Active`.
if (ballotState == JBBallotState.Active) {
ballotState = stateOf(_projectId, _configured, _fundingCycle.start);
// If the ballot is active after the cycle has started, it should be finalized as failed.
if (ballotState != JBBallotState.Active) {
// Store the updated value.
finalState[_projectId][_configured] = ballotState;
emit Finalize(_projectId, _configured, ballotState, msg.sender);
}
}
}
Name | Data |
---|---|
Finalize |
|
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 |