-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefifaProjectOwner.sol
54 lines (44 loc) · 2.34 KB
/
DefifaProjectOwner.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IJBOperatorStore} from "@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBOperatorStore.sol";
import {IJBProjects} from "@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBProjects.sol";
import {JBOperations} from "@jbx-protocol/juice-contracts-v3/contracts/libraries/JBOperations.sol";
import {JBOperatorData} from "@jbx-protocol/juice-contracts-v3/contracts/structs/JBOperatorData.sol";
import {DefifaDeployer} from "./DefifaDeployer.sol";
/// @notice A contract that can be sent a project to be burned, while still allowing defifa permissions.
contract DefifaProjectOwner is IERC721Receiver {
/// @notice The contract where operator permissions are stored.
IJBOperatorStore public operatorStore;
/// @notice The contract from which project are minted.
IJBProjects public projects;
/// @notice The Defifa deployer.
DefifaDeployer public deployer;
/// @param _operatorStore The contract where operator permissions are stored.
/// @param _projects The contract from which project are minted.
/// @param _deployer The Defifa deployer which will receive permissions to set splits.
constructor(IJBOperatorStore _operatorStore, IJBProjects _projects, DefifaDeployer _deployer) {
operatorStore = _operatorStore;
projects = _projects;
deployer = _deployer;
}
/// @notice Give the defifa deployer permission to set splits on this contract's behalf.
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
external
returns (bytes4)
{
_data;
_from;
_operator;
// Make sure the 721 received is the JBProjects contract.
if (msg.sender != address(projects)) revert();
// Set the correct permission.
uint256[] memory _permissionIndexes = new uint256[](1);
_permissionIndexes[0] = JBOperations.SET_SPLITS;
// Give the defifa deployer contract permission to set splits on this contract's behalf.
operatorStore.setOperator(
JBOperatorData({operator: address(deployer), domain: _tokenId, permissionIndexes: _permissionIndexes})
);
return IERC721Receiver.onERC721Received.selector;
}
}