mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			886 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			886 B
		
	
	
	
		
			Solidity
		
	
	
	
	
	
contract Factory {
 | 
						|
 | 
						|
    event ContractInstantiation(address sender, address instantiation);
 | 
						|
 | 
						|
    mapping(address => bool) public isInstantiation;
 | 
						|
    mapping(address => address[]) public instantiations;
 | 
						|
 | 
						|
    /// @dev Returns number of instantiations by creator.
 | 
						|
    /// @param creator Contract creator.
 | 
						|
    /// @return Returns number of instantiations by creator.
 | 
						|
    function getInstantiationCount(address creator)
 | 
						|
        public
 | 
						|
        view
 | 
						|
        returns (uint)
 | 
						|
    {
 | 
						|
        return instantiations[creator].length;
 | 
						|
    }
 | 
						|
 | 
						|
    /// @dev Registers contract in factory registry.
 | 
						|
    /// @param instantiation Address of contract instantiation.
 | 
						|
    function register(address instantiation)
 | 
						|
        internal
 | 
						|
    {
 | 
						|
        isInstantiation[instantiation] = true;
 | 
						|
        instantiations[msg.sender].push(instantiation);
 | 
						|
        emit ContractInstantiation(msg.sender, instantiation);
 | 
						|
    }
 | 
						|
}
 |