diff --git a/examples/gno.land/r/demo/boards/public.gno b/examples/gno.land/r/demo/boards/public.gno index 1d26126fcb2..8487c78081d 100644 --- a/examples/gno.land/r/demo/boards/public.gno +++ b/examples/gno.land/r/demo/boards/public.gno @@ -20,6 +20,7 @@ func CreateBoard(name string) BoardID { if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { panic("invalid non-user call") } + bid := incGetBoardID() caller := std.GetOrigCaller() if usernameOf(caller) == "" { diff --git a/examples/gno.land/r/demo/boards/z_0_a_filetest.gno b/examples/gno.land/r/demo/boards/z_0_a_filetest.gno new file mode 100644 index 00000000000..9dda564c1d8 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_0_a_filetest.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards + +import ( + "gno.land/r/demo/boards" +) + +var bid boards.BoardID + +func init() { + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid := boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + boards.CreateReply(bid, pid, pid, "Reply of the second post") +} + +func main() { + println(boards.Render("test_board")) +} + +// Error: +// expected package name [boards_test] but got [boards] diff --git a/examples/gno.land/r/demo/boards/z_0_c_filetest.gno b/examples/gno.land/r/demo/boards/z_0_c_filetest.gno new file mode 100644 index 00000000000..c894cde055b --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_0_c_filetest.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var bid boards.BoardID + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller +users.Register("gnouser123") + boards.CreateThread(1, "First Post (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board")) +} + +// Error: +// board not exist diff --git a/examples/gno.land/r/demo/boards/z_0_d_filetest.gno b/examples/gno.land/r/demo/boards/z_0_d_filetest.gno new file mode 100644 index 00000000000..14f5130fef6 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_0_d_filetest.gno @@ -0,0 +1,28 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var bid boards.BoardID + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller +users.Register("gnouser123") + bid = boards.CreateBoard("test_board") + boards.CreateReply(bid, 0, 0, "Reply of the second post") +} + +func main() { + println(boards.Render("test_board")) +} + +// Error: +// thread not exist diff --git a/examples/gno.land/r/demo/boards/z_0_e_filetest.gno b/examples/gno.land/r/demo/boards/z_0_e_filetest.gno new file mode 100644 index 00000000000..7c5aa4aad5e --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_0_e_filetest.gno @@ -0,0 +1,26 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var bid boards.BoardID + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + boards.CreateReply(bid, 0, 0, "Reply of the second post") +} + +func main() { + println(boards.Render("test_board")) +} + +// Error: +// board not exist diff --git a/examples/gno.land/r/demo/boards/z_0_filetest.gno b/examples/gno.land/r/demo/boards/z_0_filetest.gno new file mode 100644 index 00000000000..52ea5af0675 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_0_filetest.gno @@ -0,0 +1,41 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +import ( + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" + "std" +) + +var bid boards.BoardID + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + err := users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid := boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + boards.CreateReply(bid, pid, pid, "Reply of the second post") +} + +func main() { + println(boards.Render("test_board")) +} + +// Output: +// \[[post](/r/demo/boards$help&func=CreateThread&bid=1)] +// +// ---------------------------------------- +// ## [First Post (title)](/r/demo/boards:test_board/1) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] (0 replies) (0 reposts) +// +// ---------------------------------------- +// ## [Second Post (title)](/r/demo/boards:test_board/2) +// +// Body of the second post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/2) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] (1 replies) (0 reposts) +// +// diff --git a/examples/gno.land/r/demo/boards/z_10_a_filetest.gno b/examples/gno.land/r/demo/boards/z_10_a_filetest.gno new file mode 100644 index 00000000000..9a763f5ad16 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_10_a_filetest.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + // boardId 2 not exist + boards.DeletePost(2, pid, pid, "") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// board not exist diff --git a/examples/gno.land/r/demo/boards/z_10_b_filetest.gno b/examples/gno.land/r/demo/boards/z_10_b_filetest.gno new file mode 100644 index 00000000000..0c56c63e5f5 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_10_b_filetest.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + // pid of 2 not exist + boards.DeletePost(bid, 2, 2, "") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// thread not exist diff --git a/examples/gno.land/r/demo/boards/z_10_c_filetest.gno b/examples/gno.land/r/demo/boards/z_10_c_filetest.gno new file mode 100644 index 00000000000..1bece167a20 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_10_c_filetest.gno @@ -0,0 +1,51 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID + rid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") + rid = boards.CreateReply(bid, pid, pid, "First reply of the First post\n") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + boards.DeletePost(bid, pid, rid, "") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// +// > First reply of the First post +// > +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=2)] +// +// ---------------------------------------------------- +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// diff --git a/examples/gno.land/r/demo/boards/z_10_filetest.gno b/examples/gno.land/r/demo/boards/z_10_filetest.gno new file mode 100644 index 00000000000..ece633fe355 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_10_filetest.gno @@ -0,0 +1,41 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + boards.DeletePost(bid, pid, pid, "") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// +// ---------------------------------------------------- +// thread does not exist with id: 1 diff --git a/examples/gno.land/r/demo/boards/z_11_a_filetest.gno b/examples/gno.land/r/demo/boards/z_11_a_filetest.gno new file mode 100644 index 00000000000..81e840c378e --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_11_a_filetest.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + // board 2 not exist + boards.EditPost(2, pid, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// board not exist diff --git a/examples/gno.land/r/demo/boards/z_11_b_filetest.gno b/examples/gno.land/r/demo/boards/z_11_b_filetest.gno new file mode 100644 index 00000000000..34b26b07b96 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_11_b_filetest.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + // thread 2 not exist + boards.EditPost(bid, 2, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// thread not exist diff --git a/examples/gno.land/r/demo/boards/z_11_c_filetest.gno b/examples/gno.land/r/demo/boards/z_11_c_filetest.gno new file mode 100644 index 00000000000..772c6758a8a --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_11_c_filetest.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + // post 2 not exist + boards.EditPost(bid, pid, 2, "Edited: First Post in (title)", "Edited: Body of the first post. (body)") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// post not exist diff --git a/examples/gno.land/r/demo/boards/z_11_d_filetest.gno b/examples/gno.land/r/demo/boards/z_11_d_filetest.gno new file mode 100644 index 00000000000..9958c493993 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_11_d_filetest.gno @@ -0,0 +1,55 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID + rid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") + rid = boards.CreateReply(bid, pid, pid, "First reply of the First post\n") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + boards.EditPost(bid, pid, rid, "", "Edited: First reply of the First post\n") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// +// > First reply of the First post +// > +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=2)] +// +// ---------------------------------------------------- +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// +// > Edited: First reply of the First post +// > +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=2)] +// diff --git a/examples/gno.land/r/demo/boards/z_11_filetest.gno b/examples/gno.land/r/demo/boards/z_11_filetest.gno new file mode 100644 index 00000000000..2e8849830d4 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_11_filetest.gno @@ -0,0 +1,45 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + pid = boards.CreateThread(bid, "First Post in (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + boards.EditPost(bid, pid, pid, "Edited: First Post in (title)", "Edited: Body of the first post. (body)") + println("----------------------------------------------------") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// +// ---------------------------------------------------- +// # Edited: First Post in (title) +// +// Edited: Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// diff --git a/examples/gno.land/r/demo/boards/z_12_a_filetest.gno b/examples/gno.land/r/demo/boards/z_12_a_filetest.gno new file mode 100644 index 00000000000..fa714153c78 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_12_a_filetest.gno @@ -0,0 +1,33 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/p/demo/testutils" + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + // create a post via registered user + bid1 := boards.CreateBoard("test_board1") + pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") + bid2 := boards.CreateBoard("test_board2") + + // create a repost via anon user + test2 := testutils.TestAddress("test2") + std.TestSetOrigCaller(test2) + std.TestSetOrigSend(std.Coins{{"ugnot", 9000000}}, nil) + + rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2) + println(rid) + println(boards.Render("test_board1")) +} + +// Error: +// please register, otherwise minimum fee 100000000 is required if anonymous diff --git a/examples/gno.land/r/demo/boards/z_12_b_filetest.gno b/examples/gno.land/r/demo/boards/z_12_b_filetest.gno new file mode 100644 index 00000000000..6911f2bdd76 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_12_b_filetest.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + bid1 := boards.CreateBoard("test_board1") + pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") + bid2 := boards.CreateBoard("test_board2") + + // create a repost to a non-existing board + rid := boards.CreateRepost(5, pid, "", "Check this out", bid2) + println(rid) + println(boards.Render("test_board1")) +} + +// Error: +// src board not exist diff --git a/examples/gno.land/r/demo/boards/z_12_c_filetest.gno b/examples/gno.land/r/demo/boards/z_12_c_filetest.gno new file mode 100644 index 00000000000..5ffa884ee4f --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_12_c_filetest.gno @@ -0,0 +1,26 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" + "std" +) + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + bid1 := boards.CreateBoard("test_board1") + boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") + bid2 := boards.CreateBoard("test_board2") + + // create a repost to a non-existing thread + rid := boards.CreateRepost(bid1, 5, "", "Check this out", bid2) + println(rid) + println(boards.Render("test_board1")) +} + +// Error: +// thread not exist diff --git a/examples/gno.land/r/demo/boards/z_12_d_filetest.gno b/examples/gno.land/r/demo/boards/z_12_d_filetest.gno new file mode 100644 index 00000000000..137b2637328 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_12_d_filetest.gno @@ -0,0 +1,26 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" + "std" +) + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + bid1 := boards.CreateBoard("test_board1") + pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") + boards.CreateBoard("test_board2") + + // create a repost to a non-existing destination board + rid := boards.CreateRepost(bid1, pid, "", "Check this out", 5) + println(rid) + println(boards.Render("test_board1")) +} + +// Error: +// dst board not exist diff --git a/examples/gno.land/r/demo/boards/z_12_filetest.gno b/examples/gno.land/r/demo/boards/z_12_filetest.gno new file mode 100644 index 00000000000..a780874b7a1 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_12_filetest.gno @@ -0,0 +1,45 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid1 boards.BoardID + bid2 boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid1 = boards.CreateBoard("test_board1") + pid = boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") + bid2 = boards.CreateBoard("test_board2") +} + +func main() { + rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2) + println(rid) + println(boards.Render("test_board2")) +} + +// Output: +// 1 +// \[[post](/r/demo/boards$help&func=CreateThread&bid=2)] +// +// ---------------------------------------- +// Repost: Check this out +// ## [First Post (title)](/r/demo/boards:test_board1/1) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board1/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] (0 replies) (1 reposts) +// +// diff --git a/examples/gno.land/r/demo/boards/z_1_filetest.gno b/examples/gno.land/r/demo/boards/z_1_filetest.gno new file mode 100644 index 00000000000..07a978a38c1 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_1_filetest.gno @@ -0,0 +1,32 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var board *boards.Board + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + _ = boards.CreateBoard("test_board_1") + _ = boards.CreateBoard("test_board_2") +} + +func main() { + println(boards.Render("")) +} + +// Output: +// These are all the boards of this realm: +// +// * [/r/demo/boards:test_board_1](/r/demo/boards:test_board_1) +// * [/r/demo/boards:test_board_2](/r/demo/boards:test_board_2) +// diff --git a/examples/gno.land/r/demo/boards/z_2_filetest.gno b/examples/gno.land/r/demo/boards/z_2_filetest.gno new file mode 100644 index 00000000000..4a4d3c94011 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_2_filetest.gno @@ -0,0 +1,41 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + boards.CreateReply(bid, pid, pid, "Reply of the second post") +} + +func main() { + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # Second Post (title) +// +// Body of the second post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=2)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] +// +// > Reply of the second post +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/3) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=3)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=3)] +// diff --git a/examples/gno.land/r/demo/boards/z_3_filetest.gno b/examples/gno.land/r/demo/boards/z_3_filetest.gno new file mode 100644 index 00000000000..d60ea25c710 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_3_filetest.gno @@ -0,0 +1,43 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") +} + +func main() { + rid := boards.CreateReply(bid, pid, pid, "Reply of the second post") + println(rid) + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// 3 +// # Second Post (title) +// +// Body of the second post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=2)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] +// +// > Reply of the second post +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/3) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=3)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=3)] +// diff --git a/examples/gno.land/r/demo/boards/z_4_filetest.gno b/examples/gno.land/r/demo/boards/z_4_filetest.gno new file mode 100644 index 00000000000..e9d4a08f379 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_4_filetest.gno @@ -0,0 +1,921 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + rid := boards.CreateReply(bid, pid, pid, "Reply of the second post") + println(rid) +} + +func main() { + rid2 := boards.CreateReply(bid, pid, pid, "Second reply of the second post") + println(rid2) + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// 3 +// 4 +// # Second Post (title) +// +// Body of the second post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=2)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] +// +// > Reply of the second post +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/3) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=3)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=3)] +// +// > Second reply of the second post +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/4) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=4)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=4)] +// + +// Realm: +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/demo/boards"] +// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:111]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:111", +// "ModTime": "123", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:123", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "68663c8895d37d479e417c11e21badfe21345c61", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:112" +// } +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:125]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "0000000004" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.Post" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:126" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "64" +// } +// }, +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:125", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:124", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:124]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:124", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:123", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "3f34ac77289aa1d5f9a2f8b6d083138325816fb0", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:125" +// } +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:123]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "0000000004" +// } +// }, +// {}, +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "64" +// } +// }, +// { +// "N": "AgAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "94a6665a44bac6ede7f3e3b87173e537b12f9532", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:111" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "bc8e5b4e782a0bbc4ac9689681f119beb7b34d59", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:124" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:123", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:122", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:122]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:122", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:106", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "9957eadbc91dd32f33b0d815e041a32dbdea0671", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:123" +// } +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:128]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:128", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:129]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:129", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:130]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:130", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131]={ +// "Fields": [ +// { +// "N": "AAAAgJSeXbo=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "65536" +// } +// }, +// { +// "N": "AbSNdvQQIhE=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "1024" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "time.Location" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "336074805fc853987abe6f7fe3ad97a6a6f3077a:2" +// }, +// "Index": "182", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:132]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "65536" +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "1024" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "time.Location" +// } +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:132", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.Board" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:84" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "N": "BAAAAAAAAAA=", +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.PostID" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "std.Address" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "" +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "Second reply of the second post" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Tree" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "f91e355bd19240f0f3350a7fa0e6a82b72225916", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:128" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Tree" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "9ee9c4117be283fc51ffcc5ecd65b75ecef5a9dd", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:129" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Tree" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "eb768b0140a5fe95f9c58747f0960d647dacfd42", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:130" +// } +// }, +// { +// "N": "AgAAAAAAAAA=", +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.PostID" +// } +// }, +// { +// "N": "AgAAAAAAAAA=", +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.PostID" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.BoardID" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "time.Time" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "0fd3352422af0a56a77ef2c9e88f479054e3d51f", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "time.Time" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "bed4afa8ffdbbf775451c947fc68b27a345ce32a", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:132" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:126", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:126]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:126", +// "IsEscaped": true, +// "ModTime": "0", +// "RefCount": "2" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.Post" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "c45bbd47a46681a63af973db0ec2180922e4a8ae", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127" +// } +// } +// } +// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:120]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:120", +// "ModTime": "134", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:134", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "dc1f011553dc53e7a846049e08cc77fa35ea6a51", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:121" +// } +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:136]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "0000000004" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.Post" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:126" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "64" +// } +// }, +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:136", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:135", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:135]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:135", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:134", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "96b86b4585c7f1075d7794180a5581f72733a7ab", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:136" +// } +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:134]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "0000000004" +// } +// }, +// {}, +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "64" +// } +// }, +// { +// "N": "AgAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "32274e1f28fb2b97d67a1262afd362d370de7faa", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:120" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "c2cfd6aec36a462f35bf02e5bf4a127aa1bb7ac2", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:135" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:134", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:133", +// "RefCount": "1" +// } +// } +// c[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:133]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:133", +// "ModTime": "0", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:107", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "5cb875179e86d32c517322af7a323b2a5f3e6cc5", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:134" +// } +// } +// } +// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:85]={ +// "Fields": [ +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.BoardID" +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "/r/demo/boards:test_board" +// } +// }, +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "test_board" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "std.Address" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Tree" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "a416a751c3a45a1e5cba11e737c51340b081e372", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:86" +// } +// }, +// { +// "N": "BAAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "65536" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "time.Time" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "36299fccbc13f2a84c4629fad4cb940f0bd4b1c6", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:87" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Tree" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "af6ed0268f99b7f369329094eb6dfaea7812708b", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:88" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:85", +// "ModTime": "121", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:84", +// "RefCount": "1" +// } +// } +// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:106]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "9809329dc1ddc5d3556f7a8fa3c2cebcbf65560b", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:122" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:106", +// "ModTime": "121", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:105", +// "RefCount": "1" +// } +// } +// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:107]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/avl.Node" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "ceae9a1c4ed28bb51062e6ccdccfad0caafd1c4f", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:133" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:107", +// "ModTime": "121", +// "OwnerID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:105", +// "RefCount": "1" +// } +// } +// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:84]={ +// "ObjectInfo": { +// "ID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:84", +// "IsEscaped": true, +// "ModTime": "127", +// "RefCount": "6" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/boards.Board" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "a88a9b837af217656ee27084309f7cd02cd94cb3", +// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:85" +// } +// } +// } +// switchrealm["gno.land/r/demo/boards"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/sys/users"] +// switchrealm["gno.land/r/demo/boards"] +// switchrealm["gno.land/r/demo/boards_test"] diff --git a/examples/gno.land/r/demo/boards/z_5_b_filetest.gno b/examples/gno.land/r/demo/boards/z_5_b_filetest.gno new file mode 100644 index 00000000000..148e598de3d --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_5_b_filetest.gno @@ -0,0 +1,32 @@ +package main + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/p/demo/testutils" + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + // create board via registered user + bid := boards.CreateBoard("test_board") + + // create post via anon user + test2 := testutils.TestAddress("test2") + std.TestSetOrigCaller(test2) + std.TestSetOrigSend(std.Coins{{"ugnot", 9000000}}, nil) + + pid := boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// please register, otherwise minimum fee 100000000 is required if anonymous diff --git a/examples/gno.land/r/demo/boards/z_5_c_filetest.gno b/examples/gno.land/r/demo/boards/z_5_c_filetest.gno new file mode 100644 index 00000000000..2faaefeef44 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_5_c_filetest.gno @@ -0,0 +1,41 @@ +package main + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/p/demo/testutils" + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + // create board via registered user + bid := boards.CreateBoard("test_board") + + // create post via anon user + test2 := testutils.TestAddress("test2") + std.TestSetOrigCaller(test2) + std.TestSetOrigSend(std.Coins{{"ugnot", 101000000}}, nil) + + pid := boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + boards.CreateReply(bid, pid, pid, "Reply of the first post") + + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # First Post (title) +// +// Body of the first post. (body) +// \- [g1w3jhxapjta047h6lta047h6lta047h6laqcyu4](/r/gnoland/users/v1:g1w3jhxapjta047h6lta047h6lta047h6laqcyu4), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=1)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] +// +// > Reply of the first post +// > \- [g1w3jhxapjta047h6lta047h6lta047h6laqcyu4](/r/gnoland/users/v1:g1w3jhxapjta047h6lta047h6lta047h6laqcyu4), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/1/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=2)] +// diff --git a/examples/gno.land/r/demo/boards/z_5_d_filetest.gno b/examples/gno.land/r/demo/boards/z_5_d_filetest.gno new file mode 100644 index 00000000000..9dc0ddb9665 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_5_d_filetest.gno @@ -0,0 +1,33 @@ +package main + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/p/demo/testutils" + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") + +func main() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + // create board via registered user + bid := boards.CreateBoard("test_board") + pid := boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + + // create reply via anon user + test2 := testutils.TestAddress("test2") + std.TestSetOrigCaller(test2) + std.TestSetOrigSend(std.Coins{{"ugnot", 9000000}}, nil) + boards.CreateReply(bid, pid, pid, "Reply of the first post") + + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Error: +// please register, otherwise minimum fee 100000000 is required if anonymous diff --git a/examples/gno.land/r/demo/boards/z_5_filetest.gno b/examples/gno.land/r/demo/boards/z_5_filetest.gno new file mode 100644 index 00000000000..f04ea5a0b7e --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_5_filetest.gno @@ -0,0 +1,46 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + rid := boards.CreateReply(bid, pid, pid, "Reply of the second post") +} + +func main() { + rid2 := boards.CreateReply(bid, pid, pid, "Second reply of the second post\n") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # Second Post (title) +// +// Body of the second post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=2)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] +// +// > Reply of the second post +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/3) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=3)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=3)] +// +// > Second reply of the second post +// > +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/4) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=4)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=4)] +// diff --git a/examples/gno.land/r/demo/boards/z_6_filetest.gno b/examples/gno.land/r/demo/boards/z_6_filetest.gno new file mode 100644 index 00000000000..a41c2cbad97 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_6_filetest.gno @@ -0,0 +1,52 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID + rid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + rid = boards.CreateReply(bid, pid, pid, "Reply of the second post") +} + +func main() { + boards.CreateReply(bid, pid, pid, "Second reply of the second post\n") + boards.CreateReply(bid, pid, rid, "First reply of the first reply\n") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # Second Post (title) +// +// Body of the second post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=2)] \[[repost](/r/demo/boards$help&func=CreateRepost&bid=1&postid=2)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=2)] +// +// > Reply of the second post +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/3) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=3)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=3)] +// > +// > > First reply of the first reply +// > > +// > > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/5) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=5)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=5)] +// +// > Second reply of the second post +// > +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/4) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=4)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=4)] +// diff --git a/examples/gno.land/r/demo/boards/z_7_filetest.gno b/examples/gno.land/r/demo/boards/z_7_filetest.gno new file mode 100644 index 00000000000..1e98458a4cd --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_7_filetest.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +func init() { + // register + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + // create board and post + bid := boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") +} + +func main() { + println(boards.Render("test_board")) +} + +// Output: +// \[[post](/r/demo/boards$help&func=CreateThread&bid=1)] +// +// ---------------------------------------- +// ## [First Post (title)](/r/demo/boards:test_board/1) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm UTC](/r/demo/boards:test_board/1) \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=1&postid=1)] (0 replies) (0 reposts) +// +// diff --git a/examples/gno.land/r/demo/boards/z_8_filetest.gno b/examples/gno.land/r/demo/boards/z_8_filetest.gno new file mode 100644 index 00000000000..ca179b7775e --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_8_filetest.gno @@ -0,0 +1,47 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + bid boards.BoardID + pid boards.PostID + rid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + bid = boards.CreateBoard("test_board") + boards.CreateThread(bid, "First Post (title)", "Body of the first post. (body)") + pid = boards.CreateThread(bid, "Second Post (title)", "Body of the second post. (body)") + rid = boards.CreateReply(bid, pid, pid, "Reply of the second post") +} + +func main() { + boards.CreateReply(bid, pid, pid, "Second reply of the second post\n") + rid2 := boards.CreateReply(bid, pid, rid, "First reply of the first reply\n") + println(boards.Render("test_board/" + strconv.Itoa(int(pid)) + "/" + strconv.Itoa(int(rid2)))) +} + +// Output: +// _[see thread](/r/demo/boards:test_board/2)_ +// +// Reply of the second post +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/3) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=3)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=3)] +// +// _[see all 1 replies](/r/demo/boards:test_board/2/3)_ +// +// > First reply of the first reply +// > +// > \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:test_board/2/5) \[[reply](/r/demo/boards$help&func=CreateReply&bid=1&threadid=2&postid=5)] \[[x](/r/demo/boards$help&func=DeletePost&bid=1&threadid=2&postid=5)] +// diff --git a/examples/gno.land/r/demo/boards/z_9_a_filetest.gno b/examples/gno.land/r/demo/boards/z_9_a_filetest.gno new file mode 100644 index 00000000000..aff09b4aa0a --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_9_a_filetest.gno @@ -0,0 +1,28 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var dstBoard boards.BoardID + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + dstBoard = boards.CreateBoard("dst_board") + + boards.CreateRepost(0, 0, "First Post in (title)", "Body of the first post. (body)", dstBoard) +} + +func main() { +} + +// Error: +// src board not exist diff --git a/examples/gno.land/r/demo/boards/z_9_b_filetest.gno b/examples/gno.land/r/demo/boards/z_9_b_filetest.gno new file mode 100644 index 00000000000..ac017b40a0f --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_9_b_filetest.gno @@ -0,0 +1,32 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + srcBoard boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + srcBoard = boards.CreateBoard("first_board") + pid = boards.CreateThread(srcBoard, "First Post in (title)", "Body of the first post. (body)") + + boards.CreateRepost(srcBoard, pid, "First Post in (title)", "Body of the first post. (body)", 0) +} + +func main() { +} + +// Error: +// dst board not exist diff --git a/examples/gno.land/r/demo/boards/z_9_filetest.gno b/examples/gno.land/r/demo/boards/z_9_filetest.gno new file mode 100644 index 00000000000..9beb18e9977 --- /dev/null +++ b/examples/gno.land/r/demo/boards/z_9_filetest.gno @@ -0,0 +1,40 @@ +// PKGPATH: gno.land/r/demo/boards_test +package boards_test + +// SEND: 200000000ugnot + +import ( + "std" + "strconv" + + "gno.land/r/demo/boards" + users "gno.land/r/gnoland/users/v1" +) + +var ( + firstBoard boards.BoardID + secondBoard boards.BoardID + pid boards.PostID +) + +func init() { + std.TestSetRealm(std.NewUserRealm(std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"))) // so that CurrentRealm.Addr() matches OrigCaller + users.Register("gnouser123") + + firstBoard = boards.CreateBoard("first_board") + secondBoard = boards.CreateBoard("second_board") + pid = boards.CreateThread(firstBoard, "First Post in (title)", "Body of the first post. (body)") + + boards.CreateRepost(firstBoard, pid, "First Post in (title)", "Body of the first post. (body)", secondBoard) +} + +func main() { + println(boards.Render("second_board/" + strconv.Itoa(int(pid)))) +} + +// Output: +// # First Post in (title) +// +// Body of the first post. (body) +// \- [@gnouser123](/r/gnoland/users/v1:gnouser123), [2009-02-13 11:31pm (UTC)](/r/demo/boards:second_board/1/1) \[[reply](/r/demo/boards$help&func=CreateReply&bid=2&threadid=1&postid=1)] \[[x](/r/demo/boards$help&func=DeletePost&bid=2&threadid=1&postid=1)] +//