step 2: add NewPost event
This commit is contained in:
parent
393b39d973
commit
7de9fa3898
|
@ -10,13 +10,22 @@ contract DReddit {
|
|||
|
||||
Post [] public posts;
|
||||
|
||||
event NewPost(
|
||||
uint indexed postId,
|
||||
address owner,
|
||||
bytes description
|
||||
);
|
||||
|
||||
function createPost(bytes memory _description) public {
|
||||
uint postId = posts.length++;
|
||||
|
||||
posts[postId] = Post({
|
||||
creationDate: block.timestamp,
|
||||
description: _description,
|
||||
owner: msg.sender
|
||||
});
|
||||
|
||||
emit NewPost(postId, msg.sender, _description);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue