diff --git a/.gitmodules b/.gitmodules index 0db309a9..9cac08ea 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/foundry-rs/forge-std [submodule "lib/sphinx"] path = lib/sphinx - url = https://github.com/sphinx-labs/sphinx \ No newline at end of file + url = https://github.com/sphinx-labs/sphinx diff --git a/lib/sphinx b/lib/sphinx index 9c857ee4..db6d0b3b 160000 --- a/lib/sphinx +++ b/lib/sphinx @@ -1 +1 @@ -Subproject commit 9c857ee4432259c633fa1a4112ff5e43fca07fc1 +Subproject commit db6d0b3bac67fe520cb91d230edd7db5b39c19e5 diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index f18496d1..c7b86d05 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -28,7 +28,10 @@ contract Deploy is Script, Sphinx { address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87; /// @notice The address that will manage the few privileged functions of the protocol. - address private constant MANAGER = 0x823b92d6a4b2AED4b15675c7917c9f922ea8ADAD; + address private MANAGER; + + /// @notice The address that will own the fee-project. + address private FEE_PROJECT_OWNER; function configureSphinx() public override { // TODO: Update to contain JB Emergency Developers @@ -42,11 +45,20 @@ contract Deploy is Script, Sphinx { /// @notice Deploys the protocol. function run() public sphinx { - address _sender = safeAddress(); + // Set the manager, this can be changed and won't affect deployment addresses. + MANAGER = 0x823b92d6a4b2AED4b15675c7917c9f922ea8ADAD; + FEE_PROJECT_OWNER = 0x823b92d6a4b2AED4b15675c7917c9f922ea8ADAD; + + // Deploy the protocol. + deploy(); + } + + function deploy() public sphinx { + address _safe = safeAddress(); JBPermissions permissions = new JBPermissions(); - JBProjects projects = new JBProjects(MANAGER); - JBDirectory directory = new JBDirectory(permissions, projects, _sender); + JBProjects projects = new JBProjects(_safe, _safe); + JBDirectory directory = new JBDirectory(permissions, projects, _safe); JBSplits splits = new JBSplits(directory); JBRulesets rulesets = new JBRulesets(directory); directory.setIsAllowedToSetFirstController( @@ -64,20 +76,32 @@ contract Deploy is Script, Sphinx { ), true ); - directory.transferOwnership(MANAGER); + + JBFeelessAddresses feeless = new JBFeelessAddresses(_safe); + JBPrices prices = new JBPrices(permissions, projects, _safe); + new JBMultiTerminal({ permissions: permissions, projects: projects, directory: directory, splits: splits, - store: new JBTerminalStore({ - directory: directory, - rulesets: rulesets, - prices: new JBPrices(permissions, projects, MANAGER) - }), - feelessAddresses: new JBFeelessAddresses(MANAGER), + store: new JBTerminalStore({directory: directory, rulesets: rulesets, prices: prices}), + feelessAddresses: feeless, permit2: _PERMIT2, trustedForwarder: TRUSTED_FORWARDER }); + + // If the manager is not the deployer we transfer all ownership to it. + if (MANAGER != _safe && MANAGER != address(0)) { + directory.transferOwnership(MANAGER); + feeless.transferOwnership(MANAGER); + prices.transferOwnership(MANAGER); + projects.transferOwnership(MANAGER); + } + + // Transfer ownership to the fee project owner. + if (FEE_PROJECT_OWNER != _safe && FEE_PROJECT_OWNER != address(0)) { + projects.safeTransferFrom(_safe, MANAGER, 1); + } } } diff --git a/src/JBProjects.sol b/src/JBProjects.sol index f2200642..f11d5c39 100644 --- a/src/JBProjects.sol +++ b/src/JBProjects.sol @@ -56,21 +56,30 @@ contract JBProjects is ERC721Votes, Ownable, IJBProjects { //*********************************************************************// /// @param owner The owner of the contract who can set metadata. - constructor(address owner) + /// @param feeProjectOwner The address that will receive the fee-project. If `address(0)` the fee-project will not + /// be minted. + constructor( + address owner, + address feeProjectOwner + ) ERC721("Juicebox Projects", "JUICEBOX") EIP712("Juicebox Projects", "1") Ownable(owner) - {} + { + if (feeProjectOwner != address(0)) { + createFor(feeProjectOwner); + } + } //*********************************************************************// - // ---------------------- external transactions ---------------------- // + // ---------------------- public transactions ---------------------- // //*********************************************************************// /// @notice Create a new project for the specified owner, which mints an NFT (ERC-721) into their wallet. /// @dev Anyone can create a project on an owner's behalf. /// @param owner The address that will be the owner of the project. /// @return projectId The token ID of the newly created project. - function createFor(address owner) external override returns (uint256 projectId) { + function createFor(address owner) public override returns (uint256 projectId) { // Increment the count, which will be used as the ID. projectId = ++count; @@ -80,6 +89,10 @@ contract JBProjects is ERC721Votes, Ownable, IJBProjects { emit Create(projectId, owner, _msgSender()); } + //*********************************************************************// + // ---------------------- external transactions ---------------------- // + //*********************************************************************// + /// @notice Sets the address of the resolver used to retrieve the tokenURI of projects. /// @param newResolver The address of the new resolver. function setTokenUriResolver(IJBTokenUriResolver newResolver) external override onlyOwner { diff --git a/test/helpers/TestBaseWorkflow.sol b/test/helpers/TestBaseWorkflow.sol index ac0851de..d6271135 100644 --- a/test/helpers/TestBaseWorkflow.sol +++ b/test/helpers/TestBaseWorkflow.sol @@ -204,7 +204,7 @@ contract TestBaseWorkflow is Test, DeployPermit2 { // Deploys and initializes contracts for testing. function setUp() public virtual { _jbPermissions = new JBPermissions(); - _jbProjects = new JBProjects(_multisig); + _jbProjects = new JBProjects(_multisig, address(0)); _jbPrices = new JBPrices(_jbPermissions, _jbProjects, _multisig); _jbDirectory = new JBDirectory(_jbPermissions, _jbProjects, _multisig); _jbErc20 = new JBERC20(); diff --git a/test/units/static/JBProjects/JBProjectsSetup.sol b/test/units/static/JBProjects/JBProjectsSetup.sol index 3b99d261..c6ab8d14 100644 --- a/test/units/static/JBProjects/JBProjectsSetup.sol +++ b/test/units/static/JBProjects/JBProjectsSetup.sol @@ -15,6 +15,6 @@ contract JBProjectsSetup is JBTest { function projectsSetup() public virtual { // Instantiate the contract being tested - _projects = new JBProjects(_owner); + _projects = new JBProjects(_owner, address(0)); } }