Skip to content

Commit

Permalink
add new QuestClaimedData event
Browse files Browse the repository at this point in the history
  • Loading branch information
waynehoover committed Oct 17, 2023
1 parent ebb475a commit dba5fc9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
40 changes: 36 additions & 4 deletions contracts/QuestFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto
if (claimData_.ref != address(0)) {
hashc = abi.encodePacked(hashc, claimData_.ref);
}
if (bytes(claimData_.extraData).length > 0){
hashc = abi.encodePacked(hashc, claimData_.extraData);
}

bytes32 encodedHash = keccak256(hashc);

Expand Down Expand Up @@ -301,6 +304,19 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto
CLAIM
//////////////////////////////////////////////////////////////*/

/// @dev universal claim function for all quest types, with extraData
/// @param questId_ The id of the quest
/// @param hash_ The hash of the message
/// @param signature_ The signature of the hash
/// @param ref_ The referral address
/// @param extraData_ The extra data for the quest
function claim(string memory questId_, bytes32 hash_, bytes memory signature_, address ref_, string memory extraData_) external payable {
if (quests[questId_].questType.eq("erc1155")) {
claim1155RewardsRef(ClaimData(questId_, hash_, signature_, ref_, 0, extraData_));
} else { // erc20, erc20Stream
claimRewardsRef(ClaimData(questId_, hash_, signature_, ref_, 0, extraData_));
}
}

/// @dev universal claim function for all quest types
/// @param questId_ The id of the quest
Expand All @@ -309,9 +325,9 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto
/// @param ref_ The referral address
function claim(string memory questId_, bytes32 hash_, bytes memory signature_, address ref_) external payable {
if (quests[questId_].questType.eq("erc1155")) {
claim1155RewardsRef(ClaimData(questId_, hash_, signature_, ref_, 0));
claim1155RewardsRef(ClaimData(questId_, hash_, signature_, ref_, 0, ""));
} else { // erc20, erc20Stream
claimRewardsRef(ClaimData(questId_, hash_, signature_, ref_, 0));
claimRewardsRef(ClaimData(questId_, hash_, signature_, ref_, 0, ""));
}
}

Expand All @@ -320,15 +336,15 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto
/// @param hash_ The hash of the message
/// @param signature_ The signature of the hash
function claim1155Rewards(string memory questId_, bytes32 hash_, bytes memory signature_) external payable {
claim1155RewardsRef(ClaimData(questId_, hash_, signature_, address(0), 0));
claim1155RewardsRef(ClaimData(questId_, hash_, signature_, address(0), 0, ""));
}

/// @dev claim rewards for a quest
/// @param questId_ The id of the quest
/// @param hash_ The hash of the message
/// @param signature_ The signature of the hash
function claimRewards(string memory questId_, bytes32 hash_, bytes memory signature_) external payable {
claimRewardsRef(ClaimData(questId_, hash_, signature_, address(0), 0));
claimRewardsRef(ClaimData(questId_, hash_, signature_, address(0), 0, ""));
}

/*//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -541,6 +557,14 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto

if (mintFee > 0) processMintFee(claimData_.ref, currentQuest.questCreator, claimData_.questId);

emit QuestClaimedData(
msg.sender,
currentQuest.questAddress,
currentQuest.questType,
claimData_.questId,
claimData_.extraData
);

emit Quest1155Claimed(
msg.sender, currentQuest.questAddress, claimData_.questId, questContract_.rewardToken(), questContract_.tokenId()
);
Expand Down Expand Up @@ -578,6 +602,14 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto

if (mintFee > 0) processMintFee(claimData_.ref, currentQuest.questCreator, claimData_.questId);

emit QuestClaimedData(
msg.sender,
currentQuest.questAddress,
currentQuest.questType,
claimData_.questId,
claimData_.extraData
);

emit QuestClaimed(
msg.sender,
currentQuest.questAddress,
Expand Down
8 changes: 8 additions & 0 deletions contracts/interfaces/IQuestFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface IQuestFactory {
bytes signature;
address ref;
uint256 amount;
string extraData;
}

struct ERC20QuestData {
Expand All @@ -84,6 +85,13 @@ interface IQuestFactory {
event NftQuestFeeListSet(address[] addresses, uint256[] fees);
event NftQuestFeeSet(uint256 nftQuestFee);

event QuestClaimedData(
address indexed recipient,
address indexed questAddress,
string questType,
string questId,
string extraData
);
event Quest1155Claimed(
address indexed recipient, address indexed questAddress, string questId, address rewardToken, uint256 tokenId
);
Expand Down

0 comments on commit dba5fc9

Please sign in to comment.