Last active
May 2, 2022 10:47
-
-
Save ilamanov/07551002c9abdad89cb718e24e2fbcc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @title L1StandardBridge | |
| * @dev The L1 ETH and ERC20 Bridge is a contract which stores deposited L1 funds and standard | |
| * tokens that are in use on L2. It synchronizes a corresponding L2 Bridge, informing it of deposits | |
| * and listening to it for newly finalized withdrawals. | |
| * | |
| */ | |
| contract L1StandardBridge is IL1StandardBridge, CrossDomainEnabled { | |
| function depositETHTo( | |
| address _to, | |
| uint32 _l2Gas, | |
| bytes calldata _data | |
| ) external payable { | |
| _initiateETHDeposit(msg.sender, _to, _l2Gas, _data); | |
| } | |
| /** | |
| * @dev Performs the logic for deposits by storing the ETH and informing the L2 ETH Gateway of | |
| * the deposit. | |
| * @param _from Account to pull the deposit from on L1. | |
| * @param _to Account to give the deposit to on L2. | |
| * @param _l2Gas Gas limit required to complete the deposit on L2. | |
| * @param _data Optional data to forward to L2. This data is provided | |
| * solely as a convenience for external contracts. Aside from enforcing a maximum | |
| * length, these contracts provide no guarantees about its content. | |
| */ | |
| function _initiateETHDeposit( | |
| address _from, | |
| address _to, | |
| uint32 _l2Gas, | |
| bytes memory _data | |
| ) internal { | |
| // Construct calldata for finalizeDeposit call | |
| bytes memory message = abi.encodeWithSelector( | |
| IL2ERC20Bridge.finalizeDeposit.selector, | |
| address(0), | |
| Lib_PredeployAddresses.OVM_ETH, | |
| _from, | |
| _to, | |
| msg.value, | |
| _data | |
| ); | |
| // Send calldata into L2 | |
| // slither-disable-next-line reentrancy-events | |
| sendCrossDomainMessage(l2TokenBridge, _l2Gas, message); | |
| // slither-disable-next-line reentrancy-events | |
| emit ETHDepositInitiated(_from, _to, msg.value, _data); | |
| } | |
| // ... other functions (OMITTED) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment