feat: Profile creation and follow module set event flow improved

Co-authored-by: Victor Naumik <vicnaum@gmail.com>
This commit is contained in:
donosonaumczuk
2023-08-15 21:01:10 +01:00
parent a5faf88fec
commit 5d8095172e
2 changed files with 16 additions and 29 deletions

View File

@@ -44,31 +44,15 @@ library ProfileLib {
Types.Profile storage _profile = StorageLib.getProfile(profileId);
_profile.imageURI = createProfileParams.imageURI;
bytes memory followModuleReturnData;
if (createProfileParams.followModule != address(0)) {
// Load the follow module to be used in the next assembly block.
address followModule = createProfileParams.followModule;
StorageLib.getProfile(profileId).followModule = followModule;
// We don't need to check for deprecated modules here because deprecated ones are no longer whitelisted.
// Initialize the follow module.
followModuleReturnData = _initFollowModule({
profileId: profileId,
transactionExecutor: msg.sender,
followModule: createProfileParams.followModule,
followModuleInitData: createProfileParams.followModuleInitData
});
}
emit Events.ProfileCreated(
profileId,
msg.sender,
createProfileParams.to,
createProfileParams.imageURI,
createProfileParams.followModule,
followModuleReturnData,
block.timestamp
);
_setFollowModule(profileId, createProfileParams.followModule, createProfileParams.followModuleInitData);
}
/**
@@ -94,12 +78,7 @@ library ProfileLib {
address followModule,
bytes calldata followModuleInitData
) external {
StorageLib.getProfile(profileId).followModule = followModule;
bytes memory followModuleReturnData;
if (followModule != address(0)) {
followModuleReturnData = _initFollowModule(profileId, msg.sender, followModule, followModuleInitData);
}
emit Events.FollowModuleSet(profileId, followModule, followModuleReturnData, block.timestamp);
_setFollowModule(profileId, followModule, followModuleInitData);
}
function setProfileMetadataURI(uint256 profileId, string calldata metadataURI) external {
@@ -287,4 +266,17 @@ library ProfileLib {
}
return configSwitched;
}
function _setFollowModule(
uint256 profileId,
address followModule,
bytes calldata followModuleInitData
) private {
StorageLib.getProfile(profileId).followModule = followModule;
bytes memory followModuleReturnData;
if (followModule != address(0)) {
followModuleReturnData = _initFollowModule(profileId, msg.sender, followModule, followModuleInitData);
}
emit Events.FollowModuleSet(profileId, followModule, followModuleReturnData, block.timestamp);
}
}

View File

@@ -110,9 +110,6 @@ library Events {
* @param creator The profile creator, who created the token with the given profile ID.
* @param to The address receiving the profile with the given profile ID.
* @param imageURI The image URI set for the profile.
* @param followModule The profile's newly set follow module. This CAN be the zero address.
* @param followModuleReturnData The data returned from the follow module's initialization. This is ABI-encoded
* and totally depends on the follow module chosen.
* @param timestamp The current block timestamp.
*/
event ProfileCreated(
@@ -120,8 +117,6 @@ library Events {
address indexed creator,
address indexed to,
string imageURI,
address followModule,
bytes followModuleReturnData,
uint256 timestamp
);