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
5 changes: 5 additions & 0 deletions starport/pkg/gocmd/gocmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@ func ParseTarget(t string) (goos, goarch string, err error) {

return parsed[0], parsed[1], nil
}

// PackageLiteral returns the string representation of package part of go get [package].
func PackageLiteral(path, version string) string {
return fmt.Sprintf("%s@%s", path, version)
}
23 changes: 9 additions & 14 deletions starport/services/scaffolder/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ import (
)

const (
wasmImport = "github.com/CosmWasm/wasmd"
appPkg = "app"
moduleDir = "x"
wasmVersion = "v0.16.0"
wasmImport = "github.com/CosmWasm/wasmd"
wasmVersion = "v0.16.0"
extrasImport = "github.com/tendermint/spm-extras"
extrasVersion = "v0.1.0"
appPkg = "app"
moduleDir = "x"
)

// moduleCreationOptions holds options for creating a new module
Expand Down Expand Up @@ -290,17 +292,10 @@ func (s *Scaffolder) installWasm() error {
switch s.version {
case cosmosver.StargateZeroFourtyAndAbove:
return cmdrunner.
New(
cmdrunner.DefaultStderr(os.Stderr),
).
New().
Run(context.Background(),
step.New(
step.Exec(
gocmd.Name(),
"get",
wasmImport+"@"+wasmVersion,
),
),
step.New(step.Exec(gocmd.Name(), "get", gocmd.PackageLiteral(wasmImport, wasmVersion))),
step.New(step.Exec(gocmd.Name(), "get", gocmd.PackageLiteral(extrasImport, extrasVersion))),
)
default:
return errors.New("version not supported")
Expand Down
2 changes: 1 addition & 1 deletion starport/templates/app/stargate/go.mod.plush
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/tendermint/spm v0.1.0
github.com/tendermint/spm v0.1.2
github.com/tendermint/tendermint v0.34.11
github.com/tendermint/tm-db v0.6.4
google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced
Expand Down
10 changes: 8 additions & 2 deletions starport/templates/module/import/stargate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func appModifyStargate(replacer placeholder.Replacer) genny.RunFn {
}

templateImport := `%[1]v
"github.com/tendermint/spm-extras/wasmcmd"
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"`
replacementImport := fmt.Sprintf(templateImport, module.PlaceholderSgAppModuleImport)
Expand Down Expand Up @@ -114,7 +115,7 @@ func appModifyStargate(replacer placeholder.Replacer) genny.RunFn {
)

// The gov proposal types can be individually enabled
enabledProposals := cosmoscmd.GetEnabledProposals(ProposalsEnabled, EnableSpecificProposals)
enabledProposals := wasmcmd.GetEnabledProposals(ProposalsEnabled, EnableSpecificProposals)
if len(enabledProposals) != 0 {
govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.wasmKeeper, enabledProposals))
}`
Expand Down Expand Up @@ -150,11 +151,16 @@ func cmdModifyStargate(replacer placeholder.Replacer, opts *ImportOptions) genny
return err
}

templateArgs := `cosmoscmd.WithWasm(),
templateArgs := `cosmoscmd.AddSubCmd(wasmcmd.GenesisWasmMsgCmd(app.DefaultNodeHome)),
cosmoscmd.CustomizeStartCmd(wasmcmd.AddModuleInitFlags),
%[1]v`
replacementArgs := fmt.Sprintf(templateArgs, module.PlaceholderSgRootArgument)
content := replacer.Replace(f.String(), module.PlaceholderSgRootArgument, replacementArgs)

// import spm-extras.
content = replacer.Replace(content, "package main", `package main
import "github.com/tendermint/spm-extras/wasmcmd"`)

newFile := genny.NewFileS(path, content)
return r.File(newFile)
}
Expand Down