Skip to content

Commit

Permalink
feat : add prettierrc
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-shin-wt committed Jul 19, 2024
1 parent d0319f9 commit e8d971e
Show file tree
Hide file tree
Showing 27 changed files with 2,942 additions and 3,364 deletions.
14 changes: 14 additions & 0 deletions wemix/governance-contract/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 150,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": true
}
}
]
}
158 changes: 79 additions & 79 deletions wemix/governance-contract/contracts/GovChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,83 @@ import "./interface/IGov.sol";
* @dev GovChecker Contract that uses Registry contract
*/
contract GovChecker is OwnableUpgradeable {
IRegistry public reg;

bytes32 public constant GOV_NAME = "GovernanceContract";
bytes32 public constant STAKING_NAME = "Staking";
bytes32 public constant BALLOT_STORAGE_NAME = "BallotStorage";
bytes32 public constant ENV_STORAGE_NAME = "EnvStorage";
bytes32 public constant REWARD_POOL_NAME = "RewardPool";
bytes32 public constant MAINTENANCE_NAME = "Maintenance";
bytes32 public constant ECOSYSTEM_NAME = "Ecosystem";
bytes32 public constant STAKING_REWARD_NAME = "StakingReward";

/*
* @dev Function to set registry address. Contract that wants to use registry should setRegistry first.
* @param _addr address of registry
* @return A boolean that indicates if the operation was successful.
*/
event SetRegistry(address indexed addr);

function setRegistry(address _addr) public onlyOwner {
require(_addr != address(0), "Address should be non-zero");
reg = IRegistry(_addr);
emit SetRegistry(_addr);
}

modifier onlyGov() {
require(getGovAddress() == msg.sender, "No Permission");
_;
}

modifier onlyGovMem() {
require(IGov(getGovAddress()).isMember(msg.sender), "No Permission");
_;
}

modifier onlyGovStaker() {
require(IGov(getGovAddress()).isStaker(msg.sender), "No Permission");
_;
}

modifier anyGov() {
require(getGovAddress() == msg.sender || IGov(getGovAddress()).isMember(msg.sender), "No Permission");
_;
}

function getContractAddress(bytes32 name) internal view returns (address) {
return reg.getContractAddress(name);
}

function getGovAddress() internal view returns (address) {
return getContractAddress(GOV_NAME);
}

function getStakingAddress() internal view returns (address) {
return getContractAddress(STAKING_NAME);
}

function getBallotStorageAddress() internal view returns (address) {
return getContractAddress(BALLOT_STORAGE_NAME);
}

function getEnvStorageAddress() internal view returns (address) {
return getContractAddress(ENV_STORAGE_NAME);
}

function getRewardPoolAddress() internal view returns (address) {
return getContractAddress(REWARD_POOL_NAME);
}

function getEcosystemAddress() internal view returns (address) {
return getContractAddress(ECOSYSTEM_NAME);
}

function getStakingRewardAddress() internal view returns (address) {
return getContractAddress(STAKING_REWARD_NAME);
}

function getMaintenanceAddress() internal view returns (address) {
return getContractAddress(MAINTENANCE_NAME);
}
IRegistry public reg;

bytes32 public constant GOV_NAME = "GovernanceContract";
bytes32 public constant STAKING_NAME = "Staking";
bytes32 public constant BALLOT_STORAGE_NAME = "BallotStorage";
bytes32 public constant ENV_STORAGE_NAME = "EnvStorage";
bytes32 public constant REWARD_POOL_NAME = "RewardPool";
bytes32 public constant MAINTENANCE_NAME = "Maintenance";
bytes32 public constant ECOSYSTEM_NAME = "Ecosystem";
bytes32 public constant STAKING_REWARD_NAME = "StakingReward";

/*
* @dev Function to set registry address. Contract that wants to use registry should setRegistry first.
* @param _addr address of registry
* @return A boolean that indicates if the operation was successful.
*/
event SetRegistry(address indexed addr);

function setRegistry(address _addr) public onlyOwner {
require(_addr != address(0), "Address should be non-zero");
reg = IRegistry(_addr);
emit SetRegistry(_addr);
}

modifier onlyGov() {
require(getGovAddress() == msg.sender, "No Permission");
_;
}

modifier onlyGovMem() {
require(IGov(getGovAddress()).isMember(msg.sender), "No Permission");
_;
}

modifier onlyGovStaker() {
require(IGov(getGovAddress()).isStaker(msg.sender), "No Permission");
_;
}

modifier anyGov() {
require(getGovAddress() == msg.sender || IGov(getGovAddress()).isMember(msg.sender), "No Permission");
_;
}

function getContractAddress(bytes32 name) internal view returns (address) {
return reg.getContractAddress(name);
}

function getGovAddress() internal view returns (address) {
return getContractAddress(GOV_NAME);
}

function getStakingAddress() internal view returns (address) {
return getContractAddress(STAKING_NAME);
}

function getBallotStorageAddress() internal view returns (address) {
return getContractAddress(BALLOT_STORAGE_NAME);
}

function getEnvStorageAddress() internal view returns (address) {
return getContractAddress(ENV_STORAGE_NAME);
}

function getRewardPoolAddress() internal view returns (address) {
return getContractAddress(REWARD_POOL_NAME);
}

function getEcosystemAddress() internal view returns (address) {
return getContractAddress(ECOSYSTEM_NAME);
}

function getStakingRewardAddress() internal view returns (address) {
return getContractAddress(STAKING_REWARD_NAME);
}

function getMaintenanceAddress() internal view returns (address) {
return getContractAddress(MAINTENANCE_NAME);
}
}
Loading

0 comments on commit e8d971e

Please sign in to comment.