-
Notifications
You must be signed in to change notification settings - Fork 81
/
Bridge.sol
54 lines (45 loc) · 1.75 KB
/
Bridge.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "./AbsBridge.sol";
import "./IEthBridge.sol";
import "./Messages.sol";
import "../libraries/DelegateCallAware.sol";
import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";
/**
* @title Staging ground for incoming and outgoing messages
* @notice It is also the ETH escrow for value sent with these messages.
*/
contract Bridge is AbsBridge, IEthBridge {
using AddressUpgradeable for address;
/// @inheritdoc IEthBridge
function initialize(IOwnable rollup_) external initializer onlyDelegated {
_activeOutbox = EMPTY_ACTIVEOUTBOX;
rollup = rollup_;
}
/// @inheritdoc IEthBridge
function enqueueDelayedMessage(
uint8 kind,
address sender,
bytes32 messageDataHash
) external payable returns (uint256) {
return _enqueueDelayedMessage(kind, sender, messageDataHash, msg.value);
}
function _transferFunds(uint256) internal override {
// do nothing as Eth transfer is part of TX execution
}
function _executeLowLevelCall(
address to,
uint256 value,
bytes memory data
) internal override returns (bool success, bytes memory returnData) {
// solhint-disable-next-line avoid-low-level-calls
(success, returnData) = to.call{value: value}(data);
}
function _baseFeeToReport() internal view override returns (uint256) {
return block.basefee;
}
}