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

chore: In r/demo/boards public API, change AssertOriginCall() to PrevRealm().IsUser() #2358

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Changes from 3 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
24 changes: 18 additions & 6 deletions examples/gno.land/r/demo/boards/public.gno
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func GetBoardIDFromName(name string) (BoardID, bool) {
}

func CreateBoard(name string) BoardID {
std.AssertOriginCall()
if !(std.IsOriginCall() || std.PrevRealm().IsUser()) {
panic("invalid non-user call")
}
bid := incGetBoardID()
caller := std.GetOrigCaller()
if usernameOf(caller) == "" {
Expand All @@ -41,7 +43,9 @@ func checkAnonFee() bool {
}

func CreateThread(bid BoardID, title string, body string) PostID {
std.AssertOriginCall()
if !(std.IsOriginCall() || std.PrevRealm().IsUser()) {
panic("invalid non-user call")
}
caller := std.GetOrigCaller()
if usernameOf(caller) == "" {
if !checkAnonFee() {
Expand All @@ -57,7 +61,9 @@ func CreateThread(bid BoardID, title string, body string) PostID {
}

func CreateReply(bid BoardID, threadid, postid PostID, body string) PostID {
std.AssertOriginCall()
if !(std.IsOriginCall() || std.PrevRealm().IsUser()) {
panic("invalid non-user call")
}
caller := std.GetOrigCaller()
if usernameOf(caller) == "" {
if !checkAnonFee() {
Expand Down Expand Up @@ -85,7 +91,9 @@ func CreateReply(bid BoardID, threadid, postid PostID, body string) PostID {
// If dstBoard is private, does not ping back.
// If board specified by bid is private, panics.
func CreateRepost(bid BoardID, postid PostID, title string, body string, dstBoardID BoardID) PostID {
std.AssertOriginCall()
if !(std.IsOriginCall() || std.PrevRealm().IsUser()) {
panic("invalid non-user call")
}
caller := std.GetOrigCaller()
if usernameOf(caller) == "" {
// TODO: allow with gDefaultAnonFee payment.
Expand Down Expand Up @@ -113,7 +121,9 @@ func CreateRepost(bid BoardID, postid PostID, title string, body string, dstBoar
}

func DeletePost(bid BoardID, threadid, postid PostID, reason string) {
std.AssertOriginCall()
if !(std.IsOriginCall() || std.PrevRealm().IsUser()) {
panic("invalid non-user call")
}
caller := std.GetOrigCaller()
board := getBoard(bid)
if board == nil {
Expand Down Expand Up @@ -143,7 +153,9 @@ func DeletePost(bid BoardID, threadid, postid PostID, reason string) {
}

func EditPost(bid BoardID, threadid, postid PostID, title, body string) {
std.AssertOriginCall()
if !(std.IsOriginCall() || std.PrevRealm().IsUser()) {
panic("invalid non-user call")
}
caller := std.GetOrigCaller()
board := getBoard(bid)
if board == nil {
Expand Down
Loading