Skip to content

Commit

Permalink
feat: option to have JBProject mint the fee project on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
xBA5ED committed Apr 2, 2024
1 parent ef4f60d commit bbde4dd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
url = https://github.com/sphinx-labs/sphinx
46 changes: 35 additions & 11 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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);
}
}
}
21 changes: 17 additions & 4 deletions src/JBProjects.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/TestBaseWorkflow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/units/static/JBProjects/JBProjectsSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit bbde4dd

Please sign in to comment.