all files / contracts/Entity/ BountyManager.sol

100% Statements 9/9
100% Branches 2/2
100% Functions 2/2
100% Lines 10/10
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                                                    113× 113× 113×   113× 113× 113×   113×                        
/*
 
 * @name        Bounty Program Contract
 * @package     BlockBitsIO
 * @author      Micky Socaci <micky@nowlive.ro>
 
    Bounty program contract that holds and distributes tokens upon successful funding.
*/
 
pragma solidity ^0.4.17;
 
import "./../ApplicationAsset.sol";
import "./Token.sol";
import "./TokenManager.sol";
import "./Funding.sol";
 
contract BountyManager is ApplicationAsset {
 
    Funding FundingEntity;
    Token TokenEntity;
 
    function runBeforeApplyingSettings()
        internal
        requireInitialised
        requireSettingsNotApplied
    {
        address FundingAddress = getApplicationAssetAddressByName('Funding');
        FundingEntity = Funding(FundingAddress);
        EventRunBeforeApplyingSettings(assetName);
 
        address TokenManagerAddress = getApplicationAssetAddressByName('TokenManager');
        TokenManager TokenManagerEntity = TokenManager(TokenManagerAddress);
        TokenEntity = Token(TokenManagerEntity.TokenEntity());
 
        EventRunBeforeApplyingSettings(assetName);
    }
 
    function sendBounty( address _receiver, uint256 _amount )
        public
        requireInitialised
        requireSettingsApplied
        onlyDeployer
    {
        if( FundingEntity.CurrentEntityState() == FundingEntity.getEntityState("SUCCESSFUL_FINAL") ) {
            TokenEntity.transfer( _receiver, _amount );
        } else {
            revert();
        }
    }
}