Skip to content

Commit

Permalink
add .prettierrc [solidity formatter] (#115)
Browse files Browse the repository at this point in the history
* feat : add prettierrc

* fix : remove unuseful comment

* [add proposal type] governance general purpose (#116)

* feat : add execute

* fix : upgrade issue

* test : execute

* feat : append gap

* fix : gap size

* fix : [execute fail] return value

* fix : typo

* fix : typo

* feat : test code

* feat : gov abigen
  • Loading branch information
felix-shin-wt authored Aug 19, 2024
1 parent ff492c7 commit 992c93c
Show file tree
Hide file tree
Showing 34 changed files with 3,807 additions and 3,416 deletions.
62 changes: 59 additions & 3 deletions wemix/bind/gen_ballotStorage_abi.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions wemix/bind/gen_envStorage_abi.go

Large diffs are not rendered by default.

373 changes: 353 additions & 20 deletions wemix/bind/gen_gov_abi.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions wemix/bind/gen_ncpExit_abi.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wemix/bind/gen_registry_abi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wemix/bind/gen_staking_abi.go

Large diffs are not rendered by default.

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 992c93c

Please sign in to comment.