From 60628c13f5d5fcbf6f40430718e1c3d2b93bab98 Mon Sep 17 00:00:00 2001 From: Quazia Date: Tue, 19 Mar 2024 20:21:40 -0400 Subject: [PATCH] Feat(QuestFactory): overload claimCompressed with a ref function --- contracts/QuestFactory.sol | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contracts/QuestFactory.sol b/contracts/QuestFactory.sol index a6b4c4b6..b1e91edf 100644 --- a/contracts/QuestFactory.sol +++ b/contracts/QuestFactory.sol @@ -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_); ( @@ -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);