Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion api/p/memeland/memeland.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"gno.land/p/demo/avl"
"gno.land/p/demo/ownable"
"gno.land/p/demo/seqid"
"gno.land/r/demo/users"
)

const (
Expand Down Expand Up @@ -40,6 +41,12 @@ func NewMemeland() *Memeland {

// PostMeme - Adds a new post
func (m *Memeland) PostMeme(data string, timestamp int64) string {
caller := std.PrevRealm().Addr()

if users.GetUserByAddress(caller) == nil {
panic("you need to be registered in r/demo/users to post!")
}

if data == "" || timestamp <= 0 {
panic("timestamp or data cannot be empty")
}
Expand All @@ -50,7 +57,7 @@ func (m *Memeland) PostMeme(data string, timestamp int64) string {
newPost := &Post{
ID: id,
Data: data,
Author: std.PrevRealm().Addr(),
Author: caller,
Timestamp: time.Unix(timestamp, 0),
UpvoteTracker: avl.NewTree(),
}
Expand Down