diff --git a/ignite/templates/app/files/go.mod.plush b/ignite/templates/app/files/go.mod.plush index 86c13eb7c4..53aa096e38 100644 --- a/ignite/templates/app/files/go.mod.plush +++ b/ignite/templates/app/files/go.mod.plush @@ -4,7 +4,7 @@ go 1.21 require ( cosmossdk.io/api v0.7.1 - cosmossdk.io/client/v2 v2.0.0-20231005140444-10bd5a2cacdc + cosmossdk.io/client/v2 v2.0.0-20231018124024-3abc61fb75d4 cosmossdk.io/core v0.11.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.0 @@ -19,7 +19,7 @@ require ( github.com/cometbft/cometbft v0.38.0 github.com/cosmos/cosmos-db v1.0.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231005140444-10bd5a2cacdc + github.com/cosmos/cosmos-sdk v0.50.0-rc.1.0.20231018124024-3abc61fb75d4 github.com/cosmos/gogoproto v1.4.11 github.com/cosmos/ibc-go/modules/capability v1.0.0-rc6 github.com/cosmos/ibc-go/v8 v8.0.0-beta.1 diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/query_{{queryName}}.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/query_{{queryName}}.go.plush deleted file mode 100644 index 514e103d16..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/query_{{queryName}}.go.plush +++ /dev/null @@ -1,66 +0,0 @@ -package cli - -import ( - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - "<%= ModulePath %>/x/<%= moduleName %>/types" -) - -// Cmd<%= queryName.UpperCamel %>Result queries request result by reqID -func Cmd<%= queryName.UpperCamel %>Result() *cobra.Command { - cmd := &cobra.Command{ - Use: "<%= queryName.Kebab %>-result [request-id]", - Short: "Query the <%= queryName.UpperCamel %> result data by id", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - id, err := strconv.ParseInt(args[0], 10, 64) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - r, err := queryClient.<%= queryName.UpperCamel %>Result(context.Background(), &types.Query<%= queryName.UpperCamel %>Request{RequestId: id}) - if err != nil { - return err - } - - return clientCtx.PrintProto(r) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -// CmdLast<%= queryName.UpperCamel %>ID queries latest request -func CmdLast<%= queryName.UpperCamel %>ID() *cobra.Command { - cmd := &cobra.Command{ - Use: "last-<%= queryName.Kebab %>-id", - Short: "Query the last request id returned by <%= queryName.UpperCamel %> ack packet", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - r, err := queryClient.Last<%= queryName.UpperCamel %>Id(cmd.Context(), &types.QueryLast<%= queryName.UpperCamel %>IdRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(r) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/tx_oracle.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/tx_oracle.go.plush deleted file mode 100644 index 85ee6da6d2..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/tx_oracle.go.plush +++ /dev/null @@ -1,10 +0,0 @@ -package cli - -const ( - flagChannel = "channel" - flagSymbols = "symbols" - flagMultiplier = "multiplier" - flagFeeLimit = "fee-limit" - flagPrepareGas = "prepare-gas" - flagExecuteGas = "execute-gas" -) diff --git a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/tx_{{queryName}}.go.plush b/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/tx_{{queryName}}.go.plush deleted file mode 100644 index 931529fa57..0000000000 --- a/ignite/templates/ibc/files/oracle/x/{{moduleName}}/client/cli/tx_{{queryName}}.go.plush +++ /dev/null @@ -1,118 +0,0 @@ -package cli - -import ( - "strconv" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "<%= ModulePath %>/x/<%= moduleName %>/types" -) - -// CmdRequest<%= queryName.UpperCamel %>Data creates and broadcast a <%= queryName.UpperCamel %> request transaction -func CmdRequest<%= queryName.UpperCamel %>Data() *cobra.Command { - cmd := &cobra.Command{ - Use: "<%= queryName.Kebab %>-data [oracle-script-id] [requested-validator-count] [sufficient-validator-count]", - Short: "Make a new <%= queryName.UpperCamel %> query request via an existing BandChain oracle script", - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - // retrieve the oracle script id. - uint64OracleScriptID, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - oracleScriptID := types.OracleScriptID(uint64OracleScriptID) - - // retrieve the requested validator count. - askCount, err := strconv.ParseUint(args[1], 10, 64) - if err != nil { - return err - } - - // retrieve the sufficient(minimum) validator count. - minCount, err := strconv.ParseUint(args[2], 10, 64) - if err != nil { - return err - } - - channel, err := cmd.Flags().GetString(flagChannel) - if err != nil { - return err - } - - // retrieve the list of symbols for the requested oracle script. - symbols, err := cmd.Flags().GetStringSlice(flagSymbols) - if err != nil { - return err - } - - // retrieve the multiplier for the symbols' price. - multiplier, err := cmd.Flags().GetUint64(flagMultiplier) - if err != nil { - return err - } - - calldata := &types.<%= queryName.UpperCamel %>CallData{ - Symbols: symbols, - Multiplier: multiplier, - } - - // retrieve the amount of coins allowed to be paid for oracle request fee from the pool account. - coinStr, err := cmd.Flags().GetString(flagFeeLimit) - if err != nil { - return err - } - feeLimit, err := sdk.ParseCoinsNormalized(coinStr) - if err != nil { - return err - } - - // retrieve the amount of gas allowed for the prepare step of the oracle script. - prepareGas, err := cmd.Flags().GetUint64(flagPrepareGas) - if err != nil { - return err - } - - // retrieve the amount of gas allowed for the execute step of the oracle script. - executeGas, err := cmd.Flags().GetUint64(flagExecuteGas) - if err != nil { - return err - } - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := types.NewMsg<%= queryName.UpperCamel %>Data( - clientCtx.GetFromAddress().String(), - oracleScriptID, - channel, - calldata, - askCount, - minCount, - feeLimit, - prepareGas, - executeGas, - ) - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(flagChannel, "", "The channel id") - cmd.MarkFlagRequired(flagChannel) - cmd.Flags().StringSlice(flagSymbols, nil, "Symbols used in calling the oracle script") - cmd.Flags().Uint64(flagMultiplier, 1000000, "Multiplier used in calling the oracle script") - cmd.Flags().String(flagFeeLimit, "", "the maximum tokens that will be paid to all data source providers") - cmd.Flags().Uint64(flagPrepareGas, 200000, "Prepare gas used in fee counting for prepare request") - cmd.Flags().Uint64(flagExecuteGas, 200000, "Execute gas used in fee counting for execute request") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush b/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush index f6f27b57a8..647cfda4c8 100644 --- a/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush +++ b/ignite/templates/ibc/files/packet/messages/x/{{moduleName}}/client/cli/tx_{{packetName}}.go.plush @@ -14,6 +14,7 @@ import ( var _ = strconv.Itoa(0) +// This command does not use AutoCLI because it gives a better UX to do not. func CmdSend<%= packetName.UpperCamel %>() *cobra.Command { flagPacketTimeoutTimestamp := "packet-timeout-timestamp" diff --git a/ignite/templates/ibc/packet.go b/ignite/templates/ibc/packet.go index 81dc2d3484..e953717bdd 100644 --- a/ignite/templates/ibc/packet.go +++ b/ignite/templates/ibc/packet.go @@ -346,8 +346,14 @@ func protoTxModify(opts *PacketOptions) genny.RunFn { } } +// 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 { + // TODO + // create tx.go if not exist + // add send command + // edit module.go to a tx command on app module basic + path := filepath.Join(opts.AppPath, "x", opts.ModuleName, "client/cli/tx.go") f, err := r.Disk.Find(path) if err != nil { diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/autocli.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/autocli.go.plush index 290f6cb17a..acd0bf5c6a 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/autocli.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/autocli.go.plush @@ -23,6 +23,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, Tx: &autocliv1.ServiceCommandDescriptor{ Service: modulev1.Msg_ServiceDesc.ServiceName, + EnhanceCustomCommand: true, // only required if you want to use the custom command RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "UpdateParams", diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/module.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/module.go.plush index c7a0f64b66..558c9e745d 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/module.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/module.go.plush @@ -91,6 +91,13 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r } } +// GetTxCmd returns the root Tx command for the module. +// These commands enrich the AutoCLI tx commands. +// When creating non AutoCLI commands, add the following: +// func (a AppModuleBasic) GetTxCmd() *cobra.Command { +// return cli.GetTxCmd() +// } + // ---------------------------------------------------------------------------- // AppModule // ----------------------------------------------------------------------------