-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove ownable from managerhelper. up to 2.0.0
- Loading branch information
Showing
6 changed files
with
8,762 additions
and
28,867 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
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 |
---|---|---|
@@ -1,35 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
// import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import "./interfaces/IReleaseManager.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
contract ReleaseManagerHelper is Ownable{ | ||
abstract contract ReleaseManagerHelper { | ||
using Address for address; | ||
address public releaseManager; | ||
address private _releaseManager; | ||
|
||
error RegisterReleaseManagerFirst(); | ||
error ReleaseManagerIsNoneContract(address addr); | ||
error ReleaseManagerAlreadySetup(address addr); | ||
|
||
function registerInstance(address stateContractAddress) internal { | ||
if (releaseManager == address(0)) { | ||
revert RegisterReleaseManagerFirst(); | ||
error ReleaseManagerInvalid(address addr); | ||
|
||
/** | ||
* @notice need to register release manager when factory(CommunityCoinFactory, IncomeContractFactory, etc) deployed | ||
*/ | ||
constructor(address releaseManagerAddr) { | ||
if ( | ||
releaseManagerAddr.isContract() == false || | ||
releaseManagerAddr == address(0) | ||
) { | ||
revert ReleaseManagerInvalid(releaseManagerAddr); | ||
} | ||
IReleaseManager(releaseManager).registerInstance(stateContractAddress); | ||
|
||
_releaseManager = releaseManagerAddr; | ||
} | ||
|
||
function registerReleaseManager(address releaseManager_) public onlyOwner { | ||
if (releaseManager_.isContract() == false) { | ||
revert ReleaseManagerIsNoneContract(releaseManager_); | ||
} | ||
if (releaseManager != address(0)) { | ||
revert ReleaseManagerAlreadySetup(releaseManager_); | ||
} | ||
|
||
releaseManager = releaseManager_; | ||
/** | ||
* @notice view release manager address that was regsted when factory deployed | ||
*/ | ||
function releaseManager() public view returns(address) { | ||
return _releaseManager; | ||
} | ||
|
||
/** | ||
* @param instanceAddress address that was produced by factory need to be registered in ReleaseManager. Usually such method should be called after produce/produceDeterministic | ||
*/ | ||
function registerInstance(address instanceAddress) internal { | ||
IReleaseManager(_releaseManager).registerInstance(instanceAddress); | ||
} | ||
|
||
} |
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
Oops, something went wrong.