From b1a2490967e705b38abc67370f01152123736bf3 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 08:12:56 +0100 Subject: [PATCH 01/20] feat: add grc20reg that works... today Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/Makefile | 2 +- examples/gno.land/r/demo/bar20/bar20.gno | 3 ++- examples/gno.land/r/demo/bar20/gno.mod | 1 + examples/gno.land/r/demo/foo20/foo20.gno | 3 ++- examples/gno.land/r/demo/foo20/gno.mod | 1 + examples/gno.land/r/demo/grc20factory/gno.mod | 1 + examples/gno.land/r/demo/grc20factory/grc20factory.gno | 3 ++- .../gno.land/r/demo/tests/crossrealm/crossrealm.gno | 10 ++++++++++ examples/gno.land/r/demo/tests/tests.gno | 2 ++ examples/gno.land/r/demo/wugnot/gno.mod | 1 + examples/gno.land/r/demo/wugnot/wugnot.gno | 3 ++- 11 files changed, 25 insertions(+), 5 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 578b4faf15b..cdc73ee6b3a 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -45,7 +45,7 @@ test: .PHONY: lint lint: - go run ../gnovm/cmd/gno lint $(OFFICIAL_PACKAGES) + go run ../gnovm/cmd/gno lint -v $(OFFICIAL_PACKAGES) .PHONY: test.sync test.sync: diff --git a/examples/gno.land/r/demo/bar20/bar20.gno b/examples/gno.land/r/demo/bar20/bar20.gno index de51b8b47d9..b504a55fff3 100644 --- a/examples/gno.land/r/demo/bar20/bar20.gno +++ b/examples/gno.land/r/demo/bar20/bar20.gno @@ -9,6 +9,7 @@ import ( "gno.land/p/demo/grc/grc20" "gno.land/p/demo/ufmt" + "gno.land/r/demo/grc20reg" ) var ( @@ -17,7 +18,7 @@ var ( ) func init() { - // XXX: grc20reg.Register(Token, "") + grc20reg.Register(Token, "") } func Faucet() string { diff --git a/examples/gno.land/r/demo/bar20/gno.mod b/examples/gno.land/r/demo/bar20/gno.mod index 2ec82d7be0b..9fb0f083e1b 100644 --- a/examples/gno.land/r/demo/bar20/gno.mod +++ b/examples/gno.land/r/demo/bar20/gno.mod @@ -5,4 +5,5 @@ require ( gno.land/p/demo/testutils v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/demo/urequire v0.0.0-latest + gno.land/r/demo/grc20reg v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/foo20/foo20.gno b/examples/gno.land/r/demo/foo20/foo20.gno index fe099117215..7859057d92e 100644 --- a/examples/gno.land/r/demo/foo20/foo20.gno +++ b/examples/gno.land/r/demo/foo20/foo20.gno @@ -10,6 +10,7 @@ import ( "gno.land/p/demo/ownable" "gno.land/p/demo/ufmt" pusers "gno.land/p/demo/users" + "gno.land/r/demo/grc20reg" "gno.land/r/demo/users" ) @@ -21,7 +22,7 @@ var ( func init() { privateLedger.Mint(owner.Owner(), 1_000_000*10_000) // @privateLedgeristrator (1M) - // XXX: grc20reg.Register(Token, "") + grc20reg.Register(Token, "") } func TotalSupply() uint64 { diff --git a/examples/gno.land/r/demo/foo20/gno.mod b/examples/gno.land/r/demo/foo20/gno.mod index 4035f9b1200..64b8f90a27d 100644 --- a/examples/gno.land/r/demo/foo20/gno.mod +++ b/examples/gno.land/r/demo/foo20/gno.mod @@ -7,5 +7,6 @@ require ( gno.land/p/demo/uassert v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/demo/users v0.0.0-latest + gno.land/r/demo/grc20reg v0.0.0-latest gno.land/r/demo/users v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/grc20factory/gno.mod b/examples/gno.land/r/demo/grc20factory/gno.mod index bf5e9c9ec96..a2d2a55fdf0 100644 --- a/examples/gno.land/r/demo/grc20factory/gno.mod +++ b/examples/gno.land/r/demo/grc20factory/gno.mod @@ -7,4 +7,5 @@ require ( gno.land/p/demo/testutils v0.0.0-latest gno.land/p/demo/uassert v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest + gno.land/r/demo/grc20reg v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/grc20factory/grc20factory.gno b/examples/gno.land/r/demo/grc20factory/grc20factory.gno index 901a9b9f33c..709c808c06f 100644 --- a/examples/gno.land/r/demo/grc20factory/grc20factory.gno +++ b/examples/gno.land/r/demo/grc20factory/grc20factory.gno @@ -8,6 +8,7 @@ import ( "gno.land/p/demo/grc/grc20" "gno.land/p/demo/ownable" "gno.land/p/demo/ufmt" + "gno.land/r/demo/grc20reg" ) var instances avl.Tree // symbol -> instance @@ -42,7 +43,7 @@ func NewWithAdmin(name, symbol string, decimals uint, initialMint, faucet uint64 faucet: faucet, } instances.Set(symbol, &inst) - // XXX: grc20reg.Register(token, symbol) + grc20reg.Register(token, symbol) } func (inst instance) Token() *grc20.Token { diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno index 97273f642de..acb040c1ca8 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno @@ -27,3 +27,13 @@ func Make1() *p_crossrealm.Container { B: local, } } + +type Fooer interface{ Foo() } + +var fooer Fooer + +func SetFooer(f Fooer) Fooer { + fooer = f + return fooer +} +func CallFoo() { fooer.Foo() } diff --git a/examples/gno.land/r/demo/tests/tests.gno b/examples/gno.land/r/demo/tests/tests.gno index 421ac6528c9..e7fde94ea08 100644 --- a/examples/gno.land/r/demo/tests/tests.gno +++ b/examples/gno.land/r/demo/tests/tests.gno @@ -50,6 +50,8 @@ type TestRealmObject struct { Field string } +var TestRealmObjectValue TestRealmObject + func ModifyTestRealmObject(t *TestRealmObject) { t.Field += "_modified" } diff --git a/examples/gno.land/r/demo/wugnot/gno.mod b/examples/gno.land/r/demo/wugnot/gno.mod index f076e90e068..c7081ce6963 100644 --- a/examples/gno.land/r/demo/wugnot/gno.mod +++ b/examples/gno.land/r/demo/wugnot/gno.mod @@ -4,5 +4,6 @@ require ( gno.land/p/demo/grc/grc20 v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/demo/users v0.0.0-latest + gno.land/r/demo/grc20reg v0.0.0-latest gno.land/r/demo/users v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/wugnot/wugnot.gno b/examples/gno.land/r/demo/wugnot/wugnot.gno index bb109644778..3712306bbd7 100644 --- a/examples/gno.land/r/demo/wugnot/wugnot.gno +++ b/examples/gno.land/r/demo/wugnot/wugnot.gno @@ -7,6 +7,7 @@ import ( "gno.land/p/demo/grc/grc20" "gno.land/p/demo/ufmt" pusers "gno.land/p/demo/users" + "gno.land/r/demo/grc20reg" "gno.land/r/demo/users" ) @@ -18,7 +19,7 @@ const ( ) func init() { - // XXX: grc20reg.Register(Token, "") + grc20reg.Register(Token, "") } func Deposit() { From 948bb2444ea8edf9a58d6e6bcd92104560e2bd6f Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 08:14:23 +0100 Subject: [PATCH 02/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/r/demo/grc20reg/gno.mod | 9 +++ .../gno.land/r/demo/grc20reg/grc20reg.gno | 74 +++++++++++++++++++ .../r/demo/grc20reg/grc20reg_test.gno | 74 +++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 examples/gno.land/r/demo/grc20reg/gno.mod create mode 100644 examples/gno.land/r/demo/grc20reg/grc20reg.gno create mode 100644 examples/gno.land/r/demo/grc20reg/grc20reg_test.gno diff --git a/examples/gno.land/r/demo/grc20reg/gno.mod b/examples/gno.land/r/demo/grc20reg/gno.mod new file mode 100644 index 00000000000..f02ee09c35a --- /dev/null +++ b/examples/gno.land/r/demo/grc20reg/gno.mod @@ -0,0 +1,9 @@ +module gno.land/r/demo/grc20reg + +require ( + gno.land/p/demo/avl v0.0.0-latest + gno.land/p/demo/fqname v0.0.0-latest + gno.land/p/demo/grc/grc20 v0.0.0-latest + gno.land/p/demo/ufmt v0.0.0-latest + gno.land/p/demo/urequire v0.0.0-latest +) diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg.gno b/examples/gno.land/r/demo/grc20reg/grc20reg.gno new file mode 100644 index 00000000000..5009f7d8086 --- /dev/null +++ b/examples/gno.land/r/demo/grc20reg/grc20reg.gno @@ -0,0 +1,74 @@ +package grc20reg + +import ( + "std" + + "gno.land/p/demo/avl" + "gno.land/p/demo/fqname" + "gno.land/p/demo/grc/grc20" + "gno.land/p/demo/ufmt" +) + +var registry = avl.NewTree() // rlmPath[.slug] -> Token + +func Register(token grc20.Token, slug string) { + rlmPath := std.PrevRealm().PkgPath() + key := fqname.Construct(rlmPath, slug) + registry.Set(key, token) + std.Emit( + registerEvent, + "pkgpath", rlmPath, + "slug", slug, + ) +} + +func Get(key string) grc20.Token { + token, ok := registry.Get(key) + if !ok { + return nil + } + return token.(grc20.Token) +} + +func MustGet(key string) grc20.Token { + token := Get(key) + if token == nil { + panic("unknown token: " + key) + } + return token +} + +func Render(path string) string { + switch { + case path == "": // home + // TODO: add pagination + s := "" + count := 0 + registry.Iterate("", "", func(key string, tokenI interface{}) bool { + count++ + token := tokenI.(grc20.Token) + rlmPath, slug := fqname.Parse(key) + rlmLink := fqname.RenderLink(rlmPath, slug) + infoLink := "/r/demo/grc20reg:" + key + s += ufmt.Sprintf("- **%s** - %s - [info](%s)\n", token.GetName(), rlmLink, infoLink) + return false + }) + if count == 0 { + return "No registered token." + } + return s + default: // specific token + key := path + token := MustGet(key) + rlmPath, slug := fqname.Parse(key) + rlmLink := fqname.RenderLink(rlmPath, slug) + s := ufmt.Sprintf("# %s\n", token.GetName()) + s += ufmt.Sprintf("- symbol: **%s**\n", token.GetSymbol()) + s += ufmt.Sprintf("- realm: %s\n", rlmLink) + s += ufmt.Sprintf("- decimals: %d\n", token.GetDecimals()) + s += ufmt.Sprintf("- total supply: %d\n", token.TotalSupply()) + return s + } +} + +const registerEvent = "register" diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno b/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno new file mode 100644 index 00000000000..83f639de0c4 --- /dev/null +++ b/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno @@ -0,0 +1,74 @@ +package grc20reg + +import ( + "std" + "testing" + + "gno.land/p/demo/grc/grc20" + "gno.land/p/demo/urequire" +) + +func TestRegistry(t *testing.T) { + std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/foo")) + realmAddr := std.CurrentRealm().PkgPath() + tokenImpl := &dummyImpl{} + + // register + Register(tokenImpl, "") + regToken := Get(realmAddr) + urequire.True(t, regToken != nil, "expected to find a token") // fixme: use urequire.NotNil + urequire.Equal(t, regToken.GetSymbol(), "TST") + + expected := `- **TestToken** - [gno.land/r/demo/foo](/r/demo/foo) - [info](/r/demo/grc20reg:gno.land/r/demo/foo) +` + got := Render("") + urequire.Equal(t, expected, got) + + // 404 + invalidToken := Get("0xdeadbeef") + urequire.True(t, invalidToken == nil) + + // register with a slug + Register(tokenImpl, "mySlug") + regToken = Get(realmAddr + ".mySlug") + urequire.True(t, regToken != nil, "expected to find a token") // fixme: use urequire.NotNil + urequire.Equal(t, regToken.GetSymbol(), "TST") + + // override + Register(tokenImpl, "") + regToken = Get(realmAddr + "") + urequire.True(t, regToken != nil, "expected to find a token") // fixme: use urequire.NotNil + urequire.Equal(t, regToken.GetSymbol(), "TST") + + expected = `- **TestToken** - [gno.land/r/demo/foo](/r/demo/foo) - [info](/r/demo/grc20reg:gno.land/r/demo/foo) +- **TestToken** - [gno.land/r/demo/foo](/r/demo/foo).mySlug - [info](/r/demo/grc20reg:gno.land/r/demo/foo.mySlug) +` + got = Render("") + urequire.Equal(t, expected, got) + + expected = `# TestToken +- symbol: **TST** +- realm: [gno.land/r/demo/foo](/r/demo/foo).mySlug +- decimals: 1337 +- total supply: 1234567 +` + got = Render("gno.land/r/demo/foo.mySlug") + urequire.Equal(t, expected, got) +} + +type dummyImpl struct{} + +// FIXME: this should fail. +var _ grc20.Token = (*dummyImpl)(nil) + +func (impl *dummyImpl) GetName() string { return "TestToken" } +func (impl *dummyImpl) GetSymbol() string { return "TST" } +func (impl *dummyImpl) GetDecimals() uint { return 1337 } +func (impl *dummyImpl) TotalSupply() uint64 { return 1234567 } +func (impl *dummyImpl) BalanceOf(account std.Address) uint64 { panic("not implemented") } +func (impl *dummyImpl) Transfer(to std.Address, amount uint64) error { panic("not implemented") } +func (impl *dummyImpl) Allowance(owner, spender std.Address) uint64 { panic("not implemented") } +func (impl *dummyImpl) Approve(spender std.Address, amount uint64) error { panic("not implemented") } +func (impl *dummyImpl) TransferFrom(from, to std.Address, amount uint64) error { + panic("not implemented") +} From 5c152d2333467d80da78bb002eb817e4b776641b Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 08:39:04 +0100 Subject: [PATCH 03/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/p/demo/grc/grc20/types.gno | 41 +++++++++++++------ .../gno.land/r/demo/grc20reg/grc20reg.gno | 2 +- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/examples/gno.land/p/demo/grc/grc20/types.gno b/examples/gno.land/p/demo/grc/grc20/types.gno index cf67858ccf3..816bbe8a1d9 100644 --- a/examples/gno.land/p/demo/grc/grc20/types.gno +++ b/examples/gno.land/p/demo/grc/grc20/types.gno @@ -39,11 +39,11 @@ type Teller interface { // // Returns an error if the operation failed. // - // IMPORTANT: Beware that changing an allowance with this method brings the risk - // that someone may use both the old and the new allowance by unfortunate - // transaction ordering. One possible solution to mitigate this race - // condition is to first reduce the spender's allowance to 0 and set the - // desired value afterwards: + // IMPORTANT: Beware that changing an allowance with this method brings + // the risk that someone may use both the old and the new allowance by + // unfortunate transaction ordering. One possible solution to mitigate + // this race condition is to first reduce the spender's allowance to 0 + // and set the desired value afterwards: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Approve(spender std.Address, amount uint64) error @@ -63,12 +63,23 @@ type Teller interface { // name, symbol, and decimals, as well as methods for interacting with the // ledger, including checking balances and allowances. type Token struct { - name string // Name of the token (e.g., "Dummy Token"). - symbol string // Symbol of the token (e.g., "DUMMY"). - decimals uint // Number of decimal places used for the token's precision. - ledger *PrivateLedger // Pointer to the PrivateLedger that manages balances and allowances. + // Name of the token (e.g., "Dummy Token"). + name string + // Symbol of the token (e.g., "DUMMY"). + symbol string + // Number of decimal places used for the token's precision. + decimals uint + // Pointer to the PrivateLedger that manages balances and allowances. + ledger *PrivateLedger } +// TokenGetter is a function type that returns a Token pointer. This type allows +// bypassing a limitation where we cannot directly pass Token pointers between +// realms. Instead, we pass this function which can then be called to get the +// Token pointer. For more details on this limitation and workaround, see: +// https://github.com/gnolang/gno/pull/3135 +type TokenGetter func() *Token + // PrivateLedger is a struct that holds the balances and allowances for the // token. It provides administrative functions for minting, burning, // transferring tokens, and managing allowances. @@ -77,10 +88,14 @@ type Token struct { // information regarding token balances and allowances, and allows direct, // unrestricted access to all administrative functions. type PrivateLedger struct { - totalSupply uint64 // Total supply of the token managed by this ledger. - balances avl.Tree // std.Address -> uint64 - allowances avl.Tree // owner.(std.Address)+":"+spender.(std.Address)) -> uint64 - token *Token // Pointer to the associated Token struct + // Total supply of the token managed by this ledger. + totalSupply uint64 + // std.Address -> uint64 + balances avl.Tree + // owner.(std.Address)+":"+spender.(std.Address)) -> uint64 + allowances avl.Tree + // Pointer to the associated Token struct + token *Token } var ( diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg.gno b/examples/gno.land/r/demo/grc20reg/grc20reg.gno index 5009f7d8086..b339881aa1a 100644 --- a/examples/gno.land/r/demo/grc20reg/grc20reg.gno +++ b/examples/gno.land/r/demo/grc20reg/grc20reg.gno @@ -9,7 +9,7 @@ import ( "gno.land/p/demo/ufmt" ) -var registry = avl.NewTree() // rlmPath[.slug] -> Token +var registry = avl.NewTree() // rlmPath[.slug] -> TokenGetter func Register(token grc20.Token, slug string) { rlmPath := std.PrevRealm().PkgPath() From b22cd054d7b2347e5458272ea21b8fa63aa2e781 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 08:55:46 +0100 Subject: [PATCH 04/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .../gno.land/r/demo/grc20reg/grc20reg.gno | 24 ++++++------ .../r/demo/grc20reg/grc20reg_test.gno | 39 +++++++------------ 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg.gno b/examples/gno.land/r/demo/grc20reg/grc20reg.gno index b339881aa1a..5443617b818 100644 --- a/examples/gno.land/r/demo/grc20reg/grc20reg.gno +++ b/examples/gno.land/r/demo/grc20reg/grc20reg.gno @@ -11,10 +11,10 @@ import ( var registry = avl.NewTree() // rlmPath[.slug] -> TokenGetter -func Register(token grc20.Token, slug string) { +func Register(tokenGetter grc20.TokenGetter, slug string) { rlmPath := std.PrevRealm().PkgPath() key := fqname.Construct(rlmPath, slug) - registry.Set(key, token) + registry.Set(key, tokenGetter) std.Emit( registerEvent, "pkgpath", rlmPath, @@ -22,20 +22,20 @@ func Register(token grc20.Token, slug string) { ) } -func Get(key string) grc20.Token { - token, ok := registry.Get(key) +func Get(key string) grc20.TokenGetter { + tokenGetter, ok := registry.Get(key) if !ok { return nil } - return token.(grc20.Token) + return tokenGetter.(grc20.TokenGetter) } -func MustGet(key string) grc20.Token { - token := Get(key) - if token == nil { +func MustGet(key string) grc20.TokenGetter { + tokenGetter := Get(key) + if tokenGetter == nil { panic("unknown token: " + key) } - return token + return tokenGetter } func Render(path string) string { @@ -46,7 +46,8 @@ func Render(path string) string { count := 0 registry.Iterate("", "", func(key string, tokenI interface{}) bool { count++ - token := tokenI.(grc20.Token) + tokenGetter := tokenI.(grc20.TokenGetter) + token := tokenGetter() rlmPath, slug := fqname.Parse(key) rlmLink := fqname.RenderLink(rlmPath, slug) infoLink := "/r/demo/grc20reg:" + key @@ -59,7 +60,8 @@ func Render(path string) string { return s default: // specific token key := path - token := MustGet(key) + tokenGetter := MustGet(key) + token := tokenGetter() rlmPath, slug := fqname.Parse(key) rlmLink := fqname.RenderLink(rlmPath, slug) s := ufmt.Sprintf("# %s\n", token.GetName()) diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno b/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno index 83f639de0c4..bfe834039e5 100644 --- a/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno +++ b/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno @@ -11,11 +11,13 @@ import ( func TestRegistry(t *testing.T) { std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/foo")) realmAddr := std.CurrentRealm().PkgPath() - tokenImpl := &dummyImpl{} - + token, ledger := grc20.NewToken("TestToken", "TST", 4) + ledger.Mint(std.CurrentRealm().Addr(), 1234567) + tokenGetter := func() *grc20.Token { return token } // register - Register(tokenImpl, "") - regToken := Get(realmAddr) + Register(tokenGetter, "") + regTokenGetter := Get(realmAddr) + regToken := regTokenGetter() urequire.True(t, regToken != nil, "expected to find a token") // fixme: use urequire.NotNil urequire.Equal(t, regToken.GetSymbol(), "TST") @@ -29,14 +31,16 @@ func TestRegistry(t *testing.T) { urequire.True(t, invalidToken == nil) // register with a slug - Register(tokenImpl, "mySlug") - regToken = Get(realmAddr + ".mySlug") + Register(tokenGetter, "mySlug") + regTokenGetter = Get(realmAddr + ".mySlug") + regToken = regTokenGetter() urequire.True(t, regToken != nil, "expected to find a token") // fixme: use urequire.NotNil urequire.Equal(t, regToken.GetSymbol(), "TST") // override - Register(tokenImpl, "") - regToken = Get(realmAddr + "") + Register(tokenGetter, "") + regTokenGetter = Get(realmAddr + "") + regToken = regTokenGetter() urequire.True(t, regToken != nil, "expected to find a token") // fixme: use urequire.NotNil urequire.Equal(t, regToken.GetSymbol(), "TST") @@ -49,26 +53,9 @@ func TestRegistry(t *testing.T) { expected = `# TestToken - symbol: **TST** - realm: [gno.land/r/demo/foo](/r/demo/foo).mySlug -- decimals: 1337 +- decimals: 4 - total supply: 1234567 ` got = Render("gno.land/r/demo/foo.mySlug") urequire.Equal(t, expected, got) } - -type dummyImpl struct{} - -// FIXME: this should fail. -var _ grc20.Token = (*dummyImpl)(nil) - -func (impl *dummyImpl) GetName() string { return "TestToken" } -func (impl *dummyImpl) GetSymbol() string { return "TST" } -func (impl *dummyImpl) GetDecimals() uint { return 1337 } -func (impl *dummyImpl) TotalSupply() uint64 { return 1234567 } -func (impl *dummyImpl) BalanceOf(account std.Address) uint64 { panic("not implemented") } -func (impl *dummyImpl) Transfer(to std.Address, amount uint64) error { panic("not implemented") } -func (impl *dummyImpl) Allowance(owner, spender std.Address) uint64 { panic("not implemented") } -func (impl *dummyImpl) Approve(spender std.Address, amount uint64) error { panic("not implemented") } -func (impl *dummyImpl) TransferFrom(from, to std.Address, amount uint64) error { - panic("not implemented") -} From e4249a18eca4483f690d9fa0ca115807e8d53a1c Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:08:51 +0100 Subject: [PATCH 05/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/r/demo/grc20reg/grc20reg_test.gno | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno b/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno index bfe834039e5..47c19c5a19e 100644 --- a/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno +++ b/examples/gno.land/r/demo/grc20reg/grc20reg_test.gno @@ -25,7 +25,6 @@ func TestRegistry(t *testing.T) { ` got := Render("") urequire.Equal(t, expected, got) - // 404 invalidToken := Get("0xdeadbeef") urequire.True(t, invalidToken == nil) From 7110526cba3182a82ba2a7f7a30cbfa9c4348406 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:13:03 +0100 Subject: [PATCH 06/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/r/demo/bar20/bar20.gno | 3 ++- examples/gno.land/r/demo/foo20/foo20.gno | 3 ++- examples/gno.land/r/demo/grc20factory/grc20factory.gno | 3 ++- examples/gno.land/r/demo/wugnot/wugnot.gno | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/gno.land/r/demo/bar20/bar20.gno b/examples/gno.land/r/demo/bar20/bar20.gno index b504a55fff3..25636fcda78 100644 --- a/examples/gno.land/r/demo/bar20/bar20.gno +++ b/examples/gno.land/r/demo/bar20/bar20.gno @@ -18,7 +18,8 @@ var ( ) func init() { - grc20reg.Register(Token, "") + getter := func() *grc20.Token { return Token } + grc20reg.Register(getter, "") } func Faucet() string { diff --git a/examples/gno.land/r/demo/foo20/foo20.gno b/examples/gno.land/r/demo/foo20/foo20.gno index 7859057d92e..cfefd2b1ff9 100644 --- a/examples/gno.land/r/demo/foo20/foo20.gno +++ b/examples/gno.land/r/demo/foo20/foo20.gno @@ -22,7 +22,8 @@ var ( func init() { privateLedger.Mint(owner.Owner(), 1_000_000*10_000) // @privateLedgeristrator (1M) - grc20reg.Register(Token, "") + getter := func() *grc20.Token { return Token } + grc20reg.Register(getter, "") } func TotalSupply() uint64 { diff --git a/examples/gno.land/r/demo/grc20factory/grc20factory.gno b/examples/gno.land/r/demo/grc20factory/grc20factory.gno index 709c808c06f..cfd32479f9d 100644 --- a/examples/gno.land/r/demo/grc20factory/grc20factory.gno +++ b/examples/gno.land/r/demo/grc20factory/grc20factory.gno @@ -43,7 +43,8 @@ func NewWithAdmin(name, symbol string, decimals uint, initialMint, faucet uint64 faucet: faucet, } instances.Set(symbol, &inst) - grc20reg.Register(token, symbol) + getter := func() *grc20.Token { return token } + grc20reg.Register(getter, symbol) } func (inst instance) Token() *grc20.Token { diff --git a/examples/gno.land/r/demo/wugnot/wugnot.gno b/examples/gno.land/r/demo/wugnot/wugnot.gno index 3712306bbd7..09538b860ca 100644 --- a/examples/gno.land/r/demo/wugnot/wugnot.gno +++ b/examples/gno.land/r/demo/wugnot/wugnot.gno @@ -19,7 +19,8 @@ const ( ) func init() { - grc20reg.Register(Token, "") + getter := func() *grc20.Token { return Token } + grc20reg.Register(getter, "") } func Deposit() { From a81f968b8185238b0ce841d92a5154087e41e77e Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:18:28 +0100 Subject: [PATCH 07/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .../gno.land/r/demo/tests/crossrealm/crossrealm.gno | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno index acb040c1ca8..c0a52eb1d4a 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno @@ -37,3 +37,13 @@ func SetFooer(f Fooer) Fooer { return fooer } func CallFoo() { fooer.Foo() } + +func FooerGetter() Fooer { + return fooer +} + +func FooerGetterBuilder() func() Fooer { + return func() Fooer { + return fooer + } +} From b92dd683e4a1b41fa372bf6384d862c7489c6a10 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:26:37 +0100 Subject: [PATCH 08/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/stdlibs/math/overflow/overflow.gno | 6 +- gnovm/tests/files/zrealm_crossrealm15.gno | 32 + gnovm/tests/files/zrealm_crossrealm16.gno | 618 +++++++++++++++ gnovm/tests/files/zrealm_crossrealm17.gno | 701 ++++++++++++++++++ gnovm/tests/files/zrealm_crossrealm18.gno | 35 + .../files/zrealm_crossrealm19_stdlibs.gno | 37 + .../files/zrealm_crossrealm3_stdlibs.gno | 11 +- .../files/zrealm_crossrealm4_stdlibs.gno | 12 +- .../files/zrealm_crossrealm5_stdlibs.gno | 8 +- gnovm/tests/files/zrealm_tests0_stdlibs.gno | 54 +- 10 files changed, 1475 insertions(+), 39 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm15.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm16.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm17.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm18.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno diff --git a/gnovm/stdlibs/math/overflow/overflow.gno b/gnovm/stdlibs/math/overflow/overflow.gno index 9bdeff0720f..0bc2e03a522 100644 --- a/gnovm/stdlibs/math/overflow/overflow.gno +++ b/gnovm/stdlibs/math/overflow/overflow.gno @@ -223,7 +223,7 @@ func Div8p(a, b int8) int8 { func Quo8(a, b int8) (int8, int8, bool) { if b == 0 { return 0, 0, false - } else if b == -1 && a == math.MinInt8 { + } else if b == -1 && a == int8(math.MinInt8) { return 0, 0, false } c := a / b @@ -313,7 +313,7 @@ func Div16p(a, b int16) int16 { func Quo16(a, b int16) (int16, int16, bool) { if b == 0 { return 0, 0, false - } else if b == -1 && a == math.MinInt16 { + } else if b == -1 && a == int16(math.MinInt16) { return 0, 0, false } c := a / b @@ -403,7 +403,7 @@ func Div32p(a, b int32) int32 { func Quo32(a, b int32) (int32, int32, bool) { if b == 0 { return 0, 0, false - } else if b == -1 && a == math.MinInt32 { + } else if b == -1 && a == int32(math.MinInt32) { return 0, 0, false } c := a / b diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno new file mode 100644 index 00000000000..c2c5575bfcd --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm15.gno @@ -0,0 +1,32 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f *fooer + +func init() { + f = &fooer{} + crossrealm.SetFooer(f) + crossrealm.CallFoo() +} + +func main() { + print(".") +} + +// Output: +// hello gno.land/r/crossrealm_test +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno new file mode 100644 index 00000000000..7b766ba1a88 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm16.gno @@ -0,0 +1,618 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f *fooer + +func main() { + f = &fooer{} + crossrealm.SetFooer(f) + crossrealm.CallFoo() + print(".") +} + +// Output: +// hello gno.land/r/crossrealm_test +// . + +// Error: + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:7]={ +// "Fields": [], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7", +// "ModTime": "0", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", +// "RefCount": "1" +// } +// } +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:6]={ +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", +// "IsEscaped": true, +// "ModTime": "0", +// "RefCount": "2" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "2aec554d4aaa9a1c37af933f8ca8d000088e4e7c", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// } +// } +// } +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "IsEscaped": true, +// "ModTime": "5", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "LocalStruct", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "Foo", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "Fooer", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "init.2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "19", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "Make1", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "24", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "SetFooer", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "35", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "CallFoo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "39", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "a75fdb389fedfcbbaa7f446d528c1e149726347c", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ] +// } +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "main.gno", +// "IsMethod": true, +// "Name": "Foo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// } +// ], +// "Results": [] +// } +// } +// } +// ], +// "Name": "fooer", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "16", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno new file mode 100644 index 00000000000..d52541bb653 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm17.gno @@ -0,0 +1,701 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type container struct{ *fooer } + +func (container) Foo() { println("hello container " + std.CurrentRealm().PkgPath()) } + +type fooer struct{} + +var f *fooer + +func main() { + f = &fooer{} + c := &container{f} + crossrealm.SetFooer(c) + crossrealm.CallFoo() + print(".") +} + +// Output: +// hello container gno.land/r/crossrealm_test +// . + +// Error: + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:7]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7", +// "ModTime": "0", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", +// "RefCount": "1" +// } +// } +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:6]={ +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", +// "ModTime": "0", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.container" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "2e88a06ae991c0b638c9dd94a2d80b19e476d114", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// } +// } +// } +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:9]={ +// "Fields": [], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9", +// "ModTime": "0", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", +// "RefCount": "1" +// } +// } +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:8]={ +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", +// "IsEscaped": true, +// "ModTime": "0", +// "RefCount": "2" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "e521635fd7846ccea2a330e7c114af77db07ee27", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" +// } +// } +// } +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "IsEscaped": true, +// "ModTime": "5", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "LocalStruct", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "Foo", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "Fooer", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "init.2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "19", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "Make1", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "24", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "SetFooer", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "35", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm.gno", +// "IsMethod": false, +// "Name": "CallFoo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm.gno", +// "Line": "39", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "a75fdb389fedfcbbaa7f446d528c1e149726347c", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.container" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "7041ec66b0edbe5faaa7e8e9baa1b2a862887964", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ] +// } +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": true, +// "Name": "fooer", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// } +// } +// ], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.container" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "main.gno", +// "IsMethod": true, +// "Name": "Foo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.container" +// } +// } +// ], +// "Results": [] +// } +// } +// } +// ], +// "Name": "container", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [], +// "Name": "fooer", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "18", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm18.gno b/gnovm/tests/files/zrealm_crossrealm18.gno new file mode 100644 index 00000000000..cc46e3df514 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm18.gno @@ -0,0 +1,35 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f crossrealm.Fooer = crossrealm.SetFooer(&fooer{}) + +func init() { + crossrealm.CallFoo() +} + +func main() { + crossrealm.CallFoo() + print(".") +} + +// Output: +// hello gno.land/r/crossrealm_test +// hello gno.land/r/crossrealm_test +// . + +// Error: + +// Realm: +// switchrealm["gno.land/r/crossrealm_test"] +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno new file mode 100644 index 00000000000..6a51623f7bc --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno @@ -0,0 +1,37 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + s string +} + +func (f *fooer) Foo() { + f.s = "B" + println("hello " + f.s + " " + std.CurrentRealm().PkgPath()) +} + +var f *fooer + +func init() { + f = &fooer{s: "A"} + crossrealm.SetFooer(f) + crossrealm.CallFoo() +} + +func main() { + print(".") +} + +// Output: +// hello B gno.land/r/demo/tests/crossrealm +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno index 6aa9c5247d8..105066c5ba7 100644 --- a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno @@ -13,10 +13,15 @@ func init() { } func main() { - // NOTE: but it is invalid to modify it using an external realm function. + // NOTE: it is valid to modify it using an external realm function, + // because the receiver makes the function run under this realm. somevalue.Modify() println(somevalue) + // we can even modify it directly. + somevalue.Field = "test_modified_directly" + println(somevalue) } -// Error: -// cannot modify external-realm or non-realm object +// Output: +// (struct{("test_modified" string)} gno.land/r/demo/tests.TestRealmObject) +// (struct{("test_modified_directly" string)} gno.land/r/demo/tests.TestRealmObject) diff --git a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno index 6aa9c5247d8..ed73b7ad6bb 100644 --- a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno @@ -5,18 +5,18 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. -var somevalue tests.TestRealmObject +// NOTE: it is valid to persist a pointer to an external object +var somevalue *tests.TestRealmObject func init() { - somevalue.Field = "test" + somevalue = &tests.TestRealmObjectValue } func main() { - // NOTE: but it is invalid to modify it using an external realm function. + // NOTE: it is valid to modify it using the external realm function. somevalue.Modify() println(somevalue) } -// Error: -// cannot modify external-realm or non-realm object +// Output: +// &(struct{("_modified" string)} gno.land/r/demo/tests.TestRealmObject) diff --git a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno index 6aa9c5247d8..c7560b21463 100644 --- a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno @@ -6,15 +6,15 @@ import ( ) // NOTE: it is valid to persist external realm types. -var somevalue tests.TestRealmObject +var somevalue *tests.TestRealmObject func init() { - somevalue.Field = "test" + somevalue = &tests.TestRealmObjectValue } func main() { - // NOTE: but it is invalid to modify it using an external realm function. - somevalue.Modify() + // NOTE: but it is invalid to modify it directly. + somevalue.Field = "test" println(somevalue) } diff --git a/gnovm/tests/files/zrealm_tests0_stdlibs.gno b/gnovm/tests/files/zrealm_tests0_stdlibs.gno index d11701505e5..34f8ebc106d 100644 --- a/gnovm/tests/files/zrealm_tests0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_tests0_stdlibs.gno @@ -23,7 +23,7 @@ func main() { // Realm: // switchrealm["gno.land/r/demo/tests"] -// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18]={ +// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:19]={ // "Fields": [ // { // "T": { @@ -37,17 +37,17 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18", +// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:19", // "ModTime": "0", -// "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17", +// "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18", // "RefCount": "1" // } // } -// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17]={ +// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18]={ // "ObjectInfo": { -// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17", +// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18", // "ModTime": "0", -// "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:16", +// "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17", // "RefCount": "1" // }, // "Value": { @@ -57,12 +57,12 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "d3d6ffa52602f2bc976051d79294d219750aca64", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18" +// "Hash": "6b9b731f6118c2419f23ba57e1481679f17f4a8f", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:19" // } // } // } -// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:16]={ +// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17]={ // "Data": null, // "List": [ // { @@ -77,8 +77,8 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "4ea1e08156f3849b74a0f41f92cd4b48fb94926b", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:11" +// "Hash": "148d314678615253ee2032d7ecff6b144b474baf", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:12" // }, // "Index": "0", // "TV": null @@ -96,8 +96,8 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "ce86ea1156e75a44cd9d7ba2261819b100aa4ed1", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:14" +// "Hash": "fa414e1770821b8deb8e6d46d97828c47f7d5fa5", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:15" // }, // "Index": "0", // "TV": null @@ -115,8 +115,8 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "b66192fbd8a8dde79b6f854b5cc3c4cc965cfd92", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17" +// "Hash": "aaa64d049cf8660d689780acac9f546f270eaa4e", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:18" // }, // "Index": "0", // "TV": null @@ -124,7 +124,7 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:16", +// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17", // "ModTime": "0", // "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:2", // "RefCount": "1" @@ -135,7 +135,7 @@ func main() { // "ObjectInfo": { // "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:2", // "IsEscaped": true, -// "ModTime": "15", +// "ModTime": "16", // "RefCount": "5" // }, // "Parent": null, @@ -204,8 +204,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "ad25f70f66c8c53042afd1377e5ff5ab744bf1a5", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:16" +// "Hash": "3c58838c5667649add1ff8ee48a1cdc187fcd2ef", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:17" // }, // "Length": "3", // "Maxcap": "3", @@ -1182,6 +1182,17 @@ func main() { // }, // { // "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.TestRealmObject" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "5e56ba76fc0add1a3a67f7a8b6709f4f27215f93", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:10" +// } +// }, +// { +// "T": { // "@type": "/gno.FuncType", // "Params": [ // { @@ -1758,10 +1769,7 @@ func main() { // } // ] // } -// d[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:13] -// switchrealm["gno.land/r/demo/tests_foo"] -// switchrealm["gno.land/r/demo/tests_foo"] -// switchrealm["gno.land/r/demo/tests_foo"] +// d[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:14] // switchrealm["gno.land/r/demo/tests_foo"] // switchrealm["gno.land/r/demo/tests"] // switchrealm["gno.land/r/demo/tests_test"] From 23127d6e6f0a944ece2985652a1cf7a542be79bf Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:33:45 +0100 Subject: [PATCH 09/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_crossrealm15.gno | 9 ++++++++- gnovm/tests/files/zrealm_crossrealm16.gno | 12 ++++++++++-- gnovm/tests/files/zrealm_crossrealm17.gno | 11 +++++++++-- gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno | 9 ++++++++- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno index c2c5575bfcd..2ae8a6f661e 100644 --- a/gnovm/tests/files/zrealm_crossrealm15.gno +++ b/gnovm/tests/files/zrealm_crossrealm15.gno @@ -1,6 +1,12 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test +// TODO: this test panics with the current implementation of the VM. +// we should either enable it again if we change the VM behavior (#2743). +// or consider adding a `// Panic:` filetest handler.` +func main() { /* noop */ } + +/* import ( "std" @@ -22,8 +28,9 @@ func init() { func main() { print(".") } +*/ -// Output: +// EXPECTED Output: // hello gno.land/r/crossrealm_test // . diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno index 7b766ba1a88..66fab457eae 100644 --- a/gnovm/tests/files/zrealm_crossrealm16.gno +++ b/gnovm/tests/files/zrealm_crossrealm16.gno @@ -1,6 +1,13 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test +// TODO: this test panics with the current implementation of the VM. +// we should either enable it again if we change the VM behavior (#2743). +// or consider adding a `// Panic:` filetest handler.` +func main() { /* noop */ } + +/* + import ( "std" @@ -19,14 +26,15 @@ func main() { crossrealm.CallFoo() print(".") } +*/ -// Output: +// EXPECTED Output: // hello gno.land/r/crossrealm_test // . // Error: -// Realm: +// EXPECTED Realm: // switchrealm["gno.land/r/demo/tests/crossrealm"] // c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:7]={ // "Fields": [], diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno index d52541bb653..41fd236076a 100644 --- a/gnovm/tests/files/zrealm_crossrealm17.gno +++ b/gnovm/tests/files/zrealm_crossrealm17.gno @@ -1,6 +1,12 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test +// TODO: this test panics with the current implementation of the VM. +// we should either enable it again if we change the VM behavior (#2743). +// or consider adding a `// Panic:` filetest handler.` +func main() { /* noop */ } + +/* import ( "std" @@ -22,14 +28,15 @@ func main() { crossrealm.CallFoo() print(".") } +*/ -// Output: +// EXPECTED Output: // hello container gno.land/r/crossrealm_test // . // Error: -// Realm: +// EXPECTED Realm: // switchrealm["gno.land/r/demo/tests/crossrealm"] // c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:7]={ // "Fields": [ diff --git a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno index 6a51623f7bc..e4713992326 100644 --- a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno @@ -1,6 +1,12 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test +// TODO: this test panics with the current implementation of the VM. +// we should either enable it again if we change the VM behavior (#2743). +// or consider adding a `// Panic:` filetest handler.` +func main() { /* noop */ } + +/* import ( "std" @@ -27,8 +33,9 @@ func init() { func main() { print(".") } +*/ -// Output: +// EXPECTED Output: // hello B gno.land/r/demo/tests/crossrealm // . From cddf395b5cc0a9480f0413775bc0753b01debb73 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:37:34 +0100 Subject: [PATCH 10/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno index 105066c5ba7..426e6310fe7 100644 --- a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno @@ -13,15 +13,10 @@ func init() { } func main() { - // NOTE: it is valid to modify it using an external realm function, - // because the receiver makes the function run under this realm. + // NOTE: but it is invalid to modify it using an external realm function somevalue.Modify() println(somevalue) - // we can even modify it directly. - somevalue.Field = "test_modified_directly" - println(somevalue) } -// Output: -// (struct{("test_modified" string)} gno.land/r/demo/tests.TestRealmObject) -// (struct{("test_modified_directly" string)} gno.land/r/demo/tests.TestRealmObject) +// Error: +// cannot modify external-realm or non-realm object From 6435ef0cb12addcb10e505631b0128bb17361ce9 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:52:17 +0100 Subject: [PATCH 11/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_crossrealm15.gno | 14 +- gnovm/tests/files/zrealm_crossrealm16.gno | 604 +--------------- gnovm/tests/files/zrealm_crossrealm17.gno | 683 +----------------- .../files/zrealm_crossrealm19_stdlibs.gno | 14 +- .../files/zrealm_crossrealm3_stdlibs.gno | 2 +- 5 files changed, 5 insertions(+), 1312 deletions(-) diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno index 2ae8a6f661e..4aaf3a2c44a 100644 --- a/gnovm/tests/files/zrealm_crossrealm15.gno +++ b/gnovm/tests/files/zrealm_crossrealm15.gno @@ -1,12 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// TODO: this test panics with the current implementation of the VM. -// we should either enable it again if we change the VM behavior (#2743). -// or consider adding a `// Panic:` filetest handler.` -func main() { /* noop */ } - -/* import ( "std" @@ -28,12 +22,6 @@ func init() { func main() { print(".") } -*/ - -// EXPECTED Output: -// hello gno.land/r/crossrealm_test -// . // Error: - -// Realm: +// new escaped mark has no object ID diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno index 66fab457eae..ffae24f638d 100644 --- a/gnovm/tests/files/zrealm_crossrealm16.gno +++ b/gnovm/tests/files/zrealm_crossrealm16.gno @@ -1,13 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// TODO: this test panics with the current implementation of the VM. -// we should either enable it again if we change the VM behavior (#2743). -// or consider adding a `// Panic:` filetest handler.` -func main() { /* noop */ } - -/* - import ( "std" @@ -26,601 +19,6 @@ func main() { crossrealm.CallFoo() print(".") } -*/ - -// EXPECTED Output: -// hello gno.land/r/crossrealm_test -// . // Error: - -// EXPECTED Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:7]={ -// "Fields": [], -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7", -// "ModTime": "0", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", -// "RefCount": "1" -// } -// } -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:6]={ -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", -// "IsEscaped": true, -// "ModTime": "0", -// "RefCount": "2" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "2aec554d4aaa9a1c37af933f8ca8d000088e4e7c", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" -// } -// } -// } -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", -// "IsEscaped": true, -// "ModTime": "5", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm.gno", -// "IsMethod": true, -// "Name": "String", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// } -// ], -// "Name": "LocalStruct", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.InterfaceType", -// "Generic": "", -// "Methods": [ -// { -// "Embedded": false, -// "Name": "Foo", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "Fooer", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "init.2", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "19", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "Make1", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "24", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "SetFooer", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "35", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "CallFoo", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "39", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "a75fdb389fedfcbbaa7f446d528c1e149726347c", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ] -// } -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// switchrealm["gno.land/r/crossrealm_test"] -// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", -// "IsEscaped": true, -// "ModTime": "3", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [], -// "PkgPath": "gno.land/r/crossrealm_test" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": ".recv", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "main.gno", -// "IsMethod": true, -// "Name": "Foo", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/crossrealm_test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": ".recv", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// } -// ], -// "Results": [] -// } -// } -// } -// ], -// "Name": "fooer", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "main", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/crossrealm_test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "16", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ] -// } +// new escaped mark has no object ID diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno index 41fd236076a..19abb6c0cc5 100644 --- a/gnovm/tests/files/zrealm_crossrealm17.gno +++ b/gnovm/tests/files/zrealm_crossrealm17.gno @@ -1,12 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// TODO: this test panics with the current implementation of the VM. -// we should either enable it again if we change the VM behavior (#2743). -// or consider adding a `// Panic:` filetest handler.` -func main() { /* noop */ } - -/* import ( "std" @@ -28,681 +22,6 @@ func main() { crossrealm.CallFoo() print(".") } -*/ - -// EXPECTED Output: -// hello container gno.land/r/crossrealm_test -// . // Error: - -// EXPECTED Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:7]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ], -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7", -// "ModTime": "0", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", -// "RefCount": "1" -// } -// } -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:6]={ -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6", -// "ModTime": "0", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", -// "RefCount": "1" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.container" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "2e88a06ae991c0b638c9dd94a2d80b19e476d114", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" -// } -// } -// } -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:9]={ -// "Fields": [], -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9", -// "ModTime": "0", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", -// "RefCount": "1" -// } -// } -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:8]={ -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", -// "IsEscaped": true, -// "ModTime": "0", -// "RefCount": "2" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "e521635fd7846ccea2a330e7c114af77db07ee27", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" -// } -// } -// } -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", -// "IsEscaped": true, -// "ModTime": "5", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm.gno", -// "IsMethod": true, -// "Name": "String", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// } -// ], -// "Name": "LocalStruct", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.InterfaceType", -// "Generic": "", -// "Methods": [ -// { -// "Embedded": false, -// "Name": "Foo", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "Fooer", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "init.2", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "19", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "Make1", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "24", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "SetFooer", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "35", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm.gno", -// "IsMethod": false, -// "Name": "CallFoo", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm.gno", -// "Line": "39", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "a75fdb389fedfcbbaa7f446d528c1e149726347c", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.container" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "7041ec66b0edbe5faaa7e8e9baa1b2a862887964", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:6" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ] -// } -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// switchrealm["gno.land/r/crossrealm_test"] -// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", -// "IsEscaped": true, -// "ModTime": "3", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": true, -// "Name": "fooer", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// } -// } -// ], -// "PkgPath": "gno.land/r/crossrealm_test" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": ".recv", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.container" -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "main.gno", -// "IsMethod": true, -// "Name": "Foo", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/crossrealm_test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": ".recv", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.container" -// } -// } -// ], -// "Results": [] -// } -// } -// } -// ], -// "Name": "container", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [], -// "PkgPath": "gno.land/r/crossrealm_test" -// }, -// "Methods": [], -// "Name": "fooer", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "main", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/crossrealm_test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "18", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/crossrealm_test.fooer" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ] -// } +// new escaped mark has no object ID diff --git a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno index e4713992326..fa12c282ea4 100644 --- a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno @@ -1,12 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// TODO: this test panics with the current implementation of the VM. -// we should either enable it again if we change the VM behavior (#2743). -// or consider adding a `// Panic:` filetest handler.` -func main() { /* noop */ } - -/* import ( "std" @@ -33,12 +27,6 @@ func init() { func main() { print(".") } -*/ - -// EXPECTED Output: -// hello B gno.land/r/demo/tests/crossrealm -// . // Error: - -// Realm: +// new escaped mark has no object ID diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno index 426e6310fe7..6aa9c5247d8 100644 --- a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno @@ -13,7 +13,7 @@ func init() { } func main() { - // NOTE: but it is invalid to modify it using an external realm function + // NOTE: but it is invalid to modify it using an external realm function. somevalue.Modify() println(somevalue) } From 9ff36e06d77b17a4fe53ca1ee8ab85482e76b46c Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:57:24 +0100 Subject: [PATCH 12/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .../r/demo/tests/crossrealm/crossrealm.gno | 22 +++++++++++++------ gnovm/tests/files/zrealm_crossrealm15.gno | 2 +- gnovm/tests/files/zrealm_crossrealm16.gno | 2 +- gnovm/tests/files/zrealm_crossrealm17.gno | 2 +- gnovm/tests/files/zrealm_crossrealm18.gno | 4 ++-- .../files/zrealm_crossrealm19_stdlibs.gno | 2 +- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno index c0a52eb1d4a..1cc5a3f8e18 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno @@ -36,14 +36,22 @@ func SetFooer(f Fooer) Fooer { fooer = f return fooer } -func CallFoo() { fooer.Foo() } -func FooerGetter() Fooer { - return fooer +func GetFooer() Fooer { return fooer } + +func CallFooerFoo() { fooer.Foo() } + +type FooerGetter func() Fooer + +var fooerGetter FooerGetter + +func SetFooerGetter(fg FooerGetter) FooerGetter { + fooerGetter = fg + return fg } -func FooerGetterBuilder() func() Fooer { - return func() Fooer { - return fooer - } +func GetFooerGetter() FooerGetter { + return fooerGetter } + +func CallFooerGetterFoo() { fooerGetter().Foo() } diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno index 4aaf3a2c44a..9006310c8f0 100644 --- a/gnovm/tests/files/zrealm_crossrealm15.gno +++ b/gnovm/tests/files/zrealm_crossrealm15.gno @@ -24,4 +24,4 @@ func main() { } // Error: -// new escaped mark has no object ID +// gno.land/r/crossrealm_test/main.gno:19:2: name CallFoo not declared diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno index ffae24f638d..21d7e78ce01 100644 --- a/gnovm/tests/files/zrealm_crossrealm16.gno +++ b/gnovm/tests/files/zrealm_crossrealm16.gno @@ -21,4 +21,4 @@ func main() { } // Error: -// new escaped mark has no object ID +// gno.land/r/crossrealm_test/main.gno:19:2: name CallFoo not declared diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno index 19abb6c0cc5..46c6eeb5061 100644 --- a/gnovm/tests/files/zrealm_crossrealm17.gno +++ b/gnovm/tests/files/zrealm_crossrealm17.gno @@ -24,4 +24,4 @@ func main() { } // Error: -// new escaped mark has no object ID +// gno.land/r/crossrealm_test/main.gno:22:2: name CallFoo not declared diff --git a/gnovm/tests/files/zrealm_crossrealm18.gno b/gnovm/tests/files/zrealm_crossrealm18.gno index cc46e3df514..f7a318ed3a0 100644 --- a/gnovm/tests/files/zrealm_crossrealm18.gno +++ b/gnovm/tests/files/zrealm_crossrealm18.gno @@ -14,11 +14,11 @@ func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f crossrealm.Fooer = crossrealm.SetFooer(&fooer{}) func init() { - crossrealm.CallFoo() + crossrealm.CallFooerFoo() } func main() { - crossrealm.CallFoo() + crossrealm.CallFooerFoo() print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno index fa12c282ea4..a3b864755fd 100644 --- a/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm19_stdlibs.gno @@ -21,7 +21,7 @@ var f *fooer func init() { f = &fooer{s: "A"} crossrealm.SetFooer(f) - crossrealm.CallFoo() + crossrealm.CallFooerFoo() } func main() { From 8a09fd72bd6300759ff7eae849f56471f6586ca0 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:02:19 +0100 Subject: [PATCH 13/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_crossrealm20.gno | 41 +++++++++++++++++++ .../files/zrealm_crossrealm3_stdlibs_b.gno | 35 ++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 gnovm/tests/files/zrealm_crossrealm20.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno new file mode 100644 index 00000000000..fe796755535 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -0,0 +1,41 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + s string +} + +func (f *fooer) Foo() { + f.s = "B" + println("hello " + f.s + " " + std.CurrentRealm().PkgPath()) +} + +var f *fooer + +func init() { + f = &fooer{s: "A"} + fg := func() crossrealm.Fooer { return f } + crossrealm.SetFooerGetter(fg) + crossrealm.CallFooerGetterFoo() + f.s = "C" + crossrealm.CallFooerGetterFoo() +} + +func main() { + print(".") +} + +// Output: +// hello B gno.land/r/crossrealm_test +// hello B gno.land/r/crossrealm_test +// . + +// Realm: + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno new file mode 100644 index 00000000000..800d6b8519f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno @@ -0,0 +1,35 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +// TODO: this test panics with the current implementation of the VM. +// we should either enable it again if we change the VM behavior (#2743). +// or consider adding a `// Panic:` filetest handler.` +func main() { /* noop */ } + +/* +import ( + "gno.land/r/demo/tests" +) + + +// NOTE: it is valid to persist external realm types. +var somevalue tests.TestRealmObject + +func init() { + somevalue.Field = "test" +} + +func main() { + // NOTE: it is valid to modify it using an external realm function, + // because the receiver makes the function run under this realm. + somevalue.Modify() + println(somevalue) + // we can even modify it directly. + somevalue.Field = "test_modified_directly" + println(somevalue) +} +*/ + +// EXPECTED Output: +// (struct{("test_modified" string)} gno.land/r/demo/tests.TestRealmObject) +// (struct{("test_modified_directly" string)} gno.land/r/demo/tests.TestRealmObject) From 43b46b53fc602d85a7c6795167a42a04a7fe33f7 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:03:17 +0100 Subject: [PATCH 14/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .../files/zrealm_crossrealm3_stdlibs_b.gno | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno deleted file mode 100644 index 800d6b8519f..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm3_stdlibs_b.gno +++ /dev/null @@ -1,35 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -// TODO: this test panics with the current implementation of the VM. -// we should either enable it again if we change the VM behavior (#2743). -// or consider adding a `// Panic:` filetest handler.` -func main() { /* noop */ } - -/* -import ( - "gno.land/r/demo/tests" -) - - -// NOTE: it is valid to persist external realm types. -var somevalue tests.TestRealmObject - -func init() { - somevalue.Field = "test" -} - -func main() { - // NOTE: it is valid to modify it using an external realm function, - // because the receiver makes the function run under this realm. - somevalue.Modify() - println(somevalue) - // we can even modify it directly. - somevalue.Field = "test_modified_directly" - println(somevalue) -} -*/ - -// EXPECTED Output: -// (struct{("test_modified" string)} gno.land/r/demo/tests.TestRealmObject) -// (struct{("test_modified_directly" string)} gno.land/r/demo/tests.TestRealmObject) From 06c87e5de1747544b7f3e49fd882e854c956a591 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:12:49 +0100 Subject: [PATCH 15/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .../r/demo/tests/crossrealm_b/crossrealm.gno | 25 +++++++++++++++++ .../r/demo/tests/crossrealm_b/gno.mod | 6 +++++ gnovm/tests/files/zrealm_crossrealm21.gno | 27 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 examples/gno.land/r/demo/tests/crossrealm_b/crossrealm.gno create mode 100644 examples/gno.land/r/demo/tests/crossrealm_b/gno.mod create mode 100644 gnovm/tests/files/zrealm_crossrealm21.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm_b/crossrealm.gno b/examples/gno.land/r/demo/tests/crossrealm_b/crossrealm.gno new file mode 100644 index 00000000000..d412b6ee6b1 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm_b/crossrealm.gno @@ -0,0 +1,25 @@ +package crossrealm_b + +import ( + "std" + + "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + s string +} + +func (f *fooer) SetS(newVal string) { + f.s = newVal +} + +func (f *fooer) Foo() { + println("hello " + f.s + " cur=" + std.CurrentRealm().PkgPath() + " prev=" + std.PrevRealm().PkgPath()) +} + +var ( + Fooer = &fooer{s: "A"} + FooerGetter = func() crossrealm.Fooer { return Fooer } + FooerGetterBuilder = func() crossrealm.FooerGetter { return func() crossrealm.Fooer { return Fooer } } +) diff --git a/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod b/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod new file mode 100644 index 00000000000..71a89ec2ec5 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod @@ -0,0 +1,6 @@ +module gno.land/r/demo/tests/crossrealm + +require ( + gno.land/p/demo/tests/p_crossrealm v0.0.0-latest + gno.land/p/demo/ufmt v0.0.0-latest +) diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno new file mode 100644 index 00000000000..1f864e6c855 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + "gno.land/r/demo/tests/crossrealm" + "gno.land/r/demo/tests/crossrealm_b" +) + +func main() { + f := crossrealm_b.Fooer + crossrealm.SetFooer(f) + crossrealm.CallFooerFoo() + f.SetS("B") + crossrealm.CallFooerFoo() + print(".") +} + +// Output: +// hello A cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm +// hello B cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm +// . + +// Realm: + +// Error: From 0e1b7a751ac85959eda31418805adfc71a98be02 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:13:48 +0100 Subject: [PATCH 16/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_crossrealm22.gno | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gnovm/tests/files/zrealm_crossrealm22.gno diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno new file mode 100644 index 00000000000..2f0de86beb0 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + "gno.land/r/demo/tests/crossrealm" + "gno.land/r/demo/tests/crossrealm_b" +) + +func main() { + f := crossrealm_b.Fooer + crossrealm.SetFooerGetter(func() crossrealm.Fooer { return f }) + crossrealm.CallFooerGetterFoo() + f.SetS("B") + crossrealm.CallFooerGetterFoo() + print(".") +} + +// Output: +// hello A cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm +// hello B cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm +// . + +// Realm: + +// Error: From 28b015acbcc50a75ba17c81609f7bd4d6f32130b Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:18:15 +0100 Subject: [PATCH 17/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_crossrealm22.gno | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno index 2f0de86beb0..6777973f6c8 100644 --- a/gnovm/tests/files/zrealm_crossrealm22.gno +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -14,13 +14,27 @@ func main() { crossrealm.CallFooerGetterFoo() f.SetS("B") crossrealm.CallFooerGetterFoo() - print(".") + println(".") + + f.SetS("C") + crossrealm.SetFooerGetter(crossrealm_b.FooerGetter) + crossrealm.CallFooerGetterFoo() + println(".") + + f.SetS("D") + crossrealm.SetFooerGetter(crossrealm_b.FooerGetterBuilder()) + crossrealm.CallFooerGetterFoo() + println(".") } // Output: // hello A cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm // hello B cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm // . +// hello C cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm +// . +// hello D cur=gno.land/r/demo/tests/crossrealm_b prev=gno.land/r/demo/tests/crossrealm +// . // Realm: From 8a352d446916b545e24cf8c6b47d48cc4f5bf8f6 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:24:13 +0100 Subject: [PATCH 18/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/r/demo/tests/crossrealm_b/gno.mod | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod b/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod index 71a89ec2ec5..74548712caa 100644 --- a/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod +++ b/examples/gno.land/r/demo/tests/crossrealm_b/gno.mod @@ -1,6 +1,3 @@ -module gno.land/r/demo/tests/crossrealm +module gno.land/r/demo/tests/crossrealm_b -require ( - gno.land/p/demo/tests/p_crossrealm v0.0.0-latest - gno.land/p/demo/ufmt v0.0.0-latest -) +require gno.land/r/demo/tests/crossrealm v0.0.0-latest From f926979613927f2b2d6459187a92dfc3dc8984a9 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Sat, 16 Nov 2024 10:46:03 +0100 Subject: [PATCH 19/20] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/files/zrealm_panic.gno | 1 + gnovm/tests/files/zrealm_tests0_stdlibs.gno | 25 ++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gnovm/tests/files/zrealm_panic.gno b/gnovm/tests/files/zrealm_panic.gno index 3864e2a7f7f..2bb9b807c34 100644 --- a/gnovm/tests/files/zrealm_panic.gno +++ b/gnovm/tests/files/zrealm_panic.gno @@ -18,3 +18,4 @@ func main() { // gno.land/r/test/main.gno:7 // main() // gno.land/r/test/main.gno:12 +// diff --git a/gnovm/tests/files/zrealm_tests0_stdlibs.gno b/gnovm/tests/files/zrealm_tests0_stdlibs.gno index 34f8ebc106d..63dadbb2de1 100644 --- a/gnovm/tests/files/zrealm_tests0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_tests0_stdlibs.gno @@ -1150,7 +1150,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "57", +// "Line": "59", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1229,7 +1229,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "53", +// "Line": "55", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1346,7 +1346,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "75", +// "Line": "77", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1382,7 +1382,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "80", +// "Line": "82", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1418,7 +1418,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "88", +// "Line": "90", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1464,7 +1464,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "92", +// "Line": "94", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1520,7 +1520,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "96", +// "Line": "98", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1577,7 +1577,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "100", +// "Line": "102", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1634,7 +1634,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "104", +// "Line": "106", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1690,7 +1690,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "108", +// "Line": "110", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1746,7 +1746,7 @@ func main() { // "Location": { // "Column": "1", // "File": "tests.gno", -// "Line": "112", +// "Line": "114", // "PkgPath": "gno.land/r/demo/tests" // } // }, @@ -1771,5 +1771,8 @@ func main() { // } // d[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:14] // switchrealm["gno.land/r/demo/tests_foo"] +// switchrealm["gno.land/r/demo/tests_foo"] +// switchrealm["gno.land/r/demo/tests_foo"] +// switchrealm["gno.land/r/demo/tests_foo"] // switchrealm["gno.land/r/demo/tests"] // switchrealm["gno.land/r/demo/tests_test"] From db1e4a699deb29fc6665a0ca8d075b9b9c5be026 Mon Sep 17 00:00:00 2001 From: Manfred Touron <94029+moul@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:26:42 +0100 Subject: [PATCH 20/20] Update examples/gno.land/r/demo/grc20reg/grc20reg.gno --- examples/gno.land/r/demo/grc20reg/grc20reg.gno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg.gno b/examples/gno.land/r/demo/grc20reg/grc20reg.gno index 5443617b818..ff46ec94860 100644 --- a/examples/gno.land/r/demo/grc20reg/grc20reg.gno +++ b/examples/gno.land/r/demo/grc20reg/grc20reg.gno @@ -9,7 +9,7 @@ import ( "gno.land/p/demo/ufmt" ) -var registry = avl.NewTree() // rlmPath[.slug] -> TokenGetter +var registry = avl.NewTree() // rlmPath[.slug] -> TokenGetter (slug is optional) func Register(tokenGetter grc20.TokenGetter, slug string) { rlmPath := std.PrevRealm().PkgPath()