Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 1 addition & 31 deletions starport/cmd/scaffold_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/tendermint/starport/starport/pkg/placeholder"
"github.com/tendermint/starport/starport/pkg/validation"
"github.com/tendermint/starport/starport/services/scaffolder"
"github.com/tendermint/starport/starport/templates/module"
modulecreate "github.com/tendermint/starport/starport/templates/module/create"
)

Expand All @@ -23,31 +22,7 @@ const (
flagRequireRegistration = "require-registration"
)

var ibcRouterPlaceholderInstruction = fmt.Sprintf(`
💬 To enable scaffolding of IBC modules, remove these lines from app/app.go:

%s

💬 Then, find the following line:

%s

💬 Finally, add this block of code below:
%s

`,
infoColor(`ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
app.IBCKeeper.SetRouter(ibcRouter)`),
infoColor(module.PlaceholderSgAppKeeperDefinition),
infoColor(`ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
`+module.PlaceholderIBCAppRouter+`
app.IBCKeeper.SetRouter(ibcRouter)`),
)

// NewScaffoldModule returns the command to scaffold an
// sdk module.
// NewScaffoldModule returns the command to scaffold a Cosmos SDK module
func NewScaffoldModule() *cobra.Command {
c := &cobra.Command{
Use: "module [name]",
Expand Down Expand Up @@ -125,11 +100,6 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
sm, err := sc.CreateModule(placeholder.New(), name, options...)
s.Stop()
if err != nil {
// If this is an old scaffolded application that doesn't contain the necessary placeholder
// We give instruction to the user to modify the application
if err == scaffolder.ErrNoIBCRouterPlaceholder {
fmt.Print(ibcRouterPlaceholderInstruction)
}
var validationErr validation.Error
if !requireRegistration && errors.As(err, &validationErr) {
fmt.Fprintf(&msg, "Can't register module '%s'.\n", name)
Expand Down
31 changes: 0 additions & 31 deletions starport/services/scaffolder/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"go/parser"
"go/token"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -27,10 +26,6 @@ import (
moduleimport "github.com/tendermint/starport/starport/templates/module/import"
)

var (
ErrNoIBCRouterPlaceholder = errors.New("app.go doesn't contain the necessary placeholder to generate an IBC module")
)

const (
wasmImport = "github.com/CosmWasm/wasmd"
appPkg = "app"
Expand Down Expand Up @@ -131,15 +126,6 @@ func (s *Scaffolder) CreateModule(
IBCOrdering: creationOpts.ibcChannelOrdering,
Dependencies: creationOpts.dependencies,
}
if opts.IsIBC {
ibcPlaceholder, err := checkIBCRouterPlaceholder(s.path)
if err != nil {
return sm, err
}
if !ibcPlaceholder {
return sm, ErrNoIBCRouterPlaceholder
}
}

// Generator from Cosmos SDK version
g, err := modulecreate.NewStargate(opts)
Expand Down Expand Up @@ -316,23 +302,6 @@ func (s *Scaffolder) installWasm() error {
}
}

// checkIBCRouterPlaceholder checks if app.go contains PlaceholderIBCAppRouter
// this placeholder is necessary to scaffold a new IBC module
// if it doesn't exist, we give instruction to add it to the user
func checkIBCRouterPlaceholder(appPath string) (bool, error) {
appGo, err := filepath.Abs(filepath.Join(appPath, module.PathAppGo))
if err != nil {
return false, err
}

content, err := ioutil.ReadFile(appGo)
if err != nil {
return false, err
}

return strings.Contains(string(content), module.PlaceholderIBCAppRouter), nil
}

// checkDependencies perform checks on the dependencies
func checkDependencies(dependencies []modulecreate.Dependency) error {
depMap := make(map[string]struct{})
Expand Down