From d5639e5512a6459136b69950db924d5eb385137d Mon Sep 17 00:00:00 2001 From: Miguel Victoria Date: Tue, 22 Oct 2024 20:59:40 +0200 Subject: [PATCH] fix comments on PR --- gnovm/pkg/gnolang/realm.go | 8 -------- gnovm/pkg/gnolang/values.go | 5 ----- gnovm/stdlibs/std/native.go | 3 ++- gnovm/tests/stdlibs/generated.go | 30 ------------------------------ gnovm/tests/stdlibs/std/std.gno | 1 - 5 files changed, 2 insertions(+), 45 deletions(-) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 598755da437..3710524130a 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -1532,14 +1532,6 @@ func isUnsaved(oo Object) bool { return oo.GetIsNewReal() || oo.GetIsDirty() } -// pkgPathPrefix is the prefix used to identify pkgpaths which are meant to -// be pure packages. This is used by [IsPkgPath]. -const pkgPathPrefix = "gno.land/p/" - -func IsPkgPath(pkgPath string) bool { - return strings.HasPrefix(pkgPath, pkgPathPrefix) -} - func prettyJSON(jstr []byte) []byte { var c interface{} err := json.Unmarshal(jstr, &c) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 8274f99c2c3..2761d3f574b 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -837,11 +837,6 @@ func (pv *PackageValue) IsRealm() bool { return IsRealmPath(pv.PkgPath) } -// IsPkgPath returns true if pv represents a package path. -func (pv *PackageValue) IsPkgPath() bool { - return IsPkgPath(pv.PkgPath) -} - func (pv *PackageValue) getFBlocksMap() map[Name]*Block { if pv.fBlocksMap == nil { pv.fBlocksMap = make(map[Name]*Block, len(pv.FNames)) diff --git a/gnovm/stdlibs/std/native.go b/gnovm/stdlibs/std/native.go index 00b26f4fdca..80eaed0c8ab 100644 --- a/gnovm/stdlibs/std/native.go +++ b/gnovm/stdlibs/std/native.go @@ -1,6 +1,7 @@ package std import ( + "github.com/gnolang/gno/gnovm/pkg/gnolang" gno "github.com/gnolang/gno/gnovm/pkg/gnolang" "github.com/gnolang/gno/tm2/pkg/bech32" "github.com/gnolang/gno/tm2/pkg/crypto" @@ -160,7 +161,7 @@ func X_decodeBech32(addr string) (prefix string, bytes [20]byte, ok bool) { func X_assertCallerIsRealm(m *gno.Machine) { frame := m.Frames[m.NumFrames()-2] - if frame.LastPackage.IsPkgPath() { + if path := frame.LastPackage.PkgPath; !gnolang.IsRealmPath(path) { m.Panic(typedString("caller is not a realm")) } } diff --git a/gnovm/tests/stdlibs/generated.go b/gnovm/tests/stdlibs/generated.go index f3d74e214eb..23bb3cfa594 100644 --- a/gnovm/tests/stdlibs/generated.go +++ b/gnovm/tests/stdlibs/generated.go @@ -296,36 +296,6 @@ var nativeFuncs = [...]NativeFunc{ )) }, }, - { - "std", - "isRealm", - []gno.FieldTypeExpr{ - {Name: gno.N("p0"), Type: gno.X("string")}, - }, - []gno.FieldTypeExpr{ - {Name: gno.N("r0"), Type: gno.X("bool")}, - }, - true, - func(m *gno.Machine) { - b := m.LastBlock() - var ( - p0 string - rp0 = reflect.ValueOf(&p0).Elem() - ) - - gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0) - - r0 := testlibs_std.X_isRealm( - m, - p0) - - m.PushValue(gno.Go2GnoValue( - m.Alloc, - m.Store, - reflect.ValueOf(&r0).Elem(), - )) - }, - }, { "testing", "unixNano", diff --git a/gnovm/tests/stdlibs/std/std.gno b/gnovm/tests/stdlibs/std/std.gno index e64195ddc08..3a56ecc1c47 100644 --- a/gnovm/tests/stdlibs/std/std.gno +++ b/gnovm/tests/stdlibs/std/std.gno @@ -39,4 +39,3 @@ func testSetOrigSend( func testIssueCoins(addr string, denom []string, amt []int64) func getRealm(height int) (address string, pkgPath string) func isRealm(pkgPath string) bool -