Skip to content

Commit

Permalink
Merge pull request #84 from Layr-Labs/feat/add-setters-for-state-vars
Browse files Browse the repository at this point in the history
feat: add setters for state variables
  • Loading branch information
stevennevins authored Oct 1, 2024
2 parents 20f4792 + 9e92a1e commit 7343c04
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions contracts/src/IIncredibleSquaringTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 25 additions & 3 deletions contracts/src/IncredibleSquaringTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
_;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}


}

0 comments on commit 7343c04

Please sign in to comment.