Skip to content

Commit

Permalink
3.2 controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mejango committed Aug 30, 2023
1 parent 4dfc602 commit 52deb26
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 14 deletions.
26 changes: 12 additions & 14 deletions contracts/JBController3_2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {PRBMath} from '@paulrberg/contracts/math/PRBMath.sol';
import {JBOperatable} from './abstract/JBOperatable.sol';
import {JBBallotState} from './enums/JBBallotState.sol';
import {IJBController3_0_1} from './interfaces/IJBController3_0_1.sol';
import {IJBController3_1} from './interfaces/IJBController3_1.sol';
import {IJBController3_2} from './interfaces/IJBController3_2.sol';
import {IJBController} from './interfaces/IJBController.sol';
import {IJBDirectory} from './interfaces/IJBDirectory.sol';
import {IJBFundAccessConstraintsStore} from './interfaces/IJBFundAccessConstraintsStore.sol';
Expand Down Expand Up @@ -36,7 +35,7 @@ import {JBSplit} from './structs/JBSplit.sol';

/// @notice Stitches together funding cycles and project tokens, making sure all activity is accounted for and correct.
/// @dev This Controller has the same functionality as JBController3_0_1, except it is not backwards compatible with the original IJBController view methods.
contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratable {
contract JBController3_2 is JBOperatable, ERC165, IJBController3_2, IJBMigratable {
// A library that parses the packed funding cycle metadata into a more friendly format.
using JBFundingCycleMetadataResolver3_2 for JBFundingCycle;

Expand Down Expand Up @@ -123,7 +122,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
external
view
override
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata memory metadata)
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata3_2 memory metadata)
{
fundingCycle = fundingCycleStore.get(_projectId, _configuration);
metadata = fundingCycle.expandMetadata();
Expand All @@ -142,7 +141,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
override
returns (
JBFundingCycle memory fundingCycle,
JBFundingCycleMetadata memory metadata,
JBFundingCycleMetadata3_2 memory metadata,
JBBallotState ballotState
)
{
Expand All @@ -160,7 +159,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
external
view
override
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata memory metadata)
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata3_2 memory metadata)
{
fundingCycle = fundingCycleStore.currentOf(_projectId);
metadata = fundingCycle.expandMetadata();
Expand All @@ -176,7 +175,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
external
view
override
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata memory metadata)
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata3_2 memory metadata)
{
fundingCycle = fundingCycleStore.queuedOf(_projectId);
metadata = fundingCycle.expandMetadata();
Expand All @@ -202,8 +201,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
bytes4 _interfaceId
) public view virtual override(ERC165, IERC165) returns (bool) {
return
_interfaceId == type(IJBController3_1).interfaceId ||
_interfaceId == type(IJBController3_0_1).interfaceId ||
_interfaceId == type(IJBController3_2).interfaceId ||
_interfaceId == type(IJBMigratable).interfaceId ||
_interfaceId == type(IJBOperatable).interfaceId ||
super.supportsInterface(_interfaceId);
Expand Down Expand Up @@ -258,7 +256,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
address _owner,
JBProjectMetadata calldata _projectMetadata,
JBFundingCycleData calldata _data,
JBFundingCycleMetadata calldata _metadata,
JBFundingCycleMetadata3_2 calldata _metadata,
uint256 _mustStartAtOrAfter,
JBGroupedSplits[] calldata _groupedSplits,
JBFundAccessConstraints[] calldata _fundAccessConstraints,
Expand Down Expand Up @@ -305,7 +303,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
function launchFundingCyclesFor(
uint256 _projectId,
JBFundingCycleData calldata _data,
JBFundingCycleMetadata calldata _metadata,
JBFundingCycleMetadata3_2 calldata _metadata,
uint256 _mustStartAtOrAfter,
JBGroupedSplits[] calldata _groupedSplits,
JBFundAccessConstraints[] memory _fundAccessConstraints,
Expand Down Expand Up @@ -354,7 +352,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
function reconfigureFundingCyclesOf(
uint256 _projectId,
JBFundingCycleData calldata _data,
JBFundingCycleMetadata calldata _metadata,
JBFundingCycleMetadata3_2 calldata _metadata,
uint256 _mustStartAtOrAfter,
JBGroupedSplits[] calldata _groupedSplits,
JBFundAccessConstraints[] calldata _fundAccessConstraints,
Expand Down Expand Up @@ -706,7 +704,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
function _configure(
uint256 _projectId,
JBFundingCycleData calldata _data,
JBFundingCycleMetadata calldata _metadata,
JBFundingCycleMetadata3_2 calldata _metadata,
uint256 _mustStartAtOrAfter,
JBGroupedSplits[] memory _groupedSplits,
JBFundAccessConstraints[] memory _fundAccessConstraints
Expand All @@ -725,7 +723,7 @@ contract JBController3_1 is JBOperatable, ERC165, IJBController3_1, IJBMigratabl
JBFundingCycle memory _fundingCycle = fundingCycleStore.configureFor(
_projectId,
_data,
JBFundingCycleMetadataResolver.packFundingCycleMetadata(_metadata),
JBFundingCycleMetadataResolver3_2.packFundingCycleMetadata(_metadata),
_mustStartAtOrAfter
);

Expand Down
178 changes: 178 additions & 0 deletions contracts/interfaces/IJBController3_2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol';
import {JBBallotState} from './../enums/JBBallotState.sol';
import {JBFundAccessConstraints} from './../structs/JBFundAccessConstraints.sol';
import {JBFundingCycle} from './../structs/JBFundingCycle.sol';
import {JBFundingCycleData} from './../structs/JBFundingCycleData.sol';
import {JBFundingCycleMetadata3_2} from './../structs/JBFundingCycleMetadata3_2.sol';
import {JBGroupedSplits} from './../structs/JBGroupedSplits.sol';
import {JBProjectMetadata} from './../structs/JBProjectMetadata.sol';
import {JBSplit} from './../structs/JBSplit.sol';
import {IJBController3_0_1} from './IJBController3_0_1.sol';
import {IJBDirectory} from './IJBDirectory.sol';
import {IJBFundAccessConstraintsStore} from './IJBFundAccessConstraintsStore.sol';
import {IJBFundingCycleStore} from './IJBFundingCycleStore.sol';
import {IJBMigratable} from './IJBMigratable.sol';
import {IJBPaymentTerminal} from './IJBPaymentTerminal.sol';
import {IJBProjects} from './IJBProjects.sol';
import {IJBSplitsStore} from './IJBSplitsStore.sol';
import {IJBTokenStore} from './IJBTokenStore.sol';

interface IJBController3_2 is IJBController3_0_1, IERC165 {
event LaunchProject(uint256 configuration, uint256 projectId, string memo, address caller);

event LaunchFundingCycles(uint256 configuration, uint256 projectId, string memo, address caller);

event ReconfigureFundingCycles(
uint256 configuration,
uint256 projectId,
string memo,
address caller
);

event DistributeReservedTokens(
uint256 indexed fundingCycleConfiguration,
uint256 indexed fundingCycleNumber,
uint256 indexed projectId,
address beneficiary,
uint256 tokenCount,
uint256 beneficiaryTokenCount,
string memo,
address caller
);

event DistributeToReservedTokenSplit(
uint256 indexed projectId,
uint256 indexed domain,
uint256 indexed group,
JBSplit split,
uint256 tokenCount,
address caller
);

event MintTokens(
address indexed beneficiary,
uint256 indexed projectId,
uint256 tokenCount,
uint256 beneficiaryTokenCount,
string memo,
uint256 reservedRate,
address caller
);

event BurnTokens(
address indexed holder,
uint256 indexed projectId,
uint256 tokenCount,
string memo,
address caller
);

event Migrate(uint256 indexed projectId, IJBMigratable to, address caller);

event PrepMigration(uint256 indexed projectId, address from, address caller);

function projects() external view returns (IJBProjects);

function fundingCycleStore() external view returns (IJBFundingCycleStore);

function tokenStore() external view returns (IJBTokenStore);

function splitsStore() external view returns (IJBSplitsStore);

function fundAccessConstraintsStore() external view returns (IJBFundAccessConstraintsStore);

function directory() external view returns (IJBDirectory);

function reservedTokenBalanceOf(uint256 projectId) external view returns (uint256);

function totalOutstandingTokensOf(uint256 projectId) external view returns (uint256);

function getFundingCycleOf(
uint256 projectId,
uint256 configuration
)
external
view
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata3_2 memory metadata);

function latestConfiguredFundingCycleOf(
uint256 projectId
)
external
view
returns (JBFundingCycle memory, JBFundingCycleMetadata3_2 memory metadata, JBBallotState);

function currentFundingCycleOf(
uint256 projectId
)
external
view
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata3_2 memory metadata);

function queuedFundingCycleOf(
uint256 projectId
)
external
view
returns (JBFundingCycle memory fundingCycle, JBFundingCycleMetadata3_2 memory metadata);

function launchProjectFor(
address owner,
JBProjectMetadata calldata projectMetadata,
JBFundingCycleData calldata data,
JBFundingCycleMetadata3_2 calldata metadata,
uint256 mustStartAtOrAfter,
JBGroupedSplits[] memory groupedSplits,
JBFundAccessConstraints[] memory fundAccessConstraints,
IJBPaymentTerminal[] memory terminals,
string calldata memo
) external returns (uint256 projectId);

function launchFundingCyclesFor(
uint256 projectId,
JBFundingCycleData calldata data,
JBFundingCycleMetadata3_2 calldata metadata,
uint256 mustStartAtOrAfter,
JBGroupedSplits[] memory groupedSplits,
JBFundAccessConstraints[] memory fundAccessConstraints,
IJBPaymentTerminal[] memory terminals,
string calldata memo
) external returns (uint256 configuration);

function reconfigureFundingCyclesOf(
uint256 projectId,
JBFundingCycleData calldata data,
JBFundingCycleMetadata3_2 calldata metadata,
uint256 mustStartAtOrAfter,
JBGroupedSplits[] memory groupedSplits,
JBFundAccessConstraints[] memory fundAccessConstraints,
string calldata memo
) external returns (uint256);

function mintTokensOf(
uint256 projectId,
uint256 tokenCount,
address beneficiary,
string calldata memo,
bool preferClaimedTokens,
bool useReservedRate
) external returns (uint256 beneficiaryTokenCount);

function burnTokensOf(
address holder,
uint256 projectId,
uint256 tokenCount,
string calldata memo,
bool preferClaimedTokens
) external;

function distributeReservedTokensOf(
uint256 projectId,
string memory memo
) external returns (uint256);

function migrate(uint256 projectId, IJBMigratable to) external;
}

0 comments on commit 52deb26

Please sign in to comment.