added example of emergency shutdown controller contract (#572)
This commit is contained in:
parent
98155e3075
commit
8f72516374
52
oracle/esController.sol
Normal file
52
oracle/esController.sol
Normal file
@ -0,0 +1,52 @@
|
||||
//SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
/*
|
||||
This contract can be used together with the emergency shutdown
|
||||
functionality of the TokenBridge oracles.
|
||||
*/
|
||||
|
||||
pragma solidity 0.7.6;
|
||||
|
||||
contract PauseController {
|
||||
address public manager;
|
||||
bool internal paused;
|
||||
bytes32 private immutable ID;
|
||||
|
||||
constructor (string memory _id, address _manager) {
|
||||
require(bytes(_id).length <= 32);
|
||||
bytes32 id;
|
||||
assembly {
|
||||
id := mload(add(_id, 32))
|
||||
}
|
||||
ID = id;
|
||||
|
||||
manager = _manager;
|
||||
}
|
||||
|
||||
modifier onlyManager() {
|
||||
require(msg.sender == manager);
|
||||
_;
|
||||
}
|
||||
|
||||
function changeManager(address _newmanager) external onlyManager {
|
||||
require(_newmanager != address(0));
|
||||
manager = _newmanager;
|
||||
}
|
||||
|
||||
function pause() external onlyManager {
|
||||
paused = true;
|
||||
}
|
||||
|
||||
function play() external onlyManager {
|
||||
paused = false;
|
||||
}
|
||||
|
||||
function isPaused() external view returns(bool) {
|
||||
return paused;
|
||||
}
|
||||
|
||||
function id() external view returns(string memory) {
|
||||
return string(abi.encodePacked(ID));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user