Skip to content

Commit

Permalink
chore: Address linting issues in apps/ (#6117)
Browse files Browse the repository at this point in the history
* Address linting issues in apps/

* Update modules/apps/callbacks/testing/simapp/app.go

Co-authored-by: Carlos Rodriguez <[email protected]>

* Better panic messages

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Cian Hatton <[email protected]>
  • Loading branch information
3 people authored Apr 9, 2024
1 parent 8547b0b commit 9543cc6
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,9 @@ func (suite *InterchainAccountsTestSuite) TestGetAppVersion() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

controllerStack := cbs.(porttypes.ICS4Wrapper)
controllerStack, ok := cbs.(porttypes.ICS4Wrapper)
suite.Require().True(ok)

appVersion, found := controllerStack.GetAppVersion(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
suite.Require().True(found)
suite.Require().Equal(path.EndpointA.ChannelConfig.Version, appVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
v6 "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6"
"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/migrations/v6"
"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
Expand Down
10 changes: 8 additions & 2 deletions modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,14 @@ func newModuleQuerySafeAllowList() []string {
sd := fd.Services().Get(i)

// Skip services that are annotated with the "cosmos.msg.v1.service" option.
if ext := proto.GetExtension(sd.Options(), msgv1.E_Service); ext != nil && ext.(bool) {
continue
if ext := proto.GetExtension(sd.Options(), msgv1.E_Service); ext != nil {
val, ok := ext.(bool)
if !ok {
panic(fmt.Errorf("cannot convert %T to %T", ext, ok))
}
if val {
continue
}
}

for j := 0; j < sd.Methods().Len(); j++ {
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/types/keys_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types_test

import (
fmt "fmt"
"fmt"

"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/27-interchain-accounts/types/router.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types

import (
baseapp "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down
4 changes: 3 additions & 1 deletion modules/apps/29-fee/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,9 @@ func (suite *FeeTestSuite) TestGetAppVersion() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

feeModule := cbs.(porttypes.ICS4Wrapper)
feeModule, ok := cbs.(porttypes.ICS4Wrapper)
suite.Require().True(ok)

appVersion, found := feeModule.GetAppVersion(suite.chainA.GetContext(), portID, channelID)

if tc.expFound {
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/callbacks/callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

abci "github.com/cometbft/cometbft/abci/types"

simapp "github.com/cosmos/ibc-go/modules/apps/callbacks/testing/simapp"
"github.com/cosmos/ibc-go/modules/apps/callbacks/testing/simapp"
"github.com/cosmos/ibc-go/modules/apps/callbacks/types"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
Expand Down
9 changes: 6 additions & 3 deletions modules/apps/callbacks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,8 @@ func (s *CallbacksTestSuite) TestGetAppVersion() {
icaControllerStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(icacontrollertypes.SubModuleName)
s.Require().True(ok)

controllerStack := icaControllerStack.(porttypes.ICS4Wrapper)
controllerStack, ok := icaControllerStack.(porttypes.ICS4Wrapper)
s.Require().True(ok)
appVersion, found := controllerStack.GetAppVersion(s.chainA.GetContext(), s.path.EndpointA.ChannelConfig.PortID, s.path.EndpointA.ChannelID)
s.Require().True(found)
s.Require().Equal(s.path.EndpointA.ChannelConfig.Version, appVersion)
Expand All @@ -987,7 +988,8 @@ func (s *CallbacksTestSuite) TestOnChanCloseInit() {
icaControllerStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(icacontrollertypes.SubModuleName)
s.Require().True(ok)

controllerStack := icaControllerStack.(porttypes.Middleware)
controllerStack, ok := icaControllerStack.(porttypes.Middleware)
s.Require().True(ok)
err := controllerStack.OnChanCloseInit(s.chainA.GetContext(), s.path.EndpointA.ChannelConfig.PortID, s.path.EndpointA.ChannelID)
// we just check that this call is passed down to the icacontroller to return an error
s.Require().ErrorIs(err, errorsmod.Wrap(ibcerrors.ErrInvalidRequest, "user cannot close channel"))
Expand All @@ -1001,7 +1003,8 @@ func (s *CallbacksTestSuite) TestOnChanCloseConfirm() {
icaControllerStack, ok := s.chainA.App.GetIBCKeeper().Router.GetRoute(icacontrollertypes.SubModuleName)
s.Require().True(ok)

controllerStack := icaControllerStack.(porttypes.Middleware)
controllerStack, ok := icaControllerStack.(porttypes.Middleware)
s.Require().True(ok)
err := controllerStack.OnChanCloseConfirm(s.chainA.GetContext(), s.path.EndpointA.ChannelConfig.PortID, s.path.EndpointA.ChannelID)
// we just check that this call is passed down to the icacontroller
s.Require().NoError(err)
Expand Down
22 changes: 17 additions & 5 deletions modules/apps/callbacks/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensus "github.com/cosmos/cosmos-sdk/x/consensus"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
Expand Down Expand Up @@ -118,7 +118,7 @@ import (
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
Expand Down Expand Up @@ -511,7 +511,12 @@ func NewSimApp(
var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibccallbacks.NewIBCMiddleware(transferStack, app.IBCFeeKeeper, app.MockContractKeeper, maxCallbackGas)
transferICS4Wrapper := transferStack.(porttypes.ICS4Wrapper)
var transferICS4Wrapper porttypes.ICS4Wrapper
transferICS4Wrapper, ok := transferStack.(porttypes.ICS4Wrapper)
if !ok {
panic(fmt.Errorf("cannot convert %T to %T", transferStack, transferICS4Wrapper))
}

transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)
// Since the callbacks middleware itself is an ics4wrapper, it needs to be passed to the transfer keeper
app.TransferKeeper.WithICS4Wrapper(transferICS4Wrapper)
Expand All @@ -526,10 +531,17 @@ func NewSimApp(
// initialize ICA module with mock module as the authentication module on the controller side
var icaControllerStack porttypes.IBCModule
icaControllerStack = ibcmock.NewIBCModule(&mockModule, ibcmock.NewIBCApp("", scopedICAMockKeeper))
app.ICAAuthModule = icaControllerStack.(ibcmock.IBCModule)
app.ICAAuthModule, ok = icaControllerStack.(ibcmock.IBCModule)
if !ok {
panic(fmt.Errorf("cannot convert %T to %T", icaControllerStack, app.ICAAuthModule))
}
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper)
icaControllerStack = ibccallbacks.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper, app.MockContractKeeper, maxCallbackGas)
icaICS4Wrapper := icaControllerStack.(porttypes.ICS4Wrapper)
var icaICS4Wrapper porttypes.ICS4Wrapper
icaICS4Wrapper, ok = icaControllerStack.(porttypes.ICS4Wrapper)
if !ok {
panic(fmt.Errorf("cannot convert %T to %T", icaControllerStack, icaICS4Wrapper))
}
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)
// Since the callbacks middleware itself is an ics4wrapper, it needs to be passed to the ica controller keeper
app.ICAControllerKeeper.WithICS4Wrapper(icaICS4Wrapper)
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/callbacks/types/callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cometbft/cometbft/crypto/secp256k1"

"github.com/cosmos/ibc-go/modules/apps/callbacks/types"
transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/types/transfer_authorization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
sdkmath "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
authz "github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/authz"

"github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
Expand Down

0 comments on commit 9543cc6

Please sign in to comment.