This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
L1CrossDomainMessenger.sol
70 lines (63 loc) · 2.09 KB
/
L1CrossDomainMessenger.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Predeploys } from "../libraries/Predeploys.sol";
import { OptimismPortal } from "./OptimismPortal.sol";
import { CrossDomainMessenger } from "../universal/CrossDomainMessenger.sol";
import { Semver } from "../universal/Semver.sol";
/**
* @custom:proxied
* @title L1CrossDomainMessenger
* @notice The L1CrossDomainMessenger is a message passing interface between L1 and L2 responsible
* for sending and receiving data on the L1 side. Users are encouraged to use this
* interface instead of interacting with lower-level contracts directly.
*/
contract L1CrossDomainMessenger is CrossDomainMessenger, Semver {
/**
* @notice Address of the OptimismPortal.
*/
OptimismPortal public immutable PORTAL;
/**
* @custom:semver 1.0.0
*
* @param _portal Address of the OptimismPortal contract on this network.
*/
constructor(OptimismPortal _portal)
Semver(1, 0, 0)
CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER)
{
PORTAL = _portal;
initialize(address(0));
}
/**
* @notice Initializer.
*
* @param _owner Address of the initial owner of this contract.
*/
function initialize(address _owner) public initializer {
__CrossDomainMessenger_init();
_transferOwnership(_owner);
}
/**
* @inheritdoc CrossDomainMessenger
*/
function _sendMessage(
address _to,
uint64 _gasLimit,
uint256 _value,
bytes memory _data
) internal override {
PORTAL.depositTransaction{ value: _value }(_to, _value, _gasLimit, false, _data);
}
/**
* @inheritdoc CrossDomainMessenger
*/
function _isOtherMessenger() internal view override returns (bool) {
return msg.sender == address(PORTAL) && PORTAL.l2Sender() == OTHER_MESSENGER;
}
/**
* @inheritdoc CrossDomainMessenger
*/
function _isUnsafeTarget(address _target) internal view override returns (bool) {
return _target == address(this) || _target == address(PORTAL);
}
}