contract RequestForForgiveness is Owned {

    ERC20TokenInterface private token;

    // receiving account
    address payable private receivingAccount;

    // Owner adds receiving account for accounting purposes
    function addEthReceivingAccount(address addr) public onlyOwner {
        require(addr != address(0));
        receivingAccount = address(uint160(addr));
    }

    // Owner adds ForgivenetToken address
    function addToken(address ercTokenAddress) public onlyOwner {
        require(ercTokenAddress != address(0));
        token = ERC20TokenInterface(ercTokenAddress);
    }

    // Owner deposits token into the contract
    function depositToken(uint256 amount) public onlyOwner {
        token = ERC20TokenInterface(token);
        require(token.transferFrom(msg.sender, address(this), amount) == true);
    }
    
    
    
    // A minimum value for a request for forgiveness transaction may disincentivize bad behaviour
    uint private disincentive;
    
    function setDisincentiveInWei(uint number) public onlyOwner {
        disincentive = number;
    }

    function getDisincentive() public view returns (uint) {
        return disincentive;
    }
    
    
    
    // Make Ether payment into receiving account and call withdrawToken with the request
    function requestForgiveness(string memory forgiveness_request) public payable {
        
        uint256 length = bytes(forgiveness_request).length;
        require(length > 500 && length < 2000);
        string memory requestStr = forgiveness_request;
  
        require(msg.sender != address(0));
        require(msg.value > disincentive);
        receivingAccount.transfer(msg.value);
        withdrawToken(msg.sender, msg.value, requestStr);
    }


    // Send 1 FRGVN token to recipient
    function withdrawToken(address recipient, uint256 amount, string memory requestString) internal {
        // placeholder variable for request
        string memory data = requestString;
        require(recipient != address(0));
        require(bytes(data).length > 0);
        token = ERC20TokenInterface(token);
        require(token.transfer(recipient, 1) == true);
        emit RequestMade(recipient, data, amount, now);
    }

    // events
    event RequestMade(address indexed from, string data, uint256 donation, uint256 timestamp);

}
function depositToken(uint256 amount) public onlyOwner {
    token = ERC20TokenInterface(token);
    require(token.transferFrom(msg.sender, address(this), amount) == true);
}

// Owner deposits token into the contract