Skip to content

Commit febbf32

Browse files
authored
fix(scaffolder): remove the ibc missing placeholder error (ignite#1328)
1 parent 4c3533d commit febbf32

File tree

2 files changed

+1
-62
lines changed

2 files changed

+1
-62
lines changed

starport/cmd/scaffold_module.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/tendermint/starport/starport/pkg/placeholder"
1313
"github.com/tendermint/starport/starport/pkg/validation"
1414
"github.com/tendermint/starport/starport/services/scaffolder"
15-
"github.com/tendermint/starport/starport/templates/module"
1615
modulecreate "github.com/tendermint/starport/starport/templates/module/create"
1716
)
1817

@@ -23,31 +22,7 @@ const (
2322
flagRequireRegistration = "require-registration"
2423
)
2524

26-
var ibcRouterPlaceholderInstruction = fmt.Sprintf(`
27-
💬 To enable scaffolding of IBC modules, remove these lines from app/app.go:
28-
29-
%s
30-
31-
💬 Then, find the following line:
32-
33-
%s
34-
35-
💬 Finally, add this block of code below:
36-
%s
37-
38-
`,
39-
infoColor(`ibcRouter := porttypes.NewRouter()
40-
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
41-
app.IBCKeeper.SetRouter(ibcRouter)`),
42-
infoColor(module.PlaceholderSgAppKeeperDefinition),
43-
infoColor(`ibcRouter := porttypes.NewRouter()
44-
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
45-
`+module.PlaceholderIBCAppRouter+`
46-
app.IBCKeeper.SetRouter(ibcRouter)`),
47-
)
48-
49-
// NewScaffoldModule returns the command to scaffold an
50-
// sdk module.
25+
// NewScaffoldModule returns the command to scaffold a Cosmos SDK module
5126
func NewScaffoldModule() *cobra.Command {
5227
c := &cobra.Command{
5328
Use: "module [name]",
@@ -125,11 +100,6 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error {
125100
sm, err := sc.CreateModule(placeholder.New(), name, options...)
126101
s.Stop()
127102
if err != nil {
128-
// If this is an old scaffolded application that doesn't contain the necessary placeholder
129-
// We give instruction to the user to modify the application
130-
if err == scaffolder.ErrNoIBCRouterPlaceholder {
131-
fmt.Print(ibcRouterPlaceholderInstruction)
132-
}
133103
var validationErr validation.Error
134104
if !requireRegistration && errors.As(err, &validationErr) {
135105
fmt.Fprintf(&msg, "Can't register module '%s'.\n", name)

starport/services/scaffolder/module.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"go/parser"
88
"go/token"
9-
"io/ioutil"
109
"os"
1110
"path/filepath"
1211
"strings"
@@ -27,10 +26,6 @@ import (
2726
moduleimport "github.com/tendermint/starport/starport/templates/module/import"
2827
)
2928

30-
var (
31-
ErrNoIBCRouterPlaceholder = errors.New("app.go doesn't contain the necessary placeholder to generate an IBC module")
32-
)
33-
3429
const (
3530
wasmImport = "github.com/CosmWasm/wasmd"
3631
appPkg = "app"
@@ -131,15 +126,6 @@ func (s *Scaffolder) CreateModule(
131126
IBCOrdering: creationOpts.ibcChannelOrdering,
132127
Dependencies: creationOpts.dependencies,
133128
}
134-
if opts.IsIBC {
135-
ibcPlaceholder, err := checkIBCRouterPlaceholder(s.path)
136-
if err != nil {
137-
return sm, err
138-
}
139-
if !ibcPlaceholder {
140-
return sm, ErrNoIBCRouterPlaceholder
141-
}
142-
}
143129

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

319-
// checkIBCRouterPlaceholder checks if app.go contains PlaceholderIBCAppRouter
320-
// this placeholder is necessary to scaffold a new IBC module
321-
// if it doesn't exist, we give instruction to add it to the user
322-
func checkIBCRouterPlaceholder(appPath string) (bool, error) {
323-
appGo, err := filepath.Abs(filepath.Join(appPath, module.PathAppGo))
324-
if err != nil {
325-
return false, err
326-
}
327-
328-
content, err := ioutil.ReadFile(appGo)
329-
if err != nil {
330-
return false, err
331-
}
332-
333-
return strings.Contains(string(content), module.PlaceholderIBCAppRouter), nil
334-
}
335-
336305
// checkDependencies perform checks on the dependencies
337306
func checkDependencies(dependencies []modulecreate.Dependency) error {
338307
depMap := make(map[string]struct{})

0 commit comments

Comments
 (0)