diff --git a/src/user/AppBase.sol b/src/user/AppBase.sol index 9d2e7f4..a102a23 100644 --- a/src/user/AppBase.sol +++ b/src/user/AppBase.sol @@ -19,11 +19,10 @@ pragma solidity ^0.8.17; // https://eips.ethereum.org/EIPS/eip-5164 abstract contract AppBase { - function ormpSender() public view virtual returns (address); - function ormpRecver() public view virtual returns (address); + function protocol() public view virtual returns (address); - modifier onlyORMPRecver() { - require(ormpRecver() == msg.sender, "!ormp-recver"); + modifier onlyORMP() { + require(protocol() == msg.sender, "!ormp-recver"); _; } diff --git a/src/user/Application.sol b/src/user/Application.sol index 101a191..458e470 100644 --- a/src/user/Application.sol +++ b/src/user/Application.sol @@ -27,15 +27,11 @@ abstract contract Application is AppBase { _ORMP = ormp; } - function ormpSender() public view virtual override returns (address) { - return _ORMP; - } - - function ormpRecver() public view virtual override returns (address) { + function protocol() public view virtual override returns (address) { return _ORMP; } function _setAppConfig(address oracle, address relayer) internal virtual { - IORMP(_ORMP).setAppConfig(oracle, relayer); + IORMP(protocol()).setAppConfig(oracle, relayer); } } diff --git a/src/user/UpgradeableApplication.sol b/src/user/UpgradeableApplication.sol index 995ebce..1f0bc47 100644 --- a/src/user/UpgradeableApplication.sol +++ b/src/user/UpgradeableApplication.sol @@ -21,40 +21,24 @@ import "../interfaces/IORMP.sol"; import "./AppBase.sol"; abstract contract UpgradeableApplication is AppBase { - address private _sender; - address private _recver; + address private _ormp; - event SetSender(address ormp); - event SetRecver(address ormp); + event SetORMP(address ormp); constructor(address ormp) { - _sender = ormp; - _recver = ormp; + _ormp = ormp; } - function ormpSender() public view virtual override returns (address) { - return _sender; + function protocol() public view virtual override returns (address) { + return _ormp; } - function ormpRecver() public view virtual override returns (address) { - return _recver; + function _setORMP(address ormp) internal virtual { + _ormp = ormp; + emit SetORMP(ormp); } - function _setSender(address ormp) internal virtual { - _sender = ormp; - emit SetSender(ormp); - } - - function _setRecver(address ormp) internal virtual { - _recver = ormp; - emit SetRecver(ormp); - } - - function _setSenderConfig(address oracle, address relayer) internal virtual { - IORMP(ormpSender()).setAppConfig(oracle, relayer); - } - - function _setRecverConfig(address oracle, address relayer) internal virtual { - IORMP(ormpRecver()).setAppConfig(oracle, relayer); + function _setAppConfig(address oracle, address relayer) internal virtual { + IORMP(protocol()).setAppConfig(oracle, relayer); } } diff --git a/test/user/Application.t.sol b/test/user/Application.t.sol index e83cf47..e390bec 100644 --- a/test/user/Application.t.sol +++ b/test/user/Application.t.sol @@ -57,6 +57,6 @@ contract UserApplication is Application { address xmsgSender = _xmsgSender(); require(msgHash == bytes32(uint256(1))); require(fromChainid == 1); - require(xmsgSender == ormpRecver()); + require(xmsgSender == protocol()); } }