Skip to content

Commit

Permalink
Remove -pkgPath from addPkg in favour of gno.mod
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed May 15, 2024
1 parent 220d13e commit c541c94
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions gno.land/pkg/keyscli/addpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"flag"
"fmt"
"path/filepath"

"github.com/gnolang/gno/gno.land/pkg/sdk/vm"
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/pkg/gnomod"
"github.com/gnolang/gno/tm2/pkg/amino"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/crypto/keys"
Expand All @@ -18,7 +20,6 @@ import (
type MakeAddPkgCfg struct {
RootCfg *client.MakeTxCfg

PkgPath string
PkgDir string
Deposit string
}
Expand All @@ -42,13 +43,6 @@ func NewMakeAddPkgCmd(rootCfg *client.MakeTxCfg, io commands.IO) *commands.Comma
}

func (c *MakeAddPkgCfg) RegisterFlags(fs *flag.FlagSet) {
fs.StringVar(
&c.PkgPath,
"pkgpath",
"",
"package path (required)",
)

fs.StringVar(
&c.PkgDir,
"pkgdir",
Expand All @@ -65,9 +59,6 @@ func (c *MakeAddPkgCfg) RegisterFlags(fs *flag.FlagSet) {
}

func execMakeAddPkg(cfg *MakeAddPkgCfg, args []string, io commands.IO) error {
if cfg.PkgPath == "" {
return errors.New("pkgpath not specified")
}
if cfg.PkgDir == "" {
return errors.New("pkgdir not specified")
}
Expand Down Expand Up @@ -95,10 +86,17 @@ func execMakeAddPkg(cfg *MakeAddPkgCfg, args []string, io commands.IO) error {
panic(err)
}

// read and parse gno.mod
gm, err := gnomod.ParseGnoMod(filepath.Join(cfg.PkgDir, "gno.mod"))
if err != nil {
panic(err)
}

pkgPath := gm.Module.Mod.Path
// open files in directory as MemPackage.
memPkg := gno.ReadMemPackage(cfg.PkgDir, cfg.PkgPath)
memPkg := gno.ReadMemPackage(cfg.PkgDir, pkgPath)
if memPkg.IsEmpty() {
panic(fmt.Sprintf("found an empty package %q", cfg.PkgPath))
panic(fmt.Sprintf("found an empty package %q", pkgPath))
}

// parse gas wanted & fee.
Expand Down

0 comments on commit c541c94

Please sign in to comment.