pragma solidity ^0.4.11; import "./module.sol"; import "./announcementTypes.sol"; import "./multiOwner.sol"; import "./publisher.sol"; import "./token.sol"; import "./provider.sol"; import "./schelling.sol"; import "./premium.sol"; import "./ico.sol"; contract abstractModule { function connectModule() external returns (bool success) {} function disconnectModule() external returns (bool success) {} function replaceModule(address addr) external returns (bool success) {} function disableModule(bool forever) external returns (bool success) {} function isActive() public constant returns (bool success) {} function replaceModuleHandler(address newHandler) external returns (bool success) {} function transferEvent(address from, address to, uint256 value) external returns (bool success) {} function newSchellingRoundEvent(uint256 roundID, uint256 reward) external returns (bool success) {} } contract moduleHandler is multiOwner, announcementTypes { struct modules_s { address addr; bytes32 name; bool schellingEvent; bool transferEvent; } modules_s[] public modules; address public foundationAddress; uint256 debugModeUntil = block.number + 1000000; constructor(address[] newOwners) multiOwner(newOwners) {} function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) { /* Loading modulest to ModuleHandler. This module can be called only once and only by the owner, if every single module and its database are already put on the blockchain. If forReaplace is true, than the ModuleHandler will be replaced. Before the publishing of its replace, the new contract must be already on the blockchain. @foundation Address of foundation. @forReplace Is it for replace or not. If not, it will be connected to the module. @Token address of token. @Publisher address of publisher. @Schelling address of Schelling. @Provider address of provider */ require( owners[msg.sender] ); require( modules.length == 0 ); foundationAddress = foundation; addModule( modules_s(Token, keccak256('Token'), false, false), ! forReplace); addModule( modules_s(Premium, keccak256('Premium'), false, false), ! forReplace); addModule( modules_s(Publisher, keccak256('Publisher'), false, true), ! forReplace); addModule( modules_s(Schelling, keccak256('Schelling'), false, true), ! forReplace); addModule( modules_s(Provider, keccak256('Provider'), true, true), ! forReplace); } function addModule(modules_s input, bool call) internal { /* Inside function for registration of the modules in the database. If the call is false, wont happen any direct call. @input _Structure of module. @call Is connect to the module or not. */ if ( call ) { require( abstractModule(input.addr).connectModule() ); } (bool success, bool found, uint256 id) = getModuleIDByAddress(input.addr); require( success && ! found ); (success, found, id) = getModuleIDByHash(input.name); require( success && ! found ); (success, found, id) = getModuleIDByAddress(address(0x00)); require( success ); if ( ! found ) { id = modules.length; modules.length++; } modules[id] = input; } function getModuleAddressByName(string name) public constant returns( bool success, bool found, address addr ) { /* Search by name for module. The result is an Ethereum address. @name Name of module. @addr Address of module. @found Is there any result. @success Was the transaction succesfull or not. */ (bool _success, bool _found, uint256 _id) = getModuleIDByName(name); if ( _success && _found ) { return (true, true, modules[_id].addr); } return (true, false, address(0x00)); } function getModuleIDByHash(bytes32 hashOfName) public constant returns( bool success, bool found, uint256 id ) { /* Search by hash of name in the module array. The result is an index array. @name Name of module. @id Index of module. @found Was there any result or not. */ for ( uint256 a=0 ; a