Skip to content

Commit

Permalink
remove superfluous configs / globals
Browse files Browse the repository at this point in the history
  • Loading branch information
simplemachine92 committed Jun 19, 2024
1 parent 9ba6deb commit 5d34764
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 54 deletions.
28 changes: 3 additions & 25 deletions src/JBCCIPSucker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------- //
Expand Down Expand Up @@ -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);
}
}
22 changes: 4 additions & 18 deletions src/JBSucker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions src/deployers/JBCCIPSuckerDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions src/interfaces/IJBSucker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 2 additions & 6 deletions test/Fork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5d34764

Please sign in to comment.