Skip to content

Commit

Permalink
rename msgline->msgport
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Feb 7, 2024
1 parent 1bbce6f commit fab321e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
11 changes: 10 additions & 1 deletion helix-contract/address/ln-product.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
"lzChainId": 214,
"lzEndpoint": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7",
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3"
},
"darwinia-dvm": {
"name": "darwinia-dvm",
"url": "https://rpc.darwinia.network",
"dao": "0x88a39B052d477CfdE47600a7C9950a441Ce61cb4",
"chainId": 46,
"deployer": "0x80D4c766C5142D1313D531Afe7384D0D5E108Db3",
"ormpPort": "0x0000000005d961F950adA391C1511c92bbc64D9F"
}
},
"messagers": {
Expand All @@ -105,7 +113,8 @@
},
"darwinia": {
"DarwiniaMsglineMessager": "0x6035Eb7783d7Aab8d0a57a7b154f5DD5D5477Ff2",
"DarwiniaSub2SubMessager": "0x9dF64c435F02fb46bd8eB3757D3dF42dDA912bDe"
"DarwiniaSub2SubMessager": "0x9dF64c435F02fb46bd8eB3757D3dF42dDA912bDe",
"MsgportMessager": "0x65Be094765731F394bc6d9DF53bDF3376F1Fc8B0"
},
"crab": {
"DarwiniaSub2SubMessager": "0x9dF64c435F02fb46bd8eB3757D3dF42dDA912bDe"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.17;

interface IMessageLine {
interface IMessagePort {
function send(uint256 toChainId, address toDapp, bytes calldata message, bytes calldata params) external payable;
function fee(uint256 toChainId, address toDapp, bytes calldata message, bytes calldata params) external view returns (uint256);
}

abstract contract Application {
function _msgSender() internal view returns (address payable _line) {
_line = payable(msg.sender);
function _msgSender() internal view returns (address payable _port) {
_port = payable(msg.sender);
}

function _fromChainId() internal pure returns (uint256 _msgDataFromChainId) {
Expand All @@ -19,7 +19,7 @@ abstract contract Application {
}

function _xmsgSender() internal pure returns (address payable _from) {
require(msg.data.length >= 20, "!line");
require(msg.data.length >= 20, "!port");
assembly {
_from := shr(96, calldataload(sub(calldatasize(), 20)))
}
Expand Down
14 changes: 7 additions & 7 deletions helix-contract/contracts/messagers/MsgportMessager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity ^0.8.17;

import "../utils/AccessController.sol";
import "../interfaces/IMessageLine.sol";
import "../interfaces/IMessagePort.sol";

contract MsgportMessager is Application, AccessController {
IMessageLine public msgport;
IMessagePort public msgport;

struct RemoteMessager {
uint256 msgportRemoteChainId;
Expand All @@ -29,18 +29,18 @@ contract MsgportMessager is Application, AccessController {
_;
}

modifier onlyMsgline() {
modifier onlyMsgPort() {
require(msg.sender == address(msgport), "invalid caller");
_;
}

constructor(address _dao, address _msgport) {
_initialize(_dao);
msgport = IMessageLine(_msgport);
msgport = IMessagePort(_msgport);
}

function setMsgline(address _msgport) onlyDao external {
msgport = IMessageLine(_msgport);
function setMsgPort(address _msgport) onlyDao external {
msgport = IMessagePort(_msgport);
}

function setRemoteMessager(uint256 _appRemoteChainId, uint256 _msgportRemoteChainId, address _remoteMessager) onlyDao external {
Expand Down Expand Up @@ -80,7 +80,7 @@ contract MsgportMessager is Application, AccessController {
);
}

function receiveMessage(uint256 _srcAppChainId, address _remoteAppAddress, address _localAppAddress, bytes memory _message) onlyMsgline external {
function receiveMessage(uint256 _srcAppChainId, address _remoteAppAddress, address _localAppAddress, bytes memory _message) onlyMsgPort external {
uint256 srcChainId = _fromChainId();
RemoteMessager memory remoteMessager = remoteMessagers[_srcAppChainId];
require(srcChainId == remoteMessager.msgportRemoteChainId, "invalid remote chainid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function main() {
const configure = JSON.parse(
fs.readFileSync(pathConfig, "utf8")
);
const network = configure.chains['pangolin'];
const network = configure.chains['sepolia'];
const w = wallet(configure, network);
await deployMessager(w, network.dao, network.ormpPort, network.deployer, "msgport-messager-v1.0.0");
}
Expand Down

0 comments on commit fab321e

Please sign in to comment.