Skip to content

Commit

Permalink
Feat(QuestFactory): overload claimCompressed with a ref function
Browse files Browse the repository at this point in the history
  • Loading branch information
Quazia committed Mar 20, 2024
1 parent d6facaf commit 60628c1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion contracts/QuestFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto
/// @dev Claim rewards for a quest
/// @param compressedData_ The claim data in abi encoded bytes, compressed with cdCompress from solady LibZip
function claimCompressed(bytes calldata compressedData_) external payable {
_claimCompressed(compressedData_, msg.sender);
}

function claimCompressedRef(bytes calldata compressedData_, address claimer) external payable {
_claimCompressed(compressedData_, claimer);
}

/// @dev Claim rewards for a quest
/// @param compressedData_ The claim data in abi encoded bytes, compressed with cdCompress from solady LibZip
/// @param claimer The address of the claimer - where rewards are sent
function _claimCompressed(bytes calldata compressedData_, address claimer) internal {
bytes memory data_ = LibZip.cdDecompress(compressedData_);

(
Expand All @@ -346,7 +357,7 @@ contract QuestFactory is Initializable, LegacyStorage, OwnableRoles, IQuestFacto
Quest storage quest_ = quests[questIdString_];

string memory jsonData_ = _buildJsonString(txHash_, txHashChainId_, quest_.actionType);
bytes memory claimData_ = abi.encode(msg.sender, ref_, questIdString_, jsonData_);
bytes memory claimData_ = abi.encode(claimer, ref_, questIdString_, jsonData_);

// Since `vs_` includes `s` and the bit for `v`, we can extract `s` by masking out the `v` bit.
bytes32 s = vs_ & bytes32(0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
Expand Down

0 comments on commit 60628c1

Please sign in to comment.