-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capx Community Quest and Community Quest Forger With Reputation Score Changes #6
base: feature/gameResources
Are you sure you want to change the base?
Capx Community Quest and Community Quest Forger With Reputation Score Changes #6
Conversation
@@ -73,15 +96,10 @@ contract CapxCommunityQuest is ReentrancyGuard, PausableUpgradeable, OwnableUpgr | |||
return string(buffer); | |||
} | |||
|
|||
function recoverSigner(bytes32 messagehash, bytes memory signature) public pure returns (address) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary imports from the file associated to the deleted functions.
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
contracts/CapxCommunityQuest.sol
Outdated
if(IERC20(currCapxQuest.rewardToken).balanceOf(address(this)) < _rewardAmountInWei) revert NoRewardsToClaim(); | ||
require( | ||
_timestamp < block.timestamp, | ||
"CapxCommunityQuest: Cannot Claim Future Rewards" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert this error message into an error category.
contracts/CapxCommunityQuest.sol
Outdated
_timestamp < block.timestamp, | ||
"CapxCommunityQuest: Cannot Claim Future Rewards" | ||
); | ||
require(_questId != 0, "CapxCommunityQuest: Invalid Community QuestId"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert this error message into an error category.
contracts/CapxCommunityQuest.sol
Outdated
_receiver, | ||
_timestamp, | ||
currCapxQuest.rewardToken, | ||
address(this), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the need to have address(this)
as a parameter in the even emission ?
@@ -69,6 +87,13 @@ contract CapxCommunityQuestForger is Initializable, UUPSUpgradeable, OwnableUpgr | |||
capxCommunityQuest = _capxCommunityQuest; | |||
} | |||
|
|||
function updateCapxReputationScoreAddress(address _capxReputationScore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is capxReputationScore
contract not part of the initialize function ?
string memory _questId = string(abi.encodePacked(quest.communityId,"_",uintToStr(quest.questNumber))); | ||
require( | ||
community[quest.communityId] != address(0), | ||
"CapxCommunityQuestForger: Invalid Community Id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert this error message into an error category.
_rewardAmount | ||
require( | ||
address(capxQuest) != address(0), | ||
"CapxCommunityQuestForger: Invalid Capx Quest ID" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert this error message into an error category.
); | ||
}else{ | ||
revert InvalidRewardType(); | ||
} | ||
} | ||
|
||
function emitClaim( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we remove this function as emission of the ReputationScore is in the claim
function but the IOU Token reward claim has a seperate function. This would reduce the number of internal contract calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rewardToken is stored in memory in the community contract and not in the forger contract , should I keep a map of communityIds to their respective token contracts in the forger contract? While emitting the event it requires the token contract address as well.
|
||
function recoverSigner(bytes32 messagehash, bytes memory signature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a public function and not an internal function ?
@@ -22,11 +21,9 @@ interface ICapxCommunityQuest { | |||
error ClaimedRewardsExceedTotalRewards(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove un-used error categories from the interface.
contracts/CapxCommunityQuest.sol
Outdated
QuestDTO memory quest | ||
) external nonReentrant whenNotPaused onlyForger { | ||
// Transfer tokens. | ||
ITokenPoweredByCapx(quest.rewardToken).addToWhitelist(address(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjaybaskaran01 Why are we whitelisting the rewardToken in this method ?
string memory _communityQuestId = string(abi.encodePacked(communityId,"_",uintToStr(_questId))); | ||
if(currCapxQuest.rewardToken != address(0)) revert QuestIdUsed(); | ||
|
||
function setQuestDetails( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for naming this function setQuestDetails
and not createQuest
can we modify the quest details apart from the reference variables once we have created it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for naming this function
setQuestDetails
and notcreateQuest
can we modify the quest details apart from the reference variables once we have created it ?
Yes, we utilise the same function for updating the quest details.
if(currCapxQuest.rewardToken != address(0)) revert QuestIdUsed(); | ||
|
||
function setQuestDetails( | ||
QuestDTO memory quest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the naming convention behind QuestDTO ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the naming convention behind QuestDTO ?
We are creating transferrable objects for setting the quest details in both communityQuest contract and as well as reputationScore contract.
CommunityForger -> CapxQuestDetails (struct )
Community -> QuestDTO ( struct , part of CapxQuestDetails of CommunityForger )
CapxReputationScore -> QuestDTO ( struct, part of CapxQuestDetails of CommunityForger )
Using the term DTO to signify that they are merely just a transfer objects for respective contracts which will be set as CapxQuestDetail for their respective contracts.
) external nonReentrant whenNotPaused onlyForger { | ||
// Transfer tokens. | ||
ITokenPoweredByCapx(quest.rewardToken).addToWhitelist(address(this)); | ||
IERC20(quest.rewardToken).safeTransferFrom( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the transfer of tokens being done from the community quest contract and not from the CommunityQuestForger ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted all the community specific actions to exist inside the communityQuest contract.
This is the differentiation I was going for:
CapxCommunityQuest Contract:
- This contract will handle the details of individual community quests
- Its main job is to manage everything about a quest, like tracking rewards, who is participating, and the quest's overall status
- It deals with ERC20 token transactions directly. This way, all the important actions and changes for a quest happen in one place, which makes the system more organized and easier to handle
CapxCommunityQuestForger Contract:
- This contract acts like creator and manager for multiple CapxCommunityQuest instances.
- Its main role is to set up new community quests, establish their initial settings, and link quests to their respective communities.
- It should not get involved in the specifics of token transactions for quests. It focuses on higher-level tasks like setting up and managing quests, which keeps things simpler and more focused.
contracts/CapxCommunityQuest.sol
Outdated
@@ -1,17 +1,22 @@ | |||
//SPDX-License-Identifier: MIT | |||
pragma solidity ^0.8.16; | |||
pragma solidity ^0.8.18 .0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this solidity version naming convention ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had it modified due to this linting rule:
https://protofire.github.io/solhint/docs/rules/security/compiler-version.html
This is the stack overflow link:
https://stackoverflow.com/questions/72180057/error-compiler-version-0-8-0-does-not-satisfy-the-r-semver-requirement
But reverted the versioning to ^0.8.18 and removed the linting rule for semver.
|
||
// Create Quest. | ||
if (quest.rewardType == 1) { | ||
ICapxCommunityQuest(communityAddress).setQuestDetails( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this method is called, the QuestForger should transfer the necessary amount tokens into the community Forger.
|
||
function updateRewardType( | ||
RewardTypeDTO calldata _newRewards, | ||
bytes calldata _IOURewardsData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the need to encode the IOURewardsData when you are only using the corresponding QuestDTO as the only decoded input value ?
ICapxCommunityQuest(communityAddress).withdrawTokens(tokens); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function missing to withdrawETH & WithdrawTokens from CapxCommunityQuestForger.
contracts/CapxReputationScore.sol
Outdated
|
||
// Scores for different categories | ||
// 1. Social 2. Defi 3. Game | ||
struct ReputationScoreTypes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define all the structs , events in the Interface.
|
||
interface ICapxCommunityQuest { | ||
|
||
error AlreadyClaimed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unncessary error types from the contract definition.
201aac0
to
4287c4d
Compare
No description provided.