mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-15 00:48:12 -05:00
feat: Updated collect modules to match new interface and functionality.
This commit is contained in:
@@ -61,6 +61,7 @@ contract FeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICollect
|
||||
*/
|
||||
function initializePublicationCollectModule(
|
||||
uint256 profileId,
|
||||
address,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
) external override onlyHub returns (bytes memory) {
|
||||
@@ -95,6 +96,7 @@ contract FeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICollect
|
||||
function processCollect(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -102,9 +104,9 @@ contract FeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICollect
|
||||
if (_dataByPublicationByProfile[profileId][pubId].followerOnly)
|
||||
_checkFollowValidity(profileId, collector);
|
||||
if (referrerProfileId == profileId) {
|
||||
_processCollect(collector, profileId, pubId, data);
|
||||
_processCollect(executor, profileId, pubId, data);
|
||||
} else {
|
||||
_processCollectWithReferral(referrerProfileId, collector, profileId, pubId, data);
|
||||
_processCollectWithReferral(referrerProfileId, executor, profileId, pubId, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +128,7 @@ contract FeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICollect
|
||||
}
|
||||
|
||||
function _processCollect(
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -140,14 +142,14 @@ contract FeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICollect
|
||||
uint256 treasuryAmount = (amount * treasuryFee) / BPS_MAX;
|
||||
uint256 adjustedAmount = amount - treasuryAmount;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
|
||||
function _processCollectWithReferral(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -177,12 +179,12 @@ contract FeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICollect
|
||||
|
||||
address referralRecipient = IERC721(HUB).ownerOf(referrerProfileId);
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, referralRecipient, referralAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, referralRecipient, referralAmount);
|
||||
}
|
||||
address recipient = _dataByPublicationByProfile[profileId][pubId].recipient;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ contract FreeCollectModule is FollowValidationModuleBase, ICollectModule {
|
||||
*/
|
||||
function initializePublicationCollectModule(
|
||||
uint256 profileId,
|
||||
address,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
) external override onlyHub returns (bytes memory) {
|
||||
@@ -37,11 +38,12 @@ contract FreeCollectModule is FollowValidationModuleBase, ICollectModule {
|
||||
* 1. Ensuring the collector is a follower, if needed
|
||||
*/
|
||||
function processCollect(
|
||||
uint256 referrerProfileId,
|
||||
uint256,
|
||||
address collector,
|
||||
address,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
bytes calldata
|
||||
) external view override {
|
||||
if (_followerOnlyByPublicationByProfile[profileId][pubId])
|
||||
_checkFollowValidity(profileId, collector);
|
||||
|
||||
@@ -66,6 +66,7 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I
|
||||
*/
|
||||
function initializePublicationCollectModule(
|
||||
uint256 profileId,
|
||||
address,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
) external override onlyHub returns (bytes memory) {
|
||||
@@ -104,6 +105,7 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I
|
||||
function processCollect(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -111,16 +113,18 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I
|
||||
if (_dataByPublicationByProfile[profileId][pubId].followerOnly)
|
||||
_checkFollowValidity(profileId, collector);
|
||||
if (
|
||||
_dataByPublicationByProfile[profileId][pubId].currentCollects >=
|
||||
_dataByPublicationByProfile[profileId][pubId].currentCollects ==
|
||||
_dataByPublicationByProfile[profileId][pubId].collectLimit
|
||||
) {
|
||||
revert Errors.MintLimitExceeded();
|
||||
} else {
|
||||
++_dataByPublicationByProfile[profileId][pubId].currentCollects;
|
||||
unchecked {
|
||||
++_dataByPublicationByProfile[profileId][pubId].currentCollects;
|
||||
}
|
||||
if (referrerProfileId == profileId) {
|
||||
_processCollect(collector, profileId, pubId, data);
|
||||
_processCollect(executor, profileId, pubId, data);
|
||||
} else {
|
||||
_processCollectWithReferral(referrerProfileId, collector, profileId, pubId, data);
|
||||
_processCollectWithReferral(referrerProfileId, executor, profileId, pubId, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +147,7 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I
|
||||
}
|
||||
|
||||
function _processCollect(
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -157,14 +161,14 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I
|
||||
uint256 treasuryAmount = (amount * treasuryFee) / BPS_MAX;
|
||||
uint256 adjustedAmount = amount - treasuryAmount;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
|
||||
function _processCollectWithReferral(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -194,12 +198,12 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I
|
||||
|
||||
address referralRecipient = IERC721(HUB).ownerOf(referrerProfileId);
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, referralRecipient, referralAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, referralRecipient, referralAmount);
|
||||
}
|
||||
address recipient = _dataByPublicationByProfile[profileId][pubId].recipient;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa
|
||||
*/
|
||||
function initializePublicationCollectModule(
|
||||
uint256 profileId,
|
||||
address,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
) external override onlyHub returns (bytes memory) {
|
||||
@@ -124,6 +125,7 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa
|
||||
function processCollect(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -141,9 +143,9 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa
|
||||
} else {
|
||||
++_dataByPublicationByProfile[profileId][pubId].currentCollects;
|
||||
if (referrerProfileId == profileId) {
|
||||
_processCollect(collector, profileId, pubId, data);
|
||||
_processCollect(executor, profileId, pubId, data);
|
||||
} else {
|
||||
_processCollectWithReferral(referrerProfileId, collector, profileId, pubId, data);
|
||||
_processCollectWithReferral(referrerProfileId, executor, profileId, pubId, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +168,7 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa
|
||||
}
|
||||
|
||||
function _processCollect(
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -180,14 +182,14 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa
|
||||
uint256 treasuryAmount = (amount * treasuryFee) / BPS_MAX;
|
||||
uint256 adjustedAmount = amount - treasuryAmount;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
|
||||
function _processCollectWithReferral(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -217,12 +219,12 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa
|
||||
|
||||
address referralRecipient = IERC721(HUB).ownerOf(referrerProfileId);
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, referralRecipient, referralAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, referralRecipient, referralAmount);
|
||||
}
|
||||
address recipient = _dataByPublicationByProfile[profileId][pubId].recipient;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@ contract RevertCollectModule is ICollectModule {
|
||||
* @dev There is nothing needed at initialization.
|
||||
*/
|
||||
function initializePublicationCollectModule(
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
uint256,
|
||||
address,
|
||||
uint256,
|
||||
bytes calldata
|
||||
) external pure override returns (bytes memory) {
|
||||
return new bytes(0);
|
||||
}
|
||||
@@ -30,11 +31,12 @@ contract RevertCollectModule is ICollectModule {
|
||||
* 1. Always reverting
|
||||
*/
|
||||
function processCollect(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
uint256,
|
||||
address,
|
||||
address,
|
||||
uint256,
|
||||
uint256,
|
||||
bytes calldata
|
||||
) external pure override {
|
||||
revert Errors.CollectNotAllowed();
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ contract TimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICo
|
||||
*/
|
||||
function initializePublicationCollectModule(
|
||||
uint256 profileId,
|
||||
address,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
) external override onlyHub returns (bytes memory) {
|
||||
@@ -110,6 +111,7 @@ contract TimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICo
|
||||
function processCollect(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -120,9 +122,9 @@ contract TimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICo
|
||||
if (block.timestamp > endTimestamp) revert Errors.CollectExpired();
|
||||
|
||||
if (referrerProfileId == profileId) {
|
||||
_processCollect(collector, profileId, pubId, data);
|
||||
_processCollect(executor, profileId, pubId, data);
|
||||
} else {
|
||||
_processCollectWithReferral(referrerProfileId, collector, profileId, pubId, data);
|
||||
_processCollectWithReferral(referrerProfileId, executor, profileId, pubId, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +146,7 @@ contract TimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICo
|
||||
}
|
||||
|
||||
function _processCollect(
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -158,14 +160,14 @@ contract TimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICo
|
||||
uint256 treasuryAmount = (amount * treasuryFee) / BPS_MAX;
|
||||
uint256 adjustedAmount = amount - treasuryAmount;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
|
||||
function _processCollectWithReferral(
|
||||
uint256 referrerProfileId,
|
||||
address collector,
|
||||
address executor,
|
||||
uint256 profileId,
|
||||
uint256 pubId,
|
||||
bytes calldata data
|
||||
@@ -195,12 +197,12 @@ contract TimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, ICo
|
||||
|
||||
address referralRecipient = IERC721(HUB).ownerOf(referrerProfileId);
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, referralRecipient, referralAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, referralRecipient, referralAmount);
|
||||
}
|
||||
address recipient = _dataByPublicationByProfile[profileId][pubId].recipient;
|
||||
|
||||
IERC20(currency).safeTransferFrom(collector, recipient, adjustedAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, recipient, adjustedAmount);
|
||||
if (treasuryAmount > 0)
|
||||
IERC20(currency).safeTransferFrom(collector, treasury, treasuryAmount);
|
||||
IERC20(currency).safeTransferFrom(executor, treasury, treasuryAmount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user