mirror of
https://github.com/status-im/contracts.git
synced 2025-02-23 12:08:47 +00:00
included fee collector, moved executed flag to democracy and +
This commit is contained in:
parent
d7b6c0f964
commit
31cabbb83b
26
contracts/democracy/FeeCollector.sol
Normal file
26
contracts/democracy/FeeCollector.sol
Normal file
@ -0,0 +1,26 @@
|
||||
pragma solidity ^0.4.21;
|
||||
|
||||
/** @notice Interface for fee collector */
|
||||
contract FeeCollector {
|
||||
|
||||
/**
|
||||
* @notice Collect a fee from yourself in your address
|
||||
* @param _amount to be collected
|
||||
*/
|
||||
function collect(uint256 _amount) external;
|
||||
|
||||
/**
|
||||
* @notice Collect a fee from your address in name of someone
|
||||
* @param _from to which address fee will be registered to
|
||||
* @param _amount to be collected
|
||||
*/
|
||||
function collectFor(address _from, uint256 _amount) external;
|
||||
|
||||
/**
|
||||
* @notice Collect a fee from someone
|
||||
* @param _from who allowed collection
|
||||
* @param _amount to be collected
|
||||
*/
|
||||
function collectFrom(address _from, uint256 _amount) external;
|
||||
|
||||
}
|
@ -2,14 +2,14 @@ pragma solidity ^0.4.21;
|
||||
|
||||
import "../common/Controlled.sol";
|
||||
import "../token/ERC20Token.sol";
|
||||
import "../token/MiniMeToken.sol";
|
||||
|
||||
import "../token/MiniMeTokenInterface.sol";
|
||||
import "./FeeCollector.sol";
|
||||
/**
|
||||
* @title FeeRecycler
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmBH)
|
||||
* @dev Allow user selecting predefined destinations to where this fees will be invested
|
||||
*/
|
||||
contract FeeRecycler is Controlled {
|
||||
contract FeeRecycler is Controlled, FeeCollector {
|
||||
|
||||
//allowed democratically choosen destinations
|
||||
mapping (address => bool) public destinations;
|
||||
@ -18,22 +18,43 @@ contract FeeRecycler is Controlled {
|
||||
//used for withdrawing lost tokens
|
||||
uint256 public totalLocked;
|
||||
//base token
|
||||
MiniMeToken public token;
|
||||
MiniMeTokenInterface public token;
|
||||
|
||||
/**
|
||||
* @notice Constructor defines the unchangable (?) baseToken
|
||||
* @param _token base token
|
||||
*/
|
||||
function FeeRecycler(MiniMeToken _token) public {
|
||||
function FeeRecycler(MiniMeTokenInterface _token) public {
|
||||
token = _token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Collect a fee from yourself in your address
|
||||
* @param _amount to be collected
|
||||
*/
|
||||
function collect(uint256 _amount) external {
|
||||
require(token.transferFrom(msg.sender, address(this), _amount));
|
||||
balances[msg.sender] += _amount;
|
||||
totalLocked += _amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Collect a fee from someone
|
||||
* @param _from who allowed collection
|
||||
* @param _amount to be collected
|
||||
*/
|
||||
function collectFrom(address _from, uint256 _amount) external {
|
||||
require(token.transferFrom(_from, address(this), _amount));
|
||||
balances[_from] += _amount;
|
||||
totalLocked += _amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Lock a fee in name of someone
|
||||
* @param _from who would be able to recycle this funds
|
||||
* @param _amount to be locked
|
||||
*/
|
||||
function lock(address _from, uint256 _amount) external {
|
||||
function collectFor(address _from, uint256 _amount) external {
|
||||
require(token.transferFrom(msg.sender, address(this), _amount));
|
||||
balances[_from] += _amount;
|
||||
totalLocked += _amount;
|
||||
@ -77,7 +98,7 @@ contract FeeRecycler is Controlled {
|
||||
if (address(_token) == address(token)) {
|
||||
require(_amount <= _token.balanceOf(address(this)) - totalLocked);
|
||||
} else if (address(_token) == address(0)) {
|
||||
require(this.balance <= _amount);
|
||||
require(address(this).balance <= _amount);
|
||||
}
|
||||
if (address(_token) != address(0)) {
|
||||
_token.transfer(_destination, _amount);
|
||||
|
Loading…
x
Reference in New Issue
Block a user