-
Notifications
You must be signed in to change notification settings - Fork 45
/
Controller.sol
64 lines (54 loc) · 1.98 KB
/
Controller.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IController.sol";
import "./IManager.sol";
import "./zeppelin/Pausable.sol";
contract Controller is Pausable, IController {
// Track information about a registered contract
struct ContractInfo {
address contractAddress; // Address of contract
bytes20 gitCommitHash; // SHA1 hash of head Git commit during registration of this contract
}
// Track contract ids and contract info
mapping(bytes32 => ContractInfo) private registry;
constructor() {
// Start system as paused
paused = true;
}
/**
* @notice Register contract id and mapped address
* @param _id Contract id (keccak256 hash of contract name)
* @param _contractAddress Contract address
*/
function setContractInfo(
bytes32 _id,
address _contractAddress,
bytes20 _gitCommitHash
) external override onlyOwner {
registry[_id].contractAddress = _contractAddress;
registry[_id].gitCommitHash = _gitCommitHash;
emit SetContractInfo(_id, _contractAddress, _gitCommitHash);
}
/**
* @notice Update contract's controller
* @param _id Contract id (keccak256 hash of contract name)
* @param _controller Controller address
*/
function updateController(bytes32 _id, address _controller) external override onlyOwner {
return IManager(registry[_id].contractAddress).setController(_controller);
}
/**
* @notice Return contract info for a given contract id
* @param _id Contract id (keccak256 hash of contract name)
*/
function getContractInfo(bytes32 _id) public view returns (address, bytes20) {
return (registry[_id].contractAddress, registry[_id].gitCommitHash);
}
/**
* @notice Get contract address for an id
* @param _id Contract id
*/
function getContract(bytes32 _id) public view override returns (address) {
return registry[_id].contractAddress;
}
}