-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from 1inch/refactor/SC-929-Improve-farming-cod…
…e-readability-Distributor [SC-929] Created abstract `Distributor` contract
- Loading branch information
Showing
12 changed files
with
73 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
import { IDistributor } from "./interfaces/IDistributor.sol"; | ||
|
||
abstract contract Distributor is IDistributor, Ownable { | ||
address internal _distributor; | ||
|
||
modifier onlyDistributor { | ||
if (msg.sender != _distributor) revert NotDistributor(); | ||
_; | ||
} | ||
|
||
/** | ||
* @notice See {IDistributor-setDistributor} | ||
*/ | ||
function setDistributor(address distributor_) public virtual onlyOwner { | ||
if (distributor_ == address(0)) revert ZeroDistributorAddress(); | ||
emit DistributorChanged(distributor_); | ||
_distributor = distributor_; | ||
} | ||
|
||
/** | ||
* @notice See {IDistributor-distributor} | ||
*/ | ||
function distributor() public view virtual returns (address) { | ||
return _distributor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
interface IDistributor { | ||
event DistributorChanged(address newDistributor); | ||
|
||
error NotDistributor(); | ||
error ZeroDistributorAddress(); | ||
|
||
/** | ||
* @notice Sets the entity that can manage the farming | ||
*/ | ||
function setDistributor(address distributor_) external; | ||
|
||
/** | ||
* @notice Returns the entity that can manage the farming | ||
*/ | ||
function distributor() external view returns(address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters