From 91b88f6a355240b0f0c05d897a30c71a44b85d4a Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt Date: Wed, 19 Dec 2018 15:13:24 -0200 Subject: [PATCH] remove payment processing --- contracts/communication/MessageTribute.sol | 59 ++++++++-------------- 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/contracts/communication/MessageTribute.sol b/contracts/communication/MessageTribute.sol index 51cc21d..32cea18 100644 --- a/contracts/communication/MessageTribute.sol +++ b/contracts/communication/MessageTribute.sol @@ -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; } } \ No newline at end of file