lens-modules 1.0.13 → 1.1.0
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/contracts/FollowNFT.sol +507 -0
- package/contracts/LensHub.sol +590 -0
- package/contracts/base/LensGovernable.sol +114 -0
- package/contracts/base/LensHubEventHooks.sol +42 -0
- package/contracts/base/LensHubStorage.sol +69 -0
- package/contracts/base/LensImplGetters.sol +32 -0
- package/contracts/base/LensProfiles.sol +162 -0
- package/contracts/base/LensVersion.sol +36 -0
- package/contracts/base/upgradeability/FollowNFTProxy.sol +21 -0
- package/contracts/interfaces/IFollowTokenURI.sol +11 -0
- package/contracts/interfaces/ILegacyCollectModule.sol +45 -0
- package/contracts/interfaces/ILegacyCollectNFT.sol +46 -0
- package/contracts/interfaces/ILegacyFollowModule.sol +82 -0
- package/contracts/interfaces/IProfileTokenURI.sol +7 -0
- package/contracts/interfaces/ITokenHandleRegistry.sol +90 -0
- package/contracts/libraries/ActionLib.sol +69 -0
- package/contracts/libraries/FollowLib.sol +175 -0
- package/contracts/libraries/GovernanceLib.sol +111 -0
- package/contracts/libraries/LegacyCollectLib.sol +176 -0
- package/contracts/libraries/ProfileLib.sol +284 -0
- package/contracts/libraries/PublicationLib.sol +567 -0
- package/contracts/libraries/ValidationLib.sol +228 -0
- package/dist/index.d.ts +5 -0
- package/dist/{src/index.js → index.js} +4 -4
- package/dist/verified-modules/follow-modules.d.ts +12 -0
- package/dist/verified-modules/follow-modules.js +15 -0
- package/dist/verified-modules/open-actions.d.ts +42 -0
- package/dist/verified-modules/open-actions.js +45 -0
- package/dist/verified-modules/reference-modules.d.ts +17 -0
- package/dist/verified-modules/reference-modules.js +20 -0
- package/package.json +1 -1
- package/dist/src/index.d.ts +0 -5
- /package/dist/{deployments/lens-contracts.d.ts → lens-contracts.d.ts} +0 -0
- /package/dist/{deployments/lens-contracts.js → lens-contracts.js} +0 -0
- /package/dist/{src/lenshub-abi.d.ts → lenshub-abi.d.ts} +0 -0
- /package/dist/{src/lenshub-abi.js → lenshub-abi.js} +0 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.15;
|
|
4
|
+
|
|
5
|
+
// Interfaces
|
|
6
|
+
import {ILensProtocol} from './interfaces/ILensProtocol.sol';
|
|
7
|
+
import {IFollowNFT} from './interfaces/IFollowNFT.sol';
|
|
8
|
+
|
|
9
|
+
// Constants
|
|
10
|
+
import {Types} from './libraries/constants/Types.sol';
|
|
11
|
+
import {Errors} from './libraries/constants/Errors.sol';
|
|
12
|
+
|
|
13
|
+
// Lens Hub Components
|
|
14
|
+
import {LensHubStorage} from './base/LensHubStorage.sol';
|
|
15
|
+
import {LensImplGetters} from './base/LensImplGetters.sol';
|
|
16
|
+
import {LensGovernable} from './base/LensGovernable.sol';
|
|
17
|
+
import {LensProfiles} from './base/LensProfiles.sol';
|
|
18
|
+
import {LensHubEventHooks} from './base/LensHubEventHooks.sol';
|
|
19
|
+
import {LensVersion} from './base/LensVersion.sol';
|
|
20
|
+
|
|
21
|
+
// Libraries
|
|
22
|
+
import {ActionLib} from './libraries/ActionLib.sol';
|
|
23
|
+
import {LegacyCollectLib} from './libraries/LegacyCollectLib.sol';
|
|
24
|
+
import {FollowLib} from './libraries/FollowLib.sol';
|
|
25
|
+
import {MetaTxLib} from './libraries/MetaTxLib.sol';
|
|
26
|
+
import {ProfileLib} from './libraries/ProfileLib.sol';
|
|
27
|
+
import {PublicationLib} from './libraries/PublicationLib.sol';
|
|
28
|
+
import {StorageLib} from './libraries/StorageLib.sol';
|
|
29
|
+
import {ValidationLib} from './libraries/ValidationLib.sol';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @title LensHub
|
|
33
|
+
* @author Lens Protocol
|
|
34
|
+
*
|
|
35
|
+
* @notice This is the main entry point of the Lens Protocol. It contains governance functionality as well as
|
|
36
|
+
* publishing and profile interaction functionality.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: The Lens Protocol is unique in that frontend operators need to track a potentially overwhelming
|
|
39
|
+
* number of NFT contracts and interactions at once. For that reason, we've made two quirky design decisions:
|
|
40
|
+
* 1. Both Follow & Collect NFTs invoke a LensHub callback on transfer with the sole purpose of emitting an event.
|
|
41
|
+
* 2. Almost every event in the protocol emits the current block timestamp, reducing the need to fetch it manually.
|
|
42
|
+
*
|
|
43
|
+
* @custom:upgradeable Transparent upgradeable proxy. In this version, without initializer.
|
|
44
|
+
* See `../misc/LensHubInitializable.sol` for the initializable version.
|
|
45
|
+
*/
|
|
46
|
+
contract LensHub is
|
|
47
|
+
LensProfiles,
|
|
48
|
+
LensGovernable,
|
|
49
|
+
LensImplGetters,
|
|
50
|
+
LensHubEventHooks,
|
|
51
|
+
LensHubStorage,
|
|
52
|
+
LensVersion,
|
|
53
|
+
ILensProtocol
|
|
54
|
+
{
|
|
55
|
+
modifier onlyProfileOwnerOrDelegatedExecutor(address expectedOwnerOrDelegatedExecutor, uint256 profileId) {
|
|
56
|
+
ValidationLib.validateAddressIsProfileOwnerOrDelegatedExecutor(expectedOwnerOrDelegatedExecutor, profileId);
|
|
57
|
+
_;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
modifier whenPublishingEnabled() {
|
|
61
|
+
if (StorageLib.getState() != Types.ProtocolState.Unpaused) {
|
|
62
|
+
revert Errors.PublishingPaused();
|
|
63
|
+
}
|
|
64
|
+
_;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
constructor(
|
|
68
|
+
address followNFTImpl,
|
|
69
|
+
address legacyCollectNFTImpl, // We still pass the deprecated CollectNFTImpl for legacy Collects to work
|
|
70
|
+
address moduleRegistry,
|
|
71
|
+
uint256 tokenGuardianCooldown
|
|
72
|
+
)
|
|
73
|
+
LensProfiles(tokenGuardianCooldown)
|
|
74
|
+
LensImplGetters(followNFTImpl, legacyCollectNFTImpl, moduleRegistry)
|
|
75
|
+
{}
|
|
76
|
+
|
|
77
|
+
/// @inheritdoc ILensProtocol
|
|
78
|
+
function createProfile(
|
|
79
|
+
Types.CreateProfileParams calldata createProfileParams
|
|
80
|
+
) external override whenNotPaused returns (uint256) {
|
|
81
|
+
ValidationLib.validateProfileCreatorWhitelisted(msg.sender);
|
|
82
|
+
unchecked {
|
|
83
|
+
uint256 profileId = ++_profileCounter;
|
|
84
|
+
_mint(createProfileParams.to, profileId);
|
|
85
|
+
ProfileLib.createProfile(createProfileParams, profileId);
|
|
86
|
+
return profileId;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
///////////////////////////////////////////
|
|
91
|
+
/// PROFILE OWNER FUNCTIONS ///
|
|
92
|
+
///////////////////////////////////////////
|
|
93
|
+
|
|
94
|
+
/// @inheritdoc ILensProtocol
|
|
95
|
+
function setProfileMetadataURI(
|
|
96
|
+
uint256 profileId,
|
|
97
|
+
string calldata metadataURI
|
|
98
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(msg.sender, profileId) {
|
|
99
|
+
ProfileLib.setProfileMetadataURI(profileId, metadataURI, msg.sender);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// @inheritdoc ILensProtocol
|
|
103
|
+
function setProfileMetadataURIWithSig(
|
|
104
|
+
uint256 profileId,
|
|
105
|
+
string calldata metadataURI,
|
|
106
|
+
Types.EIP712Signature calldata signature
|
|
107
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, profileId) {
|
|
108
|
+
MetaTxLib.validateSetProfileMetadataURISignature(signature, profileId, metadataURI);
|
|
109
|
+
ProfileLib.setProfileMetadataURI(profileId, metadataURI, signature.signer);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/// @inheritdoc ILensProtocol
|
|
113
|
+
function setFollowModule(
|
|
114
|
+
uint256 profileId,
|
|
115
|
+
address followModule,
|
|
116
|
+
bytes calldata followModuleInitData
|
|
117
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(msg.sender, profileId) {
|
|
118
|
+
ProfileLib.setFollowModule(profileId, followModule, followModuleInitData, msg.sender);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// @inheritdoc ILensProtocol
|
|
122
|
+
function setFollowModuleWithSig(
|
|
123
|
+
uint256 profileId,
|
|
124
|
+
address followModule,
|
|
125
|
+
bytes calldata followModuleInitData,
|
|
126
|
+
Types.EIP712Signature calldata signature
|
|
127
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, profileId) {
|
|
128
|
+
MetaTxLib.validateSetFollowModuleSignature(signature, profileId, followModule, followModuleInitData);
|
|
129
|
+
ProfileLib.setFollowModule(profileId, followModule, followModuleInitData, signature.signer);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// @inheritdoc ILensProtocol
|
|
133
|
+
function changeDelegatedExecutorsConfig(
|
|
134
|
+
uint256 delegatorProfileId,
|
|
135
|
+
address[] calldata delegatedExecutors,
|
|
136
|
+
bool[] calldata approvals,
|
|
137
|
+
uint64 configNumber,
|
|
138
|
+
bool switchToGivenConfig
|
|
139
|
+
) external override whenNotPaused onlyProfileOwner(msg.sender, delegatorProfileId) {
|
|
140
|
+
ProfileLib.changeGivenDelegatedExecutorsConfig(
|
|
141
|
+
delegatorProfileId,
|
|
142
|
+
delegatedExecutors,
|
|
143
|
+
approvals,
|
|
144
|
+
configNumber,
|
|
145
|
+
switchToGivenConfig
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function changeDelegatedExecutorsConfig(
|
|
150
|
+
uint256 delegatorProfileId,
|
|
151
|
+
address[] calldata delegatedExecutors,
|
|
152
|
+
bool[] calldata approvals
|
|
153
|
+
) external override whenNotPaused onlyProfileOwner(msg.sender, delegatorProfileId) {
|
|
154
|
+
ProfileLib.changeDelegatedExecutorsConfig(delegatorProfileId, delegatedExecutors, approvals);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/// @inheritdoc ILensProtocol
|
|
158
|
+
function changeDelegatedExecutorsConfigWithSig(
|
|
159
|
+
uint256 delegatorProfileId,
|
|
160
|
+
address[] calldata delegatedExecutors,
|
|
161
|
+
bool[] calldata approvals,
|
|
162
|
+
uint64 configNumber,
|
|
163
|
+
bool switchToGivenConfig,
|
|
164
|
+
Types.EIP712Signature calldata signature
|
|
165
|
+
) external override whenNotPaused onlyProfileOwner(signature.signer, delegatorProfileId) {
|
|
166
|
+
MetaTxLib.validateChangeDelegatedExecutorsConfigSignature(
|
|
167
|
+
signature,
|
|
168
|
+
delegatorProfileId,
|
|
169
|
+
delegatedExecutors,
|
|
170
|
+
approvals,
|
|
171
|
+
configNumber,
|
|
172
|
+
switchToGivenConfig
|
|
173
|
+
);
|
|
174
|
+
ProfileLib.changeGivenDelegatedExecutorsConfig(
|
|
175
|
+
delegatorProfileId,
|
|
176
|
+
delegatedExecutors,
|
|
177
|
+
approvals,
|
|
178
|
+
configNumber,
|
|
179
|
+
switchToGivenConfig
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
////////////////////////////////////////
|
|
184
|
+
/// PUBLISHING FUNCTIONS ///
|
|
185
|
+
////////////////////////////////////////
|
|
186
|
+
|
|
187
|
+
/// @inheritdoc ILensProtocol
|
|
188
|
+
function post(
|
|
189
|
+
Types.PostParams calldata postParams
|
|
190
|
+
)
|
|
191
|
+
external
|
|
192
|
+
override
|
|
193
|
+
whenPublishingEnabled
|
|
194
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, postParams.profileId)
|
|
195
|
+
returns (uint256)
|
|
196
|
+
{
|
|
197
|
+
return PublicationLib.post({postParams: postParams, transactionExecutor: msg.sender});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// @inheritdoc ILensProtocol
|
|
201
|
+
function postWithSig(
|
|
202
|
+
Types.PostParams calldata postParams,
|
|
203
|
+
Types.EIP712Signature calldata signature
|
|
204
|
+
)
|
|
205
|
+
external
|
|
206
|
+
override
|
|
207
|
+
whenPublishingEnabled
|
|
208
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, postParams.profileId)
|
|
209
|
+
returns (uint256)
|
|
210
|
+
{
|
|
211
|
+
MetaTxLib.validatePostSignature(signature, postParams);
|
|
212
|
+
return PublicationLib.post({postParams: postParams, transactionExecutor: signature.signer});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// @inheritdoc ILensProtocol
|
|
216
|
+
function comment(
|
|
217
|
+
Types.CommentParams calldata commentParams
|
|
218
|
+
)
|
|
219
|
+
external
|
|
220
|
+
override
|
|
221
|
+
whenPublishingEnabled
|
|
222
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, commentParams.profileId)
|
|
223
|
+
returns (uint256)
|
|
224
|
+
{
|
|
225
|
+
return PublicationLib.comment({commentParams: commentParams, transactionExecutor: msg.sender});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/// @inheritdoc ILensProtocol
|
|
229
|
+
function commentWithSig(
|
|
230
|
+
Types.CommentParams calldata commentParams,
|
|
231
|
+
Types.EIP712Signature calldata signature
|
|
232
|
+
)
|
|
233
|
+
external
|
|
234
|
+
override
|
|
235
|
+
whenPublishingEnabled
|
|
236
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, commentParams.profileId)
|
|
237
|
+
returns (uint256)
|
|
238
|
+
{
|
|
239
|
+
MetaTxLib.validateCommentSignature(signature, commentParams);
|
|
240
|
+
return PublicationLib.comment({commentParams: commentParams, transactionExecutor: signature.signer});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/// @inheritdoc ILensProtocol
|
|
244
|
+
function mirror(
|
|
245
|
+
Types.MirrorParams calldata mirrorParams
|
|
246
|
+
)
|
|
247
|
+
external
|
|
248
|
+
override
|
|
249
|
+
whenPublishingEnabled
|
|
250
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, mirrorParams.profileId)
|
|
251
|
+
returns (uint256)
|
|
252
|
+
{
|
|
253
|
+
return PublicationLib.mirror({mirrorParams: mirrorParams, transactionExecutor: msg.sender});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/// @inheritdoc ILensProtocol
|
|
257
|
+
function mirrorWithSig(
|
|
258
|
+
Types.MirrorParams calldata mirrorParams,
|
|
259
|
+
Types.EIP712Signature calldata signature
|
|
260
|
+
)
|
|
261
|
+
external
|
|
262
|
+
override
|
|
263
|
+
whenPublishingEnabled
|
|
264
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, mirrorParams.profileId)
|
|
265
|
+
returns (uint256)
|
|
266
|
+
{
|
|
267
|
+
MetaTxLib.validateMirrorSignature(signature, mirrorParams);
|
|
268
|
+
return PublicationLib.mirror({mirrorParams: mirrorParams, transactionExecutor: signature.signer});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// @inheritdoc ILensProtocol
|
|
272
|
+
function quote(
|
|
273
|
+
Types.QuoteParams calldata quoteParams
|
|
274
|
+
)
|
|
275
|
+
external
|
|
276
|
+
override
|
|
277
|
+
whenPublishingEnabled
|
|
278
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, quoteParams.profileId)
|
|
279
|
+
returns (uint256)
|
|
280
|
+
{
|
|
281
|
+
return PublicationLib.quote({quoteParams: quoteParams, transactionExecutor: msg.sender});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/// @inheritdoc ILensProtocol
|
|
285
|
+
function quoteWithSig(
|
|
286
|
+
Types.QuoteParams calldata quoteParams,
|
|
287
|
+
Types.EIP712Signature calldata signature
|
|
288
|
+
)
|
|
289
|
+
external
|
|
290
|
+
override
|
|
291
|
+
whenPublishingEnabled
|
|
292
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, quoteParams.profileId)
|
|
293
|
+
returns (uint256)
|
|
294
|
+
{
|
|
295
|
+
MetaTxLib.validateQuoteSignature(signature, quoteParams);
|
|
296
|
+
return PublicationLib.quote({quoteParams: quoteParams, transactionExecutor: signature.signer});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/////////////////////////////////////////////////
|
|
300
|
+
/// PROFILE INTERACTION FUNCTIONS ///
|
|
301
|
+
/////////////////////////////////////////////////
|
|
302
|
+
|
|
303
|
+
/// @inheritdoc ILensProtocol
|
|
304
|
+
function follow(
|
|
305
|
+
uint256 followerProfileId,
|
|
306
|
+
uint256[] calldata idsOfProfilesToFollow,
|
|
307
|
+
uint256[] calldata followTokenIds,
|
|
308
|
+
bytes[] calldata datas
|
|
309
|
+
)
|
|
310
|
+
external
|
|
311
|
+
override
|
|
312
|
+
whenNotPaused
|
|
313
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, followerProfileId)
|
|
314
|
+
returns (uint256[] memory)
|
|
315
|
+
{
|
|
316
|
+
return
|
|
317
|
+
FollowLib.follow({
|
|
318
|
+
followerProfileId: followerProfileId,
|
|
319
|
+
idsOfProfilesToFollow: idsOfProfilesToFollow,
|
|
320
|
+
followTokenIds: followTokenIds,
|
|
321
|
+
followModuleDatas: datas,
|
|
322
|
+
transactionExecutor: msg.sender
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/// @inheritdoc ILensProtocol
|
|
327
|
+
function followWithSig(
|
|
328
|
+
uint256 followerProfileId,
|
|
329
|
+
uint256[] calldata idsOfProfilesToFollow,
|
|
330
|
+
uint256[] calldata followTokenIds,
|
|
331
|
+
bytes[] calldata datas,
|
|
332
|
+
Types.EIP712Signature calldata signature
|
|
333
|
+
)
|
|
334
|
+
external
|
|
335
|
+
override
|
|
336
|
+
whenNotPaused
|
|
337
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, followerProfileId)
|
|
338
|
+
returns (uint256[] memory)
|
|
339
|
+
{
|
|
340
|
+
MetaTxLib.validateFollowSignature(signature, followerProfileId, idsOfProfilesToFollow, followTokenIds, datas);
|
|
341
|
+
return
|
|
342
|
+
FollowLib.follow({
|
|
343
|
+
followerProfileId: followerProfileId,
|
|
344
|
+
idsOfProfilesToFollow: idsOfProfilesToFollow,
|
|
345
|
+
followTokenIds: followTokenIds,
|
|
346
|
+
followModuleDatas: datas,
|
|
347
|
+
transactionExecutor: signature.signer
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/// @inheritdoc ILensProtocol
|
|
352
|
+
function unfollow(
|
|
353
|
+
uint256 unfollowerProfileId,
|
|
354
|
+
uint256[] calldata idsOfProfilesToUnfollow
|
|
355
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(msg.sender, unfollowerProfileId) {
|
|
356
|
+
FollowLib.unfollow({
|
|
357
|
+
unfollowerProfileId: unfollowerProfileId,
|
|
358
|
+
idsOfProfilesToUnfollow: idsOfProfilesToUnfollow,
|
|
359
|
+
transactionExecutor: msg.sender
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/// @inheritdoc ILensProtocol
|
|
364
|
+
function unfollowWithSig(
|
|
365
|
+
uint256 unfollowerProfileId,
|
|
366
|
+
uint256[] calldata idsOfProfilesToUnfollow,
|
|
367
|
+
Types.EIP712Signature calldata signature
|
|
368
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, unfollowerProfileId) {
|
|
369
|
+
MetaTxLib.validateUnfollowSignature(signature, unfollowerProfileId, idsOfProfilesToUnfollow);
|
|
370
|
+
|
|
371
|
+
FollowLib.unfollow({
|
|
372
|
+
unfollowerProfileId: unfollowerProfileId,
|
|
373
|
+
idsOfProfilesToUnfollow: idsOfProfilesToUnfollow,
|
|
374
|
+
transactionExecutor: signature.signer
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/// @inheritdoc ILensProtocol
|
|
379
|
+
function setBlockStatus(
|
|
380
|
+
uint256 byProfileId,
|
|
381
|
+
uint256[] calldata idsOfProfilesToSetBlockStatus,
|
|
382
|
+
bool[] calldata blockStatus
|
|
383
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(msg.sender, byProfileId) {
|
|
384
|
+
ProfileLib.setBlockStatus(byProfileId, idsOfProfilesToSetBlockStatus, blockStatus, msg.sender);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/// @inheritdoc ILensProtocol
|
|
388
|
+
function setBlockStatusWithSig(
|
|
389
|
+
uint256 byProfileId,
|
|
390
|
+
uint256[] calldata idsOfProfilesToSetBlockStatus,
|
|
391
|
+
bool[] calldata blockStatus,
|
|
392
|
+
Types.EIP712Signature calldata signature
|
|
393
|
+
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, byProfileId) {
|
|
394
|
+
MetaTxLib.validateSetBlockStatusSignature(signature, byProfileId, idsOfProfilesToSetBlockStatus, blockStatus);
|
|
395
|
+
ProfileLib.setBlockStatus(byProfileId, idsOfProfilesToSetBlockStatus, blockStatus, signature.signer);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/// @inheritdoc ILensProtocol
|
|
399
|
+
function collectLegacy(
|
|
400
|
+
Types.LegacyCollectParams calldata collectParams
|
|
401
|
+
)
|
|
402
|
+
external
|
|
403
|
+
override
|
|
404
|
+
whenNotPaused
|
|
405
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, collectParams.collectorProfileId)
|
|
406
|
+
returns (uint256)
|
|
407
|
+
{
|
|
408
|
+
return
|
|
409
|
+
LegacyCollectLib.collect({
|
|
410
|
+
collectParams: collectParams,
|
|
411
|
+
transactionExecutor: msg.sender,
|
|
412
|
+
collectorProfileOwner: ownerOf(collectParams.collectorProfileId),
|
|
413
|
+
collectNFTImpl: this.getLegacyCollectNFTImpl()
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/// @inheritdoc ILensProtocol
|
|
418
|
+
function collectLegacyWithSig(
|
|
419
|
+
Types.LegacyCollectParams calldata collectParams,
|
|
420
|
+
Types.EIP712Signature calldata signature
|
|
421
|
+
)
|
|
422
|
+
external
|
|
423
|
+
override
|
|
424
|
+
whenNotPaused
|
|
425
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, collectParams.collectorProfileId)
|
|
426
|
+
returns (uint256)
|
|
427
|
+
{
|
|
428
|
+
MetaTxLib.validateLegacyCollectSignature(signature, collectParams);
|
|
429
|
+
return
|
|
430
|
+
LegacyCollectLib.collect({
|
|
431
|
+
collectParams: collectParams,
|
|
432
|
+
transactionExecutor: signature.signer,
|
|
433
|
+
collectorProfileOwner: ownerOf(collectParams.collectorProfileId),
|
|
434
|
+
collectNFTImpl: this.getLegacyCollectNFTImpl()
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/// @inheritdoc ILensProtocol
|
|
439
|
+
function act(
|
|
440
|
+
Types.PublicationActionParams calldata publicationActionParams
|
|
441
|
+
)
|
|
442
|
+
external
|
|
443
|
+
override
|
|
444
|
+
whenNotPaused
|
|
445
|
+
onlyProfileOwnerOrDelegatedExecutor(msg.sender, publicationActionParams.actorProfileId)
|
|
446
|
+
returns (bytes memory)
|
|
447
|
+
{
|
|
448
|
+
return
|
|
449
|
+
ActionLib.act({
|
|
450
|
+
publicationActionParams: publicationActionParams,
|
|
451
|
+
transactionExecutor: msg.sender,
|
|
452
|
+
actorProfileOwner: ownerOf(publicationActionParams.actorProfileId)
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/// @inheritdoc ILensProtocol
|
|
457
|
+
function actWithSig(
|
|
458
|
+
Types.PublicationActionParams calldata publicationActionParams,
|
|
459
|
+
Types.EIP712Signature calldata signature
|
|
460
|
+
)
|
|
461
|
+
external
|
|
462
|
+
override
|
|
463
|
+
whenNotPaused
|
|
464
|
+
onlyProfileOwnerOrDelegatedExecutor(signature.signer, publicationActionParams.actorProfileId)
|
|
465
|
+
returns (bytes memory)
|
|
466
|
+
{
|
|
467
|
+
MetaTxLib.validateActSignature(signature, publicationActionParams);
|
|
468
|
+
return
|
|
469
|
+
ActionLib.act({
|
|
470
|
+
publicationActionParams: publicationActionParams,
|
|
471
|
+
transactionExecutor: signature.signer,
|
|
472
|
+
actorProfileOwner: ownerOf(publicationActionParams.actorProfileId)
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/// @inheritdoc ILensProtocol
|
|
477
|
+
function incrementNonce(uint8 increment) external {
|
|
478
|
+
MetaTxLib.incrementNonce(increment);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
///////////////////////////////////////////
|
|
482
|
+
/// EXTERNAL VIEW FUNCTIONS ///
|
|
483
|
+
///////////////////////////////////////////
|
|
484
|
+
|
|
485
|
+
/// @inheritdoc ILensProtocol
|
|
486
|
+
function isFollowing(uint256 followerProfileId, uint256 followedProfileId) external view returns (bool) {
|
|
487
|
+
address followNFT = _profiles[followedProfileId].followNFT;
|
|
488
|
+
return followNFT != address(0) && IFollowNFT(followNFT).isFollowing(followerProfileId);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/// @inheritdoc ILensProtocol
|
|
492
|
+
function isDelegatedExecutorApproved(
|
|
493
|
+
uint256 delegatorProfileId,
|
|
494
|
+
address delegatedExecutor,
|
|
495
|
+
uint64 configNumber
|
|
496
|
+
) external view returns (bool) {
|
|
497
|
+
return StorageLib.getDelegatedExecutorsConfig(delegatorProfileId).isApproved[configNumber][delegatedExecutor];
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/// @inheritdoc ILensProtocol
|
|
501
|
+
function isDelegatedExecutorApproved(
|
|
502
|
+
uint256 delegatorProfileId,
|
|
503
|
+
address delegatedExecutor
|
|
504
|
+
) external view returns (bool) {
|
|
505
|
+
return ProfileLib.isExecutorApproved(delegatorProfileId, delegatedExecutor);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/// @inheritdoc ILensProtocol
|
|
509
|
+
function getDelegatedExecutorsConfigNumber(uint256 delegatorProfileId) external view returns (uint64) {
|
|
510
|
+
return StorageLib.getDelegatedExecutorsConfig(delegatorProfileId).configNumber;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/// @inheritdoc ILensProtocol
|
|
514
|
+
function getDelegatedExecutorsPrevConfigNumber(uint256 delegatorProfileId) external view returns (uint64) {
|
|
515
|
+
return StorageLib.getDelegatedExecutorsConfig(delegatorProfileId).prevConfigNumber;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/// @inheritdoc ILensProtocol
|
|
519
|
+
function getDelegatedExecutorsMaxConfigNumberSet(uint256 delegatorProfileId) external view returns (uint64) {
|
|
520
|
+
return StorageLib.getDelegatedExecutorsConfig(delegatorProfileId).maxConfigNumberSet;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/// @inheritdoc ILensProtocol
|
|
524
|
+
function isBlocked(uint256 profileId, uint256 byProfileId) external view returns (bool) {
|
|
525
|
+
return _blockedStatus[byProfileId][profileId];
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/// @inheritdoc ILensProtocol
|
|
529
|
+
function getContentURI(uint256 profileId, uint256 pubId) external view override returns (string memory) {
|
|
530
|
+
// This function is used by the Collect NFTs' tokenURI function.
|
|
531
|
+
return PublicationLib.getContentURI(profileId, pubId);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/// @inheritdoc ILensProtocol
|
|
535
|
+
function getProfile(uint256 profileId) external view override returns (Types.Profile memory) {
|
|
536
|
+
return _profiles[profileId];
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/// @inheritdoc ILensProtocol
|
|
540
|
+
function getPublication(
|
|
541
|
+
uint256 profileId,
|
|
542
|
+
uint256 pubId
|
|
543
|
+
) external pure override returns (Types.PublicationMemory memory) {
|
|
544
|
+
return StorageLib.getPublicationMemory(profileId, pubId);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/// @inheritdoc ILensProtocol
|
|
548
|
+
function isActionModuleEnabledInPublication(
|
|
549
|
+
uint256 profileId,
|
|
550
|
+
uint256 pubId,
|
|
551
|
+
address module
|
|
552
|
+
) external view returns (bool) {
|
|
553
|
+
return StorageLib.getPublication(profileId, pubId).actionModuleEnabled[module];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/// @inheritdoc ILensProtocol
|
|
557
|
+
function getPublicationType(
|
|
558
|
+
uint256 profileId,
|
|
559
|
+
uint256 pubId
|
|
560
|
+
) external view override returns (Types.PublicationType) {
|
|
561
|
+
return PublicationLib.getPublicationType(profileId, pubId);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function getFollowModule(uint256 profileId) external view returns (address) {
|
|
565
|
+
if (__DEPRECATED__collectModuleWhitelisted[msg.sender]) {
|
|
566
|
+
// Injecting LensHub as follow module when a Lens V1 collect module is performing the call.
|
|
567
|
+
// This is a hack to make legacy collect work when configured for followers only.
|
|
568
|
+
return address(this);
|
|
569
|
+
} else {
|
|
570
|
+
return StorageLib.getProfile(profileId).followModule;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function isFollowing(
|
|
575
|
+
uint256 followedProfileId,
|
|
576
|
+
address followerAddress,
|
|
577
|
+
uint256 /* tokenId */
|
|
578
|
+
) external view returns (bool) {
|
|
579
|
+
if (__DEPRECATED__collectModuleWhitelisted[msg.sender]) {
|
|
580
|
+
// This state was pre-filled at LegacyCollectLib and it is a hack to make legacy collect work when
|
|
581
|
+
// configured for followers only.
|
|
582
|
+
return
|
|
583
|
+
_legacyCollectFollowValidationHelper[followerAddress] == followedProfileId ||
|
|
584
|
+
ProfileLib.isExecutorApproved(followedProfileId, followerAddress) ||
|
|
585
|
+
ProfileLib.ownerOf(followedProfileId) == followerAddress;
|
|
586
|
+
} else {
|
|
587
|
+
revert Errors.ExecutorInvalid();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|