Skip to content

Commit 9380f1c

Browse files
committed
fix: gnodev, gnogensis
Signed-off-by: Norman <norman@samourai.coop>
1 parent 7523824 commit 9380f1c

File tree

5 files changed

+15
-29
lines changed

5 files changed

+15
-29
lines changed

contribs/gnodev/pkg/dev/node.go

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/gnolang/gno/gno.land/pkg/gnoland"
1717
"github.com/gnolang/gno/gno.land/pkg/gnoland/ugnot"
1818
"github.com/gnolang/gno/gno.land/pkg/integration"
19-
"github.com/gnolang/gno/gnovm/pkg/gnolang"
2019
"github.com/gnolang/gno/gnovm/pkg/packages"
2120
"github.com/gnolang/gno/tm2/pkg/amino"
2221
tmcfg "github.com/gnolang/gno/tm2/pkg/bft/config"
@@ -250,10 +249,6 @@ func (n *Node) updatePackages(paths ...string) error {
250249

251250
// Update or add package in the current known list.
252251
for _, pkg := range pkgslist {
253-
if pkg.ImportPath != "" && gnolang.IsStdlib(pkg.ImportPath) {
254-
continue
255-
}
256-
257252
n.pkgs[pkg.Dir] = Package{
258253
Package: pkg,
259254
Creator: deployer,

contribs/gnodev/pkg/dev/packages.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ func NewPackagesMap(cfg *packages.LoadConfig, ppaths []PackagePath) (PackagesMap
9898
continue
9999
}
100100

101-
if pkg.ImportPath != "" && gnolang.IsStdlib(pkg.ImportPath) {
102-
continue
103-
}
104-
105101
if _, ok := pkgs[pkg.Dir]; ok {
106102
continue // skip
107103
}
@@ -136,6 +132,10 @@ func (pm PackagesMap) Load(fee std.Fee, start time.Time) ([]gnoland.TxWithMetada
136132

137133
metatxs := make([]gnoland.TxWithMetadata, 0, len(nonDraft))
138134
for _, modPkg := range nonDraft {
135+
if modPkg.ImportPath == "" || gnolang.IsStdlib(modPkg.ImportPath) {
136+
continue
137+
}
138+
139139
pkg := pm[modPkg.Dir]
140140
if pkg.Creator.IsZero() {
141141
return nil, fmt.Errorf("no creator set for %q", pkg.Dir)

contribs/gnogenesis/internal/txs/txs_add_packages.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func execTxsAddPackages(
125125
parsedTxs := make([]gnoland.TxWithMetadata, 0)
126126
for _, path := range args {
127127
// Generate transactions from the packages (recursively)
128-
loadCfg := &packages.LoadConfig{IO: io, SelfContained: true}
128+
loadCfg := &packages.LoadConfig{IO: io, Deps: true}
129129
txs, err := gnoland.LoadPackagesFromDir(loadCfg, path, creator, genesisDeployFee)
130130
if err != nil {
131131
return fmt.Errorf("unable to load txs from directory, %w", err)

gnovm/pkg/packages/analyze_packages.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@ func readPkgDir(pkgDir string, importPath string, fset *token.FileSet) *Package
7373
ImportPath: importPath,
7474
}
7575

76-
stdlibsPath := filepath.Join(gnoenv.RootDir(), "gnovm", "stdlibs")
77-
if strings.HasPrefix(filepath.Clean(pkg.Dir), stdlibsPath) {
78-
libPath, err := filepath.Rel(stdlibsPath, pkg.Dir)
79-
if err != nil {
80-
pkg.Errors = append(pkg.Errors, err)
81-
return pkg
76+
if pkg.ImportPath == "" {
77+
stdlibsPath := filepath.Join(gnoenv.RootDir(), "gnovm", "stdlibs")
78+
if strings.HasPrefix(filepath.Clean(pkg.Dir), stdlibsPath) {
79+
libPath, err := filepath.Rel(stdlibsPath, pkg.Dir)
80+
if err != nil {
81+
pkg.Errors = append(pkg.Errors, err)
82+
return pkg
83+
}
84+
pkg.ImportPath = libPath
8285
}
83-
pkg.ImportPath = libPath
8486
}
8587

8688
files := []string{}

gnovm/pkg/packages/load.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,7 @@ func Load(conf *LoadConfig, patterns ...string) (PkgList, error) {
120120

121121
// check if this is a stdlib and queue it
122122
if gnolang.IsStdlib(imp) {
123-
dir := filepath.Join(gnoroot, "gnovm", "stdlibs", filepath.FromSlash(imp))
124-
dirInfo, err := os.Stat(dir)
125-
if err == nil && !dirInfo.IsDir() {
126-
err = fmt.Errorf("%q is not a directory", dir)
127-
}
128-
if err != nil {
129-
pkg.Errors = append(pkg.Errors, err)
130-
delete(queuedByPkgPath, imp) // stop trying to get this lib, we can't
131-
continue
132-
}
133-
134-
pkg := readPkgDir(dir, imp, fset)
123+
pkg := readPkgDir(filepath.Join(gnoroot, "gnovm", "stdlibs", filepath.FromSlash(imp)), imp, fset)
135124
markForVisit(pkg)
136125
continue
137126
}

0 commit comments

Comments
 (0)