Skip to content

Commit

Permalink
renames, remove error
Browse files Browse the repository at this point in the history
  • Loading branch information
thehowl committed May 31, 2024
1 parent babd3d0 commit 2fbae1f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 42 deletions.
32 changes: 0 additions & 32 deletions gno.land/cmd/gnoland/testdata/maketx_call_forbidden.txtar

This file was deleted.

32 changes: 32 additions & 0 deletions gno.land/cmd/gnoland/testdata/maketx_call_pure.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# load the package
loadpkg gno.land/p/foo/call_package $WORK/package
loadpkg gno.land/r/foo/call_realm $WORK/realm

# start a new node
gnoland start

# 1. call to package ERROR
! gnokey maketx call -pkgpath gno.land/p/foo/call_package -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stderr '"gnokey" error: --= Error =--\nData: invalid package path'

# 2. call to stdlibs ERROR
! gnokey maketx call -pkgpath strconv -func Itoa -args 11 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stderr '"gnokey" error: --= Error =--\nData: invalid package path'

# 3. normal call to realm PASS
gnokey maketx call -pkgpath gno.land/r/foo/call_realm -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
stdout OK!

-- package/package.gno --
package call_package

func Render() string {
return "notok"
}

-- realm/realm.gno --
package call_realm

func Render() string {
return "ok"
}
6 changes: 0 additions & 6 deletions gno.land/pkg/sdk/vm/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type (
abciError
Errors []string
}
ForbiddenPkgCallError struct{ abciError }
)

func (e InvalidPkgPathError) Error() string { return "invalid package path" }
Expand All @@ -34,7 +33,6 @@ func (e TypeCheckError) Error() string {
bld.WriteString(strings.Join(e.Errors, "\n"))
return bld.String()
}
func (e ForbiddenPkgCallError) Error() string { return "forbidden/bad package called" }

func ErrInvalidPkgPath(msg string) error {
return errors.Wrap(InvalidPkgPathError{}, msg)
Expand All @@ -56,7 +54,3 @@ func ErrTypeCheck(err error) error {
}
return errors.NewWithData(tce).Stacktrace()
}

func ErrForbiddenPkgCall(msg string) error {
return errors.Wrap(ForbiddenPkgCallError{}, msg)
}
4 changes: 2 additions & 2 deletions gno.land/pkg/sdk/vm/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ func (msg MsgCall) ValidateBasic() error {
if msg.Caller.IsZero() {
return std.ErrInvalidAddress("missing caller address")
}
if msg.PkgPath == "" { // XXX
if msg.PkgPath == "" {

Check warning on line 116 in gno.land/pkg/sdk/vm/msgs.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/msgs.go#L116

Added line #L116 was not covered by tests
return ErrInvalidPkgPath("missing package path")
}
if !gno.IsRealmPath(msg.PkgPath) {
return ErrForbiddenPkgCall("pkgpath must be a realm")
return ErrInvalidPkgPath("pkgpath must be of a realm")

Check warning on line 120 in gno.land/pkg/sdk/vm/msgs.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/msgs.go#L119-L120

Added lines #L119 - L120 were not covered by tests
}
if msg.Func == "" { // XXX
return ErrInvalidExpr("missing function to call")
Expand Down
1 change: 0 additions & 1 deletion gno.land/pkg/sdk/vm/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ var Package = amino.RegisterPackage(amino.NewPackage(
InvalidStmtError{}, "InvalidStmtError",
InvalidExprError{}, "InvalidExprError",
TypeCheckError{}, "TypeCheckError",
ForbiddenPkgCallError{}, "ForbiddenPkgCallError",
))
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ func isUnsaved(oo Object) bool {
// be realms and as such to have their state persisted. This is used by [IsRealmPath].
const realmPathPrefix = "gno.land/r/"

var ReGnoRunPath = regexp.MustCompile(`gno\.land/r/g[a-z0-9]+/run`)
var ReGnoRunPath = regexp.MustCompile(`^gno\.land/r/g[a-z0-9]+/run$`)

// IsRealmPath determines whether the given pkgpath is for a realm, and as such
// should persist the global state.
Expand Down

0 comments on commit 2fbae1f

Please sign in to comment.