lens-modules 1.2.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -2
- package/README.md +35 -132
- package/contracts/actions/account/TippingAccountAction.sol +41 -0
- package/contracts/actions/account/base/BaseAccountAction.sol +61 -0
- package/contracts/actions/account/base/OwnableMetadataBasedAccountAction.sol +24 -0
- package/contracts/actions/base/BaseAction.sol +35 -0
- package/contracts/actions/post/TippingPostAction.sol +43 -0
- package/contracts/actions/post/base/BasePostAction.sol +64 -0
- package/contracts/actions/post/base/OwnableMetadataBasedPostAction.sol +24 -0
- package/contracts/actions/post/collect/IERC7572.sol +16 -0
- package/contracts/actions/post/collect/ISimpleCollectAction.sol +33 -0
- package/contracts/actions/post/collect/LensCollectedPost.sol +72 -0
- package/contracts/actions/post/collect/SimpleCollectAction.sol +302 -0
- package/contracts/core/access/AccessControlled.sol +76 -0
- package/contracts/core/access/Ownable.sol +42 -0
- package/contracts/core/access/RoleBasedAccessControl.sol +211 -0
- package/contracts/core/base/BaseSource.sol +99 -0
- package/contracts/core/base/ExtraStorageBased.sol +129 -0
- package/contracts/core/base/LensERC721.sol +458 -0
- package/contracts/core/base/MetadataBased.sol +51 -0
- package/contracts/core/base/RuleBasedPrimitive.sol +265 -0
- package/contracts/core/base/SourceStampBased.sol +64 -0
- package/contracts/core/interfaces/IAccessControl.sol +28 -0
- package/contracts/core/interfaces/IERC4906Events.sol +15 -0
- package/contracts/core/interfaces/IERC721Namespace.sol +16 -0
- package/contracts/core/interfaces/IFeed.sol +181 -0
- package/contracts/core/interfaces/IFeedRule.sol +40 -0
- package/contracts/core/interfaces/IFollowRule.sol +18 -0
- package/contracts/core/interfaces/IGraph.sol +117 -0
- package/contracts/core/interfaces/IGraphRule.sol +34 -0
- package/contracts/core/interfaces/IGroup.sol +110 -0
- package/contracts/core/interfaces/IGroupRule.sol +39 -0
- package/contracts/core/interfaces/ILock.sol +10 -0
- package/contracts/core/interfaces/IMetadataBased.sol +8 -0
- package/contracts/core/interfaces/INamespace.sol +125 -0
- package/contracts/core/interfaces/INamespaceRule.sol +44 -0
- package/contracts/core/interfaces/IOwnable.sol +9 -0
- package/contracts/core/interfaces/IPostRule.sol +28 -0
- package/contracts/core/interfaces/IRoleBasedAccessControl.sol +38 -0
- package/contracts/core/interfaces/ISource.sol +11 -0
- package/contracts/core/interfaces/ITokenURIProvider.sol +7 -0
- package/contracts/core/interfaces/IVersionedBeacon.sol +19 -0
- package/contracts/core/libraries/AccessControlLib.sol +50 -0
- package/contracts/core/libraries/CallLib.sol +54 -0
- package/contracts/core/libraries/EIP712EncodingLib.sol +144 -0
- package/contracts/core/libraries/KeyValueStorageLib.sol +34 -0
- package/contracts/core/libraries/RulesLib.sol +156 -0
- package/contracts/core/primitives/feed/Feed.sol +295 -0
- package/contracts/core/primitives/feed/FeedCore.sol +95 -0
- package/contracts/core/primitives/feed/RuleBasedFeed.sol +483 -0
- package/contracts/core/primitives/graph/Graph.sol +173 -0
- package/contracts/core/primitives/graph/GraphCore.sol +62 -0
- package/contracts/core/primitives/graph/RuleBasedGraph.sol +398 -0
- package/contracts/core/primitives/group/Group.sol +191 -0
- package/contracts/core/primitives/group/GroupCore.sol +53 -0
- package/contracts/core/primitives/group/RuleBasedGroup.sol +295 -0
- package/contracts/core/primitives/namespace/LensUsernameTokenURIProvider.sol +319 -0
- package/contracts/core/primitives/namespace/Namespace.sol +348 -0
- package/contracts/core/primitives/namespace/NamespaceCore.sol +54 -0
- package/contracts/core/primitives/namespace/RuleBasedNamespace.sol +320 -0
- package/contracts/core/types/Errors.sol +48 -0
- package/contracts/core/types/Events.sol +9 -0
- package/contracts/core/types/Types.sol +46 -0
- package/contracts/core/upgradeability/Beacon.sol +48 -0
- package/contracts/core/upgradeability/BeaconProxy.sol +206 -0
- package/contracts/core/upgradeability/Initializable.sol +32 -0
- package/contracts/core/upgradeability/LegacyBeaconProxy.sol +186 -0
- package/contracts/core/upgradeability/Lock.sol +42 -0
- package/contracts/core/upgradeability/ProxyAdmin.sol +42 -0
- package/contracts/extensions/access/OwnerAdminOnlyAccessControl.sol +59 -0
- package/contracts/extensions/access/PermissionlessAccessControl.sol +30 -0
- package/contracts/extensions/account/Account.sol +262 -0
- package/contracts/extensions/account/IAccount.sol +67 -0
- package/contracts/extensions/actions/ActionHub.sol +255 -0
- package/contracts/extensions/factories/AccessControlFactory.sol +34 -0
- package/contracts/extensions/factories/AccountFactory.sol +51 -0
- package/contracts/extensions/factories/AppFactory.sol +36 -0
- package/contracts/extensions/factories/FeedFactory.sol +33 -0
- package/contracts/extensions/factories/GraphFactory.sol +33 -0
- package/contracts/extensions/factories/GroupFactory.sol +38 -0
- package/contracts/extensions/factories/LensFactory.sol +465 -0
- package/contracts/extensions/factories/NamespaceFactory.sol +40 -0
- package/contracts/extensions/factories/PrimitiveFactory.sol +18 -0
- package/contracts/extensions/primitives/app/App.sol +405 -0
- package/contracts/extensions/primitives/app/AppCore.sol +194 -0
- package/contracts/extensions/primitives/app/IApp.sol +107 -0
- package/contracts/migration/WhitelistedAddresses.sol +165 -0
- package/contracts/migration/WhitelistedMulticall.sol +273 -0
- package/contracts/migration/factories/MigrationLensFactory.sol +150 -0
- package/contracts/migration/primitives/MigrationAccount.sol +94 -0
- package/contracts/migration/primitives/MigrationFeed.sol +173 -0
- package/contracts/migration/primitives/MigrationGraph.sol +80 -0
- package/contracts/migration/primitives/MigrationNamespace.sol +215 -0
- package/contracts/rules/AccountBlockingRule.sol +129 -0
- package/contracts/rules/base/OwnableMetadataBasedRule.sol +23 -0
- package/contracts/rules/base/RestrictedSignersRule.sol +171 -0
- package/contracts/rules/base/SimplePaymentRule.sol +51 -0
- package/contracts/rules/base/TokenGatedRule.sol +63 -0
- package/contracts/rules/base/TrustBasedRule.sol +36 -0
- package/contracts/rules/feed/GroupGatedFeedRule.sol +69 -0
- package/contracts/rules/feed/RestrictedSignersFeedRule.sol +79 -0
- package/contracts/rules/feed/SimplePaymentFeedRule.sol +122 -0
- package/contracts/rules/feed/TokenGatedFeedRule.sol +105 -0
- package/contracts/rules/follow/SimplePaymentFollowRule.sol +48 -0
- package/contracts/rules/follow/TokenGatedFollowRule.sol +44 -0
- package/contracts/rules/graph/GroupGatedGraphRule.sol +105 -0
- package/contracts/rules/graph/RestrictedSignersGraphRule.sol +66 -0
- package/contracts/rules/graph/TokenGatedGraphRule.sol +106 -0
- package/contracts/rules/group/BanMemberGroupRule.sol +128 -0
- package/contracts/rules/group/MembershipApprovalGroupRule.sol +114 -0
- package/contracts/rules/group/SimplePaymentGroupRule.sol +121 -0
- package/contracts/rules/group/TokenGatedGroupRule.sol +112 -0
- package/contracts/rules/namespace/SimplePaymentNamespaceRule.sol +140 -0
- package/contracts/rules/namespace/TokenGatedNamespaceRule.sol +120 -0
- package/contracts/rules/namespace/UsernameCharsetNamespaceRule.sol +203 -0
- package/contracts/rules/namespace/UsernameLengthNamespaceRule.sol +132 -0
- package/contracts/rules/namespace/UsernamePricePerLengthNamespaceRule.sol +149 -0
- package/contracts/rules/namespace/UsernameReservedNamespaceRule.sol +131 -0
- package/contracts/rules/namespace/UsernameSimpleCharsetNamespaceRule.sol +83 -0
- package/contracts/rules/post/FollowersOnlyPostRule.sol +112 -0
- package/dist/abis.d.ts +38900 -0
- package/dist/abis.js +1 -0
- package/dist/deployments.d.ts +758 -0
- package/dist/deployments.js +1 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -21
- package/package.json +43 -8
- package/contracts/FollowNFT.sol +0 -507
- package/contracts/LensHub.sol +0 -523
- package/contracts/base/ERC2981CollectionRoyalties.sol +0 -75
- package/contracts/base/HubRestricted.sol +0 -27
- package/contracts/base/LensBaseERC721.sol +0 -509
- package/contracts/base/LensGovernable.sol +0 -114
- package/contracts/base/LensHubEventHooks.sol +0 -23
- package/contracts/base/LensHubStorage.sol +0 -69
- package/contracts/base/LensImplGetters.sol +0 -25
- package/contracts/base/LensProfiles.sol +0 -209
- package/contracts/base/LensVersion.sol +0 -36
- package/contracts/base/upgradeability/FollowNFTProxy.sol +0 -21
- package/contracts/base/upgradeability/VersionedInitializable.sol +0 -50
- package/contracts/interfaces/ICollectNFT.sol +0 -40
- package/contracts/interfaces/IERC721Burnable.sol +0 -19
- package/contracts/interfaces/IERC721MetaTx.sol +0 -27
- package/contracts/interfaces/IERC721Timestamped.sol +0 -50
- package/contracts/interfaces/IFollowModule.sol +0 -55
- package/contracts/interfaces/IFollowNFT.sol +0 -209
- package/contracts/interfaces/IFollowTokenURI.sol +0 -11
- package/contracts/interfaces/IHandleTokenURI.sol +0 -11
- package/contracts/interfaces/ILensERC721.sol +0 -11
- package/contracts/interfaces/ILensGovernable.sol +0 -141
- package/contracts/interfaces/ILensHandles.sol +0 -106
- package/contracts/interfaces/ILensHub.sol +0 -19
- package/contracts/interfaces/ILensHubEventHooks.sol +0 -26
- package/contracts/interfaces/ILensHubInitializable.sol +0 -28
- package/contracts/interfaces/ILensImplGetters.sol +0 -26
- package/contracts/interfaces/ILensProfiles.sol +0 -37
- package/contracts/interfaces/ILensProtocol.sol +0 -452
- package/contracts/interfaces/ILensVersion.sol +0 -31
- package/contracts/interfaces/IModuleRegistry.sol +0 -32
- package/contracts/interfaces/IProfileTokenURI.sol +0 -7
- package/contracts/interfaces/IPublicationActionModule.sol +0 -53
- package/contracts/interfaces/IReferenceModule.sol +0 -72
- package/contracts/interfaces/ITokenHandleRegistry.sol +0 -90
- package/contracts/libraries/ActionLib.sol +0 -69
- package/contracts/libraries/FollowLib.sol +0 -175
- package/contracts/libraries/GovernanceLib.sol +0 -111
- package/contracts/libraries/MetaTxLib.sol +0 -415
- package/contracts/libraries/ProfileLib.sol +0 -284
- package/contracts/libraries/PublicationLib.sol +0 -497
- package/contracts/libraries/StorageLib.sol +0 -256
- package/contracts/libraries/ValidationLib.sol +0 -206
- package/contracts/libraries/constants/Errors.sol +0 -51
- package/contracts/libraries/constants/Events.sol +0 -395
- package/contracts/libraries/constants/Typehash.sol +0 -32
- package/contracts/libraries/constants/Types.sol +0 -394
- package/contracts/libraries/svgs/Follow/FollowSVG.sol +0 -16
- package/contracts/libraries/svgs/Handle/GintoNordFontSVG.sol +0 -9
- package/contracts/libraries/svgs/Handle/HandleSVG.sol +0 -255
- package/contracts/libraries/svgs/Profile/Body/BodyHoodie.sol +0 -21
- package/contracts/libraries/svgs/Profile/Body/BodyJacket.sol +0 -21
- package/contracts/libraries/svgs/Profile/Body/BodyTShirt.sol +0 -21
- package/contracts/libraries/svgs/Profile/Body/BodyTanktop.sol +0 -21
- package/contracts/libraries/svgs/Profile/Body.sol +0 -119
- package/contracts/libraries/svgs/Profile/Face.sol +0 -145
- package/contracts/libraries/svgs/Profile/Hands.sol +0 -121
- package/contracts/libraries/svgs/Profile/Head.sol +0 -33
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearBeanie.sol +0 -71
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearCrown.sol +0 -67
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearFloral.sol +0 -67
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearGlasses.sol +0 -67
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearHat.sol +0 -79
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearIcecream.sol +0 -55
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearLeafs.sol +0 -67
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearMushroom.sol +0 -83
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearNightcap.sol +0 -67
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearPartyhat.sol +0 -69
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearPlants.sol +0 -71
- package/contracts/libraries/svgs/Profile/Headwear/HeadwearSparkles.sol +0 -55
- package/contracts/libraries/svgs/Profile/Headwear.sol +0 -155
- package/contracts/libraries/svgs/Profile/Helpers.sol +0 -83
- package/contracts/libraries/svgs/Profile/Legs.sol +0 -37
- package/contracts/libraries/svgs/Profile/Logo.sol +0 -167
- package/contracts/libraries/svgs/Profile/ProfileSVG.sol +0 -384
- package/contracts/libraries/svgs/Profile/Shoes.sol +0 -37
- package/contracts/libraries/svgs/Profile/SimpleProfileSVG.sol +0 -8
- package/contracts/misc/CreditsFaucet.sol +0 -25
- package/contracts/misc/ImmutableOwnable.sol +0 -30
- package/contracts/misc/LensHubInitializable.sol +0 -48
- package/contracts/misc/ModuleRegistry.sol +0 -140
- package/contracts/misc/PermissionlessCreator.sol +0 -353
- package/contracts/misc/ProfileCreationProxy.sol +0 -66
- package/contracts/misc/PublicActProxy.sol +0 -97
- package/contracts/misc/PublicActProxy_MetaTx.sol +0 -156
- package/contracts/misc/access/LitAccessControl.sol +0 -125
- package/contracts/misc/token-uris/FollowTokenURI.sol +0 -47
- package/contracts/misc/token-uris/HandleTokenURI.sol +0 -42
- package/contracts/misc/token-uris/ProfileTokenURI.sol +0 -57
- package/contracts/misc/token-uris/SimpleProfileTokenURI.sol +0 -57
- package/contracts/modules/ActionRestricted.sol +0 -27
- package/contracts/modules/FeeModuleBase.sol +0 -43
- package/contracts/modules/LensModule.sol +0 -11
- package/contracts/modules/LensModuleMetadata.sol +0 -17
- package/contracts/modules/LensModuleMetadataInitializable.sol +0 -18
- package/contracts/modules/act/collect/CollectNFT.sol +0 -125
- package/contracts/modules/act/collect/CollectPublicationAction.sol +0 -237
- package/contracts/modules/act/collect/MultirecipientFeeCollectModule.sol +0 -224
- package/contracts/modules/act/collect/SimpleFeeCollectModule.sol +0 -79
- package/contracts/modules/act/collect/base/BaseFeeCollectModule.sol +0 -298
- package/contracts/modules/base/LensModuleRegistrant.sol +0 -49
- package/contracts/modules/constants/Errors.sol +0 -16
- package/contracts/modules/follow/FeeFollowModule.sol +0 -131
- package/contracts/modules/follow/RevertFollowModule.sol +0 -48
- package/contracts/modules/interfaces/IBaseFeeCollectModule.sol +0 -75
- package/contracts/modules/interfaces/ICollectModule.sol +0 -50
- package/contracts/modules/interfaces/ILensModule.sol +0 -18
- package/contracts/modules/interfaces/IModuleRegistrant.sol +0 -22
- package/contracts/modules/interfaces/IWMATIC.sol +0 -11
- package/contracts/modules/libraries/FollowValidationLib.sol +0 -32
- package/contracts/modules/libraries/TokenGateLib.sol +0 -76
- package/contracts/modules/libraries/constants/ModuleTypes.sol +0 -25
- package/contracts/modules/reference/DegreesOfSeparationReferenceModule.sol +0 -314
- package/contracts/modules/reference/FollowerOnlyReferenceModule.sol +0 -96
- package/contracts/modules/reference/TokenGatedReferenceModule.sol +0 -167
- package/contracts/namespaces/LensHandles.sol +0 -326
- package/contracts/namespaces/TokenHandleRegistry.sol +0 -320
- package/contracts/namespaces/constants/Errors.sol +0 -27
- package/contracts/namespaces/constants/Events.sol +0 -63
- package/contracts/namespaces/constants/Typehash.sol +0 -12
- package/contracts/namespaces/constants/Types.sol +0 -21
- package/dist/deployments/follow-modules.d.ts +0 -12
- package/dist/deployments/follow-modules.js +0 -15
- package/dist/deployments/open-actions.d.ts +0 -42
- package/dist/deployments/open-actions.js +0 -45
- package/dist/deployments/reference-modules.d.ts +0 -17
- package/dist/deployments/reference-modules.js +0 -20
- package/dist/lens-contracts.d.ts +0 -115
- package/dist/lens-contracts.js +0 -140
- package/dist/lenshub-abi.d.ts +0 -2573
- package/dist/lenshub-abi.js +0 -1445
- package/dist/verified-modules/follow-modules.d.ts +0 -12
- package/dist/verified-modules/follow-modules.js +0 -15
- package/dist/verified-modules/open-actions.d.ts +0 -42
- package/dist/verified-modules/open-actions.js +0 -45
- package/dist/verified-modules/reference-modules.d.ts +0 -17
- package/dist/verified-modules/reference-modules.js +0 -20
package/LICENSE
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2023 Avara Labs Ltd
|
|
4
|
-
|
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
7
5
|
in the Software without restriction, including without limitation the rights
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# Lens
|
|
1
|
+
# Lens Modules
|
|
2
2
|
|
|
3
|
-
This repository contains the
|
|
3
|
+
This repository contains the contracts from the core Lens Protocol repo ([link](https://github.com/lens-protocol/lens-v3/tree/latest-mainnet)) as a standalone library, useful in Hardhat and Foundry projects.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It includes the Solidity source code of the contracts, their ABIs, and deployment addresses for Lens Chain mainnet and testnet.
|
|
6
|
+
|
|
7
|
+
The files are kept in sync with the `latest-mainnet` tag.
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -12,138 +14,39 @@ npm i lens-modules
|
|
|
12
14
|
|
|
13
15
|
## Usage
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
#### Contracts
|
|
18
|
+
|
|
19
|
+
Import Lens contracts you want to use in your Solidity project. The paths mirror the `lens-v3` repo structure. Eg:
|
|
16
20
|
|
|
17
21
|
```solidity
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
import {IPublicationActionModule} from "lens-modules/contracts/interfaces/IPublicationActionModule.sol";
|
|
22
|
-
import {Types} from "lens-modules/contracts/libraries/constants/Types.sol";
|
|
23
|
-
import {LensModuleMetadata} from "lens-modules/contracts/modules/LensModuleMetadata.sol";
|
|
24
|
-
|
|
25
|
-
contract OpenActionModule is
|
|
26
|
-
HubRestricted,
|
|
27
|
-
IPublicationActionModule,
|
|
28
|
-
LensModuleMetadata
|
|
29
|
-
{
|
|
30
|
-
constructor(
|
|
31
|
-
address owner,
|
|
32
|
-
address hub
|
|
33
|
-
)
|
|
34
|
-
Ownable(owner)
|
|
35
|
-
HubRestricted(hub)
|
|
36
|
-
LensModuleMetadata()
|
|
37
|
-
{
|
|
38
|
-
// ...
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function supportsInterface(
|
|
42
|
-
bytes4 interfaceID
|
|
43
|
-
) public pure virtual override returns (bool) {
|
|
44
|
-
return
|
|
45
|
-
interfaceID == type(IPublicationActionModule).interfaceId ||
|
|
46
|
-
super.supportsInterface(interfaceID);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function initializePublicationAction(
|
|
50
|
-
uint256 profileId,
|
|
51
|
-
uint256 pubId,
|
|
52
|
-
address /* transactionExecutor */,
|
|
53
|
-
bytes calldata data
|
|
54
|
-
) external override onlyHub returns (bytes memory) {
|
|
55
|
-
// ...
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function processPublicationAction(
|
|
59
|
-
Types.ProcessActionParams calldata params
|
|
60
|
-
) external override onlyHub returns (bytes memory) {
|
|
61
|
-
// ...
|
|
62
|
-
}
|
|
63
|
-
}
|
|
22
|
+
import {Account} from "lens-modules/contracts/extensions/account/Account.sol";
|
|
23
|
+
import {IGraph} from "lens-modules/contracts/core/interfaces/IGraph.sol";
|
|
24
|
+
import {KeyValue} from "lens-modules/contracts/core/types/Types.sol";
|
|
64
25
|
```
|
|
65
26
|
|
|
66
|
-
|
|
27
|
+
#### Deployments
|
|
67
28
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
import {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
constructor(
|
|
93
|
-
address hub,
|
|
94
|
-
address actionModule,
|
|
95
|
-
address moduleRegistry,
|
|
96
|
-
address moduleOwner
|
|
97
|
-
)
|
|
98
|
-
Ownable(moduleOwner)
|
|
99
|
-
BaseFeeCollectModule(hub, actionModule, moduleRegistry)
|
|
100
|
-
LensModuleMetadata()
|
|
101
|
-
{}
|
|
102
|
-
|
|
103
|
-
function supportsInterface(
|
|
104
|
-
bytes4 interfaceID
|
|
105
|
-
) public pure override(BaseFeeCollectModule, LensModule) returns (bool) {
|
|
106
|
-
return
|
|
107
|
-
BaseFeeCollectModule.supportsInterface(interfaceID) ||
|
|
108
|
-
LensModule.supportsInterface(interfaceID);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function initializePublicationCollectModule(
|
|
112
|
-
uint256 profileId,
|
|
113
|
-
uint256 pubId,
|
|
114
|
-
address /* transactionExecutor */,
|
|
115
|
-
bytes calldata data
|
|
116
|
-
) external override onlyActionModule returns (bytes memory) {
|
|
117
|
-
BaseFeeCollectModuleInitData memory baseInitData = abi.decode(
|
|
118
|
-
data,
|
|
119
|
-
(BaseFeeCollectModuleInitData)
|
|
120
|
-
);
|
|
121
|
-
_validateBaseInitData(baseInitData);
|
|
122
|
-
_storeBasePublicationCollectParameters(profileId, pubId, baseInitData);
|
|
123
|
-
return data;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function calculateFee(
|
|
127
|
-
ModuleTypes.ProcessCollectParams calldata processCollectParams
|
|
128
|
-
) public view virtual override returns (uint160) {
|
|
129
|
-
// Override calculateFee to add custom logic to calculate the fee
|
|
130
|
-
return
|
|
131
|
-
_dataByPublicationByProfile[processCollectParams.profileId][
|
|
132
|
-
processCollectParams.pubId
|
|
133
|
-
].amount;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function processCollect(
|
|
137
|
-
ModuleTypes.ProcessCollectParams calldata processCollectParams
|
|
138
|
-
) external override returns (bytes memory) {
|
|
139
|
-
_validateAndStoreCollect(processCollectParams);
|
|
140
|
-
// Override processCollect to add custom logic to process the collect
|
|
141
|
-
if (processCollectParams.referrerProfileIds.length == 0) {
|
|
142
|
-
_processCollect(processCollectParams);
|
|
143
|
-
} else {
|
|
144
|
-
_processCollectWithReferral(processCollectParams);
|
|
145
|
-
}
|
|
146
|
-
return processCollectParams.data;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
29
|
+
Use the `Deployments` helper JavaScript class to get the contract addresses of the Lens deployments on mainnet and testnet. Eg:
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
import { lensDeployments } from "lens-modules/deployments";
|
|
33
|
+
|
|
34
|
+
const lensFactoryAddress = lensDeployments.mainnet.LensFactory.address;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### ABIs
|
|
38
|
+
|
|
39
|
+
Use the `ABIs` helper JavaScript class to get the ABI of any Lens contract. Eg:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { accountAbi } from "lens-modules/abis";
|
|
43
|
+
|
|
44
|
+
await walletClient.writeContract({
|
|
45
|
+
address: "0xYourAccountContractAddress",
|
|
46
|
+
abi: accountAbi,
|
|
47
|
+
functionName: "executeTransaction",
|
|
48
|
+
args: [
|
|
49
|
+
// ... your function arguments
|
|
50
|
+
],
|
|
51
|
+
});
|
|
149
52
|
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {OwnableMetadataBasedAccountAction} from "./base/OwnableMetadataBasedAccountAction.sol";
|
|
6
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
7
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
8
|
+
import {KeyValue} from "../../core/types/Types.sol";
|
|
9
|
+
import {Errors} from "../../core/types/Errors.sol";
|
|
10
|
+
|
|
11
|
+
contract TippingAccountAction is OwnableMetadataBasedAccountAction {
|
|
12
|
+
using SafeERC20 for IERC20;
|
|
13
|
+
|
|
14
|
+
/// @custom:keccak lens.param.amount
|
|
15
|
+
bytes32 constant PARAM__TIP_AMOUNT = 0xc8a06abcb0f2366f32dc2741bdf075c3215e3108918311ec0ac742f1ffd37f49;
|
|
16
|
+
/// @custom:keccak lens.param.token
|
|
17
|
+
bytes32 constant PARAM__TIP_TOKEN = 0xee737c77be2981e91c179485406e6d793521b20aca5e2137b6c497949a74bc94;
|
|
18
|
+
|
|
19
|
+
constructor(address actionHub, address owner, string memory metadataURI)
|
|
20
|
+
OwnableMetadataBasedAccountAction(actionHub, owner, metadataURI)
|
|
21
|
+
{}
|
|
22
|
+
|
|
23
|
+
function _execute(address originalMsgSender, address account, KeyValue[] calldata params)
|
|
24
|
+
internal
|
|
25
|
+
override
|
|
26
|
+
returns (bytes memory)
|
|
27
|
+
{
|
|
28
|
+
address erc20Token;
|
|
29
|
+
uint256 tipAmount;
|
|
30
|
+
for (uint256 i = 0; i < params.length; i++) {
|
|
31
|
+
if (params[i].key == PARAM__TIP_AMOUNT) {
|
|
32
|
+
tipAmount = abi.decode(params[i].value, (uint256));
|
|
33
|
+
} else if (params[i].key == PARAM__TIP_TOKEN) {
|
|
34
|
+
erc20Token = abi.decode(params[i].value, (address));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
require(tipAmount > 0, Errors.InvalidParameter());
|
|
38
|
+
IERC20(erc20Token).safeTransferFrom(originalMsgSender, account, tipAmount);
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {KeyValue} from "../../../core/types/Types.sol";
|
|
6
|
+
import {BaseAction} from "../../base/BaseAction.sol";
|
|
7
|
+
import {IAccountAction} from "../../../extensions/actions/ActionHub.sol";
|
|
8
|
+
import {Errors} from "../../../core/types/Errors.sol";
|
|
9
|
+
|
|
10
|
+
abstract contract BaseAccountAction is BaseAction, IAccountAction {
|
|
11
|
+
constructor(address actionHub) BaseAction(actionHub) {}
|
|
12
|
+
|
|
13
|
+
function configure(address originalMsgSender, address account, KeyValue[] calldata params)
|
|
14
|
+
external
|
|
15
|
+
override
|
|
16
|
+
onlyActionHub
|
|
17
|
+
returns (bytes memory)
|
|
18
|
+
{
|
|
19
|
+
return _configure(originalMsgSender, account, params);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function execute(address originalMsgSender, address account, KeyValue[] calldata params)
|
|
23
|
+
external
|
|
24
|
+
override
|
|
25
|
+
onlyActionHub
|
|
26
|
+
returns (bytes memory)
|
|
27
|
+
{
|
|
28
|
+
return _execute(originalMsgSender, account, params);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function setDisabled(address originalMsgSender, address account, bool isDisabled, KeyValue[] calldata params)
|
|
32
|
+
external
|
|
33
|
+
override
|
|
34
|
+
onlyActionHub
|
|
35
|
+
returns (bytes memory)
|
|
36
|
+
{
|
|
37
|
+
return _setDisabled(originalMsgSender, account, isDisabled, params);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _configure(address originalMsgSender, address, /* account */ KeyValue[] calldata /* params */ )
|
|
41
|
+
internal
|
|
42
|
+
virtual
|
|
43
|
+
returns (bytes memory)
|
|
44
|
+
{
|
|
45
|
+
return _configureUniversalAction(originalMsgSender);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _execute(address originalMsgSender, address account, KeyValue[] calldata params)
|
|
49
|
+
internal
|
|
50
|
+
virtual
|
|
51
|
+
returns (bytes memory);
|
|
52
|
+
|
|
53
|
+
function _setDisabled(
|
|
54
|
+
address, /* originalMsgSender */
|
|
55
|
+
address, /* account */
|
|
56
|
+
bool, /* isDisabled */
|
|
57
|
+
KeyValue[] calldata /* params */
|
|
58
|
+
) internal virtual returns (bytes memory) {
|
|
59
|
+
revert Errors.NotImplemented();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {Ownable} from "../../../core/access/Ownable.sol";
|
|
6
|
+
import {MetadataBased} from "../../../core/base/MetadataBased.sol";
|
|
7
|
+
import {BaseAccountAction} from "./BaseAccountAction.sol";
|
|
8
|
+
|
|
9
|
+
abstract contract OwnableMetadataBasedAccountAction is BaseAccountAction, Ownable, MetadataBased {
|
|
10
|
+
event Lens_AccountAction_MetadataURISet(string metadataURI);
|
|
11
|
+
|
|
12
|
+
constructor(address actionHub, address owner, string memory metadataURI) BaseAccountAction(actionHub) {
|
|
13
|
+
_transferOwnership(owner);
|
|
14
|
+
_setMetadataURI(metadataURI);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _emitMetadataURISet(string memory metadataURI, address /* source */ ) internal virtual override {
|
|
18
|
+
emit Lens_AccountAction_MetadataURISet(metadataURI);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _beforeMetadataURIUpdate(string memory /* metadataURI */ ) internal virtual override onlyOwner {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {UNIVERSAL_ACTION_MAGIC_VALUE} from "../../extensions/actions/ActionHub.sol";
|
|
6
|
+
import {Errors} from "../../core/types/Errors.sol";
|
|
7
|
+
|
|
8
|
+
abstract contract BaseAction {
|
|
9
|
+
address immutable ACTION_HUB;
|
|
10
|
+
|
|
11
|
+
/// @custom:keccak lens.storage.Action.configured
|
|
12
|
+
bytes32 constant STORAGE__ACTION_CONFIGURED = 0x852bead036b7ef35b8026346140cc688bafe817a6c3491812e6d994b1bcda6d9;
|
|
13
|
+
|
|
14
|
+
modifier onlyActionHub() {
|
|
15
|
+
require(msg.sender == ACTION_HUB, Errors.InvalidMsgSender());
|
|
16
|
+
_;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor(address actionHub) {
|
|
20
|
+
ACTION_HUB = actionHub;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _configureUniversalAction(address originalMsgSender) internal onlyActionHub returns (bytes memory) {
|
|
24
|
+
bool configured;
|
|
25
|
+
assembly {
|
|
26
|
+
configured := sload(STORAGE__ACTION_CONFIGURED)
|
|
27
|
+
}
|
|
28
|
+
require(!configured, Errors.RedundantStateChange());
|
|
29
|
+
require(originalMsgSender == address(0), Errors.InvalidParameter());
|
|
30
|
+
assembly {
|
|
31
|
+
sstore(STORAGE__ACTION_CONFIGURED, 1)
|
|
32
|
+
}
|
|
33
|
+
return abi.encode(UNIVERSAL_ACTION_MAGIC_VALUE);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {OwnableMetadataBasedPostAction} from "./base/OwnableMetadataBasedPostAction.sol";
|
|
6
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
7
|
+
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
8
|
+
import {KeyValue} from "../../core/types/Types.sol";
|
|
9
|
+
import {IFeed} from "../../core/interfaces/IFeed.sol";
|
|
10
|
+
import {Errors} from "../../core/types/Errors.sol";
|
|
11
|
+
|
|
12
|
+
contract TippingPostAction is OwnableMetadataBasedPostAction {
|
|
13
|
+
using SafeERC20 for IERC20;
|
|
14
|
+
|
|
15
|
+
/// @custom:keccak lens.param.amount
|
|
16
|
+
bytes32 constant PARAM__TIP_AMOUNT = 0xc8a06abcb0f2366f32dc2741bdf075c3215e3108918311ec0ac742f1ffd37f49;
|
|
17
|
+
/// @custom:keccak lens.param.token
|
|
18
|
+
bytes32 constant PARAM__TIP_TOKEN = 0xee737c77be2981e91c179485406e6d793521b20aca5e2137b6c497949a74bc94;
|
|
19
|
+
|
|
20
|
+
constructor(address actionHub, address owner, string memory metadataURI)
|
|
21
|
+
OwnableMetadataBasedPostAction(actionHub, owner, metadataURI)
|
|
22
|
+
{}
|
|
23
|
+
|
|
24
|
+
function _execute(address originalMsgSender, address feed, uint256 postId, KeyValue[] calldata params)
|
|
25
|
+
internal
|
|
26
|
+
override
|
|
27
|
+
returns (bytes memory)
|
|
28
|
+
{
|
|
29
|
+
address erc20Token;
|
|
30
|
+
uint256 tipAmount;
|
|
31
|
+
for (uint256 i = 0; i < params.length; i++) {
|
|
32
|
+
if (params[i].key == PARAM__TIP_AMOUNT) {
|
|
33
|
+
tipAmount = abi.decode(params[i].value, (uint256));
|
|
34
|
+
} else if (params[i].key == PARAM__TIP_TOKEN) {
|
|
35
|
+
erc20Token = abi.decode(params[i].value, (address));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
require(tipAmount > 0, Errors.InvalidParameter());
|
|
39
|
+
address account = IFeed(feed).getPostAuthor(postId);
|
|
40
|
+
IERC20(erc20Token).safeTransferFrom(originalMsgSender, account, tipAmount);
|
|
41
|
+
return abi.encode(account);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {KeyValue} from "../../../core/types/Types.sol";
|
|
6
|
+
import {BaseAction} from "../../base/BaseAction.sol";
|
|
7
|
+
import {IPostAction} from "../../../extensions/actions/ActionHub.sol";
|
|
8
|
+
import {Errors} from "../../../core/types/Errors.sol";
|
|
9
|
+
|
|
10
|
+
abstract contract BasePostAction is BaseAction, IPostAction {
|
|
11
|
+
constructor(address actionHub) BaseAction(actionHub) {}
|
|
12
|
+
|
|
13
|
+
function configure(address originalMsgSender, address feed, uint256 postId, KeyValue[] calldata params)
|
|
14
|
+
external
|
|
15
|
+
override
|
|
16
|
+
onlyActionHub
|
|
17
|
+
returns (bytes memory)
|
|
18
|
+
{
|
|
19
|
+
return _configure(originalMsgSender, feed, postId, params);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function execute(address originalMsgSender, address feed, uint256 postId, KeyValue[] calldata params)
|
|
23
|
+
external
|
|
24
|
+
override
|
|
25
|
+
onlyActionHub
|
|
26
|
+
returns (bytes memory)
|
|
27
|
+
{
|
|
28
|
+
return _execute(originalMsgSender, feed, postId, params);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function setDisabled(
|
|
32
|
+
address originalMsgSender,
|
|
33
|
+
address feed,
|
|
34
|
+
uint256 postId,
|
|
35
|
+
bool isDisabled,
|
|
36
|
+
KeyValue[] calldata params
|
|
37
|
+
) external override onlyActionHub returns (bytes memory) {
|
|
38
|
+
return _setDisabled(originalMsgSender, feed, postId, isDisabled, params);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _configure(
|
|
42
|
+
address originalMsgSender,
|
|
43
|
+
address, /* feed */
|
|
44
|
+
uint256, /* postId */
|
|
45
|
+
KeyValue[] calldata /* params */
|
|
46
|
+
) internal virtual returns (bytes memory) {
|
|
47
|
+
return _configureUniversalAction(originalMsgSender);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _execute(address originalMsgSender, address feed, uint256 postId, KeyValue[] calldata params)
|
|
51
|
+
internal
|
|
52
|
+
virtual
|
|
53
|
+
returns (bytes memory);
|
|
54
|
+
|
|
55
|
+
function _setDisabled(
|
|
56
|
+
address, /* originalMsgSender */
|
|
57
|
+
address, /* feed */
|
|
58
|
+
uint256, /* postId */
|
|
59
|
+
bool, /* isDisabled */
|
|
60
|
+
KeyValue[] calldata /* params */
|
|
61
|
+
) internal virtual returns (bytes memory) {
|
|
62
|
+
revert Errors.NotImplemented();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {Ownable} from "../../../core/access/Ownable.sol";
|
|
6
|
+
import {MetadataBased} from "../../../core/base/MetadataBased.sol";
|
|
7
|
+
import {BasePostAction} from "./BasePostAction.sol";
|
|
8
|
+
|
|
9
|
+
abstract contract OwnableMetadataBasedPostAction is BasePostAction, Ownable, MetadataBased {
|
|
10
|
+
event Lens_PostAction_MetadataURISet(string metadataURI);
|
|
11
|
+
|
|
12
|
+
constructor(address actionHub, address owner, string memory metadataURI) BasePostAction(actionHub) {
|
|
13
|
+
_transferOwnership(owner);
|
|
14
|
+
_setMetadataURI(metadataURI);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _emitMetadataURISet(string memory metadataURI, address /* source */ ) internal virtual override {
|
|
18
|
+
emit Lens_PostAction_MetadataURISet(metadataURI);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _beforeMetadataURIUpdate(string memory /* metadataURI */ ) internal virtual override onlyOwner {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
// As appears in https://eips.ethereum.org/EIPS/eip-7572
|
|
4
|
+
|
|
5
|
+
pragma solidity ^0.8.26;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This specification standardizes contractURI() to return contract-level metadata. This is useful for dapps and
|
|
9
|
+
* offchain indexers to show rich information about a contract, such as its name, description and image, without
|
|
10
|
+
* specifying it manually or individually for each dapp.
|
|
11
|
+
*/
|
|
12
|
+
interface IERC7572 {
|
|
13
|
+
function contractURI() external view returns (string memory);
|
|
14
|
+
|
|
15
|
+
event ContractURIUpdated();
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import {IPostAction} from "../../../extensions/actions/ActionHub.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @notice A storage struct containing all data regarding a post's collect action.
|
|
9
|
+
*
|
|
10
|
+
* @param amount The collecting cost associated with this publication. 0 for free collect.
|
|
11
|
+
* @param collectLimit The maximum number of collects for this publication. 0 for no limit.
|
|
12
|
+
* @param token The token associated with this publication.
|
|
13
|
+
* @param currentCollects The current number of collects for this publication.
|
|
14
|
+
* @param recipient Recipient of collect fees.
|
|
15
|
+
* @param endTimestamp The end timestamp after which collecting is impossible. 0 for no expiry.
|
|
16
|
+
* @param collectionAddress The address of the collectible ERC721 contract.
|
|
17
|
+
*/
|
|
18
|
+
struct CollectActionData {
|
|
19
|
+
uint160 amount;
|
|
20
|
+
uint96 collectLimit;
|
|
21
|
+
address token;
|
|
22
|
+
uint96 currentCollects;
|
|
23
|
+
address recipient;
|
|
24
|
+
uint72 endTimestamp;
|
|
25
|
+
address followerOnlyGraph;
|
|
26
|
+
address collectionAddress;
|
|
27
|
+
bool isImmutable;
|
|
28
|
+
bool isDisabled;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ISimpleCollectAction is IPostAction {
|
|
32
|
+
function getCollectActionData(address feed, uint256 postId) external view returns (CollectActionData memory);
|
|
33
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Copyright (C) 2024 Lens Labs. All Rights Reserved.
|
|
3
|
+
pragma solidity ^0.8.26;
|
|
4
|
+
|
|
5
|
+
import "../../../../../../../core/base/LensERC721.sol";
|
|
6
|
+
import {IERC7572} from "./IERC7572.sol";
|
|
7
|
+
import {IFeed} from "../../../core/interfaces/IFeed.sol";
|
|
8
|
+
import {ITokenURIProvider} from "../../../core/interfaces/ITokenURIProvider.sol";
|
|
9
|
+
import {Errors} from "../../../core/types/Errors.sol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @notice A contract that represents a Lens Collected Post.
|
|
13
|
+
*
|
|
14
|
+
* @dev This contract is used to store the metadata of a Lens Collected Post.
|
|
15
|
+
* It inherits from LensERC721 and implements the IERC7572 interface.
|
|
16
|
+
* The contractURI() function returns the contract-level metadata making it compatible with the EIP-7572 proposed
|
|
17
|
+
* standard and useful for dapps and offchain indexers to show rich information about the post itself.
|
|
18
|
+
*
|
|
19
|
+
* If the Collect is immutable - it will snapshot the content of the post and always return the snapshotted tokenURI
|
|
20
|
+
* even if the post was updated or deleted. The contractURI, however, always stays the same, as it was at the moment of
|
|
21
|
+
* Collect creation.
|
|
22
|
+
*/
|
|
23
|
+
contract LensCollectedPost is LensERC721, IERC7572 {
|
|
24
|
+
string internal _contentURISnapshot;
|
|
25
|
+
string internal _contractURI;
|
|
26
|
+
address internal immutable _feed;
|
|
27
|
+
uint256 internal immutable _postId;
|
|
28
|
+
address internal immutable _collectAction;
|
|
29
|
+
|
|
30
|
+
constructor(address feed, uint256 postId, bool isImmutable) {
|
|
31
|
+
LensERC721._initialize("Lens Collected Post", "LCP", ITokenURIProvider(address(0)));
|
|
32
|
+
string memory contentURI = IFeed(feed).getPost(postId).contentURI;
|
|
33
|
+
require(bytes(contentURI).length > 0, Errors.InvalidParameter());
|
|
34
|
+
_feed = feed;
|
|
35
|
+
_postId = postId;
|
|
36
|
+
_contractURI = contentURI;
|
|
37
|
+
_collectAction = msg.sender;
|
|
38
|
+
if (isImmutable) {
|
|
39
|
+
_contentURISnapshot = contentURI;
|
|
40
|
+
}
|
|
41
|
+
emit ContractURIUpdated();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function mint(address to, uint256 tokenId) external {
|
|
45
|
+
require(msg.sender == _collectAction, Errors.InvalidMsgSender());
|
|
46
|
+
_mint(to, tokenId);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Getters
|
|
50
|
+
|
|
51
|
+
function contractURI() external view returns (string memory) {
|
|
52
|
+
return _contractURI;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function tokenURI(uint256 /*tokenId*/ ) public view override returns (string memory) {
|
|
56
|
+
if (bytes(_contentURISnapshot).length > 0) {
|
|
57
|
+
return _contentURISnapshot;
|
|
58
|
+
} else {
|
|
59
|
+
string memory contentURI = IFeed(_feed).getPost(_postId).contentURI;
|
|
60
|
+
// If content was deleted we fail. You can override this to return the empty URI if preferred.
|
|
61
|
+
require(bytes(contentURI).length > 0, Errors.DoesNotExist());
|
|
62
|
+
return contentURI;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Internal
|
|
67
|
+
|
|
68
|
+
// Disabling integrated LensERC721 tokenURIProvider
|
|
69
|
+
function _beforeTokenURIProviderSet(ITokenURIProvider /* tokenURIProvider */ ) internal pure override {
|
|
70
|
+
revert Errors.NotImplemented();
|
|
71
|
+
}
|
|
72
|
+
}
|