forked from lens-protocol/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleFeeCollectModule.sol
64 lines (60 loc) · 2.73 KB
/
SimpleFeeCollectModule.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
import {BaseFeeCollectModule} from './base/BaseFeeCollectModule.sol';
import {BaseFeeCollectModuleInitData, BaseProfilePublicationData} from './base/IBaseFeeCollectModule.sol';
/**
* @title SimpleFeeCollectModule
* @author Lens Protocol
*
* @notice This is a simple Lens CollectModule implementation, allowing customization of time to collect,
* number of collects and whether only followers can collect.
*
* You can build your own collect modules by inheriting from BaseFeeCollectModule and adding your
* functionality along with getPublicationData function.
*/
contract SimpleFeeCollectModule is BaseFeeCollectModule {
constructor(address hub, address moduleGlobals) BaseFeeCollectModule(hub, moduleGlobals) {}
/**
* @notice This collect module levies a fee on collects and supports referrals. Thus, we need to decode data.
* @param data The arbitrary data parameter, decoded into:
* amount: The collecting cost associated with this publication. 0 for free collect.
* collectLimit: The maximum number of collects for this publication. 0 for no limit.
* currency: The currency associated with this publication.
* referralFee: The referral fee associated with this publication.
* followerOnly: True if only followers of publisher may collect the post.
* endTimestamp: The end timestamp after which collecting is impossible. 0 for no expiry.
* recipient: Recipient of collect fees.
*
* @return An abi encoded bytes parameter, which is the same as the passed data parameter.
*/
function initializePublicationCollectModule(
uint256 profileId,
uint256 pubId,
bytes calldata data
) external virtual onlyHub returns (bytes memory) {
BaseFeeCollectModuleInitData memory baseInitData = abi.decode(
data,
(BaseFeeCollectModuleInitData)
);
_validateBaseInitData(baseInitData);
_storeBasePublicationCollectParameters(profileId, pubId, baseInitData);
return data;
}
/**
* @notice Returns the publication data for a given publication, or an empty struct if that publication was not
* initialized with this module.
*
* @param profileId The token ID of the profile mapped to the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return The BaseProfilePublicationData struct mapped to that publication.
*/
function getPublicationData(uint256 profileId, uint256 pubId)
external
view
virtual
returns (BaseProfilePublicationData memory)
{
return getBasePublicationData(profileId, pubId);
}
}