diff --git a/changelog.md b/changelog.md index 21d383a894..e3ee587373 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixes + +- [#4833](https://github.com/ignite/cli/pull/4833) IBC consensus state not found. + ## [`v29.6.1`](https://github.com/ignite/cli/releases/tag/v29.6.1) ### Changes diff --git a/ignite/templates/app/files/app/app.go.plush b/ignite/templates/app/files/app/app.go.plush index ad956c108e..cabb3fab91 100644 --- a/ignite/templates/app/files/app/app.go.plush +++ b/ignite/templates/app/files/app/app.go.plush @@ -143,6 +143,13 @@ func New( depinject.Supply( appOpts, // supply app options logger, // supply logger + + // Supply with IBC keeper getter for the IBC modules with App Wiring. + // The IBC Keeper cannot be passed because it has not been initiated yet. + // Passing the getter, the app IBC Keeper will always be accessible. + // This needs to be removed after IBC supports App Wiring. + app.GetIBCKeeper, + // here alternative options can be supplied to the DI container. // those options can be used f.e to override the default behavior of some modules. // for instance supplying a custom address codec for not using bech32 addresses. diff --git a/ignite/templates/app/files/app/ibc.go.plush b/ignite/templates/app/files/app/ibc.go.plush index 8417129cc6..ce79e6fe14 100644 --- a/ignite/templates/app/files/app/ibc.go.plush +++ b/ignite/templates/app/files/app/ibc.go.plush @@ -166,3 +166,9 @@ func RegisterIBC(cdc codec.Codec) map[string]appmodule.AppModule { return modules } + +// GetIBCKeeper returns the IBC keeper. +// Used for supply with IBC keeper getter for the IBC modules with App Wiring. +func (app *App) GetIBCKeeper() *ibckeeper.Keeper { + return app.IBCKeeper +} 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 7d87ff9a85..ca7ad15f3c 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 @@ -3,13 +3,12 @@ package cli import ( <%= for (goImport) in mergeGoImports(fields) { %> <%= goImport.Alias %> "<%= goImport.Name %>"<% } %> - "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" + "time" + + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" - channelutils "github.com/cosmos/ibc-go/v10/modules/core/04-channel/client/utils" - "github.com/cosmos/ibc-go/v10/modules/core/exported" + "github.com/spf13/cobra" "<%= ModulePath %>/x/<%= moduleName %>/types" ) @@ -42,30 +41,14 @@ func CmdSend<%= packetName.PascalCase %>() *cobra.Command { return err } -clientRes, err := channelutils.QueryChannelClientState(clientCtx, srcPort, srcChannel, false) - if err != nil { - return err + if timeoutTimestamp != 0 { + now := time.Now().UnixNano() + if now <= 0 { + return err + } + timeoutTimestamp = uint64(now) + timeoutTimestamp } - var clientState exported.ClientState - if err := clientCtx.InterfaceRegistry.UnpackAny(clientRes.IdentifiedClientState.ClientState, &clientState); err != nil { - return err - } - - consensusStateAny, err := channelutils.QueryChannelConsensusState(clientCtx, srcPort, srcChannel, clienttypes.Height{}, false) - if err != nil { - return err - } - - var consensusState exported.ConsensusState - if err := clientCtx.InterfaceRegistry.UnpackAny(consensusStateAny.GetConsensusState(), &consensusState); err != nil { - return err - } - - if timeoutTimestamp != 0 { - timeoutTimestamp = consensusState.GetTimestamp() + timeoutTimestamp //nolint:staticcheck // client side - } - msg := types.NewMsgSend<%= packetName.PascalCase %>(<%= MsgSigner.LowerCamel %>, srcPort, srcChannel, timeoutTimestamp<%= for (i, field) in fields { %>, arg<%= field.Name.PascalCase %><% } %>) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)