From 9e92a1e06a9b2eef1b33a720c2bfb5d805c79708 Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 1 Oct 2024 07:47:08 -0400 Subject: [PATCH] feat: add setters for state variables --- .../src/IIncredibleSquaringTaskManager.sol | 4 +++ .../src/IncredibleSquaringTaskManager.sol | 28 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/contracts/src/IIncredibleSquaringTaskManager.sol b/contracts/src/IIncredibleSquaringTaskManager.sol index 6e6fcfcb..f57faa36 100644 --- a/contracts/src/IIncredibleSquaringTaskManager.sol +++ b/contracts/src/IIncredibleSquaringTaskManager.sol @@ -24,6 +24,10 @@ interface IIncredibleSquaringTaskManager { address indexed challenger ); + event AggregatorUpdated(address indexed oldAggregator, address indexed newAggregator); + + event GeneratorUpdated(address indexed oldGenerator, address indexed newGenerator); + // STRUCTS struct Task { uint256 numberToBeSquared; diff --git a/contracts/src/IncredibleSquaringTaskManager.sol b/contracts/src/IncredibleSquaringTaskManager.sol index d1762cf3..85fbefd0 100644 --- a/contracts/src/IncredibleSquaringTaskManager.sol +++ b/contracts/src/IncredibleSquaringTaskManager.sol @@ -46,7 +46,7 @@ contract IncredibleSquaringTaskManager is address public aggregator; address public generator; - /* MODIFIERS */ + modifier onlyAggregator() { require(msg.sender == aggregator, "Aggregator must be the caller"); _; @@ -74,8 +74,16 @@ contract IncredibleSquaringTaskManager is ) public initializer { _initializePauser(_pauserRegistry, UNPAUSE_ALL); _transferOwnership(initialOwner); - aggregator = _aggregator; - generator = _generator; + _setAggregator(_aggregator); + _setGenerator(_generator); + } + + function setGenerator(address newGenerator) external onlyOwner { + _setGenerator(newGenerator); + } + + function setAggregator(address newAggregator) external onlyOwner { + _setAggregator(newAggregator); } /* FUNCTIONS */ @@ -317,4 +325,18 @@ contract IncredibleSquaringTaskManager is function getTaskResponseWindowBlock() external view returns (uint32) { return TASK_RESPONSE_WINDOW_BLOCK; } + + function _setGenerator(address newGenerator) internal { + address oldGenerator = generator; + generator = newGenerator; + emit GeneratorUpdated(oldGenerator, newGenerator); + } + + function _setAggregator(address newAggregator) internal { + address oldAggregator = aggregator; + aggregator = newAggregator; + emit AggregatorUpdated(oldAggregator, newAggregator); + } + + }