all files / contracts/ FathomToken.sol

100% Statements 26/26
83.33% Branches 15/18
100% Functions 6/6
100% Lines 26/26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                                                                                867×           133× 131× 89×     129× 129× 129× 129× 129× 129×                          
pragma solidity ^0.4.23;
 
import "./Concept.sol";
import "./ConceptRegistry.sol";
import "./lib/openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
import "./Minter.sol";
 
 
/*
@type: contract
@name: UserRegistry
@purpose: To store data about users for easy, secure access and manage token balances
*/
contract FathomToken is StandardToken {
    ConceptRegistry public conceptRegistry;
    string public constant NAME = "Aha";
    string public constant SYMBOL = "AHA";
    uint8 public constant DECIMALS = 9;
 
    address public minter;
    address public owner;
 
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    event Notification(address indexed user, address indexed assessment, Note indexed topic);
 
    enum Note {
      StartedAnAssessment,
      CalledAsAssessor,
      ConfirmedAsAssessor,
      AssessmentCancelled,
      AssessmentHasBegun,
      RevealScore,
      ConsensusReached,
      AssessmentFinished
    }
 
    constructor(address _conceptRegistry, address _initialUser, uint _initialBalance, address _minter) public {
        owner = msg.sender;
        conceptRegistry = ConceptRegistry(_conceptRegistry);
        minter = _minter;
        totalSupply_ = _initialBalance;
        balances[_initialUser] = _initialBalance;
    }
 
    function notification(address user, Note topic) public {
        emit Notification(user, msg.sender, topic);
    }
 
    // function that can only be called by assessments
    //@purpose: To perform payments and staking for assessments
    function takeBalance(address _from, address _to, uint _amount, address _concept) public returns(bool) {
        require(conceptRegistry.conceptExists(_concept), 'Concept does not exist');
        if (msg.sender != _concept) {
            require(Concept(_concept).assessmentExists(msg.sender), 'Assessment access only');
        }
 
        Erequire(balances[_from] >= _amount, 'Token balance too low');
        Erequire(balances[_to] + _amount >= balances[_to], 'Overflow error');
        balances[_from] -= _amount;
        balances[_to] += _amount;
        emit Transfer(_from, _to, _amount);
        return true;
    }
 
    function mint(address _to, uint _amount) public returns(bool) {
        require(msg.sender == minter, 'Minter access only');
        Erequire(totalSupply_ + _amount > totalSupply_, 'Overflow error: max number of tokens reached');
 
        totalSupply_ += _amount;
        balances[_to] += _amount;
        emit Transfer(address(0), _to, _amount);
        return true;
    }
 
    function changeMinter(address _newMinter) public {
        require(msg.sender == owner, 'Owner access only');
        minter = _newMinter;
    }
 
    function transferOwnership(address _newOwner) public {
        require(msg.sender == owner, 'Owner access only');
        emit OwnershipTransferred(owner, _newOwner);
        owner = _newOwner;
    }
}