From e6caa36cfbe8652f03ff38de0e339e321429faa8 Mon Sep 17 00:00:00 2001 From: Peter Michael Date: Thu, 7 Apr 2022 15:27:26 -0400 Subject: [PATCH] feat: Initial basic implementation of current collect tracking events in limited collect modules. --- .../modules/collect/LimitedFeeCollectModule.sol | 8 +++++++- .../collect/LimitedTimedFeeCollectModule.sol | 8 +++++++- contracts/libraries/Events.sol | 13 +++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/contracts/core/modules/collect/LimitedFeeCollectModule.sol b/contracts/core/modules/collect/LimitedFeeCollectModule.sol index a18bead..38edb47 100644 --- a/contracts/core/modules/collect/LimitedFeeCollectModule.sol +++ b/contracts/core/modules/collect/LimitedFeeCollectModule.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.10; import {ICollectModule} from '../../../interfaces/ICollectModule.sol'; import {Errors} from '../../../libraries/Errors.sol'; +import {Events} from '../../../libraries/Events.sol'; import {FeeModuleBase} from '../FeeModuleBase.sol'; import {ModuleBase} from '../ModuleBase.sol'; import {FollowValidationModuleBase} from '../FollowValidationModuleBase.sol'; @@ -116,12 +117,17 @@ contract LimitedFeeCollectModule is FeeModuleBase, FollowValidationModuleBase, I ) { revert Errors.MintLimitExceeded(); } else { - ++_dataByPublicationByProfile[profileId][pubId].currentCollects; if (referrerProfileId == profileId) { _processCollect(collector, profileId, pubId, data); } else { _processCollectWithReferral(referrerProfileId, collector, profileId, pubId, data); } + // We can increment the currentCollects here since there are no external calls in the above processing functions + emit Events.LimitedPubCollected( + profileId, + pubId, + ++_dataByPublicationByProfile[profileId][pubId].currentCollects + ); } } diff --git a/contracts/core/modules/collect/LimitedTimedFeeCollectModule.sol b/contracts/core/modules/collect/LimitedTimedFeeCollectModule.sol index b1e2ac8..1e64286 100644 --- a/contracts/core/modules/collect/LimitedTimedFeeCollectModule.sol +++ b/contracts/core/modules/collect/LimitedTimedFeeCollectModule.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.10; import {ICollectModule} from '../../../interfaces/ICollectModule.sol'; import {Errors} from '../../../libraries/Errors.sol'; +import {Events} from '../../../libraries/Events.sol'; import {FeeModuleBase} from '../FeeModuleBase.sol'; import {ModuleBase} from '../ModuleBase.sol'; import {FollowValidationModuleBase} from '../FollowValidationModuleBase.sol'; @@ -139,12 +140,17 @@ contract LimitedTimedFeeCollectModule is FeeModuleBase, FollowValidationModuleBa ) { revert Errors.MintLimitExceeded(); } else { - ++_dataByPublicationByProfile[profileId][pubId].currentCollects; if (referrerProfileId == profileId) { _processCollect(collector, profileId, pubId, data); } else { _processCollectWithReferral(referrerProfileId, collector, profileId, pubId, data); } + // We can increment the currentCollects here since there are no external calls in the above processing functions + emit Events.LimitedPubCollected( + profileId, + pubId, + ++_dataByPublicationByProfile[profileId][pubId].currentCollects + ); } } diff --git a/contracts/libraries/Events.sol b/contracts/libraries/Events.sol index 234ee39..29c4052 100644 --- a/contracts/libraries/Events.sol +++ b/contracts/libraries/Events.sol @@ -476,6 +476,19 @@ library Events { uint256 timestamp ); + /** + * @notice Emitted when a collect is successfully processed in a limited collect module. + * + * @param profileId The profile ID of the collected publication. + * @param pubId The publication ID of the collected publication. + * @param remainingCollects The remaining collects for the collected publication. + */ + event LimitedPubCollected( + uint256 indexed profileId, + uint256 indexed pubId, + uint256 remainingCollects + ); + /** * @dev Emitted when the user wants to enable or disable follows in the `LensPeripheryDataProvider`. *