Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: user registration #19

Closed
wants to merge 3 commits into from
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