123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // SPDX-License-Identifier: UNLICENSED
- pragma solidity ^0.8.0;
- contract receiver {
- address public endpoint;
- mapping(uint16 => bytes) public trustedRemoteLookup;
- address public owner;
- event done(address from);
- constructor(address _endpoint) {
- owner = msg.sender;
- endpoint = _endpoint;
- }
- modifier onlyOwner() {
- require(owner == msg.sender, "not owner");
- _;
- }
- function setEndpoint(address _endpoint) external onlyOwner {
- endpoint = _endpoint;
- }
- function setTrustRemoteLookup(uint16 _chainId, bytes memory _address) external onlyOwner {
- trustedRemoteLookup[_chainId] = _address;
- }
- function lzReceive(
- uint16 _srcChainId,
- bytes memory _srcAddress,
- uint64 _nonce,
- bytes memory _payload
- ) external payable{
- require(msg.sender == address(endpoint));
- require(keccak256(_srcAddress) == keccak256(trustedRemoteLookup[_srcChainId]));
- address fromAddress;
- assembly {
- fromAddress := mload(add(_srcAddress, 20))
- }
- emit done(fromAddress);
- }
- }
|