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.
Files changed (265) hide show
  1. package/LICENSE +0 -2
  2. package/README.md +35 -132
  3. package/contracts/actions/account/TippingAccountAction.sol +41 -0
  4. package/contracts/actions/account/base/BaseAccountAction.sol +61 -0
  5. package/contracts/actions/account/base/OwnableMetadataBasedAccountAction.sol +24 -0
  6. package/contracts/actions/base/BaseAction.sol +35 -0
  7. package/contracts/actions/post/TippingPostAction.sol +43 -0
  8. package/contracts/actions/post/base/BasePostAction.sol +64 -0
  9. package/contracts/actions/post/base/OwnableMetadataBasedPostAction.sol +24 -0
  10. package/contracts/actions/post/collect/IERC7572.sol +16 -0
  11. package/contracts/actions/post/collect/ISimpleCollectAction.sol +33 -0
  12. package/contracts/actions/post/collect/LensCollectedPost.sol +72 -0
  13. package/contracts/actions/post/collect/SimpleCollectAction.sol +302 -0
  14. package/contracts/core/access/AccessControlled.sol +76 -0
  15. package/contracts/core/access/Ownable.sol +42 -0
  16. package/contracts/core/access/RoleBasedAccessControl.sol +211 -0
  17. package/contracts/core/base/BaseSource.sol +99 -0
  18. package/contracts/core/base/ExtraStorageBased.sol +129 -0
  19. package/contracts/core/base/LensERC721.sol +458 -0
  20. package/contracts/core/base/MetadataBased.sol +51 -0
  21. package/contracts/core/base/RuleBasedPrimitive.sol +265 -0
  22. package/contracts/core/base/SourceStampBased.sol +64 -0
  23. package/contracts/core/interfaces/IAccessControl.sol +28 -0
  24. package/contracts/core/interfaces/IERC4906Events.sol +15 -0
  25. package/contracts/core/interfaces/IERC721Namespace.sol +16 -0
  26. package/contracts/core/interfaces/IFeed.sol +181 -0
  27. package/contracts/core/interfaces/IFeedRule.sol +40 -0
  28. package/contracts/core/interfaces/IFollowRule.sol +18 -0
  29. package/contracts/core/interfaces/IGraph.sol +117 -0
  30. package/contracts/core/interfaces/IGraphRule.sol +34 -0
  31. package/contracts/core/interfaces/IGroup.sol +110 -0
  32. package/contracts/core/interfaces/IGroupRule.sol +39 -0
  33. package/contracts/core/interfaces/ILock.sol +10 -0
  34. package/contracts/core/interfaces/IMetadataBased.sol +8 -0
  35. package/contracts/core/interfaces/INamespace.sol +125 -0
  36. package/contracts/core/interfaces/INamespaceRule.sol +44 -0
  37. package/contracts/core/interfaces/IOwnable.sol +9 -0
  38. package/contracts/core/interfaces/IPostRule.sol +28 -0
  39. package/contracts/core/interfaces/IRoleBasedAccessControl.sol +38 -0
  40. package/contracts/core/interfaces/ISource.sol +11 -0
  41. package/contracts/core/interfaces/ITokenURIProvider.sol +7 -0
  42. package/contracts/core/interfaces/IVersionedBeacon.sol +19 -0
  43. package/contracts/core/libraries/AccessControlLib.sol +50 -0
  44. package/contracts/core/libraries/CallLib.sol +54 -0
  45. package/contracts/core/libraries/EIP712EncodingLib.sol +144 -0
  46. package/contracts/core/libraries/KeyValueStorageLib.sol +34 -0
  47. package/contracts/core/libraries/RulesLib.sol +156 -0
  48. package/contracts/core/primitives/feed/Feed.sol +295 -0
  49. package/contracts/core/primitives/feed/FeedCore.sol +95 -0
  50. package/contracts/core/primitives/feed/RuleBasedFeed.sol +483 -0
  51. package/contracts/core/primitives/graph/Graph.sol +173 -0
  52. package/contracts/core/primitives/graph/GraphCore.sol +62 -0
  53. package/contracts/core/primitives/graph/RuleBasedGraph.sol +398 -0
  54. package/contracts/core/primitives/group/Group.sol +191 -0
  55. package/contracts/core/primitives/group/GroupCore.sol +53 -0
  56. package/contracts/core/primitives/group/RuleBasedGroup.sol +295 -0
  57. package/contracts/core/primitives/namespace/LensUsernameTokenURIProvider.sol +319 -0
  58. package/contracts/core/primitives/namespace/Namespace.sol +348 -0
  59. package/contracts/core/primitives/namespace/NamespaceCore.sol +54 -0
  60. package/contracts/core/primitives/namespace/RuleBasedNamespace.sol +320 -0
  61. package/contracts/core/types/Errors.sol +48 -0
  62. package/contracts/core/types/Events.sol +9 -0
  63. package/contracts/core/types/Types.sol +46 -0
  64. package/contracts/core/upgradeability/Beacon.sol +48 -0
  65. package/contracts/core/upgradeability/BeaconProxy.sol +206 -0
  66. package/contracts/core/upgradeability/Initializable.sol +32 -0
  67. package/contracts/core/upgradeability/LegacyBeaconProxy.sol +186 -0
  68. package/contracts/core/upgradeability/Lock.sol +42 -0
  69. package/contracts/core/upgradeability/ProxyAdmin.sol +42 -0
  70. package/contracts/extensions/access/OwnerAdminOnlyAccessControl.sol +59 -0
  71. package/contracts/extensions/access/PermissionlessAccessControl.sol +30 -0
  72. package/contracts/extensions/account/Account.sol +262 -0
  73. package/contracts/extensions/account/IAccount.sol +67 -0
  74. package/contracts/extensions/actions/ActionHub.sol +255 -0
  75. package/contracts/extensions/factories/AccessControlFactory.sol +34 -0
  76. package/contracts/extensions/factories/AccountFactory.sol +51 -0
  77. package/contracts/extensions/factories/AppFactory.sol +36 -0
  78. package/contracts/extensions/factories/FeedFactory.sol +33 -0
  79. package/contracts/extensions/factories/GraphFactory.sol +33 -0
  80. package/contracts/extensions/factories/GroupFactory.sol +38 -0
  81. package/contracts/extensions/factories/LensFactory.sol +465 -0
  82. package/contracts/extensions/factories/NamespaceFactory.sol +40 -0
  83. package/contracts/extensions/factories/PrimitiveFactory.sol +18 -0
  84. package/contracts/extensions/primitives/app/App.sol +405 -0
  85. package/contracts/extensions/primitives/app/AppCore.sol +194 -0
  86. package/contracts/extensions/primitives/app/IApp.sol +107 -0
  87. package/contracts/migration/WhitelistedAddresses.sol +165 -0
  88. package/contracts/migration/WhitelistedMulticall.sol +273 -0
  89. package/contracts/migration/factories/MigrationLensFactory.sol +150 -0
  90. package/contracts/migration/primitives/MigrationAccount.sol +94 -0
  91. package/contracts/migration/primitives/MigrationFeed.sol +173 -0
  92. package/contracts/migration/primitives/MigrationGraph.sol +80 -0
  93. package/contracts/migration/primitives/MigrationNamespace.sol +215 -0
  94. package/contracts/rules/AccountBlockingRule.sol +129 -0
  95. package/contracts/rules/base/OwnableMetadataBasedRule.sol +23 -0
  96. package/contracts/rules/base/RestrictedSignersRule.sol +171 -0
  97. package/contracts/rules/base/SimplePaymentRule.sol +51 -0
  98. package/contracts/rules/base/TokenGatedRule.sol +63 -0
  99. package/contracts/rules/base/TrustBasedRule.sol +36 -0
  100. package/contracts/rules/feed/GroupGatedFeedRule.sol +69 -0
  101. package/contracts/rules/feed/RestrictedSignersFeedRule.sol +79 -0
  102. package/contracts/rules/feed/SimplePaymentFeedRule.sol +122 -0
  103. package/contracts/rules/feed/TokenGatedFeedRule.sol +105 -0
  104. package/contracts/rules/follow/SimplePaymentFollowRule.sol +48 -0
  105. package/contracts/rules/follow/TokenGatedFollowRule.sol +44 -0
  106. package/contracts/rules/graph/GroupGatedGraphRule.sol +105 -0
  107. package/contracts/rules/graph/RestrictedSignersGraphRule.sol +66 -0
  108. package/contracts/rules/graph/TokenGatedGraphRule.sol +106 -0
  109. package/contracts/rules/group/BanMemberGroupRule.sol +128 -0
  110. package/contracts/rules/group/MembershipApprovalGroupRule.sol +114 -0
  111. package/contracts/rules/group/SimplePaymentGroupRule.sol +121 -0
  112. package/contracts/rules/group/TokenGatedGroupRule.sol +112 -0
  113. package/contracts/rules/namespace/SimplePaymentNamespaceRule.sol +140 -0
  114. package/contracts/rules/namespace/TokenGatedNamespaceRule.sol +120 -0
  115. package/contracts/rules/namespace/UsernameCharsetNamespaceRule.sol +203 -0
  116. package/contracts/rules/namespace/UsernameLengthNamespaceRule.sol +132 -0
  117. package/contracts/rules/namespace/UsernamePricePerLengthNamespaceRule.sol +149 -0
  118. package/contracts/rules/namespace/UsernameReservedNamespaceRule.sol +131 -0
  119. package/contracts/rules/namespace/UsernameSimpleCharsetNamespaceRule.sol +83 -0
  120. package/contracts/rules/post/FollowersOnlyPostRule.sol +112 -0
  121. package/dist/abis.d.ts +38900 -0
  122. package/dist/abis.js +1 -0
  123. package/dist/deployments.d.ts +758 -0
  124. package/dist/deployments.js +1 -0
  125. package/dist/index.d.ts +2 -5
  126. package/dist/index.js +2 -21
  127. package/package.json +43 -8
  128. package/contracts/FollowNFT.sol +0 -507
  129. package/contracts/LensHub.sol +0 -523
  130. package/contracts/base/ERC2981CollectionRoyalties.sol +0 -75
  131. package/contracts/base/HubRestricted.sol +0 -27
  132. package/contracts/base/LensBaseERC721.sol +0 -509
  133. package/contracts/base/LensGovernable.sol +0 -114
  134. package/contracts/base/LensHubEventHooks.sol +0 -23
  135. package/contracts/base/LensHubStorage.sol +0 -69
  136. package/contracts/base/LensImplGetters.sol +0 -25
  137. package/contracts/base/LensProfiles.sol +0 -209
  138. package/contracts/base/LensVersion.sol +0 -36
  139. package/contracts/base/upgradeability/FollowNFTProxy.sol +0 -21
  140. package/contracts/base/upgradeability/VersionedInitializable.sol +0 -50
  141. package/contracts/interfaces/ICollectNFT.sol +0 -40
  142. package/contracts/interfaces/IERC721Burnable.sol +0 -19
  143. package/contracts/interfaces/IERC721MetaTx.sol +0 -27
  144. package/contracts/interfaces/IERC721Timestamped.sol +0 -50
  145. package/contracts/interfaces/IFollowModule.sol +0 -55
  146. package/contracts/interfaces/IFollowNFT.sol +0 -209
  147. package/contracts/interfaces/IFollowTokenURI.sol +0 -11
  148. package/contracts/interfaces/IHandleTokenURI.sol +0 -11
  149. package/contracts/interfaces/ILensERC721.sol +0 -11
  150. package/contracts/interfaces/ILensGovernable.sol +0 -141
  151. package/contracts/interfaces/ILensHandles.sol +0 -106
  152. package/contracts/interfaces/ILensHub.sol +0 -19
  153. package/contracts/interfaces/ILensHubEventHooks.sol +0 -26
  154. package/contracts/interfaces/ILensHubInitializable.sol +0 -28
  155. package/contracts/interfaces/ILensImplGetters.sol +0 -26
  156. package/contracts/interfaces/ILensProfiles.sol +0 -37
  157. package/contracts/interfaces/ILensProtocol.sol +0 -452
  158. package/contracts/interfaces/ILensVersion.sol +0 -31
  159. package/contracts/interfaces/IModuleRegistry.sol +0 -32
  160. package/contracts/interfaces/IProfileTokenURI.sol +0 -7
  161. package/contracts/interfaces/IPublicationActionModule.sol +0 -53
  162. package/contracts/interfaces/IReferenceModule.sol +0 -72
  163. package/contracts/interfaces/ITokenHandleRegistry.sol +0 -90
  164. package/contracts/libraries/ActionLib.sol +0 -69
  165. package/contracts/libraries/FollowLib.sol +0 -175
  166. package/contracts/libraries/GovernanceLib.sol +0 -111
  167. package/contracts/libraries/MetaTxLib.sol +0 -415
  168. package/contracts/libraries/ProfileLib.sol +0 -284
  169. package/contracts/libraries/PublicationLib.sol +0 -497
  170. package/contracts/libraries/StorageLib.sol +0 -256
  171. package/contracts/libraries/ValidationLib.sol +0 -206
  172. package/contracts/libraries/constants/Errors.sol +0 -51
  173. package/contracts/libraries/constants/Events.sol +0 -395
  174. package/contracts/libraries/constants/Typehash.sol +0 -32
  175. package/contracts/libraries/constants/Types.sol +0 -394
  176. package/contracts/libraries/svgs/Follow/FollowSVG.sol +0 -16
  177. package/contracts/libraries/svgs/Handle/GintoNordFontSVG.sol +0 -9
  178. package/contracts/libraries/svgs/Handle/HandleSVG.sol +0 -255
  179. package/contracts/libraries/svgs/Profile/Body/BodyHoodie.sol +0 -21
  180. package/contracts/libraries/svgs/Profile/Body/BodyJacket.sol +0 -21
  181. package/contracts/libraries/svgs/Profile/Body/BodyTShirt.sol +0 -21
  182. package/contracts/libraries/svgs/Profile/Body/BodyTanktop.sol +0 -21
  183. package/contracts/libraries/svgs/Profile/Body.sol +0 -119
  184. package/contracts/libraries/svgs/Profile/Face.sol +0 -145
  185. package/contracts/libraries/svgs/Profile/Hands.sol +0 -121
  186. package/contracts/libraries/svgs/Profile/Head.sol +0 -33
  187. package/contracts/libraries/svgs/Profile/Headwear/HeadwearBeanie.sol +0 -71
  188. package/contracts/libraries/svgs/Profile/Headwear/HeadwearCrown.sol +0 -67
  189. package/contracts/libraries/svgs/Profile/Headwear/HeadwearFloral.sol +0 -67
  190. package/contracts/libraries/svgs/Profile/Headwear/HeadwearGlasses.sol +0 -67
  191. package/contracts/libraries/svgs/Profile/Headwear/HeadwearHat.sol +0 -79
  192. package/contracts/libraries/svgs/Profile/Headwear/HeadwearIcecream.sol +0 -55
  193. package/contracts/libraries/svgs/Profile/Headwear/HeadwearLeafs.sol +0 -67
  194. package/contracts/libraries/svgs/Profile/Headwear/HeadwearMushroom.sol +0 -83
  195. package/contracts/libraries/svgs/Profile/Headwear/HeadwearNightcap.sol +0 -67
  196. package/contracts/libraries/svgs/Profile/Headwear/HeadwearPartyhat.sol +0 -69
  197. package/contracts/libraries/svgs/Profile/Headwear/HeadwearPlants.sol +0 -71
  198. package/contracts/libraries/svgs/Profile/Headwear/HeadwearSparkles.sol +0 -55
  199. package/contracts/libraries/svgs/Profile/Headwear.sol +0 -155
  200. package/contracts/libraries/svgs/Profile/Helpers.sol +0 -83
  201. package/contracts/libraries/svgs/Profile/Legs.sol +0 -37
  202. package/contracts/libraries/svgs/Profile/Logo.sol +0 -167
  203. package/contracts/libraries/svgs/Profile/ProfileSVG.sol +0 -384
  204. package/contracts/libraries/svgs/Profile/Shoes.sol +0 -37
  205. package/contracts/libraries/svgs/Profile/SimpleProfileSVG.sol +0 -8
  206. package/contracts/misc/CreditsFaucet.sol +0 -25
  207. package/contracts/misc/ImmutableOwnable.sol +0 -30
  208. package/contracts/misc/LensHubInitializable.sol +0 -48
  209. package/contracts/misc/ModuleRegistry.sol +0 -140
  210. package/contracts/misc/PermissionlessCreator.sol +0 -353
  211. package/contracts/misc/ProfileCreationProxy.sol +0 -66
  212. package/contracts/misc/PublicActProxy.sol +0 -97
  213. package/contracts/misc/PublicActProxy_MetaTx.sol +0 -156
  214. package/contracts/misc/access/LitAccessControl.sol +0 -125
  215. package/contracts/misc/token-uris/FollowTokenURI.sol +0 -47
  216. package/contracts/misc/token-uris/HandleTokenURI.sol +0 -42
  217. package/contracts/misc/token-uris/ProfileTokenURI.sol +0 -57
  218. package/contracts/misc/token-uris/SimpleProfileTokenURI.sol +0 -57
  219. package/contracts/modules/ActionRestricted.sol +0 -27
  220. package/contracts/modules/FeeModuleBase.sol +0 -43
  221. package/contracts/modules/LensModule.sol +0 -11
  222. package/contracts/modules/LensModuleMetadata.sol +0 -17
  223. package/contracts/modules/LensModuleMetadataInitializable.sol +0 -18
  224. package/contracts/modules/act/collect/CollectNFT.sol +0 -125
  225. package/contracts/modules/act/collect/CollectPublicationAction.sol +0 -237
  226. package/contracts/modules/act/collect/MultirecipientFeeCollectModule.sol +0 -224
  227. package/contracts/modules/act/collect/SimpleFeeCollectModule.sol +0 -79
  228. package/contracts/modules/act/collect/base/BaseFeeCollectModule.sol +0 -298
  229. package/contracts/modules/base/LensModuleRegistrant.sol +0 -49
  230. package/contracts/modules/constants/Errors.sol +0 -16
  231. package/contracts/modules/follow/FeeFollowModule.sol +0 -131
  232. package/contracts/modules/follow/RevertFollowModule.sol +0 -48
  233. package/contracts/modules/interfaces/IBaseFeeCollectModule.sol +0 -75
  234. package/contracts/modules/interfaces/ICollectModule.sol +0 -50
  235. package/contracts/modules/interfaces/ILensModule.sol +0 -18
  236. package/contracts/modules/interfaces/IModuleRegistrant.sol +0 -22
  237. package/contracts/modules/interfaces/IWMATIC.sol +0 -11
  238. package/contracts/modules/libraries/FollowValidationLib.sol +0 -32
  239. package/contracts/modules/libraries/TokenGateLib.sol +0 -76
  240. package/contracts/modules/libraries/constants/ModuleTypes.sol +0 -25
  241. package/contracts/modules/reference/DegreesOfSeparationReferenceModule.sol +0 -314
  242. package/contracts/modules/reference/FollowerOnlyReferenceModule.sol +0 -96
  243. package/contracts/modules/reference/TokenGatedReferenceModule.sol +0 -167
  244. package/contracts/namespaces/LensHandles.sol +0 -326
  245. package/contracts/namespaces/TokenHandleRegistry.sol +0 -320
  246. package/contracts/namespaces/constants/Errors.sol +0 -27
  247. package/contracts/namespaces/constants/Events.sol +0 -63
  248. package/contracts/namespaces/constants/Typehash.sol +0 -12
  249. package/contracts/namespaces/constants/Types.sol +0 -21
  250. package/dist/deployments/follow-modules.d.ts +0 -12
  251. package/dist/deployments/follow-modules.js +0 -15
  252. package/dist/deployments/open-actions.d.ts +0 -42
  253. package/dist/deployments/open-actions.js +0 -45
  254. package/dist/deployments/reference-modules.d.ts +0 -17
  255. package/dist/deployments/reference-modules.js +0 -20
  256. package/dist/lens-contracts.d.ts +0 -115
  257. package/dist/lens-contracts.js +0 -140
  258. package/dist/lenshub-abi.d.ts +0 -2573
  259. package/dist/lenshub-abi.js +0 -1445
  260. package/dist/verified-modules/follow-modules.d.ts +0 -12
  261. package/dist/verified-modules/follow-modules.js +0 -15
  262. package/dist/verified-modules/open-actions.d.ts +0 -42
  263. package/dist/verified-modules/open-actions.js +0 -45
  264. package/dist/verified-modules/reference-modules.d.ts +0 -17
  265. 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 Module Contracts
1
+ # Lens Modules
2
2
 
3
- This repository contains the module contracts from the core Lens Protocol repo ([link](https://github.com/lens-protocol/core/tree/5454b58664fab805b6888a68ff40915d251f32f3/contracts)) as a standalone library, useful in Hardhat and Foundry projects.
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 provides all the libraries, interfaces, and base contracts required when creating follow, collect, and Open Action modules.
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
- Boilerplate for an Open Action module:
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
- pragma solidity ^0.8.21;
19
-
20
- import {HubRestricted} from "lens-modules/contracts/base/HubRestricted.sol";
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
- The library also has the contracts needed to create a Follow or Collect Module. Here's a basic example of a `CollectModule` that can be registered with the platform `CollectPublicationAction` contract.
27
+ #### Deployments
67
28
 
68
- ```solidity
69
- // SPDX-License-Identifier: MIT
70
- pragma solidity 0.8.23;
71
-
72
- import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
73
- import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
74
- import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
75
- import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
76
-
77
- import {Types} from "lens-modules/contracts/libraries/constants/Types.sol";
78
- import {IPublicationActionModule} from "lens-modules/contracts/interfaces/IPublicationActionModule.sol";
79
- import {HubRestricted} from "lens-modules/contracts/base/HubRestricted.sol";
80
- import {IModuleRegistry} from "lens-modules/contracts/interfaces/IModuleRegistry.sol";
81
- import {LensModuleMetadata} from "lens-modules/contracts/modules/LensModuleMetadata.sol";
82
- import {LensModuleRegistrant} from "lens-modules/contracts/modules/base/LensModuleRegistrant.sol";
83
- import {ICollectModule} from "lens-modules/contracts/modules/interfaces/ICollectModule.sol";
84
- import {BaseFeeCollectModule} from "lens-modules/contracts/modules/act/collect/base/BaseFeeCollectModule.sol";
85
- import {IBaseFeeCollectModule, BaseFeeCollectModuleInitData} from "lens-modules/contracts/modules/interfaces/IBaseFeeCollectModule.sol";
86
- import {ModuleTypes} from "lens-modules/contracts/modules/libraries/constants/ModuleTypes.sol";
87
- import {LensModule} from "lens-modules/contracts/modules/LensModule.sol";
88
-
89
- contract YourCollectModule is Ownable, BaseFeeCollectModule, LensModuleMetadata {
90
- using SafeERC20 for IERC20;
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
+ }