-
Notifications
You must be signed in to change notification settings - Fork 8
/
Types.sol
410 lines (387 loc) · 17.6 KB
/
Types.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
/**
* @title Types
* @author Lens Protocol
*
* @notice A standard library of data types used throughout the Lens Protocol.
*/
library Types {
/**
* @notice ERC721Timestamped storage. Contains the owner address and the mint timestamp for every NFT.
*
* Note: Instead of the owner address in the _tokenOwners private mapping, we now store it in the
* _tokenData mapping, alongside the mint timestamp.
*
* @param owner The token owner.
* @param mintTimestamp The mint timestamp.
*/
struct TokenData {
address owner;
uint96 mintTimestamp;
}
/**
* @notice A struct containing token follow-related data.
*
* @param followerProfileId The ID of the profile using the token to follow.
* @param originalFollowTimestamp The timestamp of the first follow performed with the token.
* @param followTimestamp The timestamp of the current follow, if a profile is using the token to follow.
* @param profileIdAllowedToRecover The ID of the profile allowed to recover the follow ID, if any.
*/
struct FollowData {
uint160 followerProfileId;
uint48 originalFollowTimestamp;
uint48 followTimestamp;
uint256 profileIdAllowedToRecover;
}
/**
* @notice An enum containing the different states the protocol can be in, limiting certain actions.
*
* @param Unpaused The fully unpaused state.
* @param PublishingPaused The state where only publication creation functions are paused.
* @param Paused The fully paused state.
*/
enum ProtocolState {
// TODO: Reverse order, so Paused becomes 0 and the default. This will get rid of the initializer needs.
// It needs to be done carefully, as it might pause the protocol in the Lens V2 upgrade.
Unpaused,
PublishingPaused,
Paused
}
/**
* @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations.
*
* @param Nonexistent An indicator showing the queried publication does not exist.
* @param Post A standard post, having an URI, action modules and no pointer to another publication.
* @param Comment A comment, having an URI, action modules and a pointer to another publication.
* @param Mirror A mirror, having a pointer to another publication, but no URI or action modules.
* @param Quote A quote, having an URI, action modules, and a pointer to another publication.
*/
enum PublicationType {
Nonexistent,
Post,
Comment,
Mirror,
Quote
}
/**
* @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature.
*
* @param signer The address of the signer.
* @param v The signature's recovery parameter.
* @param r The signature's r parameter.
* @param s The signature's s parameter.
* @param deadline The signature's deadline.
*/
struct EIP712Signature {
address signer;
uint8 v;
bytes32 r;
bytes32 s;
uint256 deadline;
}
/**
* @notice A struct containing profile data.
*
* @param pubCount The number of publications made to this profile.
* @param followModule The address of the current follow module in use by this profile, can be address(0) in none.
* @param followNFT The address of the followNFT associated with this profile. It can be address(0) if the
* profile has not been followed yet, as the collection is lazy-deployed upon the first follow.
* @param __DEPRECATED__handle DEPRECATED in V2: handle slot, was replaced with LensHandles.
* @param imageURI The URI to be used for the profile's image.
* @param __DEPRECATED__followNFTURI DEPRECATED in V2: The UR
* @param metadataURI MetadataURI is used to store the profile's metadata, for example: displayed name, description,
* interests, etc.
* @param metadataURI The URI to be used for the profile's metadata.
*/
struct Profile {
uint256 pubCount; // offset 0
address followModule; // offset 1
address followNFT; // offset 2
string __DEPRECATED__handle; // offset 3
string imageURI; // offset 4
string __DEPRECATED__followNFTURI; // Deprecated in V2 as we have a common tokenURI for all Follows, offset 5
string metadataURI; // offset 6
}
/**
* @notice A struct containing publication data.
*
* @param pointedProfileId The profile token ID to point the publication to.
* @param pointedPubId The publication ID to point the publication to.
* These are used to implement the "reference" feature of the platform and is used in:
* - Mirrors
* - Comments
* - Quotes
* There are (0,0) if the publication is not pointing to any other publication (i.e. the publication is a Post).
* @param contentURI The URI to set for the content of publication (can be ipfs, arweave, http, etc).
* @param referenceModule Reference module associated with this profile, if any.
* @param __DEPRECATED__collectModule Collect module associated with this publication, if any. Deprecated in V2.
* @param __DEPRECATED__collectNFT Collect NFT associated with this publication, if any. Deprecated in V2.
* @param pubType The type of publication, can be Nonexistent, Post, Comment, Mirror or Quote.
* @param rootProfileId The profile ID of the root post (to determine if comments/quotes and mirrors come from it).
* Posts, V1 publications and publications rooted in V1 publications don't have it set.
* @param rootPubId The publication ID of the root post (to determine if comments/quotes and mirrors come from it).
* Posts, V1 publications and publications rooted in V1 publications don't have it set.
* @param enabledActionModulesBitmap The action modules enabled in a given publication as a bitmap.
* The bitmap is a uint256 where each bit represents an action module: 1 if the publication uses it, 0 if not.
* You can use getActionModuleById() to get the address of the action module associated with a given bit.
* In the future this can be replaced with a getter that allows to query the bitmap by index, if there are more
* than 256 action modules.
*/
struct Publication {
uint256 pointedProfileId;
uint256 pointedPubId;
string contentURI;
address referenceModule;
address __DEPRECATED__collectModule; // Deprecated in V2
address __DEPRECATED__collectNFT; // Deprecated in V2
// Added in Lens V2, so these will be zero for old publications:
PublicationType pubType;
uint256 rootProfileId;
uint256 rootPubId;
uint256 enabledActionModulesBitmap; // In future this can be (uint256 => uint256) mapping if we need >256 modules
}
/**
* @notice A struct containing the parameters required for the `createProfile()` function.
*
* @param to The address receiving the profile.
* @param imageURI The URI to set for the profile image.
* @param followModule The follow module to use, can be the zero address.
* @param followModuleInitData The follow module initialization data, if any.
*/
struct CreateProfileParams {
address to;
string imageURI;
address followModule;
bytes followModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `post()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct PostParams {
uint256 profileId;
string contentURI;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `comment()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param pointedProfileId The profile token ID to point the comment to.
* @param pointedPubId The publication ID to point the comment to.
* @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted.
* @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted.
* @param referenceModuleData The data passed to the reference module.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct CommentParams {
uint256 profileId;
string contentURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `quote()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param pointedProfileId The profile token ID of the publication author that is quoted.
* @param pointedPubId The publication ID that is quoted.
* @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted.
* @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted.
* @param referenceModuleData The data passed to the reference module.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct QuoteParams {
uint256 profileId;
string contentURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `comment()` or `quote()` internal functions.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param pointedProfileId The profile token ID of the publication author that is commented on/quoted.
* @param pointedPubId The publication ID that is commented on/quoted.
* @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted.
* @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted.
* @param referenceModuleData The data passed to the reference module.
* @param actionModules The action modules to set for this new publication.
* @param actionModulesInitDatas The data to pass to the action modules' initialization.
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
*/
struct ReferencePubParams {
uint256 profileId;
string contentURI;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `mirror()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param pointedProfileId The profile token ID to point the mirror to.
* @param pointedPubId The publication ID to point the mirror to.
* @param referenceModuleData The data passed to the reference module.
*/
struct MirrorParams {
uint256 profileId;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
}
/**
* Deprecated in V2: Will be removed after some time after upgrading to V2.
* @notice A struct containing the parameters required for the legacy `collect()` function.
* @dev The referrer can only be a mirror of the publication being collected.
*
* @param publicationCollectedProfileId The token ID of the profile that published the publication to collect.
* @param publicationCollectedId The publication to collect's publication ID.
* @param collectorProfileId The collector profile.
* @param referrerProfileId The ID of a profile that authored a mirror that helped discovering the collected pub.
* @param referrerPubId The ID of the mirror that helped discovering the collected pub.
* @param collectModuleData The arbitrary data to pass to the collectModule if needed.
*/
struct CollectParams {
uint256 publicationCollectedProfileId;
uint256 publicationCollectedId;
uint256 collectorProfileId;
uint256 referrerProfileId;
uint256 referrerPubId;
bytes collectModuleData;
}
/**
* @notice A struct containing the parameters required for the `action()` function.
*
* @param publicationActedProfileId The token ID of the profile that published the publication to action.
* @param publicationActedId The publication to action's publication ID.
* @param actorProfileId The actor profile.
* @param referrerProfileId
* @param referrerPubId
* @param actionModuleAddress
* @param actionModuleData The arbitrary data to pass to the actionModule if needed.
*/
struct PublicationActionParams {
uint256 publicationActedProfileId;
uint256 publicationActedId;
uint256 actorProfileId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
address actionModuleAddress;
bytes actionModuleData;
}
struct ProcessActionParams {
uint256 publicationActedProfileId;
uint256 publicationActedId;
uint256 actorProfileId;
address actorProfileOwner;
address transactionExecutor;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes actionModuleData;
}
// TODO: Shouldn't this be in the modules Types?
struct ProcessCollectParams {
uint256 publicationCollectedProfileId;
uint256 publicationCollectedId;
uint256 collectorProfileId;
address collectorProfileOwner;
address transactionExecutor;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
struct ProcessCommentParams {
uint256 profileId;
address transactionExecutor;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
struct ProcessQuoteParams {
uint256 profileId;
address transactionExecutor;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
struct ProcessMirrorParams {
uint256 profileId;
address transactionExecutor;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
Types.PublicationType[] referrerPubTypes;
bytes data;
}
/**
* @notice A struct containing a profile's delegated executors configuration.
*
* @param isApproved Tells when an address is approved as delegated executor in the given configuration number.
* @param configNumber Current configuration number in use.
* @param prevConfigNumber Previous configuration number set, before switching to the current one.
* @param maxConfigNumberSet Maximum configuration number ever used.
*/
struct DelegatedExecutorsConfig {
mapping(uint256 => mapping(address => bool)) isApproved; // isApproved[configNumber][delegatedExecutor]
uint64 configNumber;
uint64 prevConfigNumber;
uint64 maxConfigNumberSet;
}
struct ActionModuleWhitelistData {
uint248 id;
bool isWhitelisted;
}
}