Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dependencies option for module create #1287

Merged
merged 41 commits into from
Jul 5, 2021
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1d55c02
expected keeper template
lumtis Jun 21, 2021
34aaa49
add dependenciy options
lumtis Jun 21, 2021
565831c
Template init
lumtis Jun 22, 2021
8b9eafe
Add misc errors to tracer
lumtis Jun 22, 2021
6148c53
app.go modification
lumtis Jun 22, 2021
398aa98
Merge branch 'develop' into feat/module-deps
lumtis Jun 22, 2021
c73e72e
app.go update gov
lumtis Jun 22, 2021
aed8bc3
Add tests
lumtis Jun 22, 2021
7099905
Fix generated tests
lumtis Jun 22, 2021
c4ba699
gov module warning
lumtis Jun 22, 2021
f909d96
Check dependencies
lumtis Jun 22, 2021
dc64f5d
Fix test
lumtis Jun 22, 2021
7f40b9b
bank permissions
lumtis Jun 22, 2021
bff0de3
Merge branch 'develop' into feat/module-deps
lumtis Jun 22, 2021
8661015
Fix ibc test
lumtis Jun 22, 2021
5c4c201
Merge branch 'develop' into feat/module-deps
lumtis Jun 22, 2021
0675a45
Merge branch 'develop' into feat/module-deps
lumtis Jun 23, 2021
a00c3d4
Merge branch 'develop' into feat/module-deps
lumtis Jun 24, 2021
6aef2c3
Update starport/cmd/module-create.go
lumtis Jun 25, 2021
70af24c
Use string slice
lumtis Jun 25, 2021
1492ad8
Conflict
lumtis Jun 25, 2021
be07620
lint
lumtis Jun 25, 2021
cfc3349
Merge branch 'develop' into feat/module-deps
lumtis Jun 28, 2021
cc449ae
Parse app module
lumtis Jun 29, 2021
5aa900d
Update dependency type
lumtis Jun 29, 2021
5c557fe
Fix validation error bug
lumtis Jun 29, 2021
49ee9c0
Add tests for app analysis
lumtis Jun 29, 2021
76399e4
Lint
lumtis Jun 29, 2021
f9693c4
Merge branch 'develop' into feat/module-deps
lumtis Jun 29, 2021
ce86cb6
Merge branch 'develop' into feat/module-deps
lumtis Jul 1, 2021
f345741
Refactor cosmosanalysis
lumtis Jul 1, 2021
6a92b6c
Lint
lumtis Jul 1, 2021
9efd501
Interface
lumtis Jul 1, 2021
cd1cb63
Parse module instead of files
lumtis Jul 1, 2021
f2a8633
Ilker comment
lumtis Jul 1, 2021
08812cb
No non-registered
lumtis Jul 1, 2021
a177ef5
New test
lumtis Jul 1, 2021
38e0329
Conflicts
lumtis Jul 5, 2021
5e50910
Fix tests
lumtis Jul 5, 2021
67e1870
Module create fix
lumtis Jul 5, 2021
f4b5a1f
Merge branch 'develop' into feat/module-deps
lumtis Jul 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions starport/pkg/cosmosanalysis/app/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package app

import (
"fmt"
"go/ast"
"go/parser"
"go/token"
)

const (
appTypeName = "App"
lumtis marked this conversation as resolved.
Show resolved Hide resolved
)

// CheckKeeper checks for the existence of the keeper with the provided name in the app structure
func CheckKeeper(appPath, keeperName string) error {
fileSet := token.NewFileSet()
f, err := parser.ParseFile(fileSet, appPath, nil, 0)
if err != nil {
return err
}

// Inspect the file for app struct
var found bool
ast.Inspect(f, func(n ast.Node) bool {
// look for struct methods.
appType, ok := n.(*ast.TypeSpec)
if !ok || appType.Name.Name != appTypeName {
return true
}

appStruct, ok := appType.Type.(*ast.StructType)
if !ok {
return true
}

// Search for the keeper specific field
for _, field := range appStruct.Fields.List {
for _, fieldName := range field.Names {
if fieldName.Name == keeperName {
found = true
lumtis marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

return false
})

if !found {
return fmt.Errorf("app doesn't contain %s", keeperName)
}
return nil
}