-
Notifications
You must be signed in to change notification settings - Fork 5
/
EthicHubCMC.sol
44 lines (36 loc) · 1.84 KB
/
EthicHubCMC.sol
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
pragma solidity ^0.4.23;
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';
import "./EthicHubBase.sol";
/**
* @title EthichubCMC
* @dev This contract manage ethichub contracts creation and update.
*/
contract EthicHubCMC is EthicHubBase, Ownable {
event ContractUpgraded (
address indexed _oldContractAddress, // Address of the contract being upgraded
address indexed _newContractAddress, // Address of the new contract
uint256 created // Creation timestamp
);
modifier onlyOwnerOrLocalNode() {
bool isLocalNode = ethicHubStorage.getBool(keccak256("user", "localNode", msg.sender));
require(isLocalNode || owner == msg.sender);
_;
}
constructor(address _storageAddress) EthicHubBase(_storageAddress) public {
// Version
version = 1;
}
function addNewLendingContract(address _lendingAddress) public onlyOwnerOrLocalNode {
require(_lendingAddress != address(0));
ethicHubStorage.setAddress(keccak256("contract.address", _lendingAddress), _lendingAddress);
}
function upgradeContract(address _newContractAddress, string _contractName) public onlyOwner {
require(_newContractAddress != address(0));
require(keccak256("contract.name","") != keccak256("contract.name",_contractName));
address oldAddress = ethicHubStorage.getAddress(keccak256("contract.name", _contractName));
ethicHubStorage.setAddress(keccak256("contract.address", _newContractAddress), _newContractAddress);
ethicHubStorage.setAddress(keccak256("contract.name", _contractName), _newContractAddress);
ethicHubStorage.deleteAddress(keccak256("contract.address", oldAddress));
emit ContractUpgraded(oldAddress, _newContractAddress, now);
}
}