-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
151 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// This file is part of Darwinia. | ||
// Copyright (C) 2018-2023 Darwinia Network | ||
// SPDX-License-Identifier: GPL-3.0 | ||
// | ||
// Darwinia is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Darwinia is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity ^0.8.17; | ||
|
||
import "../interfaces/IORMP.sol"; | ||
|
||
// https://eips.ethereum.org/EIPS/eip-5164 | ||
abstract contract AppBase { | ||
function protocol() public view virtual returns (address); | ||
|
||
function _setAppConfig(address oracle, address relayer) internal virtual { | ||
IORMP(protocol()).setAppConfig(oracle, relayer); | ||
} | ||
|
||
modifier onlyORMP() { | ||
require(protocol() == msg.sender, "!ormp-recver"); | ||
_; | ||
} | ||
|
||
function _messageId() internal pure returns (bytes32 _msgDataMessageId) { | ||
require(msg.data.length >= 84, "!messageId"); | ||
assembly { | ||
_msgDataMessageId := calldataload(sub(calldatasize(), 84)) | ||
} | ||
} | ||
|
||
function _fromChainId() internal pure returns (uint256 _msgDataFromChainId) { | ||
require(msg.data.length >= 52, "!fromChainId"); | ||
assembly { | ||
_msgDataFromChainId := calldataload(sub(calldatasize(), 52)) | ||
} | ||
} | ||
|
||
function _xmsgSender() internal pure returns (address payable _from) { | ||
require(msg.data.length >= 20, "!xmsgSender"); | ||
assembly { | ||
_from := shr(96, calldataload(sub(calldatasize(), 20))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This file is part of Darwinia. | ||
// Copyright (C) 2018-2023 Darwinia Network | ||
// SPDX-License-Identifier: GPL-3.0 | ||
// | ||
// Darwinia is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Darwinia is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity ^0.8.17; | ||
|
||
import "./AppBase.sol"; | ||
|
||
abstract contract UpgradeableApplication is AppBase { | ||
address private _ormp; | ||
|
||
event SetORMP(address ormp); | ||
|
||
constructor(address ormp) { | ||
_ormp = ormp; | ||
} | ||
|
||
function protocol() public view virtual override returns (address) { | ||
return _ormp; | ||
} | ||
|
||
function _setORMP(address ormp) internal virtual { | ||
_ormp = ormp; | ||
emit SetORMP(ormp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters