moved signers to deployed contracts

This commit is contained in:
Sowmay Jain 2020-09-12 20:12:37 +10:00
parent 52fbd8c0fc
commit beaa67232e
3 changed files with 27 additions and 33 deletions

View File

@ -8,10 +8,13 @@ contract Controller {
event LogUpdateMaster(address indexed master); event LogUpdateMaster(address indexed master);
event LogEnableConnector(address indexed connector); event LogEnableConnector(address indexed connector);
event LogDisableConnector(address indexed connector); event LogDisableConnector(address indexed connector);
event LogAddSigner(address indexed signer);
event LogRemoveSigner(address indexed signer);
address private newMaster; address private newMaster;
address public master; address public master;
mapping (address => bool) public connectors; mapping (address => bool) public connectors;
mapping (address => bool) public signer;
modifier isMaster() { modifier isMaster() {
require(msg.sender == master, "not-master"); require(msg.sender == master, "not-master");
@ -36,21 +39,37 @@ contract Controller {
emit LogUpdateMaster(master); emit LogUpdateMaster(master);
} }
// enable flusher connector // enable connector
function enableConnector(address _connector) external isChief { function enableConnector(address _connector) external isMaster {
require(!connectors[_connector], "already-enabled"); require(!connectors[_connector], "already-enabled");
require(_connector != address(0), "invalid-connector"); require(_connector != address(0), "invalid-connector");
connectors[_connector] = true; connectors[_connector] = true;
emit LogEnableConnector(_connector); emit LogEnableConnector(_connector);
} }
// disable flusher connector // disable connector
function disableConnector(address _connector) external isChief { function disableConnector(address _connector) external isMaster {
require(connectors[_connector], "already-disabled"); require(connectors[_connector], "already-disabled");
delete connectors[_connector]; delete connectors[_connector];
emit LogDisableConnector(_connector); emit LogDisableConnector(_connector);
} }
// enable signer
function enableSigner(address _signer) external isMaster {
require(_signer != address(0), "invalid-address");
require(!signer[_signer], "signer-already-enabled");
signer[_signer] = true;
emit LogAddSigner(_signer);
}
// disable signer
function disableSigner(address _signer) external isMaster {
require(_signer != address(0), "invalid-address");
require(signer[_signer], "signer-already-disabled");
delete signer[_signer];
emit LogRemoveSigner(_signer);
}
// check if connectors[] are enabled // check if connectors[] are enabled
function isConnector(address[] calldata _connectors) external view returns (bool isOk) { function isConnector(address[] calldata _connectors) external view returns (bool isOk) {
isOk = true; isOk = true;

View File

@ -3,7 +3,7 @@
pragma solidity ^0.6.8; pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2; pragma experimental ABIEncoderV2;
interface RegistryInterface { interface DeployerInterface {
function signer(address) external view returns (bool); function signer(address) external view returns (bool);
function isConnector(address[] calldata) external view returns (bool); function isConnector(address[] calldata) external view returns (bool);
} }
@ -13,7 +13,7 @@ contract Flusher {
string constant public name = "Flusher-v1"; string constant public name = "Flusher-v1";
RegistryInterface public constant registry = RegistryInterface(address(0)); // TODO - Change while deploying DeployerInterface public constant deployer = DeployerInterface(address(0)); // TODO - Change while deploying
function spell(address _target, bytes memory _data) internal { function spell(address _target, bytes memory _data) internal {
require(_target != address(0), "target-invalid"); require(_target != address(0), "target-invalid");
@ -29,9 +29,9 @@ contract Flusher {
} }
function cast(address[] calldata _targets, bytes[] calldata _datas) external payable { function cast(address[] calldata _targets, bytes[] calldata _datas) external payable {
require(registry.signer(msg.sender), "not-signer"); require(deployer.signer(msg.sender), "not-signer");
require(_targets.length == _datas.length , "invalid-array-length"); require(_targets.length == _datas.length , "invalid-array-length");
require(registry.isConnector(_targets), "not-connector"); require(deployer.isConnector(_targets), "not-connector");
for (uint i = 0; i < _targets.length; i++) { for (uint i = 0; i < _targets.length; i++) {
spell(_targets[i], _datas[i]); spell(_targets[i], _datas[i]);
} }

View File

@ -11,8 +11,6 @@ contract Registry {
event LogAddChief(address indexed chief); event LogAddChief(address indexed chief);
event LogRemoveChief(address indexed chief); event LogRemoveChief(address indexed chief);
event LogAddSigner(address indexed signer);
event LogRemoveSigner(address indexed signer);
event LogUpdatePoolLogic(address token, address newLogic); event LogUpdatePoolLogic(address token, address newLogic);
event LogUpdateFee(address token, uint newFee); event LogUpdateFee(address token, uint newFee);
event LogUpdateCap(address token, uint newFee); event LogUpdateCap(address token, uint newFee);
@ -22,7 +20,6 @@ contract Registry {
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
mapping (address => bool) public chief; mapping (address => bool) public chief;
mapping (address => bool) public signer;
mapping (address => address) public poolLogic; mapping (address => address) public poolLogic;
mapping (address => uint) public poolCap; mapping (address => uint) public poolCap;
mapping (address => uint) public fee; mapping (address => uint) public fee;
@ -60,28 +57,6 @@ contract Registry {
emit LogRemoveChief(_chief); emit LogRemoveChief(_chief);
} }
/**
* @dev Enable New Signer.
* @param _signer Address of the new signer.
*/
function enableSigner(address _signer) external isChief {
require(_signer != address(0), "invalid-address");
require(!signer[_signer], "signer-already-enabled");
signer[_signer] = true;
emit LogAddSigner(_signer);
}
/**
* @dev Disable Signer.
* @param _signer Address of the existing signer.
*/
function disableSigner(address _signer) external isChief {
require(_signer != address(0), "invalid-address");
require(signer[_signer], "signer-already-disabled");
delete signer[_signer];
emit LogRemoveSigner(_signer);
}
/** /**
* @dev update pool rate logic * @dev update pool rate logic
* @param _pool pool address * @param _pool pool address