-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathL1Contract.sol
34 lines (29 loc) · 923 Bytes
/
L1Contract.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
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
contract L1Contract {
string private greeting;
address l2Contract;
address l1Bridge;
address private caller;
constructor(address _l2Contract, address _l1Bridge) {
l2Contract = _l2Contract;
l1Bridge = _l1Bridge;
}
function greet() public view returns (string memory) {
return greeting;
}
function onMessageReceived(address originAddress, uint32 originNetwork, bytes memory data) external payable {
require(originAddress == l2Contract);
require(originNetwork == 1);
caller = originAddress;
(bool success, ) = address(this).call(data);
if (!success) {
revert('metadata execution failed');
}
caller = address(0);
}
function setGreeting(string memory _greeting) public {
require(caller == l2Contract);
greeting = _greeting;
}
}