Skip to content

Commit

Permalink
chore: rename to usdcbridge
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed Mar 22, 2024
1 parent 2ba5514 commit 12996ea
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
28 changes: 14 additions & 14 deletions packages/contracts-bedrock/src/L1/L1UsdcBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
pragma solidity 0.8.15;

import { Predeploys } from "src/libraries/Predeploys.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol";
import { UsdcBridge } from "src/universal/UsdcBridge.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
import { Constants } from "src/libraries/Constants.sol";

/// @custom:proxied
/// @title L1StandardBridge
/// @notice The L1StandardBridge is responsible for transfering ETH and ERC20 tokens between L1 and
/// @title L1UsdcBridge
/// @notice The L1UsdcBridge is responsible for transfering ETH and ERC20 tokens between L1 and
/// L2. In the case that an ERC20 token is native to L1, it will be escrowed within this
/// contract. If the ERC20 token is native to L2, it will be burnt. Before Bedrock, ETH was
/// stored within this contract. After Bedrock, ETH is instead stored inside the
/// OptimismPortal contract.
/// NOTE: this contract is not intended to support all variations of ERC20 tokens. Examples
/// of some token types that may not be properly supported by this contract include, but are
/// not limited to: tokens with transfer fees, rebasing tokens, and tokens with blocklists.
contract L1StandardBridge is StandardBridge, ISemver {
contract L1UsdcBridge is UsdcBridge, ISemver {
/// @custom:legacy
/// @notice Emitted whenever a deposit of ETH from L1 into L2 is initiated.
/// @param from Address of the depositor.
Expand Down Expand Up @@ -76,8 +76,8 @@ contract L1StandardBridge is StandardBridge, ISemver {
/// @notice Address of the SuperchainConfig contract.
SuperchainConfig public superchainConfig;

/// @notice Constructs the L1StandardBridge contract.
constructor() StandardBridge() {
/// @notice Constructs the L1UsdcBridge contract.
constructor() UsdcBridge() {
initialize({ _messenger: CrossDomainMessenger(address(0)), _superchainConfig: SuperchainConfig(address(0)) });
}

Expand All @@ -86,13 +86,13 @@ contract L1StandardBridge is StandardBridge, ISemver {
/// @param _superchainConfig Contract for the SuperchainConfig on this network.
function initialize(CrossDomainMessenger _messenger, SuperchainConfig _superchainConfig) public initializer {
superchainConfig = _superchainConfig;
__StandardBridge_init({
__UsdcBridge_init({
_messenger: _messenger,
_otherBridge: StandardBridge(payable(Predeploys.L2_STANDARD_BRIDGE))
_otherBridge: UsdcBridge(payable(Predeploys.L2_STANDARD_BRIDGE))
});
}

/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
function paused() public view override returns (bool) {
return superchainConfig.paused();
}
Expand All @@ -115,7 +115,7 @@ contract L1StandardBridge is StandardBridge, ISemver {
/// @custom:legacy
/// @notice Deposits some amount of ETH into a target account on L2.
/// Note that if ETH is sent to a contract on L2 and the call fails, then that ETH will
/// be locked in the L2StandardBridge. ETH may be recoverable if the call can be
/// be locked in the L2UsdcBridge. ETH may be recoverable if the call can be
/// successfully replayed by increasing the amount of gas supplied to the call. If the
/// call will fail for any amount of gas, then the ETH will be locked permanently.
/// @param _to Address of the recipient on L2.
Expand Down Expand Up @@ -251,7 +251,7 @@ contract L1StandardBridge is StandardBridge, ISemver {
_initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _extraData);
}

/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
/// @notice Emits the legacy ETHDepositInitiated event followed by the ETHBridgeInitiated event.
/// This is necessary for backwards compatibility with the legacy bridge.
function _emitETHBridgeInitiated(
Expand All @@ -267,7 +267,7 @@ contract L1StandardBridge is StandardBridge, ISemver {
super._emitETHBridgeInitiated(_from, _to, _amount, _extraData);
}

/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
/// @notice Emits the legacy ERC20DepositInitiated event followed by the ERC20BridgeInitiated
/// event. This is necessary for backwards compatibility with the legacy bridge.
function _emitETHBridgeFinalized(
Expand All @@ -283,7 +283,7 @@ contract L1StandardBridge is StandardBridge, ISemver {
super._emitETHBridgeFinalized(_from, _to, _amount, _extraData);
}

/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
/// @notice Emits the legacy ERC20WithdrawalFinalized event followed by the ERC20BridgeFinalized
/// event. This is necessary for backwards compatibility with the legacy bridge.
function _emitERC20BridgeInitiated(
Expand All @@ -301,7 +301,7 @@ contract L1StandardBridge is StandardBridge, ISemver {
super._emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
}

/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
/// @notice Emits the legacy ERC20WithdrawalFinalized event followed by the ERC20BridgeFinalized
/// event. This is necessary for backwards compatibility with the legacy bridge.
function _emitERC20BridgeFinalized(
Expand Down
28 changes: 14 additions & 14 deletions packages/contracts-bedrock/src/L2/L2UsdcBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
pragma solidity 0.8.15;

import { Predeploys } from "src/libraries/Predeploys.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol";
import { UsdcBridge } from "src/universal/UsdcBridge.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol";
import { Constants } from "src/libraries/Constants.sol";

/// @custom:proxied
/// @custom:predeploy 0x4200000000000000000000000000000000000010
/// @title L2StandardBridge
/// @notice The L2StandardBridge is responsible for transfering ETH and ERC20 tokens between L1 and
/// @title L2UsdcBridge
/// @notice The L2UsdcBridge is responsible for transfering ETH and ERC20 tokens between L1 and
/// L2. In the case that an ERC20 token is native to L2, it will be escrowed within this
/// contract. If the ERC20 token is native to L1, it will be burnt.
/// NOTE: this contract is not intended to support all variations of ERC20 tokens. Examples
/// of some token types that may not be properly supported by this contract include, but are
/// not limited to: tokens with transfer fees, rebasing tokens, and tokens with blocklists.
contract L2StandardBridge is StandardBridge, ISemver {
contract L2UsdcBridge is UsdcBridge, ISemver {
/// @custom:legacy
/// @notice Emitted whenever a withdrawal from L2 to L1 is initiated.
/// @param l1Token Address of the token on L1.
Expand Down Expand Up @@ -55,15 +55,15 @@ contract L2StandardBridge is StandardBridge, ISemver {
/// @custom:semver 1.8.0
string public constant version = "1.8.0";

/// @notice Constructs the L2StandardBridge contract.
constructor() StandardBridge() {
initialize({ _otherBridge: StandardBridge(payable(address(0))) });
/// @notice Constructs the L2UsdcBridge contract.
constructor() UsdcBridge() {
initialize({ _otherBridge: UsdcBridge(payable(address(0))) });
}

/// @notice Initializer.
/// @param _otherBridge Contract for the corresponding bridge on the other chain.
function initialize(StandardBridge _otherBridge) public initializer {
__StandardBridge_init({
function initialize(UsdcBridge _otherBridge) public initializer {
__UsdcBridge_init({
_messenger: CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER),
_otherBridge: _otherBridge
});
Expand Down Expand Up @@ -101,7 +101,7 @@ contract L2StandardBridge is StandardBridge, ISemver {
/// @custom:legacy
/// @notice Initiates a withdrawal from L2 to L1 to a target account on L1.
/// Note that if ETH is sent to a contract on L1 and the call fails, then that ETH will
/// be locked in the L1StandardBridge. ETH may be recoverable if the call can be
/// be locked in the L1UsdcBridge. ETH may be recoverable if the call can be
/// successfully replayed by increasing the amount of gas supplied to the call. If the
/// call will fail for any amount of gas, then the ETH will be locked permanently.
/// This function only works with OptimismMintableERC20 tokens or ether. Use the
Expand Down Expand Up @@ -188,7 +188,7 @@ contract L2StandardBridge is StandardBridge, ISemver {

/// @notice Emits the legacy WithdrawalInitiated event followed by the ETHBridgeInitiated event.
/// This is necessary for backwards compatibility with the legacy bridge.
/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
function _emitETHBridgeInitiated(
address _from,
address _to,
Expand All @@ -204,7 +204,7 @@ contract L2StandardBridge is StandardBridge, ISemver {

/// @notice Emits the legacy DepositFinalized event followed by the ETHBridgeFinalized event.
/// This is necessary for backwards compatibility with the legacy bridge.
/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
function _emitETHBridgeFinalized(
address _from,
address _to,
Expand All @@ -220,7 +220,7 @@ contract L2StandardBridge is StandardBridge, ISemver {

/// @notice Emits the legacy WithdrawalInitiated event followed by the ERC20BridgeInitiated
/// event. This is necessary for backwards compatibility with the legacy bridge.
/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
function _emitERC20BridgeInitiated(
address _localToken,
address _remoteToken,
Expand All @@ -238,7 +238,7 @@ contract L2StandardBridge is StandardBridge, ISemver {

/// @notice Emits the legacy DepositFinalized event followed by the ERC20BridgeFinalized event.
/// This is necessary for backwards compatibility with the legacy bridge.
/// @inheritdoc StandardBridge
/// @inheritdoc UsdcBridge
function _emitERC20BridgeFinalized(
address _localToken,
address _remoteToken,
Expand Down
46 changes: 23 additions & 23 deletions packages/contracts-bedrock/src/universal/UsdcBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";

/// @custom:upgradeable
/// @title StandardBridge
/// @notice StandardBridge is a base contract for the L1 and L2 standard ERC20 bridges. It handles
/// @title UsdcBridge
/// @notice UsdcBridge is a base contract for the L1 and L2 standard ERC20 bridges. It handles
/// the core bridging logic, including escrowing tokens that are native to the local chain
/// and minting/burning tokens that are native to the remote chain.
abstract contract StandardBridge is Initializable {
abstract contract UsdcBridge is Initializable {
using SafeERC20 for IERC20;

/// @notice The L2 gas limit set when eth is depoisited using the receive() function.
Expand All @@ -41,7 +41,7 @@ abstract contract StandardBridge is Initializable {

/// @notice Corresponding bridge on the other domain.
/// @custom:network-specific
StandardBridge public otherBridge;
UsdcBridge public otherBridge;

/// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
/// A gap size of 45 was chosen here, so that the first slot used in a child contract
Expand Down Expand Up @@ -98,25 +98,25 @@ abstract contract StandardBridge is Initializable {
/// calling code within their constructors, but also doesn't really matter since we're
/// just trying to prevent users accidentally depositing with smart contract wallets.
modifier onlyEOA() {
require(!Address.isContract(msg.sender), "StandardBridge: function can only be called from an EOA");
require(!Address.isContract(msg.sender), "UsdcBridge: function can only be called from an EOA");
_;
}

/// @notice Ensures that the caller is a cross-chain message from the other bridge.
modifier onlyOtherBridge() {
require(
msg.sender == address(messenger) && messenger.xDomainMessageSender() == address(otherBridge),
"StandardBridge: function can only be called from the other bridge"
"UsdcBridge: function can only be called from the other bridge"
);
_;
}

/// @notice Initializer.
/// @param _messenger Contract for CrossDomainMessenger on this network.
/// @param _otherBridge Contract for the other StandardBridge contract.
function __StandardBridge_init(
/// @param _otherBridge Contract for the other UsdcBridge contract.
function __UsdcBridge_init(
CrossDomainMessenger _messenger,
StandardBridge _otherBridge
UsdcBridge _otherBridge
)
internal
onlyInitializing
Expand All @@ -141,7 +141,7 @@ abstract contract StandardBridge is Initializable {
/// Public getter is legacy and will be removed in the future. Use `otherBridge` instead.
/// @return Contract of the bridge on the other network.
/// @custom:legacy
function OTHER_BRIDGE() external view returns (StandardBridge) {
function OTHER_BRIDGE() external view returns (UsdcBridge) {
return otherBridge;
}

Expand All @@ -164,9 +164,9 @@ abstract contract StandardBridge is Initializable {

/// @notice Sends ETH to a receiver's address on the other chain. Note that if ETH is sent to a
/// smart contract and the call fails, the ETH will be temporarily locked in the
/// StandardBridge on the other chain until the call is replayed. If the call cannot be
/// UsdcBridge on the other chain until the call is replayed. If the call cannot be
/// replayed with any amount of gas (call always reverts), then the ETH will be
/// permanently locked in the StandardBridge on the other chain. ETH will also
/// permanently locked in the UsdcBridge on the other chain. ETH will also
/// be locked if the receiver is the other bridge, because finalizeBridgeETH will revert
/// in that case.
/// @param _to Address of the receiver.
Expand Down Expand Up @@ -230,7 +230,7 @@ abstract contract StandardBridge is Initializable {
}

/// @notice Finalizes an ETH bridge on this chain. Can only be triggered by the other
/// StandardBridge contract on the remote chain.
/// UsdcBridge contract on the remote chain.
/// @param _from Address of the sender.
/// @param _to Address of the receiver.
/// @param _amount Amount of ETH being bridged.
Expand All @@ -247,21 +247,21 @@ abstract contract StandardBridge is Initializable {
payable
onlyOtherBridge
{
require(paused() == false, "StandardBridge: paused");
require(msg.value == _amount, "StandardBridge: amount sent does not match amount required");
require(_to != address(this), "StandardBridge: cannot send to self");
require(_to != address(messenger), "StandardBridge: cannot send to messenger");
require(paused() == false, "UsdcBridge: paused");
require(msg.value == _amount, "UsdcBridge: amount sent does not match amount required");
require(_to != address(this), "UsdcBridge: cannot send to self");
require(_to != address(messenger), "UsdcBridge: cannot send to messenger");

// Emit the correct events. By default this will be _amount, but child
// contracts may override this function in order to emit legacy events as well.
_emitETHBridgeFinalized(_from, _to, _amount, _extraData);

bool success = SafeCall.call(_to, gasleft(), _amount, hex"");
require(success, "StandardBridge: ETH transfer failed");
require(success, "UsdcBridge: ETH transfer failed");
}

/// @notice Finalizes an ERC20 bridge on this chain. Can only be triggered by the other
/// StandardBridge contract on the remote chain.
/// UsdcBridge contract on the remote chain.
/// @param _localToken Address of the ERC20 on this chain.
/// @param _remoteToken Address of the corresponding token on the remote chain.
/// @param _from Address of the sender.
Expand All @@ -281,11 +281,11 @@ abstract contract StandardBridge is Initializable {
public
onlyOtherBridge
{
require(paused() == false, "StandardBridge: paused");
require(paused() == false, "UsdcBridge: paused");
if (_isOptimismMintableERC20(_localToken)) {
require(
_isCorrectTokenPair(_localToken, _remoteToken),
"StandardBridge: wrong remote token for Optimism Mintable ERC20 local token"
"UsdcBridge: wrong remote token for Optimism Mintable ERC20 local token"
);

OptimismMintableERC20(_localToken).mint(_to, _amount);
Expand Down Expand Up @@ -316,7 +316,7 @@ abstract contract StandardBridge is Initializable {
)
internal
{
require(msg.value == _amount, "StandardBridge: bridging ETH must include sufficient ETH value");
require(msg.value == _amount, "UsdcBridge: bridging ETH must include sufficient ETH value");

// Emit the correct events. By default this will be _amount, but child
// contracts may override this function in order to emit legacy events as well.
Expand Down Expand Up @@ -352,7 +352,7 @@ abstract contract StandardBridge is Initializable {
if (_isOptimismMintableERC20(_localToken)) {
require(
_isCorrectTokenPair(_localToken, _remoteToken),
"StandardBridge: wrong remote token for Optimism Mintable ERC20 local token"
"UsdcBridge: wrong remote token for Optimism Mintable ERC20 local token"
);

OptimismMintableERC20(_localToken).burn(_from, _amount);
Expand Down

0 comments on commit 12996ea

Please sign in to comment.