Skip to content

Commit 5a331ed

Browse files
committed
fix all errors
1 parent a0bf113 commit 5a331ed

File tree

22 files changed

+181
-154
lines changed

22 files changed

+181
-154
lines changed

modules/apps/27-interchain-accounts/controller/keeper/account.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
sdk "github.com/cosmos/cosmos-sdk/types"
99
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
1010

11-
"github.com/cosmos/ibc-go/v9/internal/logging"
1211
icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types"
1312
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
1413
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
@@ -84,12 +83,6 @@ func (k Keeper) registerInterchainAccount(ctx context.Context, connectionID, por
8483
return "", err
8584
}
8685

87-
events := sdkCtx.EventManager().Events()
88-
k.Logger(ctx).Debug("emitting interchain account registration events", logging.SdkEventsToLogArguments(events))
89-
90-
// NOTE: The sdk msg handler creates a new EventManager, so events must be correctly propagated back to the current context
91-
sdkCtx.EventManager().EmitEvents(events)
92-
9386
firstMsgResponse := res.MsgResponses[0]
9487
channelOpenInitResponse, ok := firstMsgResponse.GetCachedValue().(*channeltypes.MsgChannelOpenInitResponse)
9588
if !ok {

modules/apps/27-interchain-accounts/host/client/cli/tx_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/stretchr/testify/require"
88

9+
"cosmossdk.io/core/registry"
910
banktypes "cosmossdk.io/x/bank/types"
1011
stakingtypes "cosmossdk.io/x/staking/types"
1112
"github.com/cosmos/cosmos-sdk/codec"
@@ -46,15 +47,15 @@ func TestGeneratePacketData(t *testing.T) {
4647
memo string
4748
expectedPass bool
4849
message string
49-
registerInterfaceFn func(registry codectypes.InterfaceRegistry)
50+
registerInterfaceFn func(registry registry.InterfaceRegistrar)
5051
assertionFn func(t *testing.T, msgs []sdk.Msg)
5152
}{
5253
{
5354
name: "packet data generation succeeds (MsgDelegate & MsgSend)",
5455
memo: "",
5556
expectedPass: true,
5657
message: multiMsg,
57-
registerInterfaceFn: func(registry codectypes.InterfaceRegistry) {
58+
registerInterfaceFn: func(registry registry.InterfaceRegistrar) {
5859
stakingtypes.RegisterInterfaces(registry)
5960
banktypes.RegisterInterfaces(registry)
6061
},

modules/apps/27-interchain-accounts/simulation/proposals.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package simulation
22

33
import (
4+
"context"
45
"math/rand"
56

7+
coreaddress "cosmossdk.io/core/address"
68
sdk "github.com/cosmos/cosmos-sdk/types"
79
"github.com/cosmos/cosmos-sdk/types/address"
810
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
@@ -25,14 +27,14 @@ const (
2527
func ProposalMsgs(controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkeeper.Keeper) []simtypes.WeightedProposalMsg {
2628
msgs := make([]simtypes.WeightedProposalMsg, 0, 2)
2729
if hostKeeper != nil {
28-
msgs = append(msgs, simulation.NewWeightedProposalMsg(
30+
msgs = append(msgs, simulation.NewWeightedProposalMsgX(
2931
OpWeightMsgUpdateParams,
3032
DefaultWeightMsgUpdateParams,
3133
SimulateHostMsgUpdateParams,
3234
))
3335
}
3436
if controllerKeeper != nil {
35-
msgs = append(msgs, simulation.NewWeightedProposalMsg(
37+
msgs = append(msgs, simulation.NewWeightedProposalMsgX(
3638
OpWeightMsgUpdateParams,
3739
DefaultWeightMsgUpdateParams,
3840
SimulateControllerMsgUpdateParams,
@@ -42,25 +44,25 @@ func ProposalMsgs(controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkee
4244
}
4345

4446
// SimulateHostMsgUpdateParams returns a MsgUpdateParams for the host module
45-
func SimulateHostMsgUpdateParams(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
47+
func SimulateHostMsgUpdateParams(ctx context.Context, _ *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) {
4648
var signer sdk.AccAddress = address.Module("gov")
4749
params := types.DefaultParams()
4850
params.HostEnabled = false
4951

5052
return &types.MsgUpdateParams{
5153
Signer: signer.String(),
5254
Params: params,
53-
}
55+
}, nil
5456
}
5557

5658
// SimulateControllerMsgUpdateParams returns a MsgUpdateParams for the controller module
57-
func SimulateControllerMsgUpdateParams(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
59+
func SimulateControllerMsgUpdateParams(ctx context.Context, _ *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) {
5860
var signer sdk.AccAddress = address.Module("gov")
5961
params := controllertypes.DefaultParams()
6062
params.ControllerEnabled = false
6163

6264
return &controllertypes.MsgUpdateParams{
6365
Signer: signer.String(),
6466
Params: params,
65-
}
67+
}, nil
6668
}

modules/apps/27-interchain-accounts/simulation/proposals_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func TestProposalMsgs(t *testing.T) {
8484
require.Equal(t, simulation.OpWeightMsgUpdateParams, weightedMsg.AppParamsKey())
8585
require.Equal(t, simulation.DefaultWeightMsgUpdateParams, weightedMsg.DefaultWeight())
8686

87-
msg := weightedMsg.MsgSimulatorFn()(r, ctx, accounts)
87+
msg, err := weightedMsg.MsgSimulatorFn()(ctx, r, accounts, nil)
88+
require.NoError(t, err)
8889

8990
if msgUpdateHostParams, ok := msg.(*hosttypes.MsgUpdateParams); ok {
9091
require.Equal(t, tc.expMsgs[idx], msgUpdateHostParams)

modules/apps/29-fee/module.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/cosmos/cosmos-sdk/client"
1414
"github.com/cosmos/cosmos-sdk/codec"
1515
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
16-
sdk "github.com/cosmos/cosmos-sdk/types"
1716
"github.com/cosmos/cosmos-sdk/types/module"
1817
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
1918

@@ -23,18 +22,18 @@ import (
2322
)
2423

2524
var (
26-
_ module.AppModule = (*AppModule)(nil)
27-
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
28-
_ module.AppModuleSimulation = (*AppModule)(nil)
29-
_ module.HasGenesis = (*AppModule)(nil)
30-
_ module.HasName = (*AppModule)(nil)
31-
_ module.HasConsensusVersion = (*AppModule)(nil)
32-
_ module.HasServices = (*AppModule)(nil)
33-
_ appmodule.AppModule = (*AppModule)(nil)
25+
_ module.AppModule = (*AppModule)(nil)
26+
_ module.AppModuleSimulation = (*AppModule)(nil)
27+
_ module.HasGenesis = (*AppModule)(nil)
28+
_ appmodule.HasConsensusVersion = (*AppModule)(nil)
29+
_ module.HasServices = (*AppModule)(nil)
30+
_ appmodule.AppModule = (*AppModule)(nil)
3431
)
3532

3633
// AppModuleBasic is the 29-fee AppModuleBasic
37-
type AppModuleBasic struct{}
34+
type AppModuleBasic struct {
35+
cdc codec.Codec
36+
}
3837

3938
// Name implements AppModuleBasic interface
4039
func (AppModuleBasic) Name() string {
@@ -59,14 +58,14 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
5958

6059
// DefaultGenesis returns default genesis state as raw bytes for the ibc
6160
// 29-fee module.
62-
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
63-
return cdc.MustMarshalJSON(types.DefaultGenesisState())
61+
func (am AppModuleBasic) DefaultGenesis() json.RawMessage {
62+
return am.cdc.MustMarshalJSON(types.DefaultGenesisState())
6463
}
6564

6665
// ValidateGenesis performs genesis state validation for the 29-fee module.
67-
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
66+
func (am AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
6867
var gs types.GenesisState
69-
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
68+
if err := am.cdc.UnmarshalJSON(bz, &gs); err != nil {
7069
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
7170
}
7271

@@ -117,17 +116,18 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
117116

118117
// InitGenesis performs genesis initialization for the ibc-29-fee module. It returns
119118
// no validator updates.
120-
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
119+
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
121120
var genesisState types.GenesisState
122-
cdc.MustUnmarshalJSON(data, &genesisState)
121+
am.cdc.MustUnmarshalJSON(data, &genesisState)
123122
am.keeper.InitGenesis(ctx, genesisState)
123+
return nil
124124
}
125125

126126
// ExportGenesis returns the exported genesis state as raw bytes for the ibc-29-fee
127127
// module.
128-
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
128+
func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
129129
gs := am.keeper.ExportGenesis(ctx)
130-
return cdc.MustMarshalJSON(gs)
130+
return am.cdc.MarshalJSON(gs)
131131
}
132132

133133
// ConsensusVersion implements AppModule/ConsensusVersion.

modules/apps/29-fee/types/msgs_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestRegisterPayeeGetSigners(t *testing.T) {
9898
msg := types.NewMsgRegisterPayee(ibctesting.MockPort, ibctesting.FirstChannelID, accAddress.String(), defaultAccAddress)
9999

100100
encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, modulefee.AppModule{})
101-
signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg)
101+
signers, _, err := encodingCfg.Codec.GetMsgSigners(msg)
102102
require.NoError(t, err)
103103
require.Equal(t, accAddress.Bytes(), signers[0])
104104
}
@@ -186,7 +186,7 @@ func TestRegisterCountepartyAddressGetSigners(t *testing.T) {
186186
msg := types.NewMsgRegisterCounterpartyPayee(ibctesting.MockPort, ibctesting.FirstChannelID, accAddress.String(), defaultAccAddress)
187187

188188
encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, modulefee.AppModule{})
189-
signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg)
189+
signers, _, err := encodingCfg.Codec.GetMsgSigners(msg)
190190
require.NoError(t, err)
191191
require.Equal(t, accAddress.Bytes(), signers[0])
192192
}
@@ -265,7 +265,7 @@ func TestPayPacketFeeGetSigners(t *testing.T) {
265265
msg := types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, refundAddr.String(), nil)
266266

267267
encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, modulefee.AppModule{})
268-
signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg)
268+
signers, _, err := encodingCfg.Codec.GetMsgSigners(msg)
269269
require.NoError(t, err)
270270
require.Equal(t, refundAddr.Bytes(), signers[0])
271271
}
@@ -404,7 +404,7 @@ func TestPayPacketFeeAsyncGetSigners(t *testing.T) {
404404
msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee)
405405

406406
encodingCfg := moduletestutil.MakeTestEncodingConfig(testutil.CodecOptions{}, modulefee.AppModule{})
407-
signers, _, err := encodingCfg.Codec.GetMsgV1Signers(msg)
407+
signers, _, err := encodingCfg.Codec.GetMsgSigners(msg)
408408
require.NoError(t, err)
409409
require.Equal(t, refundAddr.Bytes(), signers[0])
410410
}

modules/apps/transfer/keeper/forwarding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (k Keeper) revertForwardedPacket(ctx context.Context, forwardedPacket chann
8383
// given that the packet is being reversed, we check the DestinationChannel and DestinationPort
8484
// of the forwardedPacket to see if a hop was added to the trace during the receive step
8585
if token.Denom.HasPrefix(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) {
86-
if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil {
86+
if err := k.bankKeeper.BurnCoins(ctx, forwardingAddr, sdk.NewCoins(coin)); err != nil {
8787
return err
8888
}
8989
} else {

modules/apps/transfer/keeper/genesis.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package keeper
22

33
import (
4-
sdk "github.com/cosmos/cosmos-sdk/types"
4+
"context"
55

66
"github.com/cosmos/ibc-go/v9/modules/apps/transfer/types"
77
)
88

99
// InitGenesis initializes the ibc-transfer state and binds to PortID.
10-
func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
10+
func (k Keeper) InitGenesis(ctx context.Context, state types.GenesisState) {
1111
k.SetPort(ctx, state.PortId)
1212

1313
for _, denom := range state.Denoms {
@@ -31,7 +31,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
3131
}
3232

3333
// ExportGenesis exports ibc-transfer module's portID and denom trace info into its genesis state.
34-
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
34+
func (k Keeper) ExportGenesis(ctx context.Context) *types.GenesisState {
3535
return &types.GenesisState{
3636
PortId: k.GetPort(ctx),
3737
Denoms: k.GetAllDenoms(ctx),

modules/apps/transfer/keeper/keeper_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66

77
testifysuite "github.com/stretchr/testify/suite"
88

9+
"cosmossdk.io/math"
910
sdkmath "cosmossdk.io/math"
1011
storetypes "cosmossdk.io/store/types"
1112

1213
minttypes "cosmossdk.io/x/mint/types"
1314
"github.com/cosmos/cosmos-sdk/baseapp"
14-
"github.com/cosmos/cosmos-sdk/codec"
1515
"github.com/cosmos/cosmos-sdk/runtime"
1616
sdk "github.com/cosmos/cosmos-sdk/types"
1717
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
@@ -192,7 +192,6 @@ func (suite *KeeperTestSuite) TestSetGetTotalEscrowForDenom() {
192192
func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
193193
var (
194194
store storetypes.KVStore
195-
cdc codec.Codec
196195
expDenomEscrows sdk.Coins
197196
)
198197

@@ -208,7 +207,8 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
208207
amount := sdkmath.NewInt(100)
209208
expDenomEscrows = append(expDenomEscrows, sdk.NewCoin(denom, amount))
210209

211-
bz := cdc.MustMarshal(&sdk.IntProto{Int: amount})
210+
bz, err := math.Int(amount).Marshal()
211+
suite.Require().NoError(err)
212212
store.Set(types.TotalEscrowForDenomKey(denom), bz)
213213
},
214214
true,
@@ -220,14 +220,16 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
220220
amount := sdkmath.NewInt(100)
221221
expDenomEscrows = append(expDenomEscrows, sdk.NewCoin(denom, amount))
222222

223-
bz := cdc.MustMarshal(&sdk.IntProto{Int: amount})
223+
bz, err := math.Int(amount).Marshal()
224+
suite.Require().NoError(err)
224225
store.Set(types.TotalEscrowForDenomKey(denom), bz)
225226

226227
denom = "bar/foo"
227228
amount = sdkmath.NewInt(50)
228229
expDenomEscrows = append(expDenomEscrows, sdk.NewCoin(denom, amount))
229230

230-
bz = cdc.MustMarshal(&sdk.IntProto{Int: amount})
231+
bz, err = math.Int(amount).Marshal()
232+
suite.Require().NoError(err)
231233
store.Set(types.TotalEscrowForDenomKey(denom), bz)
232234
},
233235
true,
@@ -239,7 +241,8 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
239241
amount := sdkmath.NewInt(100)
240242
expDenomEscrows = append(expDenomEscrows, sdk.NewCoin(denom, amount))
241243

242-
bz := cdc.MustMarshal(&sdk.IntProto{Int: amount})
244+
bz, err := math.Int(amount).Marshal()
245+
suite.Require().NoError(err)
243246
store.Set(types.TotalEscrowForDenomKey(denom), bz)
244247
},
245248
true,
@@ -250,7 +253,8 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
250253
denom := ""
251254
amount := sdkmath.ZeroInt()
252255

253-
bz := cdc.MustMarshal(&sdk.IntProto{Int: amount})
256+
bz, err := math.Int(amount).Marshal()
257+
suite.Require().NoError(err)
254258
store.Set(types.TotalEscrowForDenomKey(denom), bz)
255259
},
256260
false,
@@ -261,7 +265,8 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
261265
denom := "uatom"
262266
amount := sdkmath.ZeroInt()
263267

264-
bz := cdc.MustMarshal(&sdk.IntProto{Int: amount})
268+
bz, err := math.Int(amount).Marshal()
269+
suite.Require().NoError(err)
265270
store.Set([]byte(fmt.Sprintf("wrong-prefix/%s", denom)), bz)
266271
},
267272
false,
@@ -279,7 +284,6 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {
279284

280285
storeKey := suite.chainA.GetSimApp().GetKey(types.ModuleName)
281286
store = ctx.KVStore(storeKey)
282-
cdc = suite.chainA.App.AppCodec()
283287

284288
tc.malleate()
285289

modules/apps/transfer/keeper/relay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (k Keeper) sendTransfer(
119119
}
120120

121121
if err := k.bankKeeper.BurnCoins(
122-
ctx, types.ModuleName, sdk.NewCoins(coin),
122+
ctx, k.authKeeper.GetModuleAddress(types.ModuleName), sdk.NewCoins(coin),
123123
); err != nil {
124124
// NOTE: should not happen as the module account was
125125
// retrieved on the step above and it has enough balance

0 commit comments

Comments
 (0)