Skip to content

Commit

Permalink
native wrapping on Ethereum only
Browse files Browse the repository at this point in the history
  • Loading branch information
simplemachine92 committed Jun 3, 2024
1 parent 38b3531 commit 87363c4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/BPSucker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ abstract contract BPSucker is JBPermissioned, ModifiedReceiver, IBPSucker {
error MANUAL_NOT_ALLOWED();
error UNEXPECTED_MSG_VALUE();
error WRAPPED_NATIVE_ONLY();
error NATIVE_ON_ETH_ONLY();

//*********************************************************************//
// ---------------------- public stored properties ------------------- //
Expand Down Expand Up @@ -349,7 +350,8 @@ abstract contract BPSucker is JBPermissioned, ModifiedReceiver, IBPSucker {
function mapToken(BPTokenMapping calldata map) public ensureChainSupportedAndAllowed(map.remoteSelector) {
address token = map.localToken;
bool isNative = token == JBConstants.NATIVE_TOKEN;
address localWETH = CCIPHelper.wethOfChain(block.chainid);
uint256 chainId = block.chainid;
address localWETH = CCIPHelper.wethOfChain(chainId);

uint64 remoteSelector = map.remoteSelector;

Expand All @@ -359,10 +361,11 @@ abstract contract BPSucker is JBPermissioned, ModifiedReceiver, IBPSucker {
revert INVALID_TOKEN_TO_DESTINATION();
}

// Remote destinations don't support unwrapping WETH.
if (map.remoteToken == JBConstants.NATIVE_TOKEN) {
revert WRAPPED_NATIVE_ONLY();
}
// Only support native backing token (and wrapping) if on Ethereum
if (chainId != 1 && isNative) revert NATIVE_ON_ETH_ONLY();

// Cannot bridge native tokens
if (map.remoteToken == JBConstants.NATIVE_TOKEN) revert WRAPPED_NATIVE_ONLY();

// Enforce a reasonable minimum gas limit for bridging. A minimum which is too low could lead to the loss of funds.
if (map.minGas < MESSENGER_ERC20_MIN_GAS_LIMIT) {
Expand Down

0 comments on commit 87363c4

Please sign in to comment.