Skip to content

Commit

Permalink
fix: interfaces and versions
Browse files Browse the repository at this point in the history
  • Loading branch information
agusduha committed Sep 25, 2024
1 parent 416eb39 commit 1be7560
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"sourceCodeHash": "0xb55e58b5d4912edf05026878a5f5ac8019372212ed2a77843775d595fbf51b84"
},
"src/L2/L2StandardBridgeInterop.sol": {
"initCodeHash": "0x9bc28e8511a4593362c2517ff90b26f9c1ecee382cce3950b47ca08892a872ef",
"sourceCodeHash": "0x9caa8042e7639dfa63bab7ecd17d3bd5524340940965071ce3c7ff6a06fe7de5"
"initCodeHash": "0xd43d07c2ba5a73af56181c0221c28f3b495851b03cf8e35f9b009857bb9538a6",
"sourceCodeHash": "0xc52d7a8b5d747167870d9048710e960e925d39650e3bd3fbc201b9b4f771e052"
},
"src/L2/L2ToL1MessagePasser.sol": {
"initCodeHash": "0x13fe3729beb9ed966c97bef09acb9fe5043fe651d453145073d05f2567fa988d",
Expand Down Expand Up @@ -133,7 +133,7 @@
},
"src/L2/SuperchainERC20Bridge.sol": {
"initCodeHash": "0x802574bf35587e9a8dc2416e91b9fd1411c75d219545b8b55d25a75452459b10",
"sourceCodeHash": "0x109099936bacea72e4877e7745286b807f26d2e4f4e7eddfb949ff4eab861893"
"sourceCodeHash": "0xb11ce94fd6165d8ca86eebafc7235e0875380d1a5d4e8b267ff0c6477083b21c"
},
"src/L2/SuperchainWETH.sol": {
"initCodeHash": "0xd8766c7ab41d34d935febf5b48289f947804634bde38f8e346075b9f2d867275",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/L2/L2StandardBridgeInterop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ contract L2StandardBridgeInterop is L2StandardBridge {
event Converted(address indexed from, address indexed to, address indexed caller, uint256 amount);

/// @notice Semantic version.
/// @custom:semver +interop
/// @custom:semver +interop-beta.1
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop");
return string.concat(super.version(), "+interop-beta.1");
}

/// @notice Converts `amount` of `from` token to `to` token.
Expand Down
11 changes: 5 additions & 6 deletions packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity 0.8.25;
import { Predeploys } from "src/libraries/Predeploys.sol";

// Interfaces
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { ISuperchainERC20Bridge } from "src/L2/interfaces/ISuperchainERC20Bridge.sol";
import { IMintableAndBurnableERC20 } from "src/L2/interfaces/IMintableAndBurnableERC20.sol";
import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomainMessenger.sol";
Expand All @@ -16,7 +15,7 @@ import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomai
/// @notice The SuperchainERC20Bridge allows for the bridging of ERC20 tokens to make them fungible across the
/// Superchain. It builds on top of the L2ToL2CrossDomainMessenger for both replay protection and domain
/// binding.
contract SuperchainERC20Bridge is ISuperchainERC20Bridge, ISemver {
contract SuperchainERC20Bridge is ISuperchainERC20Bridge {
/// @notice Address of the L2ToL2CrossDomainMessenger Predeploy.
address internal constant MESSENGER = Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER;

Expand All @@ -29,21 +28,21 @@ contract SuperchainERC20Bridge is ISuperchainERC20Bridge, ISemver {
/// @param _to Address to send tokens to.
/// @param _amount Amount of tokens to send.
/// @param _chainId Chain ID of the destination chain.
function sendERC20(address _token, address _to, uint256 _amount, uint256 _chainId) external override {
function sendERC20(address _token, address _to, uint256 _amount, uint256 _chainId) external {
IMintableAndBurnableERC20(_token).burn(msg.sender, _amount);

bytes memory message = abi.encodeCall(this.relayERC20, (_token, msg.sender, _to, _amount));
IL2ToL2CrossDomainMessenger(MESSENGER).sendMessage(_chainId, address(this), message);

emit SendERC20(address(_token), msg.sender, _to, _amount, _chainId);
emit SendERC20(_token, msg.sender, _to, _amount, _chainId);
}

/// @notice Relays tokens received from another chain.
/// @param _token Token to relay.
/// @param _from Address of the msg.sender of sendERC20 on the source chain.
/// @param _to Address to relay tokens to.
/// @param _amount Amount of tokens to relay.
function relayERC20(address _token, address _from, address _to, uint256 _amount) external override {
function relayERC20(address _token, address _from, address _to, uint256 _amount) external {
if (msg.sender != MESSENGER) revert CallerNotL2ToL2CrossDomainMessenger();

if (IL2ToL2CrossDomainMessenger(MESSENGER).crossDomainMessageSender() != address(this)) {
Expand All @@ -54,6 +53,6 @@ contract SuperchainERC20Bridge is ISuperchainERC20Bridge, ISemver {

IMintableAndBurnableERC20(_token).mint(_to, _amount);

emit RelayERC20(address(_token), _from, _to, _amount, source);
emit RelayERC20(_token, _from, _to, _amount, source);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { ISemver } from "src/universal/interfaces/ISemver.sol";

/// @title ISuperchainERC20Bridge
/// @notice Interface for the SuperchainERC20Bridge contract.
interface ISuperchainERC20Bridge {
interface ISuperchainERC20Bridge is ISemver {
/// @notice Thrown when attempting to relay a message and the function caller (msg.sender) is not
/// L2ToL2CrossDomainMessenger.
error CallerNotL2ToL2CrossDomainMessenger();
Expand Down

0 comments on commit 1be7560

Please sign in to comment.