Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added OpenZeppelin ERC2771Forwarder to the deployment script #242

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import {JBController} from "src/JBController.sol";
import {JBTerminalStore} from "src/JBTerminalStore.sol";
import {JBMultiTerminal} from "src/JBMultiTerminal.sol";

import {ERC2771Forwarder} from "@openzeppelin/contracts/metatx/ERC2771Forwarder.sol";

contract Deploy is Script, Sphinx {
/// @notice The universal PERMIT2 address.
IPermit2 private constant _PERMIT2 = IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3);

/// @notice The address that is allowed to forward calls to the terminal and controller on a users behalf.
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
string private constant TRUSTED_FORWARDER_NAME = "Juicebox";
address private TRUSTED_FORWARDER;

/// @notice The address that will manage the few privileged functions of the protocol.
address private MANAGER;
Expand All @@ -35,7 +38,7 @@ contract Deploy is Script, Sphinx {

/// @notice The nonce that gets used across all chains to sync deployment addresses and allow for new deployments of
/// the same bytecode.
uint256 private CORE_DEPLOYMENT_NONCE = 16;
uint256 private CORE_DEPLOYMENT_NONCE = 17;

function configureSphinx() public override {
// TODO: Update to contain JB Emergency Developers
Expand All @@ -57,6 +60,9 @@ contract Deploy is Script, Sphinx {
}

function deploy() public sphinx {
TRUSTED_FORWARDER =
address(new ERC2771Forwarder{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(TRUSTED_FORWARDER_NAME));

JBPermissions permissions = new JBPermissions{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}();
JBProjects projects =
new JBProjects{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(safeAddress(), safeAddress());
Expand Down
32 changes: 17 additions & 15 deletions script/helpers/CoreDeploymentLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {JBFundAccessLimits} from "../../src/JBFundAccessLimits.sol";
import {JBController} from "../../src/JBController.sol";
import {JBTerminalStore} from "../../src/JBTerminalStore.sol";
import {JBMultiTerminal} from "../../src/JBMultiTerminal.sol";
import {ERC2771Forwarder} from "@openzeppelin/contracts/metatx/ERC2771Forwarder.sol";

import {SphinxConstants, NetworkInfo} from "@sphinx-labs/contracts/SphinxConstants.sol";

Expand All @@ -32,12 +33,14 @@ struct CoreDeployment {
JBFeelessAddresses feeless;
JBFundAccessLimits fundAccess;
JBTokens tokens;
address trustedForwarder;
}

library CoreDeploymentLib {
// Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
Vm internal constant vm = Vm(VM_ADDRESS);
string constant PROJECT_NAME = "nana-core-testnet";

function getDeployment(string memory path) internal returns (CoreDeployment memory deployment) {
// get chainId for which we need to get the deployment.
Expand Down Expand Up @@ -65,36 +68,35 @@ library CoreDeploymentLib {
view
returns (CoreDeployment memory deployment)
{
deployment.permissions =
JBPermissions(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBPermissions"));
deployment.permissions = JBPermissions(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBPermissions"));

deployment.projects = JBProjects(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBProjects"));
deployment.projects = JBProjects(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBProjects"));

deployment.directory =
JBDirectory(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBDirectory"));
deployment.directory = JBDirectory(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBDirectory"));

deployment.splits = JBSplits(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBSplits"));
deployment.splits = JBSplits(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBSplits"));

deployment.rulesets = JBRulesets(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBRulesets"));
deployment.rulesets = JBRulesets(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBRulesets"));

deployment.controller =
JBController(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBController"));
deployment.controller = JBController(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBController"));

deployment.terminal =
JBMultiTerminal(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBMultiTerminal"));
JBMultiTerminal(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBMultiTerminal"));

deployment.terminalStore =
JBTerminalStore(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBTerminalStore"));
JBTerminalStore(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBTerminalStore"));

deployment.prices = JBPrices(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBPrices"));
deployment.prices = JBPrices(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBPrices"));

deployment.feeless =
JBFeelessAddresses(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBFeelessAddresses"));
JBFeelessAddresses(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBFeelessAddresses"));

deployment.fundAccess =
JBFundAccessLimits(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBFundAccessLimits"));
JBFundAccessLimits(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBFundAccessLimits"));

deployment.tokens = JBTokens(_getDeploymentAddress(path, "nana-core-testnet", network_name, "JBTokens"));
deployment.tokens = JBTokens(_getDeploymentAddress(path, PROJECT_NAME, network_name, "JBTokens"));

deployment.trustedForwarder = _getDeploymentAddress(path, PROJECT_NAME, network_name, "ERC2771Forwarder");
}

/// @notice Get the address of a contract that was deployed by the Deploy script.
Expand Down