Skip to content

Commit

Permalink
bypass all fail cases of fulfillment
Browse files Browse the repository at this point in the history
  • Loading branch information
mejango committed Jun 23, 2023
1 parent f35f6e2 commit 084a560
Show file tree
Hide file tree
Showing 15 changed files with 27,938 additions and 26,530 deletions.
239 changes: 94 additions & 145 deletions contracts/DefifaDeployer.sol

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions contracts/DefifaProjectOwner.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}
}
1 change: 0 additions & 1 deletion contracts/forge-test/SVG.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ contract SVGTest is Test {
IJBTiered721DelegateStore _store;
ITypeface _typeface;

address defifaBallkidz = address(0);
address delegateRegistry = address(0);

function setUp() public {
Expand Down
4 changes: 1 addition & 3 deletions contracts/interfaces/IDefifaDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface IDefifaDeployer {
address caller
);

event DistributeToSplit(JBSplit split, uint256 amount, address defaultBeneficiary, address caller);
event DistributeToSplit(JBSplit split, uint256 amount, address caller);

function splitGroup() external view returns (uint256);

Expand All @@ -35,8 +35,6 @@ interface IDefifaDeployer {

function controller() external view returns (IJBController3_1);

function protocolFeeProjectTokenAccount() external view returns (address);

function delegatesRegistry() external view returns (IJBDelegatesRegistry);

function feeDivisor() external view returns (uint256);
Expand Down
39 changes: 21 additions & 18 deletions contracts/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.16;

import {Script} from "forge-std/Script.sol";
import {ITypeface} from "lib/typeface/contracts/interfaces/ITypeface.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@jbx-protocol/juice-delegates-registry/src/interfaces/IJBDelegatesRegistry.sol";
import "@jbx-protocol/juice-contracts-v3/contracts/libraries/JBTokens.sol";
import "@jbx-protocol/juice-721-delegate/contracts/interfaces/IJBTiered721DelegateStore.sol";
import "../DefifaDeployer.sol";
import "../DefifaGovernor.sol";
import "../DefifaTokenUriResolver.sol";
import "forge-std/Script.sol";
import {IJBDelegatesRegistry} from "@jbx-protocol/juice-delegates-registry/src/interfaces/IJBDelegatesRegistry.sol";
import {JBTokens} from "@jbx-protocol/juice-contracts-v3/contracts/libraries/JBTokens.sol";
import {IJBController3_1} from "@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBController3_1.sol";
import {IJBOperatable} from "@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBOperatable.sol";
import {IJBTiered721DelegateStore} from
"@jbx-protocol/juice-721-delegate/contracts/interfaces/IJBTiered721DelegateStore.sol";
import {DefifaDelegate} from "../DefifaDelegate.sol";
import {DefifaDeployer} from "../DefifaDeployer.sol";
import {DefifaGovernor} from "../DefifaGovernor.sol";
import {DefifaProjectOwner} from "../DefifaProjectOwner.sol";
import {DefifaTokenUriResolver} from "../DefifaTokenUriResolver.sol";

contract DeployMainnet is Script {
// V3_1 mainnet controller.
IJBController3_1 _controller = IJBController3_1(0x97a5b9D9F0F7cD676B69f584F29048D0Ef4BB59b);

address _defifaBallkidz = 0x11834239698c7336EF232C00a2A9926d3375DF9D;
IJBDelegatesRegistry _delegateRegistry = IJBDelegatesRegistry(0x7A53cAA1dC4d752CAD283d039501c0Ee45719FaC);
ITypeface _typeface = ITypeface(0xA77b7D93E79f1E6B4f77FaB29d9ef85733A3D44A);

uint256 _defifaProjectId = 369;
uint256 _jbxProjectId = 1;

IERC20 _defifaToken = IERC20(address(_controller.tokenStore().tokenOf(_defifaProjectId)));
IERC20 _jbxToken = IERC20(address(_controller.tokenStore().tokenOf(_defifaProjectId)));
IERC20 _jbxToken = IERC20(address(_controller.tokenStore().tokenOf(_jbxProjectId)));

uint256 _blockTime = 12;

Expand All @@ -44,25 +50,24 @@ contract DeployMainnet is Script {
_defifaGovernor,
_controller,
_delegateRegistry,
_defifaBallkidz,
_defifaProjectId,
_defifaBallkidz
_defifaProjectId
);

new DefifaProjectOwner(IJBOperatable(address(_controller)).operatorStore(), _controller.projects(), _defifaDeployer);

_defifaGovernor.transferOwnership(address(_defifaDeployer));
console.log(address(_defifaDeployer));
}
}

contract DeployGoerli is Script {
// V3_1 goerli controller.
IJBController3_1 _controller = IJBController3_1(0x1d260DE91233e650F136Bf35f8A4ea1F2b68aDB6);

address _defifaBallkidz = 0x11834239698c7336EF232C00a2A9926d3375DF9D;
IJBDelegatesRegistry _delegateRegistry = IJBDelegatesRegistry(0xCe3Ebe8A7339D1f7703bAF363d26cD2b15D23C23);
ITypeface _typeface = ITypeface(0x8Df17136B20DA6D1E23dB2DCdA8D20Aa4ebDcda7);

uint256 _defifaProjectId = 1;
uint256 _jbxProjectId = 1;

IERC20 _defifaToken = IERC20(address(_controller.tokenStore().tokenOf(_defifaProjectId)));
IERC20 _jbxToken = IERC20(address(_controller.tokenStore().tokenOf(_defifaProjectId)));
Expand All @@ -88,13 +93,11 @@ contract DeployGoerli is Script {
_defifaGovernor,
_controller,
_delegateRegistry,
_defifaBallkidz,
_defifaProjectId,
_defifaBallkidz
_defifaProjectId
);

_defifaGovernor.transferOwnership(address(_defifaDeployer));

console.log(address(_defifaDeployer));
new DefifaProjectOwner(IJBOperatable(address(_controller)).operatorStore(), _controller.projects(), _defifaDeployer);
}
}
30,307 changes: 14,402 additions & 15,905 deletions out/DefifaDeployer.sol/DefifaDeployer.json

Large diffs are not rendered by default.

Loading

0 comments on commit 084a560

Please sign in to comment.