You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure this is a problem but it could use further explanation. I was looking at an issue @leohhhn brought up regarding an error he was getting when trying to add a post to a blog. In summary, the issue was:
A realm exists with an instance of the Blog type, defined in the blog package
Calling a modifying method on the Blog instance results in the error cannot modify external-realm or non-realm object
I wrote a txtar script to exemplify the issue:
gnoland start
gnokey maketx addpkg -pkgdir $WORK/blogtest -pkgpath gno.land/r/blogtest -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK/owner -pkgpath gno.land/r/owner -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/owner -func AddPost -args 'my first post' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
-- owner/blog.gno --
package owner
import blog "gno.land/r/blogtest"
var Blog = new(blog.Blog)
func AddPost(title string) {
Blog.AddPost(title)
}
func GetPost() blog.Post {
return Blog.Post
}
-- blogtest/blog.gno --
package blogtest
type Blog struct {
Post Post
}
type Post struct {
Title string
}
func (b *Blog) AddPost(title string) {
b.Post = Post{title}
}
In the case above the error will happen when calling AddPost from the owner realm. I'm not sure why this isn't allowed because the only object being modified is that which is owned by the owner realm, so it isn't as if this call is modifying another realm's state.
The text was updated successfully, but these errors were encountered:
I'm not sure this is a problem but it could use further explanation. I was looking at an issue @leohhhn brought up regarding an error he was getting when trying to add a post to a blog. In summary, the issue was:
Blog
type, defined in the blog packageBlog
instance results in the errorcannot modify external-realm or non-realm object
I wrote a txtar script to exemplify the issue:
In the case above the error will happen when calling
AddPost
from the owner realm. I'm not sure why this isn't allowed because the only object being modified is that which is owned by the owner realm, so it isn't as if this call is modifying another realm's state.The text was updated successfully, but these errors were encountered: