all files / contracts/ ConceptProxy.sol

100% Statements 21/21
93.75% Branches 15/16
100% Functions 1/1
100% Lines 21/21
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                                        27× 27× 25×   25× 25× 27× 25× 23×   21× 20×   19×     17× 17× 17× 17× 17× 17× 17× 17×      
pragma solidity ^0.4.23;
 
import "./Proxy.sol";
import "./ConceptData.sol";
import "./ConceptRegistry.sol";
 
contract ConceptProxy is Proxy, ConceptDataInternal {
    constructor(
        address proxied,
        address _conceptRegistry,
        address[] _parents,
        uint[] _propagationRates,
        uint _lifetime,
        bytes _data,
        address _owner,
        address _cloneOf
    )
        public
        Proxy(proxied)
    {
        Erequire(_parents.length == _propagationRates.length, 'Number of parent concepts must match propagation rates');
        require(_parents.length < 6, 'Too many parents'); // NOTE: this value is a working assumption
        conceptRegistry = ConceptRegistry(_conceptRegistry);
 
        uint sumOfPropRates = 0;
        for (uint j=0; j < _parents.length; j++) {
            require(conceptRegistry.conceptExists(_parents[j]), 'Parent concept does not exist');
            require(_propagationRates[j] <= 1000, 'Propagation rate must be <1000');
            sumOfPropRates += _propagationRates[j];
        }
        if (_parents.length > 0) {
            require(sumOfPropRates == 1000, 'Propagation rates do not add up to 1000');
        }
        if (_cloneOf != address(0x0)) {
            require(conceptRegistry.conceptExists(_cloneOf), 'Desired original is not valid');
            cloneOf = _cloneOf;
        }
 
        creationDate = now;
        propagationRates = _propagationRates;
        parents = _parents;
        data = _data;
        lifetime = _lifetime;
        owner = _owner;
        fathomToken = FathomToken(conceptRegistry.fathomToken());
        CREATION_DATE = now;
    }
}