-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataTypes.sol
380 lines (358 loc) · 15.9 KB
/
DataTypes.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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
/**
* @title DataTypes
* @author Lens Protocol
*
* @notice A standard library of data types used throughout the Lens Protocol.
*/
library DataTypes {
/**
* @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 {
Unpaused,
PublishingPaused,
Paused
}
/**
* @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations.
*
* @param Post A standard post, having a URI, a collect module but no pointer to another publication.
* @param Comment A comment, having a URI, a collect module and a pointer to another publication.
* @param Mirror A mirror, having a pointer to another publication, but no URI or collect module.
* @param Nonexistent An indicator showing the queried publication does not exist.
*/
enum PubType {
Post,
Comment,
Mirror,
Nonexistent
}
/**
* @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature.
*
* @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 {
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 empty.
* @param followNFT The address of the followNFT associated with this profile, can be empty..
* @param handle The profile's associated handle.
* @param imageURI The URI to be used for the profile's image.
* @param followNFTURI The URI to be used for the follow NFT.
*/
struct ProfileStruct {
uint256 pubCount;
address followModule;
address followNFT;
string handle;
string imageURI;
string followNFTURI;
}
/**
* @notice A struct containing data associated with each new publication.
*
* @param profileIdPointed The profile token ID this publication points to, for mirrors and comments.
* @param pubIdPointed The publication ID this publication points to, for mirrors and comments.
* @param contentURI The URI associated with this publication.
* @param referenceModule The address of the current reference module in use by this profile, can be empty.
* @param collectModule The address of the collect module associated with this publication, this exists for all publication.
* @param collectNFT The address of the collectNFT associated with this publication, if any.
*/
struct PublicationStruct {
uint256 profileIdPointed;
uint256 pubIdPointed;
string contentURI;
address referenceModule;
address collectModule;
address collectNFT;
}
/**
* @notice A struct containing the parameters required for the `createProfile()` function.
*
* @param to The address receiving the profile.
* @param handle The handle to set for the profile, must be unique and non-empty.
* @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.
* @param followNFTURI The URI to use for the follow NFT.
*/
struct CreateProfileData {
address to;
string handle;
string imageURI;
address followModule;
bytes followModuleInitData;
string followNFTURI;
}
/**
* @notice A struct containing the parameters required for the `setDefaultProfileWithSig()` function. Parameters are
* the same as the regular `setDefaultProfile()` function, with an added EIP712Signature.
*
* @param wallet The address of the wallet setting the default profile.
* @param profileId The token ID of the profile which will be set as default, or zero.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct SetDefaultProfileWithSigData {
address wallet;
uint256 profileId;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `setFollowModuleWithSig()` function. Parameters are
* the same as the regular `setFollowModule()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile to change the followModule for.
* @param followModule The followModule to set for the given profile, must be whitelisted.
* @param followModuleInitData The data to be passed to the followModule for initialization.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct SetFollowModuleWithSigData {
uint256 profileId;
address followModule;
bytes followModuleInitData;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `setDispatcherWithSig()` function. Parameters are the same
* as the regular `setDispatcher()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile to set the dispatcher for.
* @param dispatcher The dispatcher address to set for the profile.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct SetDispatcherWithSigData {
uint256 profileId;
address dispatcher;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `setProfileImageURIWithSig()` function. Parameters are the same
* as the regular `setProfileImageURI()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile to set the URI for.
* @param imageURI The URI to set for the given profile image.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct SetProfileImageURIWithSigData {
uint256 profileId;
string imageURI;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `setFollowNFTURIWithSig()` function. Parameters are the same
* as the regular `setFollowNFTURI()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile for which to set the followNFT URI.
* @param followNFTURI The follow NFT URI to set.
* @param sig The EIP712Signature struct containing the followNFT's associated profile owner's signature.
*/
struct SetFollowNFTURIWithSigData {
uint256 profileId;
string followNFTURI;
EIP712Signature sig;
}
/**
* @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 collectModule The collect module to set for this new publication.
* @param collectModuleInitData The data to pass to the collect module's 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 PostData {
uint256 profileId;
string contentURI;
address collectModule;
bytes collectModuleInitData;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `postWithSig()` function. Parameters are the same as
* the regular `post()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param collectModule The collectModule to set for this new publication.
* @param collectModuleInitData The data to pass to the collectModule's 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.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct PostWithSigData {
uint256 profileId;
string contentURI;
address collectModule;
bytes collectModuleInitData;
address referenceModule;
bytes referenceModuleInitData;
EIP712Signature sig;
}
/**
* @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 profileIdPointed The profile token ID to point the comment to.
* @param pubIdPointed The publication ID to point the comment to.
* @param referenceModuleData The data passed to the reference module.
* @param collectModule The collect module to set for this new publication.
* @param collectModuleInitData The data to pass to the collect module's 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 CommentData {
uint256 profileId;
string contentURI;
uint256 profileIdPointed;
uint256 pubIdPointed;
bytes referenceModuleData;
address collectModule;
bytes collectModuleInitData;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `commentWithSig()` function. Parameters are the same as
* the regular `comment()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile to publish to.
* @param contentURI The URI to set for this new publication.
* @param profileIdPointed The profile token ID to point the comment to.
* @param pubIdPointed The publication ID to point the comment to.
* @param referenceModuleData The data passed to the reference module.
* @param collectModule The collectModule to set for this new publication.
* @param collectModuleInitData The data to pass to the collectModule's 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.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct CommentWithSigData {
uint256 profileId;
string contentURI;
uint256 profileIdPointed;
uint256 pubIdPointed;
bytes referenceModuleData;
address collectModule;
bytes collectModuleInitData;
address referenceModule;
bytes referenceModuleInitData;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `mirror()` function.
*
* @param profileId The token ID of the profile to publish to.
* @param profileIdPointed The profile token ID to point the mirror to.
* @param pubIdPointed The publication ID to point the mirror to.
* @param referenceModuleData The data passed to the reference module.
* @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 MirrorData {
uint256 profileId;
uint256 profileIdPointed;
uint256 pubIdPointed;
bytes referenceModuleData;
address referenceModule;
bytes referenceModuleInitData;
}
/**
* @notice A struct containing the parameters required for the `mirrorWithSig()` function. Parameters are the same as
* the regular `mirror()` function, with an added EIP712Signature.
*
* @param profileId The token ID of the profile to publish to.
* @param profileIdPointed The profile token ID to point the mirror to.
* @param pubIdPointed The publication ID to point the mirror to.
* @param referenceModuleData The data passed to the reference module.
* @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.
* @param sig The EIP712Signature struct containing the profile owner's signature.
*/
struct MirrorWithSigData {
uint256 profileId;
uint256 profileIdPointed;
uint256 pubIdPointed;
bytes referenceModuleData;
address referenceModule;
bytes referenceModuleInitData;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `followWithSig()` function. Parameters are the same
* as the regular `follow()` function, with the follower's (signer) address and an EIP712Signature added.
*
* @param follower The follower which is the message signer.
* @param profileIds The array of token IDs of the profiles to follow.
* @param datas The array of arbitrary data to pass to the followModules if needed.
* @param sig The EIP712Signature struct containing the follower's signature.
*/
struct FollowWithSigData {
address follower;
uint256[] profileIds;
bytes[] datas;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `collectWithSig()` function. Parameters are the same as
* the regular `collect()` function, with the collector's (signer) address and an EIP712Signature added.
*
* @param collector The collector which is the message signer.
* @param profileId The token ID of the profile that published the publication to collect.
* @param pubId The publication to collect's publication ID.
* @param data The arbitrary data to pass to the collectModule if needed.
* @param sig The EIP712Signature struct containing the collector's signature.
*/
struct CollectWithSigData {
address collector;
uint256 profileId;
uint256 pubId;
bytes data;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `setProfileMetadataWithSig()` function.
*
* @param profileId The profile ID for which to set the metadata.
* @param metadata The metadata string to set for the profile and user.
* @param sig The EIP712Signature struct containing the user's signature.
*/
struct SetProfileMetadataWithSigData {
uint256 profileId;
string metadata;
EIP712Signature sig;
}
/**
* @notice A struct containing the parameters required for the `toggleFollowWithSig()` function.
*
* @param follower The follower which is the message signer.
* @param profileIds The token ID array of the profiles.
* @param enables The array of booleans to enable/disable follows.
* @param sig The EIP712Signature struct containing the follower's signature.
*/
struct ToggleFollowWithSigData {
address follower;
uint256[] profileIds;
bool[] enables;
EIP712Signature sig;
}
}