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

fix: add missing tx.go file by default and enable cli if autocli does not exist #3849

Merged
merged 12 commits into from
Dec 20, 2023
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [#3825](https://github.com/ignite/cli/pull/3825) Fix a minor Keplr type-checking bug in TS client
- [#3836](https://github.com/ignite/cli/pull/3836) Add missing IBC commands for scaffolded chain
- [#3833](https://github.com/ignite/cli/pull/3833) Improve Cosmos SDK detection to support SDK forks
- [#3849](https://github.com/ignite/cli/pull/3849) Add missing `tx.go` file by default and enable cli if autocli does not exist
- [#3851](https://github.com/ignite/cli/pull/3851) Add missing ibc interfaces to chain client

## [`v28.0.0`](https://github.com/ignite/cli/releases/tag/v28.0.0)
Expand Down
15 changes: 0 additions & 15 deletions ignite/templates/ibc/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ibc
import (
"embed"
"fmt"
"os"
"path/filepath"

"github.com/emicklei/proto"
Expand Down Expand Up @@ -352,24 +351,10 @@ func protoTxModify(opts *PacketOptions) genny.RunFn {
}
}

//go:embed templates/packet/tx.tpl
var txTemplate string

// clientCliTxModify does not use AutoCLI here, because it as a better UX as it is.
func clientCliTxModify(replacer placeholder.Replacer, opts *PacketOptions) genny.RunFn {
return func(r *genny.Runner) error {
filePath := filepath.Join(opts.AppPath, "x", opts.ModuleName, "client/cli/tx.go")
if _, err := os.Stat(filePath); errors.Is(err, os.ErrNotExist) {
content := fmt.Sprintf(txTemplate, opts.ModulePath, opts.ModuleName)
if err := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {
return err
}

if err := os.WriteFile(filePath, []byte(content), 0o644); err != nil {
return err
}
}

f, err := r.Disk.Find(filePath)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/runtime"
<%= if (isIBC) { %>porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"<% } %>
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
"github.com/spf13/cobra"<% } %>

// this line is used by starport scaffolding # 1

modulev1 "<%= modulePath %>/api/<%= appName %>/<%= moduleName %>/module"
"<%= modulePath %>/x/<%= moduleName %>/keeper"
"<%= modulePath %>/x/<%= moduleName %>/types"
<%= if (isIBC) { %>"<%= modulePath %>/x/<%= moduleName %>/client/cli"<% } %>
)

var (
Expand Down Expand Up @@ -91,12 +93,14 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
}
}

<%= if (isIBC) { %>
// GetTxCmd returns the root Tx command for the module.
// These commands enrich the AutoCLI tx commands.
// When creating non AutoCLI commands, add the following:
Pantani marked this conversation as resolved.
Show resolved Hide resolved
Pantani marked this conversation as resolved.
Show resolved Hide resolved
// func (a AppModuleBasic) GetTxCmd() *cobra.Command {
// return cli.GetTxCmd()
// }
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.GetTxCmd()
}
<% } %>

// ----------------------------------------------------------------------------
// AppModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ import (
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"%s/x/%s/types"
// "github.com/cosmos/cosmos-sdk/client/flags"
"<%= modulePath %>/x/<%= moduleName %>/types"
)

var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())

const listSeparator = ","

// GetTxCmd returns the transaction commands for this module
// GetTxCmd returns the transaction commands for this module.
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%%s transactions subcommands", types.ModuleName),
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

// this line is used by starport scaffolding # 1

return cmd
}
return cmd
}
Loading