From 5d347647a6b6b9243c947ba58cfa341539193082 Mon Sep 17 00:00:00 2001 From: simplemachine92 Date: Wed, 19 Jun 2024 05:57:46 -0500 Subject: [PATCH] remove superfluous configs / globals --- src/JBCCIPSucker.sol | 28 +++----------------------- src/JBSucker.sol | 22 ++++---------------- src/deployers/JBCCIPSuckerDeployer.sol | 5 ++--- src/interfaces/IJBSucker.sol | 2 -- test/Fork.t.sol | 8 ++------ 5 files changed, 11 insertions(+), 54 deletions(-) diff --git a/src/JBCCIPSucker.sol b/src/JBCCIPSucker.sol index 1e31658..c22152d 100644 --- a/src/JBCCIPSucker.sol +++ b/src/JBCCIPSucker.sol @@ -38,13 +38,9 @@ contract JBCCIPSucker is JBSucker { // ---------------------------- constructor -------------------------- // //*********************************************************************// - constructor( - IJBDirectory directory, - IJBTokens tokens, - IJBPermissions permissions, - address peer, - JBAddToBalanceMode atbMode - ) JBSucker(directory, tokens, permissions, peer, atbMode) {} + constructor(IJBDirectory directory, IJBTokens tokens, IJBPermissions permissions, JBAddToBalanceMode atbMode) + JBSucker(directory, tokens, permissions, atbMode) + {} //*********************************************************************// // ------------------------ external views --------------------------- // @@ -159,22 +155,4 @@ contract JBCCIPSucker is JBSucker { feeToken: _feeTokenAddress }); } - - function getFeeForMessage(uint64 remoteSelector, Client.EVM2AnyMessage memory evm2AnyMessage) - external - view - returns (uint256 feeAmount) - { - // Initialize a router client instance to interact with cross-chain router - IRouterClient router = IRouterClient(this.getRouter()); - - // Get the fee required to send the CCIP message - return router.getFee({destinationChainSelector: remoteSelector, message: evm2AnyMessage}); - } - - /// @notice Checks if the `sender` (`msg.sender`) is a valid representative of the remote peer. - /// @param sender The message's sender. - function _isRemotePeer(address sender) internal override returns (bool valid) { - return sender == address(this); - } } diff --git a/src/JBSucker.sol b/src/JBSucker.sol index 70bc2d1..9ab973d 100644 --- a/src/JBSucker.sol +++ b/src/JBSucker.sol @@ -103,9 +103,6 @@ abstract contract JBSucker is JBPermissioned, ModifiedReceiver, IJBSucker { /// @notice The address of this contract's deployer. address public immutable DEPLOYER; - /// @notice The peer sucker on the remote chain. - address public immutable override PEER; - /// @notice The ID of the project (on the local chain) that this sucker is associated with. uint256 public immutable PROJECT_ID; @@ -120,16 +117,11 @@ abstract contract JBSucker is JBPermissioned, ModifiedReceiver, IJBSucker { //*********************************************************************// // ---------------------------- constructor -------------------------- // //*********************************************************************// - constructor( - IJBDirectory directory, - IJBTokens tokens, - IJBPermissions permissions, - address peer, - JBAddToBalanceMode atbMode - ) JBPermissioned(permissions) { + constructor(IJBDirectory directory, IJBTokens tokens, IJBPermissions permissions, JBAddToBalanceMode atbMode) + JBPermissioned(permissions) + { DIRECTORY = directory; TOKENS = tokens; - PEER = peer == address(0) ? address(this) : peer; PROJECT_ID = 1; // TODO: fix this after we make a SuckerDeployer for CCIP /* IJBSuckerDeployer(msg.sender).TEMP_ID_STORE() */; DEPLOYER = msg.sender; ADD_TO_BALANCE_MODE = atbMode; @@ -242,9 +234,7 @@ abstract contract JBSucker is JBPermissioned, ModifiedReceiver, IJBSucker { address origin = abi.decode(any2EvmMessage.sender, (address)); // Make sure that the message came from our peer. - if (!_isRemotePeer(origin)) { - revert NOT_PEER(); - } + if (origin != address(this)) revert NOT_PEER(); // Increase the outstanding amount to be added to the project's balance by the amount being received. amountToAddToBalance[root.token] += root.amount; @@ -462,10 +452,6 @@ abstract contract JBSucker is JBPermissioned, ModifiedReceiver, IJBSucker { internal virtual; - /// @notice Checks if the `sender` (`msg.sender`) is a valid representative of the remote peer. - /// @param sender The message's sender. - function _isRemotePeer(address sender) internal virtual returns (bool valid); - /// @notice Validates a leaf as being in the inbox merkle tree and registers the leaf as executed (to prevent double-spending). /// @dev Reverts if the leaf is invalid. /// @param projectTokenAmount The amount of project tokens which were redeemed. diff --git a/src/deployers/JBCCIPSuckerDeployer.sol b/src/deployers/JBCCIPSuckerDeployer.sol index 6ed70cf..5ba7781 100644 --- a/src/deployers/JBCCIPSuckerDeployer.sol +++ b/src/deployers/JBCCIPSuckerDeployer.sol @@ -51,9 +51,8 @@ contract JBCCIPSuckerDeployer is JBPermissioned, IJBSuckerDeployer { // Set for a callback to this contract. TEMP_ID_STORE = localProjectId; - sucker = IJBSucker( - address(new JBCCIPSucker{salt: salt}(DIRECTORY, TOKENS, PERMISSIONS, address(0), JBAddToBalanceMode.MANUAL)) - ); + sucker = + IJBSucker(address(new JBCCIPSucker{salt: salt}(DIRECTORY, TOKENS, PERMISSIONS, JBAddToBalanceMode.MANUAL))); // TODO: See if resetting this value is cheaper than deletion // Delete after callback should complete. diff --git a/src/interfaces/IJBSucker.sol b/src/interfaces/IJBSucker.sol index 99f9978..d4d39fe 100644 --- a/src/interfaces/IJBSucker.sol +++ b/src/interfaces/IJBSucker.sol @@ -4,8 +4,6 @@ pragma solidity ^0.8.0; import {JBTokenMapping} from "../structs/JBTokenMapping.sol"; interface IJBSucker { - function PEER() external view returns (address); - function peerChainID() external view returns (uint256 chainId); function isMapped(address token) external view returns (bool); diff --git a/test/Fork.t.sol b/test/Fork.t.sol index b013055..7f227d7 100644 --- a/test/Fork.t.sol +++ b/test/Fork.t.sol @@ -59,8 +59,6 @@ contract CCIPSuckerFork is TestBaseWorkflow { IJBToken projectOneToken; function setUp() public override { - // address(0) == peer is the same as address(this) - this being the sucker itself - address peer = address(0); JBAddToBalanceMode atbMode = JBAddToBalanceMode.ON_CLAIM; string memory ETHEREUM_SEPOLIA_RPC_URL = vm.envString("RPC_ETHEREUM_SEPOLIA"); @@ -98,7 +96,7 @@ contract CCIPSuckerFork is TestBaseWorkflow { super.setUp(); // We deploy our first sucker - suckerGlobal = new JBCCIPSucker{salt: "SUCKER"}(jbDirectory(), jbTokens(), jbPermissions(), peer, atbMode); + suckerGlobal = new JBCCIPSucker{salt: "SUCKER"}(jbDirectory(), jbTokens(), jbPermissions(), atbMode); // setup permissions vm.startPrank(multisig()); @@ -207,9 +205,7 @@ contract CCIPSuckerFork is TestBaseWorkflow { // We instead use this cheatcode to deploy what is essentially "Sucker Two" to the same address, // But on our other fork deployCodeTo( - "JBCCIPSucker.sol", - abi.encode(jbDirectory(), jbTokens(), jbPermissions(), peer, atbMode), - address(suckerGlobal) + "JBCCIPSucker.sol", abi.encode(jbDirectory(), jbTokens(), jbPermissions(), atbMode), address(suckerGlobal) ); // set permissions