remove payment processing
This commit is contained in:
parent
9d2f9dd14e
commit
91b88f6a35
|
@ -1,8 +1,4 @@
|
|||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "../token/ERC20Token.sol";
|
||||
|
||||
|
||||
/**
|
||||
* @title MessageTribute
|
||||
* @author Richard Ramos (Status Research & Development GmbH)
|
||||
|
@ -14,52 +10,41 @@ import "../token/ERC20Token.sol";
|
|||
a reply from the recipient.
|
||||
*/
|
||||
contract MessageTribute {
|
||||
|
||||
event AudienceGranted(address indexed from, address to);
|
||||
|
||||
mapping(address => mapping(address => uint256)) public feeCatalog;
|
||||
|
||||
ERC20Token public token;
|
||||
|
||||
/**
|
||||
* @notice Contructor of MessageTribute
|
||||
* @param _token Address of Status Network Token (or any ERC20 compatible token)
|
||||
**/
|
||||
constructor(ERC20Token _token) public {
|
||||
token = _token;
|
||||
uint256 defaultValue;
|
||||
|
||||
struct Fee {
|
||||
bool custom;
|
||||
uint128 value;
|
||||
}
|
||||
|
||||
mapping(address => Fee) public feeCatalog;
|
||||
|
||||
/**
|
||||
* @notice Set tribute for accounts or everyone
|
||||
* @param _to Address to set the tribute. If address(0), applies to everyone
|
||||
* @param _amount Required tribute amount (using token from constructor)
|
||||
* @param _value Required tribute value (using token from constructor)
|
||||
*/
|
||||
function setRequiredTribute(address _to, uint _amount) external {
|
||||
feeCatalog[msg.sender][_to] = _amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Pay tribute to talk
|
||||
*/
|
||||
function payTribute(address _to) external {
|
||||
address requester = msg.sender;
|
||||
uint256 amount = getFee(_to, requester);
|
||||
delete feeCatalog[_to][requester];
|
||||
require(token.transferFrom(requester, _to, amount), "Transfer fail");
|
||||
emit AudienceGranted(_to, requester);
|
||||
function setRequiredTribute(uint256 _value) external {
|
||||
feeCatalog[msg.sender] = Fee(true, uint128(_value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Obtain required fee to talk with `_from`
|
||||
* @param _from Account `msg.sender` wishes to talk to
|
||||
* @notice Reset to default value
|
||||
*/
|
||||
function reset() external {
|
||||
delete feeCatalog[msg.sender];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Obtain required fee to talk with `_to`
|
||||
* @param _to Account `msg.sender` wishes to talk to
|
||||
* @return Fee
|
||||
*/
|
||||
function getFee(address _from, address _to) public view
|
||||
function getFee(address _to) public view
|
||||
returns (uint256)
|
||||
{
|
||||
uint256 specificFee = feeCatalog[_from][_to];
|
||||
uint256 generalFee = feeCatalog[_from][address(0)];
|
||||
return specificFee > 0 ? specificFee : generalFee;
|
||||
Fee storage fee = feeCatalog[_to];
|
||||
return fee.custom ? uint256(fee.value) : defaultValue;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue