mirror of
https://github.com/status-im/contracts.git
synced 2025-02-24 04:28:51 +00:00
add stoppable capability
This commit is contained in:
parent
9b916795a8
commit
129d8c2edd
@ -1,21 +1,21 @@
|
|||||||
pragma solidity >=0.5.0 <0.6.0;
|
pragma solidity >=0.5.0 <0.6.0;
|
||||||
import "../common/MessageSigned.sol";
|
import "../common/MessageSigned.sol";
|
||||||
|
import "../common/Controlled.sol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notice Defines tribute to talk
|
* @notice Defines tribute to talk
|
||||||
*/
|
*/
|
||||||
contract MessageTribute is MessageSigned {
|
contract MessageTribute is MessageSigned, Controlled {
|
||||||
event SetTribute(address indexed account, uint256 value);
|
event SetTribute(address indexed account, uint256 value);
|
||||||
|
bool public stopped;
|
||||||
mapping(address => uint256) private tributeCatalog;
|
mapping(address => uint256) tributeCatalog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notice Set tribute of account
|
* @notice Set tribute of account
|
||||||
* @param _value Required tribute value
|
* @param _value Required tribute value
|
||||||
*/
|
*/
|
||||||
function setTribute(uint256 _value) external {
|
function setTribute(uint256 _value) external {
|
||||||
tributeCatalog[msg.sender] = _value;
|
setTribute(msg.sender, _value);
|
||||||
emit SetTribute(msg.sender, _value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,8 +29,14 @@ contract MessageTribute is MessageSigned {
|
|||||||
require(time < _ttl && _ttl-time < 1 days, "Invalid TTL");
|
require(time < _ttl && _ttl-time < 1 days, "Invalid TTL");
|
||||||
address signer = recoverAddress(getSignHash(hashTributeMessage(_value, _ttl)), _messageSignature);
|
address signer = recoverAddress(getSignHash(hashTributeMessage(_value, _ttl)), _messageSignature);
|
||||||
require(signer != address(0), "Invalid signer");
|
require(signer != address(0), "Invalid signer");
|
||||||
tributeCatalog[signer] = _value;
|
setTribute(signer, _value);
|
||||||
emit SetTribute(signer, _value);
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notice Stops the contract of being able to change values.
|
||||||
|
*/
|
||||||
|
function setStopped(bool _stopped) external onlyController {
|
||||||
|
stopped = _stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,4 +59,10 @@ contract MessageTribute is MessageSigned {
|
|||||||
return keccak256(abi.encodePacked(address(this), _value, _ttl));
|
return keccak256(abi.encodePacked(address(this), _value, _ttl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTribute(address _of, uint256 _value) internal {
|
||||||
|
require(!stopped, "Contract stopped by Controller");
|
||||||
|
tributeCatalog[_of] = _value;
|
||||||
|
emit SetTribute(_of, _value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user