diff --git a/docs/reference/stdlibs/std/chain.md b/docs/reference/stdlibs/std/chain.md index 6a1da6483fd..f3b2c6be0b8 100644 --- a/docs/reference/stdlibs/std/chain.md +++ b/docs/reference/stdlibs/std/chain.md @@ -4,18 +4,6 @@ id: chain # Chain-related -## IsOriginCall -```go -func IsOriginCall() bool -``` -Checks if the caller of the function is an EOA. Returns **true** if caller is an EOA, **false** otherwise. - -#### Usage -```go -if !std.IsOriginCall() {...} -``` ---- - ## AssertOriginCall ```go func AssertOriginCall() diff --git a/examples/gno.land/r/demo/banktest/z_3_filetest.gno b/examples/gno.land/r/demo/banktest/z_3_filetest.gno index 7b6758c3e4f..7bf2aea4f38 100644 --- a/examples/gno.land/r/demo/banktest/z_3_filetest.gno +++ b/examples/gno.land/r/demo/banktest/z_3_filetest.gno @@ -18,7 +18,6 @@ func main() { banker := std.GetBanker(std.BankerTypeRealmSend) send := std.Coins{{"ugnot", 123}} banker.SendCoins(banktestAddr, mainaddr, send) - } // Error: diff --git a/examples/gno.land/r/demo/boards/public.gno b/examples/gno.land/r/demo/boards/public.gno index 1d26126fcb2..db545446641 100644 --- a/examples/gno.land/r/demo/boards/public.gno +++ b/examples/gno.land/r/demo/boards/public.gno @@ -17,7 +17,7 @@ func GetBoardIDFromName(name string) (BoardID, bool) { } func CreateBoard(name string) BoardID { - if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { + if !std.PrevRealm().IsUser() { panic("invalid non-user call") } bid := incGetBoardID() @@ -43,7 +43,7 @@ func checkAnonFee() bool { } func CreateThread(bid BoardID, title string, body string) PostID { - if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { + if !std.PrevRealm().IsUser() { panic("invalid non-user call") } caller := std.GetOrigCaller() @@ -61,7 +61,7 @@ func CreateThread(bid BoardID, title string, body string) PostID { } func CreateReply(bid BoardID, threadid, postid PostID, body string) PostID { - if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { + if !std.PrevRealm().IsUser() { panic("invalid non-user call") } caller := std.GetOrigCaller() @@ -91,7 +91,7 @@ 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 { - if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { + if !std.PrevRealm().IsUser() { panic("invalid non-user call") } caller := std.GetOrigCaller() @@ -121,7 +121,7 @@ func CreateRepost(bid BoardID, postid PostID, title string, body string, dstBoar } func DeletePost(bid BoardID, threadid, postid PostID, reason string) { - if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { + if !std.PrevRealm().IsUser() { panic("invalid non-user call") } caller := std.GetOrigCaller() @@ -153,7 +153,7 @@ func DeletePost(bid BoardID, threadid, postid PostID, reason string) { } func EditPost(bid BoardID, threadid, postid PostID, title, body string) { - if !(std.IsOriginCall() || std.PrevRealm().IsUser()) { + if !std.PrevRealm().IsUser() { panic("invalid non-user call") } caller := std.GetOrigCaller() 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 index 5e8ff520a54..297231970a5 100644 --- a/examples/gno.land/r/demo/boards/z_0_a_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_0_a_filetest.gno @@ -2,12 +2,17 @@ package boards_test import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" ) var bid boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)") diff --git a/examples/gno.land/r/demo/boards/z_0_b_filetest.gno b/examples/gno.land/r/demo/boards/z_0_b_filetest.gno index 9bcbe9ffafa..4830161ac71 100644 --- a/examples/gno.land/r/demo/boards/z_0_b_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_0_b_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 19900000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var bid boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") } 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 index 99fd339aed8..d0b0930240d 100644 --- a/examples/gno.land/r/demo/boards/z_0_c_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_0_c_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var bid boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") boards.CreateThread(1, "First Post (title)", "Body of the first post. (body)") } 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 index c77e60e3f3a..7e21f83febd 100644 --- a/examples/gno.land/r/demo/boards/z_0_d_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_0_d_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var bid boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") boards.CreateReply(bid, 0, 0, "Reply of the second post") 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 index 6db036e87ba..bdf6d63727b 100644 --- a/examples/gno.land/r/demo/boards/z_0_e_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_0_e_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var bid boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") boards.CreateReply(bid, 0, 0, "Reply of the second post") } diff --git a/examples/gno.land/r/demo/boards/z_0_filetest.gno b/examples/gno.land/r/demo/boards/z_0_filetest.gno index a649895cb01..977c00e84a6 100644 --- a/examples/gno.land/r/demo/boards/z_0_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_0_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 20000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var bid boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") 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 index ad57283bfcf..fc04555bf39 100644 --- a/examples/gno.land/r/demo/boards/z_10_a_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_10_a_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -23,6 +27,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) // boardId 2 not exist boards.DeletePost(2, pid, pid, "") 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 index cf8a332174f..2353268ef54 100644 --- a/examples/gno.land/r/demo/boards/z_10_b_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_10_b_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -25,6 +29,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) // pid of 2 not exist + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) boards.DeletePost(bid, 2, 2, "") println("----------------------------------------------------") println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) 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 index 7dd460500d6..c735213b09c 100644 --- a/examples/gno.land/r/demo/boards/z_10_c_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_10_c_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -17,6 +19,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -26,6 +30,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) boards.DeletePost(bid, pid, rid, "") println("----------------------------------------------------") println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) diff --git a/examples/gno.land/r/demo/boards/z_10_filetest.gno b/examples/gno.land/r/demo/boards/z_10_filetest.gno index 8a6d11c79cf..e9324cec555 100644 --- a/examples/gno.land/r/demo/boards/z_10_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_10_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -23,6 +27,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) boards.DeletePost(bid, pid, pid, "") println("----------------------------------------------------") 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 index d7dc7b90782..b891e395fe6 100644 --- a/examples/gno.land/r/demo/boards/z_11_a_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_11_a_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -25,6 +29,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) // board 2 not exist + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)))) 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 index 3aa28095502..9322ac191c5 100644 --- a/examples/gno.land/r/demo/boards/z_11_b_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_11_b_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -25,6 +29,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) // thread 2 not exist + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)))) 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 index df764303562..de4f828c1ca 100644 --- a/examples/gno.land/r/demo/boards/z_11_c_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_11_c_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -25,6 +29,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) // post 2 not exist + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)))) 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 index f64b4c84bba..b5619f86c5b 100644 --- a/examples/gno.land/r/demo/boards/z_11_d_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_11_d_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -17,6 +19,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -26,6 +30,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) boards.EditPost(bid, pid, rid, "", "Edited: First reply of the First post\n") println("----------------------------------------------------") println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) diff --git a/examples/gno.land/r/demo/boards/z_11_filetest.gno b/examples/gno.land/r/demo/boards/z_11_filetest.gno index 3f56293b3bd..1a013d5db22 100644 --- a/examples/gno.land/r/demo/boards/z_11_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_11_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -24,6 +28,8 @@ func init() { func main() { println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)))) 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 index 909be880efa..380e9bc09e0 100644 --- a/examples/gno.land/r/demo/boards/z_12_a_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_12_a_filetest.gno @@ -12,6 +12,8 @@ import ( ) func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") // create a post via registered user bid1 := boards.CreateBoard("test_board1") 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 index 6b2166895c0..553108df9b3 100644 --- a/examples/gno.land/r/demo/boards/z_12_b_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_12_b_filetest.gno @@ -4,11 +4,16 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid1 := boards.CreateBoard("test_board1") pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") 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 index 7397c487d7d..3b2e7ec04c0 100644 --- a/examples/gno.land/r/demo/boards/z_12_c_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_12_c_filetest.gno @@ -4,11 +4,16 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid1 := boards.CreateBoard("test_board1") boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") 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 index 37b6473f7ac..20818b05c0f 100644 --- a/examples/gno.land/r/demo/boards/z_12_d_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_12_d_filetest.gno @@ -4,11 +4,16 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid1 := boards.CreateBoard("test_board1") pid := boards.CreateThread(bid1, "First Post (title)", "Body of the first post. (body)") diff --git a/examples/gno.land/r/demo/boards/z_12_filetest.gno b/examples/gno.land/r/demo/boards/z_12_filetest.gno index ac4adf6ee7b..fe7b58e9348 100644 --- a/examples/gno.land/r/demo/boards/z_12_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_12_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -15,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid1 = boards.CreateBoard("test_board1") @@ -23,6 +28,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) rid := boards.CreateRepost(bid1, pid, "", "Check this out", bid2) println(rid) println(boards.Render("test_board2")) diff --git a/examples/gno.land/r/demo/boards/z_1_filetest.gno b/examples/gno.land/r/demo/boards/z_1_filetest.gno index 4d46c81b83d..6db254c661d 100644 --- a/examples/gno.land/r/demo/boards/z_1_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_1_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var board *boards.Board func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") _ = boards.CreateBoard("test_board_1") diff --git a/examples/gno.land/r/demo/boards/z_2_filetest.gno b/examples/gno.land/r/demo/boards/z_2_filetest.gno index 31b39644b24..0457a0b6b42 100644 --- a/examples/gno.land/r/demo/boards/z_2_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_2_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") diff --git a/examples/gno.land/r/demo/boards/z_3_filetest.gno b/examples/gno.land/r/demo/boards/z_3_filetest.gno index 0b2a2df2f91..cffeb9bc29e 100644 --- a/examples/gno.land/r/demo/boards/z_3_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_3_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -24,6 +28,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) rid := boards.CreateReply(bid, pid, pid, "Reply of the second post") println(rid) println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) diff --git a/examples/gno.land/r/demo/boards/z_4_filetest.gno b/examples/gno.land/r/demo/boards/z_4_filetest.gno index b781e94e4db..f834f4bc248 100644 --- a/examples/gno.land/r/demo/boards/z_4_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_4_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -26,6 +30,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) rid2 := boards.CreateReply(bid, pid, pid, "Second reply of the second post") println(rid2) println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) 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 index e79da5c3677..0ad15ca2600 100644 --- a/examples/gno.land/r/demo/boards/z_5_b_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_5_b_filetest.gno @@ -14,6 +14,8 @@ import ( const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") // create board via registered user bid := boards.CreateBoard("test_board") 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 index 723e6a10204..3817595fb98 100644 --- a/examples/gno.land/r/demo/boards/z_5_c_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_5_c_filetest.gno @@ -14,6 +14,8 @@ import ( const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") // create board via registered user bid := boards.CreateBoard("test_board") 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 index 54cfe49eec6..33175efd4f2 100644 --- a/examples/gno.land/r/demo/boards/z_5_d_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_5_d_filetest.gno @@ -14,6 +14,8 @@ import ( const admin = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") // create board via registered user bid := boards.CreateBoard("test_board") diff --git a/examples/gno.land/r/demo/boards/z_5_filetest.gno b/examples/gno.land/r/demo/boards/z_5_filetest.gno index 712af483891..c5f33c497fd 100644 --- a/examples/gno.land/r/demo/boards/z_5_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_5_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -16,6 +18,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -25,6 +29,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) rid2 := boards.CreateReply(bid, pid, pid, "Second reply of the second post\n") println(boards.Render("test_board/" + strconv.Itoa(int(pid)))) } diff --git a/examples/gno.land/r/demo/boards/z_6_filetest.gno b/examples/gno.land/r/demo/boards/z_6_filetest.gno index ec40cf5f8e9..98bef7091b4 100644 --- a/examples/gno.land/r/demo/boards/z_6_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_6_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -17,6 +19,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -26,6 +30,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)))) diff --git a/examples/gno.land/r/demo/boards/z_7_filetest.gno b/examples/gno.land/r/demo/boards/z_7_filetest.gno index 353b84f6d87..d587447b193 100644 --- a/examples/gno.land/r/demo/boards/z_7_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_7_filetest.gno @@ -4,11 +4,16 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) // register users.Register("", "gnouser", "my profile") diff --git a/examples/gno.land/r/demo/boards/z_8_filetest.gno b/examples/gno.land/r/demo/boards/z_8_filetest.gno index 4896dfcfccf..33edb30a391 100644 --- a/examples/gno.land/r/demo/boards/z_8_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_8_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -17,6 +19,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") bid = boards.CreateBoard("test_board") @@ -26,6 +30,8 @@ func init() { } func main() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) 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)))) 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 index 8d07ba0e710..79f68f20200 100644 --- a/examples/gno.land/r/demo/boards/z_9_a_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_9_a_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -11,6 +14,8 @@ import ( var dstBoard boards.BoardID func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") dstBoard = boards.CreateBoard("dst_board") 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 index 68daf770b4f..703557cf476 100644 --- a/examples/gno.land/r/demo/boards/z_9_b_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_9_b_filetest.gno @@ -4,6 +4,9 @@ package boards_test // SEND: 200000000ugnot import ( + "std" + + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -14,6 +17,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") srcBoard = boards.CreateBoard("first_board") diff --git a/examples/gno.land/r/demo/boards/z_9_filetest.gno b/examples/gno.land/r/demo/boards/z_9_filetest.gno index ca37e306bda..d7f8adeda30 100644 --- a/examples/gno.land/r/demo/boards/z_9_filetest.gno +++ b/examples/gno.land/r/demo/boards/z_9_filetest.gno @@ -4,8 +4,10 @@ package boards_test // SEND: 200000000ugnot import ( + "std" "strconv" + "gno.land/p/demo/testutils" "gno.land/r/demo/boards" "gno.land/r/demo/users" ) @@ -17,6 +19,8 @@ var ( ) func init() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) users.Register("", "gnouser", "my profile") firstBoard = boards.CreateBoard("first_board") diff --git a/examples/gno.land/r/demo/tests/subtests/subtests.gno b/examples/gno.land/r/demo/tests/subtests/subtests.gno index 6bf43cba5eb..5043c704017 100644 --- a/examples/gno.land/r/demo/tests/subtests/subtests.gno +++ b/examples/gno.land/r/demo/tests/subtests/subtests.gno @@ -21,5 +21,5 @@ func CallAssertOriginCall() { } func CallIsOriginCall() bool { - return std.IsOriginCall() + return std.PrevRealm().IsUser() } diff --git a/examples/gno.land/r/demo/tests/tests.gno b/examples/gno.land/r/demo/tests/tests.gno index e7fde94ea08..cdeea62de66 100644 --- a/examples/gno.land/r/demo/tests/tests.gno +++ b/examples/gno.land/r/demo/tests/tests.gno @@ -32,7 +32,7 @@ func CallAssertOriginCall() { } func CallIsOriginCall() bool { - return std.IsOriginCall() + return std.PrevRealm().IsUser() } func CallSubtestsAssertOriginCall() { diff --git a/examples/gno.land/r/demo/tests/tests_test.gno b/examples/gno.land/r/demo/tests/tests_test.gno index ccbc6b91265..fa3872744c8 100644 --- a/examples/gno.land/r/demo/tests/tests_test.gno +++ b/examples/gno.land/r/demo/tests/tests_test.gno @@ -1,17 +1,23 @@ -package tests +package tests_test import ( "std" "testing" + + "gno.land/p/demo/testutils" + "gno.land/r/demo/tests" ) func TestAssertOriginCall(t *testing.T) { // CallAssertOriginCall(): no panic - CallAssertOriginCall() - if !CallIsOriginCall() { + caller := testutils.TestAddress("caller") + std.TestSetRealm(std.NewUserRealm(caller)) + tests.CallAssertOriginCall() + if !tests.CallIsOriginCall() { t.Errorf("expected IsOriginCall=true but got false") } + std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/tests")) // CallAssertOriginCall() from a block: panic expectedReason := "invalid non-origin call" func() { @@ -23,10 +29,10 @@ func TestAssertOriginCall(t *testing.T) { }() // if called inside a function literal, this is no longer an origin call // because there's one additional frame (the function literal block). - if CallIsOriginCall() { + if tests.CallIsOriginCall() { t.Errorf("expected IsOriginCall=false but got true") } - CallAssertOriginCall() + tests.CallAssertOriginCall() }() // CallSubtestsAssertOriginCall(): panic @@ -36,23 +42,24 @@ func TestAssertOriginCall(t *testing.T) { t.Errorf("expected panic with '%v', got '%v'", expectedReason, r) } }() - if CallSubtestsIsOriginCall() { + if tests.CallSubtestsIsOriginCall() { t.Errorf("expected IsOriginCall=false but got true") } - CallSubtestsAssertOriginCall() + tests.CallSubtestsAssertOriginCall() } func TestPrevRealm(t *testing.T) { var ( - user1Addr = std.DerivePkgAddr("user1.gno") + firstRealm = std.DerivePkgAddr("gno.land/r/demo/tests_test") rTestsAddr = std.DerivePkgAddr("gno.land/r/demo/tests") ) - // When a single realm in the frames, PrevRealm returns the user - if addr := GetPrevRealm().Addr(); addr != user1Addr { - t.Errorf("want GetPrevRealm().Addr==%s, got %s", user1Addr, addr) + // When only one realm in the frames, PrevRealm returns the same realm + if addr := tests.GetPrevRealm().Addr(); addr != firstRealm { + println(tests.GetPrevRealm()) + t.Errorf("want GetPrevRealm().Addr==%s, got %s", firstRealm, addr) } // When 2 or more realms in the frames, PrevRealm returns the second to last - if addr := GetRSubtestsPrevRealm().Addr(); addr != rTestsAddr { + if addr := tests.GetRSubtestsPrevRealm().Addr(); addr != rTestsAddr { t.Errorf("want GetRSubtestsPrevRealm().Addr==%s, got %s", rTestsAddr, addr) } } diff --git a/examples/gno.land/r/demo/users/z_11_filetest.gno b/examples/gno.land/r/demo/users/z_11_filetest.gno index 27c7e9813da..212dc169007 100644 --- a/examples/gno.land/r/demo/users/z_11_filetest.gno +++ b/examples/gno.land/r/demo/users/z_11_filetest.gno @@ -11,8 +11,8 @@ import ( const admin = std.Address("g1manfred47kzduec920z88wfr64ylksmdcedlf5") func main() { - caller := std.GetOrigCaller() // main std.TestSetOrigCaller(admin) + caller := std.GetOrigCaller() // main users.AdminAddRestrictedName("superrestricted") // test restricted name diff --git a/examples/gno.land/r/demo/users/z_11b_filetest.gno b/examples/gno.land/r/demo/users/z_11b_filetest.gno index be508963911..6041f4b7113 100644 --- a/examples/gno.land/r/demo/users/z_11b_filetest.gno +++ b/examples/gno.land/r/demo/users/z_11b_filetest.gno @@ -11,8 +11,8 @@ import ( const admin = std.Address("g1manfred47kzduec920z88wfr64ylksmdcedlf5") func main() { - caller := std.GetOrigCaller() // main std.TestSetOrigCaller(admin) + caller := std.GetOrigCaller() // main // add restricted name users.AdminAddRestrictedName("superrestricted") // grant invite to caller diff --git a/examples/gno.land/r/demo/users/z_5_filetest.gno b/examples/gno.land/r/demo/users/z_5_filetest.gno index 6465cc9c378..9080b509b8e 100644 --- a/examples/gno.land/r/demo/users/z_5_filetest.gno +++ b/examples/gno.land/r/demo/users/z_5_filetest.gno @@ -16,14 +16,17 @@ func main() { users.Register("", "gnouser", "my profile") // as admin, grant invites to gnouser std.TestSetOrigCaller(admin) + std.TestSetRealm(std.NewUserRealm(admin)) users.GrantInvites(caller.String() + ":1") // switch back to caller std.TestSetOrigCaller(caller) + std.TestSetRealm(std.NewUserRealm(caller)) // invite another addr test1 := testutils.TestAddress("test1") users.Invite(test1.String()) // switch to test1 std.TestSetOrigCaller(test1) + std.TestSetRealm(std.NewUserRealm(test1)) std.TestSetOrigSend(std.Coins{{"dontcare", 1}}, nil) users.Register(caller, "satoshi", "my other profile") println(users.Render("")) diff --git a/examples/gno.land/r/demo/users/z_6_filetest.gno b/examples/gno.land/r/demo/users/z_6_filetest.gno index 919088088a2..e6a63d83358 100644 --- a/examples/gno.land/r/demo/users/z_6_filetest.gno +++ b/examples/gno.land/r/demo/users/z_6_filetest.gno @@ -9,7 +9,7 @@ import ( const admin = std.Address("g1manfred47kzduec920z88wfr64ylksmdcedlf5") func main() { - caller := std.GetOrigCaller() + caller := std.GetOrigCaller() // main // as admin, grant invites to unregistered user. std.TestSetOrigCaller(admin) users.GrantInvites(caller.String() + ":1") diff --git a/gnovm/cmd/gno/testdata/transpile/valid_transpile_file.txtar b/gnovm/cmd/gno/testdata/transpile/valid_transpile_file.txtar index 86cc6f12f7a..b79e7f9a0bc 100644 --- a/gnovm/cmd/gno/testdata/transpile/valid_transpile_file.txtar +++ b/gnovm/cmd/gno/testdata/transpile/valid_transpile_file.txtar @@ -36,7 +36,7 @@ package main import "std" func hello() { - std.AssertOriginCall() + std.GetChainID() } -- main.gno.gen.go.golden -- @@ -61,5 +61,5 @@ package main import "github.com/gnolang/gno/gnovm/stdlibs/std" func hello() { - std.AssertOriginCall(nil) + std.GetChainID(nil) } diff --git a/gnovm/pkg/transpiler/transpiler_test.go b/gnovm/pkg/transpiler/transpiler_test.go index 2a0707f7f79..63b77e49446 100644 --- a/gnovm/pkg/transpiler/transpiler_test.go +++ b/gnovm/pkg/transpiler/transpiler_test.go @@ -344,13 +344,13 @@ func Float32bits(i float32) uint32 func testfunc() { println(Float32bits(3.14159)) - std.AssertOriginCall() + std.GetChainID() } func otherFunc() { std := 1 // This is (incorrectly) changed for now. - std.AssertOriginCall() + std.GetChainID() } `, expectedOutput: ` @@ -363,13 +363,13 @@ import "github.com/gnolang/gno/gnovm/stdlibs/std" func testfunc() { println(Float32bits(3.14159)) - std.AssertOriginCall(nil) + std.GetChainID(nil) } func otherFunc() { std := 1 // This is (incorrectly) changed for now. - std.AssertOriginCall(nil) + std.GetChainID(nil) } `, expectedImports: []*ast.ImportSpec{ @@ -388,11 +388,11 @@ func otherFunc() { source: ` package std -func AssertOriginCall() +func GetChainID() func origCaller() string func testfunc() { - AssertOriginCall() + GetChainID() println(origCaller()) } `, @@ -403,7 +403,7 @@ func testfunc() { package std func testfunc() { - AssertOriginCall(nil) + GetChainID(nil) println(X_origCaller(nil)) } `, diff --git a/gnovm/stdlibs/generated.go b/gnovm/stdlibs/generated.go index ab35fc6b6bf..12c55d5ffa0 100644 --- a/gnovm/stdlibs/generated.go +++ b/gnovm/stdlibs/generated.go @@ -428,26 +428,6 @@ var nativeFuncs = [...]NativeFunc{ ) }, }, - { - "std", - "IsOriginCall", - []gno.FieldTypeExpr{}, - []gno.FieldTypeExpr{ - {Name: gno.N("r0"), Type: gno.X("bool")}, - }, - true, - func(m *gno.Machine) { - r0 := libs_std.IsOriginCall( - m, - ) - - m.PushValue(gno.Go2GnoValue( - m.Alloc, - m.Store, - reflect.ValueOf(&r0).Elem(), - )) - }, - }, { "std", "GetChainID", diff --git a/gnovm/stdlibs/std/native.gno b/gnovm/stdlibs/std/native.gno index 9cf8808a07e..2baa1f92f48 100644 --- a/gnovm/stdlibs/std/native.gno +++ b/gnovm/stdlibs/std/native.gno @@ -1,15 +1,11 @@ package std -// AssertOriginCall panics if [IsOriginCall] returns false. -func AssertOriginCall() // injected - -// IsOriginCall returns true only if the calling method is invoked via a direct -// MsgCall. It returns false for all other cases, like if the calling method +// AssertOriginCall panics if the calling method is not invoked via a direct +// MsgCall. It panics for for other cases, like if the calling method // is invoked by another method (even from the same realm or package). -// It also returns false every time when the transaction is broadcasted via +// It also panic every time when the transaction is broadcasted via // MsgRun. -func IsOriginCall() bool // injected - +func AssertOriginCall() // injected func GetChainID() string // injected func GetChainDomain() string // injected func GetHeight() int64 // injected diff --git a/gnovm/stdlibs/std/native.go b/gnovm/stdlibs/std/native.go index 9e398e907a2..68f4542f689 100644 --- a/gnovm/stdlibs/std/native.go +++ b/gnovm/stdlibs/std/native.go @@ -7,12 +7,12 @@ import ( ) func AssertOriginCall(m *gno.Machine) { - if !IsOriginCall(m) { + if !isOriginCall(m) { m.Panic(typedString("invalid non-origin call")) } } -func IsOriginCall(m *gno.Machine) bool { +func isOriginCall(m *gno.Machine) bool { n := m.NumFrames() if n == 0 { return false diff --git a/gnovm/stdlibs/std/native_test.go b/gnovm/stdlibs/std/native_test.go index 851785575d7..acbd22055d6 100644 --- a/gnovm/stdlibs/std/native_test.go +++ b/gnovm/stdlibs/std/native_test.go @@ -184,7 +184,7 @@ func TestPrevRealmIsOrigin(t *testing.T) { assert := assert.New(t) addr, pkgPath := X_getRealm(tt.machine, 1) - isOrigin := IsOriginCall(tt.machine) + isOrigin := isOriginCall(tt.machine) assert.Equal(string(tt.expectedAddr), addr) assert.Equal(tt.expectedPkgPath, pkgPath) diff --git a/gnovm/tests/files/std5.gno b/gnovm/tests/files/std5.gno index 2f9e98bb4ec..1f1d013c3df 100644 --- a/gnovm/tests/files/std5.gno +++ b/gnovm/tests/files/std5.gno @@ -13,10 +13,10 @@ func main() { // Stacktrace: // panic: frame not found -// callerAt(n) +// callerAt(n) // gonative:std.callerAt // std.GetCallerAt(2) -// std/native.gno:45 +// std/native.gno:41 // main() // main/files/std5.gno:10 diff --git a/gnovm/tests/files/std8.gno b/gnovm/tests/files/std8.gno index dfc2b8ca5fd..3d0e4a7085e 100644 --- a/gnovm/tests/files/std8.gno +++ b/gnovm/tests/files/std8.gno @@ -23,10 +23,10 @@ func main() { // Stacktrace: // panic: frame not found -// callerAt(n) +// callerAt(n) // gonative:std.callerAt // std.GetCallerAt(4) -// std/native.gno:45 +// std/native.gno:41 // fn() // main/files/std8.gno:16 // testutils.WrapCall(inner) diff --git a/gnovm/tests/stdlibs/generated.go b/gnovm/tests/stdlibs/generated.go index db5ecdec05d..51b15d77eef 100644 --- a/gnovm/tests/stdlibs/generated.go +++ b/gnovm/tests/stdlibs/generated.go @@ -43,26 +43,6 @@ var nativeFuncs = [...]NativeFunc{ ) }, }, - { - "std", - "IsOriginCall", - []gno.FieldTypeExpr{}, - []gno.FieldTypeExpr{ - {Name: gno.N("r0"), Type: gno.X("bool")}, - }, - true, - func(m *gno.Machine) { - r0 := testlibs_std.IsOriginCall( - m, - ) - - m.PushValue(gno.Go2GnoValue( - m.Alloc, - m.Store, - reflect.ValueOf(&r0).Elem(), - )) - }, - }, { "std", "TestSkipHeights", diff --git a/gnovm/tests/stdlibs/std/std.gno b/gnovm/tests/stdlibs/std/std.gno index dcb5a64dbb3..c30071313fe 100644 --- a/gnovm/tests/stdlibs/std/std.gno +++ b/gnovm/tests/stdlibs/std/std.gno @@ -1,7 +1,6 @@ package std func AssertOriginCall() // injected -func IsOriginCall() bool // injected func TestSkipHeights(count int64) // injected func TestSetOrigCaller(addr Address) { testSetOrigCaller(string(addr)) } diff --git a/gnovm/tests/stdlibs/std/std.go b/gnovm/tests/stdlibs/std/std.go index 675194b252f..eac51c5fb0e 100644 --- a/gnovm/tests/stdlibs/std/std.go +++ b/gnovm/tests/stdlibs/std/std.go @@ -26,7 +26,7 @@ type RealmOverride struct { } func AssertOriginCall(m *gno.Machine) { - if !IsOriginCall(m) { + if !isOriginCall(m) { m.Panic(typedString("invalid non-origin call")) } } @@ -37,7 +37,7 @@ func typedString(s gno.StringValue) gno.TypedValue { return tv } -func IsOriginCall(m *gno.Machine) bool { +func isOriginCall(m *gno.Machine) bool { tname := m.Frames[0].Func.Name switch tname { case "main": // test is a _filetest