-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bb698d
commit 07b8e00
Showing
4 changed files
with
109 additions
and
7 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 |
---|---|---|
|
@@ -14,6 +14,7 @@ contract ZetaXPGov is Governor, GovernorSettings, GovernorCountingSimple, Govern | |
bytes32 public tagValidToVote; | ||
ZetaXP_V2 public xpNFT; | ||
uint256 public quorumPercentage; // New state to store the quorum percentage | ||
uint256 public minLevelToPropose; // New state to store the minimum level required to propose | ||
|
||
constructor( | ||
ZetaXP_V2 _xpNFT, | ||
|
@@ -34,14 +35,26 @@ contract ZetaXPGov is Governor, GovernorSettings, GovernorCountingSimple, Govern | |
tagValidToVote = _tag; | ||
} | ||
|
||
function setQuorumPercentage(uint256 _quorumPercentage) external onlyGovernance { | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter ZetaXPGov.setQuorumPercentage(uint256)._quorumPercentage is not in mixedCase
|
||
quorumPercentage = _quorumPercentage; | ||
} | ||
|
||
function setMinLevelToPropose(uint256 _minLevelToPropose) external onlyGovernance { | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter ZetaXPGov.setMinLevelToPropose(uint256)._minLevelToPropose is not in mixedCase
|
||
minLevelToPropose = _minLevelToPropose; | ||
} | ||
|
||
function _getLevel(address account) internal view returns (uint256) { | ||
uint256 tokenId = xpNFT.tokenByUserTag(account, tagValidToVote); | ||
return xpNFT.getLevel(tokenId); | ||
} | ||
|
||
// Override the _getVotes function to apply custom weight based on NFT levels | ||
function _getVotes( | ||
address account, | ||
uint256 blockNumber, | ||
bytes memory params | ||
) internal view override returns (uint256) { | ||
uint256 tokenId = xpNFT.tokenByUserTag(account, tagValidToVote); | ||
uint256 level = xpNFT.getLevel(tokenId); | ||
uint256 level = _getLevel(account); | ||
|
||
// Assign voting weight based on NFT level | ||
if (level == 1) { | ||
|
@@ -126,10 +139,21 @@ contract ZetaXPGov is Governor, GovernorSettings, GovernorCountingSimple, Govern | |
string memory reason, | ||
bytes memory params | ||
) internal override returns (uint256) { | ||
uint256 tokenId = xpNFT.tokenByUserTag(account, tagValidToVote); | ||
uint256 level = xpNFT.getLevel(tokenId); | ||
uint256 level = _getLevel(account); | ||
require(level > 0, "ZetaXPGov: invalid NFT level"); | ||
|
||
return super._castVote(proposalId, account, support, reason, params); | ||
} | ||
|
||
function propose( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
string memory description | ||
) public virtual override(Governor, IGovernor) returns (uint256) { | ||
uint256 level = _getLevel(msg.sender); | ||
require(level >= minLevelToPropose, "ZetaXPGov: insufficient level to propose"); | ||
|
||
return super.propose(targets, values, calldatas, description); | ||
} | ||
} |
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