diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb76696bd2..e4706f20e23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ be used to retrieve the actual proposal `Content`. Also the `NewMsgSubmitProposa ``` * (client/rpc) [\#6290](https://github.com/cosmos/cosmos-sdk/pull/6290) `RegisterRoutes` of rpc is moved from package client to client/rpc and client/rpc.RegisterRPCRoutes is removed. * (client/lcd) [\#6290](https://github.com/cosmos/cosmos-sdk/pull/6290) `CliCtx` of struct `RestServer` in package client/lcd has been renamed to `ClientCtx`. +* (types) [\#6327](https://github.com/cosmos/cosmos-sdk/pull/6327) `sdk.Msg` now inherits `proto.Message`, as a result all `sdk.Msg` types now use pointer semantics. ### Features diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 7b842bbda9c..c5137f87446 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -594,6 +594,11 @@ type msgCounter struct { FailOnHandler bool } +// dummy implementation of proto.Message +func (msg msgCounter) Reset() {} +func (msg msgCounter) String() string { return "TODO" } +func (msg msgCounter) ProtoMessage() {} + // Implements Msg func (msg msgCounter) Route() string { return routeMsgCounter } func (msg msgCounter) Type() string { return "counter1" } @@ -634,6 +639,11 @@ type msgCounter2 struct { Counter int64 } +// dummy implementation of proto.Message +func (msg msgCounter2) Reset() {} +func (msg msgCounter2) String() string { return "TODO" } +func (msg msgCounter2) ProtoMessage() {} + // Implements Msg func (msg msgCounter2) Route() string { return routeMsgCounter2 } func (msg msgCounter2) Type() string { return "counter2" } diff --git a/server/mock/tx.go b/server/mock/tx.go index 27441051ce8..0cb79c28986 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -16,7 +16,13 @@ type kvstoreTx struct { bytes []byte } +// dummy implementation of proto.Message +func (msg kvstoreTx) Reset() {} +func (msg kvstoreTx) String() string { return "TODO" } +func (msg kvstoreTx) ProtoMessage() {} + var _ sdk.Tx = kvstoreTx{} +var _ sdk.Msg = kvstoreTx{} func NewTx(key, value string) kvstoreTx { bytes := fmt.Sprintf("%s=%s", key, value) diff --git a/types/tx_msg.go b/types/tx_msg.go index 9123cd9be94..ef619bb9261 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -3,12 +3,15 @@ package types import ( "encoding/json" + "github.com/gogo/protobuf/proto" + "github.com/tendermint/tendermint/crypto" ) type ( // Msg defines the interface a transaction message must fulfill. Msg interface { + proto.Message // Return the message type. // Must be alphanumeric or empty. @@ -71,6 +74,11 @@ type TestMsg struct { signers []AccAddress } +// dummy implementation of proto.Message +func (msg *TestMsg) Reset() {} +func (msg *TestMsg) String() string { return "TODO" } +func (msg *TestMsg) ProtoMessage() {} + func NewTestMsg(addrs ...AccAddress) *TestMsg { return &TestMsg{ signers: addrs, diff --git a/x/bank/app_test.go b/x/bank/app_test.go index c30cfc9f1cc..2fff4f728ba 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -49,18 +49,18 @@ var ( sendMsg1 = types.NewMsgSend(addr1, addr2, coins) - multiSendMsg1 = types.MsgMultiSend{ + multiSendMsg1 = &types.MsgMultiSend{ Inputs: []types.Input{types.NewInput(addr1, coins)}, Outputs: []types.Output{types.NewOutput(addr2, coins)}, } - multiSendMsg2 = types.MsgMultiSend{ + multiSendMsg2 = &types.MsgMultiSend{ Inputs: []types.Input{types.NewInput(addr1, coins)}, Outputs: []types.Output{ types.NewOutput(addr2, halfCoins), types.NewOutput(addr3, halfCoins), }, } - multiSendMsg3 = types.MsgMultiSend{ + multiSendMsg3 = &types.MsgMultiSend{ Inputs: []types.Input{ types.NewInput(addr1, coins), types.NewInput(addr4, coins), @@ -70,7 +70,7 @@ var ( types.NewOutput(addr3, coins), }, } - multiSendMsg4 = types.MsgMultiSend{ + multiSendMsg4 = &types.MsgMultiSend{ Inputs: []types.Input{ types.NewInput(addr2, coins), }, @@ -78,7 +78,7 @@ var ( types.NewOutput(addr1, coins), }, } - multiSendMsg5 = types.MsgMultiSend{ + multiSendMsg5 = &types.MsgMultiSend{ Inputs: []types.Input{ types.NewInput(addr1, coins), }, @@ -128,7 +128,7 @@ func TestSendToModuleAcc(t *testing.T) { tests := []struct { name string fromBalance sdk.Coins - msg types.MsgSend + msg *types.MsgSend expSimPass bool expPass bool expFromBalance sdk.Coins diff --git a/x/bank/handler.go b/x/bank/handler.go index 5ec0033bce8..6cd77d22a7f 100644 --- a/x/bank/handler.go +++ b/x/bank/handler.go @@ -13,10 +13,10 @@ func NewHandler(k keeper.Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case types.MsgSend: + case *types.MsgSend: return handleMsgSend(ctx, k, msg) - case types.MsgMultiSend: + case *types.MsgMultiSend: return handleMsgMultiSend(ctx, k, msg) default: @@ -26,7 +26,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } // Handle MsgSend. -func handleMsgSend(ctx sdk.Context, k keeper.Keeper, msg types.MsgSend) (*sdk.Result, error) { +func handleMsgSend(ctx sdk.Context, k keeper.Keeper, msg *types.MsgSend) (*sdk.Result, error) { if !k.GetSendEnabled(ctx) { return nil, types.ErrSendDisabled } @@ -51,7 +51,7 @@ func handleMsgSend(ctx sdk.Context, k keeper.Keeper, msg types.MsgSend) (*sdk.Re } // Handle MsgMultiSend. -func handleMsgMultiSend(ctx sdk.Context, k keeper.Keeper, msg types.MsgMultiSend) (*sdk.Result, error) { +func handleMsgMultiSend(ctx sdk.Context, k keeper.Keeper, msg *types.MsgMultiSend) (*sdk.Result, error) { // NOTE: totalIn == totalOut should already have been checked if !k.GetSendEnabled(ctx) { return nil, types.ErrSendDisabled diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index a08fae98ec8..8023a376f67 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -85,7 +85,7 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio // nolint: interfacer func sendMsgSend( r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, - msg types.MsgSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, + msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, ) error { var ( @@ -198,7 +198,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope } } - msg := types.MsgMultiSend{ + msg := &types.MsgMultiSend{ Inputs: inputs, Outputs: outputs, } @@ -217,7 +217,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope // nolint: interfacer func sendMsgMultiSend( r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, - msg types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, + msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, ) error { accountNumbers := make([]uint64, len(msg.Inputs)) diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index 74874835ef2..69a18138245 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -12,8 +12,8 @@ import ( func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.SupplyI)(nil), nil) cdc.RegisterConcrete(&Supply{}, "cosmos-sdk/Supply", nil) - cdc.RegisterConcrete(MsgSend{}, "cosmos-sdk/MsgSend", nil) - cdc.RegisterConcrete(MsgMultiSend{}, "cosmos-sdk/MsgMultiSend", nil) + cdc.RegisterConcrete(&MsgSend{}, "cosmos-sdk/MsgSend", nil) + cdc.RegisterConcrete(&MsgMultiSend{}, "cosmos-sdk/MsgMultiSend", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { diff --git a/x/bank/types/msgs.go b/x/bank/types/msgs.go index 088eebfff18..9d79f37c901 100644 --- a/x/bank/types/msgs.go +++ b/x/bank/types/msgs.go @@ -11,11 +11,11 @@ const ( TypeMsgMultiSend = "multisend" ) -var _ sdk.Msg = MsgSend{} +var _ sdk.Msg = &MsgSend{} // NewMsgSend - construct arbitrary multi-in, multi-out send msg. -func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) MsgSend { - return MsgSend{FromAddress: fromAddr, ToAddress: toAddr, Amount: amount} +func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgSend { + return &MsgSend{FromAddress: fromAddr, ToAddress: toAddr, Amount: amount} } // Route Implements Msg. @@ -55,11 +55,11 @@ func (msg MsgSend) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.FromAddress} } -var _ sdk.Msg = MsgMultiSend{} +var _ sdk.Msg = &MsgMultiSend{} // NewMsgMultiSend - construct arbitrary multi-in, multi-out send msg. -func NewMsgMultiSend(in []Input, out []Output) MsgMultiSend { - return MsgMultiSend{Inputs: in, Outputs: out} +func NewMsgMultiSend(in []Input, out []Output) *MsgMultiSend { + return &MsgMultiSend{Inputs: in, Outputs: out} } // Route Implements Msg diff --git a/x/bank/types/msgs_test.go b/x/bank/types/msgs_test.go index 2a09c1b9f72..a0fe50b2bf4 100644 --- a/x/bank/types/msgs_test.go +++ b/x/bank/types/msgs_test.go @@ -31,7 +31,7 @@ func TestMsgSendValidation(t *testing.T) { cases := []struct { valid bool - tx MsgSend + tx *MsgSend }{ {true, NewMsgSend(addr1, addr2, atom123)}, // valid send {true, NewMsgSend(addr1, addr2, atom123eth123)}, // valid send with multiple coins diff --git a/x/crisis/handler.go b/x/crisis/handler.go index 733207c1004..83c7fd7ac42 100644 --- a/x/crisis/handler.go +++ b/x/crisis/handler.go @@ -15,7 +15,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case types.MsgVerifyInvariant: + case *types.MsgVerifyInvariant: return handleMsgVerifyInvariant(ctx, msg, k) default: @@ -24,7 +24,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } } -func handleMsgVerifyInvariant(ctx sdk.Context, msg types.MsgVerifyInvariant, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgVerifyInvariant(ctx sdk.Context, msg *types.MsgVerifyInvariant, k keeper.Keeper) (*sdk.Result, error) { constantFee := sdk.NewCoins(k.GetConstantFee(ctx)) if err := k.SendCoinsFromAccountToFeeCollector(ctx, msg.Sender, constantFee); err != nil { diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index 349977fc8f3..4d3a2fa3c21 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -9,9 +9,9 @@ var _ sdk.Msg = &MsgVerifyInvariant{} // NewMsgVerifyInvariant creates a new MsgVerifyInvariant object func NewMsgVerifyInvariant(sender sdk.AccAddress, invariantModuleName, - invariantRoute string) MsgVerifyInvariant { + invariantRoute string) *MsgVerifyInvariant { - return MsgVerifyInvariant{ + return &MsgVerifyInvariant{ Sender: sender, InvariantModuleName: invariantModuleName, InvariantRoute: invariantRoute, diff --git a/x/distribution/handler.go b/x/distribution/handler.go index fa6ea6ec67e..2e8c86ce037 100644 --- a/x/distribution/handler.go +++ b/x/distribution/handler.go @@ -13,16 +13,16 @@ func NewHandler(k keeper.Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case types.MsgSetWithdrawAddress: + case *types.MsgSetWithdrawAddress: return handleMsgModifyWithdrawAddress(ctx, msg, k) - case types.MsgWithdrawDelegatorReward: + case *types.MsgWithdrawDelegatorReward: return handleMsgWithdrawDelegatorReward(ctx, msg, k) - case types.MsgWithdrawValidatorCommission: + case *types.MsgWithdrawValidatorCommission: return handleMsgWithdrawValidatorCommission(ctx, msg, k) - case types.MsgFundCommunityPool: + case *types.MsgFundCommunityPool: return handleMsgFundCommunityPool(ctx, msg, k) default: @@ -33,7 +33,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { // These functions assume everything has been authenticated (ValidateBasic passed, and signatures checked) -func handleMsgModifyWithdrawAddress(ctx sdk.Context, msg types.MsgSetWithdrawAddress, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgModifyWithdrawAddress(ctx sdk.Context, msg *types.MsgSetWithdrawAddress, k keeper.Keeper) (*sdk.Result, error) { err := k.SetWithdrawAddr(ctx, msg.DelegatorAddress, msg.WithdrawAddress) if err != nil { return nil, err @@ -50,7 +50,7 @@ func handleMsgModifyWithdrawAddress(ctx sdk.Context, msg types.MsgSetWithdrawAdd return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgWithdrawDelegatorReward(ctx sdk.Context, msg types.MsgWithdrawDelegatorReward, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgWithdrawDelegatorReward(ctx sdk.Context, msg *types.MsgWithdrawDelegatorReward, k keeper.Keeper) (*sdk.Result, error) { _, err := k.WithdrawDelegationRewards(ctx, msg.DelegatorAddress, msg.ValidatorAddress) if err != nil { return nil, err @@ -67,7 +67,7 @@ func handleMsgWithdrawDelegatorReward(ctx sdk.Context, msg types.MsgWithdrawDele return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgWithdrawValidatorCommission(ctx sdk.Context, msg types.MsgWithdrawValidatorCommission, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgWithdrawValidatorCommission(ctx sdk.Context, msg *types.MsgWithdrawValidatorCommission, k keeper.Keeper) (*sdk.Result, error) { _, err := k.WithdrawValidatorCommission(ctx, msg.ValidatorAddress) if err != nil { return nil, err @@ -84,7 +84,7 @@ func handleMsgWithdrawValidatorCommission(ctx sdk.Context, msg types.MsgWithdraw return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgFundCommunityPool(ctx sdk.Context, msg types.MsgFundCommunityPool, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgFundCommunityPool(ctx sdk.Context, msg *types.MsgFundCommunityPool, k keeper.Keeper) (*sdk.Result, error) { if err := k.FundCommunityPool(ctx, msg.Amount, msg.Depositor); err != nil { return nil, err } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index d0d329c9bc0..a154c956e83 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -10,10 +10,10 @@ import ( // RegisterCodec registers the necessary x/distribution interfaces and concrete types // on the provided Amino codec. These types are used for Amino JSON serialization. func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil) - cdc.RegisterConcrete(MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil) - cdc.RegisterConcrete(MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress", nil) - cdc.RegisterConcrete(MsgFundCommunityPool{}, "cosmos-sdk/MsgFundCommunityPool", nil) + cdc.RegisterConcrete(&MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil) + cdc.RegisterConcrete(&MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil) + cdc.RegisterConcrete(&MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress", nil) + cdc.RegisterConcrete(&MsgFundCommunityPool{}, "cosmos-sdk/MsgFundCommunityPool", nil) cdc.RegisterConcrete(&CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) } diff --git a/x/distribution/types/msg.go b/x/distribution/types/msg.go index 13e9adde27f..8fa3aa4cef9 100644 --- a/x/distribution/types/msg.go +++ b/x/distribution/types/msg.go @@ -17,8 +17,8 @@ const ( // Verify interface at compile time var _, _, _ sdk.Msg = &MsgSetWithdrawAddress{}, &MsgWithdrawDelegatorReward{}, &MsgWithdrawValidatorCommission{} -func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress { - return MsgSetWithdrawAddress{ +func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) *MsgSetWithdrawAddress { + return &MsgSetWithdrawAddress{ DelegatorAddress: delAddr, WithdrawAddress: withdrawAddr, } @@ -50,8 +50,8 @@ func (msg MsgSetWithdrawAddress) ValidateBasic() error { return nil } -func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward { - return MsgWithdrawDelegatorReward{ +func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) *MsgWithdrawDelegatorReward { + return &MsgWithdrawDelegatorReward{ DelegatorAddress: delAddr, ValidatorAddress: valAddr, } @@ -82,8 +82,8 @@ func (msg MsgWithdrawDelegatorReward) ValidateBasic() error { return nil } -func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission { - return MsgWithdrawValidatorCommission{ +func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) *MsgWithdrawValidatorCommission { + return &MsgWithdrawValidatorCommission{ ValidatorAddress: valAddr, } } @@ -112,8 +112,8 @@ func (msg MsgWithdrawValidatorCommission) ValidateBasic() error { // NewMsgFundCommunityPool returns a new MsgFundCommunityPool with a sender and // a funding amount. -func NewMsgFundCommunityPool(amount sdk.Coins, depositor sdk.AccAddress) MsgFundCommunityPool { - return MsgFundCommunityPool{ +func NewMsgFundCommunityPool(amount sdk.Coins, depositor sdk.AccAddress) *MsgFundCommunityPool { + return &MsgFundCommunityPool{ Amount: amount, Depositor: depositor, } diff --git a/x/evidence/keeper/infraction_test.go b/x/evidence/keeper/infraction_test.go index 5c2f1198725..6c2506f1d29 100644 --- a/x/evidence/keeper/infraction_test.go +++ b/x/evidence/keeper/infraction_test.go @@ -10,7 +10,7 @@ import ( "github.com/tendermint/tendermint/crypto" ) -func newTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator { +func newTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) *staking.MsgCreateValidator { commission := staking.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) return staking.NewMsgCreateValidator( address, pubKey, sdk.NewCoin(sdk.DefaultBondDenom, amt), diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index 01b0af59677..3a23356a1f4 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -11,7 +11,7 @@ import ( // evidence module. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.Evidence)(nil), nil) - cdc.RegisterConcrete(MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence", nil) + cdc.RegisterConcrete(&MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence", nil) cdc.RegisterConcrete(&Equivocation{}, "cosmos-sdk/Equivocation", nil) } diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 223904b1dc6..aca411ef9d3 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -17,22 +17,22 @@ const ( ) var ( - _ sdk.Msg = MsgSubmitEvidence{} + _ sdk.Msg = &MsgSubmitEvidence{} _ types.UnpackInterfacesMessage = MsgSubmitEvidence{} - _ exported.MsgSubmitEvidence = MsgSubmitEvidence{} + _ exported.MsgSubmitEvidence = &MsgSubmitEvidence{} ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. -func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (MsgSubmitEvidence, error) { +func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (*MsgSubmitEvidence, error) { msg, ok := evi.(proto.Message) if !ok { - return MsgSubmitEvidence{}, fmt.Errorf("cannot proto marshal %T", evi) + return nil, fmt.Errorf("cannot proto marshal %T", evi) } any, err := types.NewAnyWithValue(msg) if err != nil { - return MsgSubmitEvidence{Submitter: s}, err + return nil, err } - return MsgSubmitEvidence{Submitter: s, Evidence: any}, nil + return &MsgSubmitEvidence{Submitter: s, Evidence: any}, nil } // Route returns the MsgSubmitEvidence's route. diff --git a/x/genutil/collect.go b/x/genutil/collect.go index f02ae9b323f..e7d3d35c03c 100644 --- a/x/genutil/collect.go +++ b/x/genutil/collect.go @@ -133,7 +133,7 @@ func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string, } // TODO abstract out staking message validation back to staking - msg := msgs[0].(stakingtypes.MsgCreateValidator) + msg := msgs[0].(*stakingtypes.MsgCreateValidator) // validate delegator and validator addresses and funds against the accounts in the state delAddr := msg.DelegatorAddress.String() diff --git a/x/genutil/types/genesis_state.go b/x/genutil/types/genesis_state.go index 453ecdedc9a..e8ec56f8a15 100644 --- a/x/genutil/types/genesis_state.go +++ b/x/genutil/types/genesis_state.go @@ -112,7 +112,7 @@ func ValidateGenesis(genesisState GenesisState) error { } // TODO: abstract back to staking - if _, ok := msgs[0].(stakingtypes.MsgCreateValidator); !ok { + if _, ok := msgs[0].(*stakingtypes.MsgCreateValidator); !ok { return fmt.Errorf( "genesis transaction %v does not contain a MsgCreateValidator", i) } diff --git a/x/gov/client/utils/query.go b/x/gov/client/utils/query.go index b65e1080f72..6739dc1bc22 100644 --- a/x/gov/client/utils/query.go +++ b/x/gov/client/utils/query.go @@ -54,7 +54,7 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposal for _, info := range searchResult.Txs { for _, msg := range info.Tx.GetMsgs() { if msg.Type() == types.TypeMsgDeposit { - depMsg := msg.(types.MsgDeposit) + depMsg := msg.(*types.MsgDeposit) deposits = append(deposits, types.Deposit{ Depositor: depMsg.Depositor, @@ -95,7 +95,7 @@ func QueryVotesByTxQuery(clientCtx client.Context, params types.QueryProposalVot for _, info := range searchResult.Txs { for _, msg := range info.Tx.GetMsgs() { if msg.Type() == types.TypeMsgVote { - voteMsg := msg.(types.MsgVote) + voteMsg := msg.(*types.MsgVote) votes = append(votes, types.Vote{ Voter: voteMsg.Voter, @@ -139,7 +139,7 @@ func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams) for _, msg := range info.Tx.GetMsgs() { // there should only be a single vote under the given conditions if msg.Type() == types.TypeMsgVote { - voteMsg := msg.(types.MsgVote) + voteMsg := msg.(*types.MsgVote) vote := types.Vote{ Voter: voteMsg.Voter, @@ -179,7 +179,7 @@ func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositPa for _, msg := range info.Tx.GetMsgs() { // there should only be a single deposit under the given conditions if msg.Type() == types.TypeMsgDeposit { - depMsg := msg.(types.MsgDeposit) + depMsg := msg.(*types.MsgDeposit) deposit := types.Deposit{ Depositor: depMsg.Depositor, diff --git a/x/gov/handler.go b/x/gov/handler.go index 02edefcdbd8..2805e4f8795 100644 --- a/x/gov/handler.go +++ b/x/gov/handler.go @@ -14,13 +14,13 @@ func NewHandler(keeper Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgDeposit: + case *MsgDeposit: return handleMsgDeposit(ctx, keeper, msg) case MsgSubmitProposalI: return handleMsgSubmitProposal(ctx, keeper, msg) - case MsgVote: + case *MsgVote: return handleMsgVote(ctx, keeper, msg) default: @@ -63,7 +63,7 @@ func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitPropos }, nil } -func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg MsgDeposit) (*sdk.Result, error) { +func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg *MsgDeposit) (*sdk.Result, error) { votingStarted, err := keeper.AddDeposit(ctx, msg.ProposalID, msg.Depositor, msg.Amount) if err != nil { return nil, err @@ -89,7 +89,7 @@ func handleMsgDeposit(ctx sdk.Context, keeper Keeper, msg MsgDeposit) (*sdk.Resu return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgVote(ctx sdk.Context, keeper Keeper, msg MsgVote) (*sdk.Result, error) { +func handleMsgVote(ctx sdk.Context, keeper Keeper, msg *MsgVote) (*sdk.Result, error) { err := keeper.AddVote(ctx, msg.ProposalID, msg.Voter, msg.Option) if err != nil { return nil, err diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index 2397c1f87d9..ee53c71c458 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -11,8 +11,8 @@ import ( func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*Content)(nil), nil) cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil) - cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil) - cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil) + cdc.RegisterConcrete(&MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil) + cdc.RegisterConcrete(&MsgVote{}, "cosmos-sdk/MsgVote", nil) cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil) } diff --git a/x/gov/types/msgs.go b/x/gov/types/msgs.go index a818ee2a3c4..c6d57b87df9 100644 --- a/x/gov/types/msgs.go +++ b/x/gov/types/msgs.go @@ -20,9 +20,9 @@ const ( ) var ( - _, _, _ sdk.Msg = MsgSubmitProposal{}, MsgDeposit{}, MsgVote{} + _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{} _ MsgSubmitProposalI = &MsgSubmitProposal{} - _ types.UnpackInterfacesMessage = MsgSubmitProposal{} + _ types.UnpackInterfacesMessage = &MsgSubmitProposal{} ) // MsgSubmitProposalI defines the specific interface a concrete message must @@ -143,8 +143,8 @@ func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { } // NewMsgDeposit creates a new MsgDeposit instance -func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit { - return MsgDeposit{proposalID, depositor, amount} +func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) *MsgDeposit { + return &MsgDeposit{proposalID, depositor, amount} } // Route implements Msg @@ -186,8 +186,8 @@ func (msg MsgDeposit) GetSigners() []sdk.AccAddress { } // NewMsgVote creates a message to cast a vote on an active proposal -func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) MsgVote { - return MsgVote{proposalID, voter, option} +func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) *MsgVote { + return &MsgVote{proposalID, voter, option} } // Route implements Msg diff --git a/x/ibc-transfer/handler.go b/x/ibc-transfer/handler.go index 0745febdf64..f5e30fc1f88 100644 --- a/x/ibc-transfer/handler.go +++ b/x/ibc-transfer/handler.go @@ -11,7 +11,7 @@ func NewHandler(k Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgTransfer: + case *MsgTransfer: return handleMsgTransfer(ctx, k, msg) default: return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ICS-20 transfer message type: %T", msg) @@ -20,7 +20,7 @@ func NewHandler(k Keeper) sdk.Handler { } // See createOutgoingPacket in spec:https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#packet-relay -func handleMsgTransfer(ctx sdk.Context, k Keeper, msg MsgTransfer) (*sdk.Result, error) { +func handleMsgTransfer(ctx sdk.Context, k Keeper, msg *MsgTransfer) (*sdk.Result, error) { if err := k.SendTransfer( ctx, msg.SourcePort, msg.SourceChannel, msg.DestinationHeight, msg.Amount, msg.Sender, msg.Receiver, ); err != nil { diff --git a/x/ibc-transfer/types/codec.go b/x/ibc-transfer/types/codec.go index ddf55f4f848..2e16ce038e7 100644 --- a/x/ibc-transfer/types/codec.go +++ b/x/ibc-transfer/types/codec.go @@ -10,7 +10,7 @@ import ( // RegisterCodec registers the IBC transfer types func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgTransfer{}, "cosmos-sdk/MsgTransfer", nil) + cdc.RegisterConcrete(&MsgTransfer{}, "cosmos-sdk/MsgTransfer", nil) cdc.RegisterConcrete(FungibleTokenPacketData{}, "cosmos-sdk/PacketDataTransfer", nil) } diff --git a/x/ibc-transfer/types/msgs.go b/x/ibc-transfer/types/msgs.go index 6b0eb8c9243..eb69fbf220e 100644 --- a/x/ibc-transfer/types/msgs.go +++ b/x/ibc-transfer/types/msgs.go @@ -14,8 +14,8 @@ const ( // NewMsgTransfer creates a new MsgTransfer instance func NewMsgTransfer( sourcePort, sourceChannel string, destHeight uint64, amount sdk.Coins, sender sdk.AccAddress, receiver string, -) MsgTransfer { - return MsgTransfer{ +) *MsgTransfer { + return &MsgTransfer{ SourcePort: sourcePort, SourceChannel: sourceChannel, DestinationHeight: destHeight, diff --git a/x/ibc-transfer/types/msgs_test.go b/x/ibc-transfer/types/msgs_test.go index c3d6a9ea28b..6b332fc4d83 100644 --- a/x/ibc-transfer/types/msgs_test.go +++ b/x/ibc-transfer/types/msgs_test.go @@ -48,7 +48,7 @@ func TestMsgTransferType(t *testing.T) { // TestMsgTransferValidation tests ValidateBasic for MsgTransfer func TestMsgTransferValidation(t *testing.T) { - testMsgs := []MsgTransfer{ + testMsgs := []*MsgTransfer{ NewMsgTransfer(validPort, validChannel, 10, coins, addr1, addr2), // valid msg NewMsgTransfer(invalidShortPort, validChannel, 10, coins, addr1, addr2), // too short port id NewMsgTransfer(invalidLongPort, validChannel, 10, coins, addr1, addr2), // too long port id @@ -64,7 +64,7 @@ func TestMsgTransferValidation(t *testing.T) { } testCases := []struct { - msg MsgTransfer + msg *MsgTransfer expPass bool errMsg string }{ diff --git a/x/ibc/03-connection/handler.go b/x/ibc/03-connection/handler.go index fc89687a766..1b3c7a4342b 100644 --- a/x/ibc/03-connection/handler.go +++ b/x/ibc/03-connection/handler.go @@ -6,7 +6,7 @@ import ( ) // HandleMsgConnectionOpenInit defines the sdk.Handler for MsgConnectionOpenInit -func HandleMsgConnectionOpenInit(ctx sdk.Context, k Keeper, msg MsgConnectionOpenInit) (*sdk.Result, error) { +func HandleMsgConnectionOpenInit(ctx sdk.Context, k Keeper, msg *MsgConnectionOpenInit) (*sdk.Result, error) { if err := k.ConnOpenInit( ctx, msg.ConnectionID, msg.ClientID, msg.Counterparty, ); err != nil { @@ -32,7 +32,7 @@ func HandleMsgConnectionOpenInit(ctx sdk.Context, k Keeper, msg MsgConnectionOpe } // HandleMsgConnectionOpenTry defines the sdk.Handler for MsgConnectionOpenTry -func HandleMsgConnectionOpenTry(ctx sdk.Context, k Keeper, msg MsgConnectionOpenTry) (*sdk.Result, error) { +func HandleMsgConnectionOpenTry(ctx sdk.Context, k Keeper, msg *MsgConnectionOpenTry) (*sdk.Result, error) { if err := k.ConnOpenTry( ctx, msg.ConnectionID, msg.Counterparty, msg.ClientID, msg.CounterpartyVersions, msg.ProofInit, msg.ProofConsensus, @@ -60,7 +60,7 @@ func HandleMsgConnectionOpenTry(ctx sdk.Context, k Keeper, msg MsgConnectionOpen } // HandleMsgConnectionOpenAck defines the sdk.Handler for MsgConnectionOpenAck -func HandleMsgConnectionOpenAck(ctx sdk.Context, k Keeper, msg MsgConnectionOpenAck) (*sdk.Result, error) { +func HandleMsgConnectionOpenAck(ctx sdk.Context, k Keeper, msg *MsgConnectionOpenAck) (*sdk.Result, error) { if err := k.ConnOpenAck( ctx, msg.ConnectionID, msg.Version, msg.ProofTry, msg.ProofConsensus, msg.ProofHeight, msg.ConsensusHeight, @@ -85,7 +85,7 @@ func HandleMsgConnectionOpenAck(ctx sdk.Context, k Keeper, msg MsgConnectionOpen } // HandleMsgConnectionOpenConfirm defines the sdk.Handler for MsgConnectionOpenConfirm -func HandleMsgConnectionOpenConfirm(ctx sdk.Context, k Keeper, msg MsgConnectionOpenConfirm) (*sdk.Result, error) { +func HandleMsgConnectionOpenConfirm(ctx sdk.Context, k Keeper, msg *MsgConnectionOpenConfirm) (*sdk.Result, error) { if err := k.ConnOpenConfirm( ctx, msg.ConnectionID, msg.ProofAck, msg.ProofHeight, ); err != nil { diff --git a/x/ibc/03-connection/types/codec.go b/x/ibc/03-connection/types/codec.go index 5ae9aa6ed89..f5ebbbe6bdb 100644 --- a/x/ibc/03-connection/types/codec.go +++ b/x/ibc/03-connection/types/codec.go @@ -14,10 +14,10 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*exported.CounterpartyI)(nil), nil) cdc.RegisterConcrete(ConnectionEnd{}, "ibc/connection/ConnectionEnd", nil) - cdc.RegisterConcrete(MsgConnectionOpenInit{}, "ibc/connection/MsgConnectionOpenInit", nil) - cdc.RegisterConcrete(MsgConnectionOpenTry{}, "ibc/connection/MsgConnectionOpenTry", nil) - cdc.RegisterConcrete(MsgConnectionOpenAck{}, "ibc/connection/MsgConnectionOpenAck", nil) - cdc.RegisterConcrete(MsgConnectionOpenConfirm{}, "ibc/connection/MsgConnectionOpenConfirm", nil) + cdc.RegisterConcrete(&MsgConnectionOpenInit{}, "ibc/connection/MsgConnectionOpenInit", nil) + cdc.RegisterConcrete(&MsgConnectionOpenTry{}, "ibc/connection/MsgConnectionOpenTry", nil) + cdc.RegisterConcrete(&MsgConnectionOpenAck{}, "ibc/connection/MsgConnectionOpenAck", nil) + cdc.RegisterConcrete(&MsgConnectionOpenConfirm{}, "ibc/connection/MsgConnectionOpenConfirm", nil) } // RegisterInterfaces register the ibc interfaces submodule implementations to protobuf diff --git a/x/ibc/03-connection/types/msgs.go b/x/ibc/03-connection/types/msgs.go index f459abd6c91..669525040cc 100644 --- a/x/ibc/03-connection/types/msgs.go +++ b/x/ibc/03-connection/types/msgs.go @@ -9,16 +9,16 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -var _ sdk.Msg = MsgConnectionOpenInit{} +var _ sdk.Msg = &MsgConnectionOpenInit{} // NewMsgConnectionOpenInit creates a new MsgConnectionOpenInit instance func NewMsgConnectionOpenInit( connectionID, clientID, counterpartyConnectionID, counterpartyClientID string, counterpartyPrefix commitmenttypes.MerklePrefix, signer sdk.AccAddress, -) MsgConnectionOpenInit { +) *MsgConnectionOpenInit { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) - return MsgConnectionOpenInit{ + return &MsgConnectionOpenInit{ ConnectionID: connectionID, ClientID: clientID, Counterparty: counterparty, @@ -60,7 +60,7 @@ func (msg MsgConnectionOpenInit) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgConnectionOpenTry{} +var _ sdk.Msg = &MsgConnectionOpenTry{} // NewMsgConnectionOpenTry creates a new MsgConnectionOpenTry instance func NewMsgConnectionOpenTry( @@ -68,9 +68,9 @@ func NewMsgConnectionOpenTry( counterpartyClientID string, counterpartyPrefix commitmenttypes.MerklePrefix, counterpartyVersions []string, proofInit, proofConsensus commitmenttypes.MerkleProof, proofHeight, consensusHeight uint64, signer sdk.AccAddress, -) MsgConnectionOpenTry { +) *MsgConnectionOpenTry { counterparty := NewCounterparty(counterpartyClientID, counterpartyConnectionID, counterpartyPrefix) - return MsgConnectionOpenTry{ + return &MsgConnectionOpenTry{ ConnectionID: connectionID, ClientID: clientID, Counterparty: counterparty, @@ -140,15 +140,15 @@ func (msg MsgConnectionOpenTry) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgConnectionOpenAck{} +var _ sdk.Msg = &MsgConnectionOpenAck{} // NewMsgConnectionOpenAck creates a new MsgConnectionOpenAck instance func NewMsgConnectionOpenAck( connectionID string, proofTry, proofConsensus commitmenttypes.MerkleProof, proofHeight, consensusHeight uint64, version string, signer sdk.AccAddress, -) MsgConnectionOpenAck { - return MsgConnectionOpenAck{ +) *MsgConnectionOpenAck { + return &MsgConnectionOpenAck{ ConnectionID: connectionID, ProofTry: proofTry, ProofConsensus: proofConsensus, @@ -208,14 +208,14 @@ func (msg MsgConnectionOpenAck) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgConnectionOpenConfirm{} +var _ sdk.Msg = &MsgConnectionOpenConfirm{} // NewMsgConnectionOpenConfirm creates a new MsgConnectionOpenConfirm instance func NewMsgConnectionOpenConfirm( connectionID string, proofAck commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgConnectionOpenConfirm { - return MsgConnectionOpenConfirm{ +) *MsgConnectionOpenConfirm { + return &MsgConnectionOpenConfirm{ ConnectionID: connectionID, ProofAck: proofAck, ProofHeight: proofHeight, diff --git a/x/ibc/03-connection/types/msgs_test.go b/x/ibc/03-connection/types/msgs_test.go index bc542e1be40..50dccb40a71 100644 --- a/x/ibc/03-connection/types/msgs_test.go +++ b/x/ibc/03-connection/types/msgs_test.go @@ -56,7 +56,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey")) signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") - testMsgs := []MsgConnectionOpenInit{ + testMsgs := []*MsgConnectionOpenInit{ NewMsgConnectionOpenInit("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, signer), NewMsgConnectionOpenInit("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, signer), NewMsgConnectionOpenInit("ibcconntest", "clienttotest", "test/conn1", "clienttotest", prefix, signer), @@ -67,7 +67,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenInit() { } var testCases = []struct { - msg MsgConnectionOpenInit + msg *MsgConnectionOpenInit expPass bool errMsg string }{ @@ -94,7 +94,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { prefix := commitmenttypes.NewMerklePrefix([]byte("storePrefixKey")) signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") - testMsgs := []MsgConnectionOpenTry{ + testMsgs := []*MsgConnectionOpenTry{ NewMsgConnectionOpenTry("test/conn1", "clienttotesta", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "test/iris", "connectiontotest", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), NewMsgConnectionOpenTry("ibcconntest", "clienttotesta", "ibc/test", "clienttotest", prefix, []string{"1.0.0"}, suite.proof, suite.proof, 10, 10, signer), @@ -110,7 +110,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { } var testCases = []struct { - msg MsgConnectionOpenTry + msg *MsgConnectionOpenTry expPass bool errMsg string }{ @@ -141,7 +141,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") - testMsgs := []MsgConnectionOpenAck{ + testMsgs := []*MsgConnectionOpenAck{ NewMsgConnectionOpenAck("test/conn1", suite.proof, suite.proof, 10, 10, "1.0.0", signer), NewMsgConnectionOpenAck("ibcconntest", emptyProof, suite.proof, 10, 10, "1.0.0", signer), NewMsgConnectionOpenAck("ibcconntest", suite.proof, emptyProof, 10, 10, "1.0.0", signer), @@ -152,7 +152,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { NewMsgConnectionOpenAck("ibcconntest", suite.proof, suite.proof, 10, 10, "1.0.0", signer), } var testCases = []struct { - msg MsgConnectionOpenAck + msg *MsgConnectionOpenAck expPass bool errMsg string }{ @@ -179,7 +179,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") - testMsgs := []MsgConnectionOpenConfirm{ + testMsgs := []*MsgConnectionOpenConfirm{ NewMsgConnectionOpenConfirm("test/conn1", suite.proof, 10, signer), NewMsgConnectionOpenConfirm("ibcconntest", emptyProof, 10, signer), NewMsgConnectionOpenConfirm("ibcconntest", suite.proof, 0, signer), @@ -188,7 +188,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() { } var testCases = []struct { - msg MsgConnectionOpenConfirm + msg *MsgConnectionOpenConfirm expPass bool errMsg string }{ diff --git a/x/ibc/04-channel/handler.go b/x/ibc/04-channel/handler.go index c79c2991f25..47c2ba805e7 100644 --- a/x/ibc/04-channel/handler.go +++ b/x/ibc/04-channel/handler.go @@ -8,7 +8,7 @@ import ( ) // HandleMsgChannelOpenInit defines the sdk.Handler for MsgChannelOpenInit -func HandleMsgChannelOpenInit(ctx sdk.Context, k keeper.Keeper, portCap *capability.Capability, msg types.MsgChannelOpenInit) (*sdk.Result, *capability.Capability, error) { +func HandleMsgChannelOpenInit(ctx sdk.Context, k keeper.Keeper, portCap *capability.Capability, msg *MsgChannelOpenInit) (*sdk.Result, *capability.Capability, error) { capKey, err := k.ChanOpenInit( ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortID, msg.ChannelID, portCap, msg.Channel.Counterparty, msg.Channel.Version, @@ -38,7 +38,7 @@ func HandleMsgChannelOpenInit(ctx sdk.Context, k keeper.Keeper, portCap *capabil } // HandleMsgChannelOpenTry defines the sdk.Handler for MsgChannelOpenTry -func HandleMsgChannelOpenTry(ctx sdk.Context, k keeper.Keeper, portCap *capability.Capability, msg types.MsgChannelOpenTry) (*sdk.Result, *capability.Capability, error) { +func HandleMsgChannelOpenTry(ctx sdk.Context, k keeper.Keeper, portCap *capability.Capability, msg *MsgChannelOpenTry) (*sdk.Result, *capability.Capability, error) { capKey, err := k.ChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortID, msg.ChannelID, portCap, msg.Channel.Counterparty, msg.Channel.Version, msg.CounterpartyVersion, msg.ProofInit, msg.ProofHeight, ) @@ -67,7 +67,7 @@ func HandleMsgChannelOpenTry(ctx sdk.Context, k keeper.Keeper, portCap *capabili } // HandleMsgChannelOpenAck defines the sdk.Handler for MsgChannelOpenAck -func HandleMsgChannelOpenAck(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg types.MsgChannelOpenAck) (*sdk.Result, error) { +func HandleMsgChannelOpenAck(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg *MsgChannelOpenAck) (*sdk.Result, error) { err := k.ChanOpenAck( ctx, msg.PortID, msg.ChannelID, channelCap, msg.CounterpartyVersion, msg.ProofTry, msg.ProofHeight, ) @@ -93,7 +93,7 @@ func HandleMsgChannelOpenAck(ctx sdk.Context, k keeper.Keeper, channelCap *capab } // HandleMsgChannelOpenConfirm defines the sdk.Handler for MsgChannelOpenConfirm -func HandleMsgChannelOpenConfirm(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg types.MsgChannelOpenConfirm) (*sdk.Result, error) { +func HandleMsgChannelOpenConfirm(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg *MsgChannelOpenConfirm) (*sdk.Result, error) { err := k.ChanOpenConfirm(ctx, msg.PortID, msg.ChannelID, channelCap, msg.ProofAck, msg.ProofHeight) if err != nil { return nil, err @@ -117,7 +117,7 @@ func HandleMsgChannelOpenConfirm(ctx sdk.Context, k keeper.Keeper, channelCap *c } // HandleMsgChannelCloseInit defines the sdk.Handler for MsgChannelCloseInit -func HandleMsgChannelCloseInit(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg types.MsgChannelCloseInit) (*sdk.Result, error) { +func HandleMsgChannelCloseInit(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg *MsgChannelCloseInit) (*sdk.Result, error) { err := k.ChanCloseInit(ctx, msg.PortID, msg.ChannelID, channelCap) if err != nil { return nil, err @@ -141,7 +141,7 @@ func HandleMsgChannelCloseInit(ctx sdk.Context, k keeper.Keeper, channelCap *cap } // HandleMsgChannelCloseConfirm defines the sdk.Handler for MsgChannelCloseConfirm -func HandleMsgChannelCloseConfirm(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg types.MsgChannelCloseConfirm) (*sdk.Result, error) { +func HandleMsgChannelCloseConfirm(ctx sdk.Context, k keeper.Keeper, channelCap *capability.Capability, msg *MsgChannelCloseConfirm) (*sdk.Result, error) { err := k.ChanCloseConfirm(ctx, msg.PortID, msg.ChannelID, channelCap, msg.ProofInit, msg.ProofHeight) if err != nil { return nil, err diff --git a/x/ibc/04-channel/types/codec.go b/x/ibc/04-channel/types/codec.go index 66e0e65ac33..01b4bbe0353 100644 --- a/x/ibc/04-channel/types/codec.go +++ b/x/ibc/04-channel/types/codec.go @@ -14,15 +14,15 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(Channel{}, "ibc/channel/Channel", nil) cdc.RegisterConcrete(Packet{}, "ibc/channel/Packet", nil) - cdc.RegisterConcrete(MsgChannelOpenInit{}, "ibc/channel/MsgChannelOpenInit", nil) - cdc.RegisterConcrete(MsgChannelOpenTry{}, "ibc/channel/MsgChannelOpenTry", nil) - cdc.RegisterConcrete(MsgChannelOpenAck{}, "ibc/channel/MsgChannelOpenAck", nil) - cdc.RegisterConcrete(MsgChannelOpenConfirm{}, "ibc/channel/MsgChannelOpenConfirm", nil) - cdc.RegisterConcrete(MsgChannelCloseInit{}, "ibc/channel/MsgChannelCloseInit", nil) - cdc.RegisterConcrete(MsgChannelCloseConfirm{}, "ibc/channel/MsgChannelCloseConfirm", nil) - cdc.RegisterConcrete(MsgPacket{}, "ibc/channel/MsgPacket", nil) - cdc.RegisterConcrete(MsgAcknowledgement{}, "ibc/channel/MsgAcknowledgement", nil) - cdc.RegisterConcrete(MsgTimeout{}, "ibc/channel/MsgTimeout", nil) + cdc.RegisterConcrete(&MsgChannelOpenInit{}, "ibc/channel/MsgChannelOpenInit", nil) + cdc.RegisterConcrete(&MsgChannelOpenTry{}, "ibc/channel/MsgChannelOpenTry", nil) + cdc.RegisterConcrete(&MsgChannelOpenAck{}, "ibc/channel/MsgChannelOpenAck", nil) + cdc.RegisterConcrete(&MsgChannelOpenConfirm{}, "ibc/channel/MsgChannelOpenConfirm", nil) + cdc.RegisterConcrete(&MsgChannelCloseInit{}, "ibc/channel/MsgChannelCloseInit", nil) + cdc.RegisterConcrete(&MsgChannelCloseConfirm{}, "ibc/channel/MsgChannelCloseConfirm", nil) + cdc.RegisterConcrete(&MsgPacket{}, "ibc/channel/MsgPacket", nil) + cdc.RegisterConcrete(&MsgAcknowledgement{}, "ibc/channel/MsgAcknowledgement", nil) + cdc.RegisterConcrete(&MsgTimeout{}, "ibc/channel/MsgTimeout", nil) } // RegisterInterfaces register the ibc channel submodule interfaces to protobuf diff --git a/x/ibc/04-channel/types/msgs.go b/x/ibc/04-channel/types/msgs.go index 1c3c617acb1..ab5427a0272 100644 --- a/x/ibc/04-channel/types/msgs.go +++ b/x/ibc/04-channel/types/msgs.go @@ -10,16 +10,16 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/24-host" ) -var _ sdk.Msg = MsgChannelOpenInit{} +var _ sdk.Msg = &MsgChannelOpenInit{} // NewMsgChannelOpenInit creates a new MsgChannelCloseInit MsgChannelOpenInit func NewMsgChannelOpenInit( portID, channelID string, version string, channelOrder Order, connectionHops []string, counterpartyPortID, counterpartyChannelID string, signer sdk.AccAddress, -) MsgChannelOpenInit { +) *MsgChannelOpenInit { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := NewChannel(INIT, channelOrder, counterparty, connectionHops, version) - return MsgChannelOpenInit{ + return &MsgChannelOpenInit{ PortID: portID, ChannelID: channelID, Channel: channel, @@ -59,17 +59,17 @@ func (msg MsgChannelOpenInit) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgChannelOpenTry{} +var _ sdk.Msg = &MsgChannelOpenTry{} // NewMsgChannelOpenTry creates a new MsgChannelOpenTry instance func NewMsgChannelOpenTry( portID, channelID, version string, channelOrder Order, connectionHops []string, counterpartyPortID, counterpartyChannelID, counterpartyVersion string, proofInit commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgChannelOpenTry { +) *MsgChannelOpenTry { counterparty := NewCounterparty(counterpartyPortID, counterpartyChannelID) channel := NewChannel(INIT, channelOrder, counterparty, connectionHops, version) - return MsgChannelOpenTry{ + return &MsgChannelOpenTry{ PortID: portID, ChannelID: channelID, Channel: channel, @@ -124,14 +124,14 @@ func (msg MsgChannelOpenTry) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgChannelOpenAck{} +var _ sdk.Msg = &MsgChannelOpenAck{} // NewMsgChannelOpenAck creates a new MsgChannelOpenAck instance func NewMsgChannelOpenAck( portID, channelID string, cpv string, proofTry commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgChannelOpenAck { - return MsgChannelOpenAck{ +) *MsgChannelOpenAck { + return &MsgChannelOpenAck{ PortID: portID, ChannelID: channelID, CounterpartyVersion: cpv, @@ -185,14 +185,14 @@ func (msg MsgChannelOpenAck) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgChannelOpenConfirm{} +var _ sdk.Msg = &MsgChannelOpenConfirm{} // NewMsgChannelOpenConfirm creates a new MsgChannelOpenConfirm instance func NewMsgChannelOpenConfirm( portID, channelID string, proofAck commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgChannelOpenConfirm { - return MsgChannelOpenConfirm{ +) *MsgChannelOpenConfirm { + return &MsgChannelOpenConfirm{ PortID: portID, ChannelID: channelID, ProofAck: proofAck, @@ -242,13 +242,13 @@ func (msg MsgChannelOpenConfirm) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgChannelCloseInit{} +var _ sdk.Msg = &MsgChannelCloseInit{} // NewMsgChannelCloseInit creates a new MsgChannelCloseInit instance func NewMsgChannelCloseInit( portID string, channelID string, signer sdk.AccAddress, -) MsgChannelCloseInit { - return MsgChannelCloseInit{ +) *MsgChannelCloseInit { + return &MsgChannelCloseInit{ PortID: portID, ChannelID: channelID, Signer: signer, @@ -287,14 +287,14 @@ func (msg MsgChannelCloseInit) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgChannelCloseConfirm{} +var _ sdk.Msg = &MsgChannelCloseConfirm{} // NewMsgChannelCloseConfirm creates a new MsgChannelCloseConfirm instance func NewMsgChannelCloseConfirm( portID, channelID string, proofInit commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgChannelCloseConfirm { - return MsgChannelCloseConfirm{ +) *MsgChannelCloseConfirm { + return &MsgChannelCloseConfirm{ PortID: portID, ChannelID: channelID, ProofInit: proofInit, @@ -344,14 +344,14 @@ func (msg MsgChannelCloseConfirm) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Signer} } -var _ sdk.Msg = MsgPacket{} +var _ sdk.Msg = &MsgPacket{} // NewMsgPacket constructs new MsgPacket func NewMsgPacket( packet Packet, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgPacket { - return MsgPacket{ +) *MsgPacket { + return &MsgPacket{ Packet: packet, Proof: proof, ProofHeight: proofHeight, @@ -404,14 +404,14 @@ func (msg MsgPacket) Type() string { return "ics04/opaque" } -var _ sdk.Msg = MsgTimeout{} +var _ sdk.Msg = &MsgTimeout{} // NewMsgTimeout constructs new MsgTimeout func NewMsgTimeout( packet Packet, nextSequenceRecv uint64, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress, -) MsgTimeout { - return MsgTimeout{ +) *MsgTimeout { + return &MsgTimeout{ Packet: packet, NextSequenceRecv: nextSequenceRecv, Proof: proof, @@ -458,12 +458,12 @@ func (msg MsgTimeout) Type() string { return "ics04/timeout" } -var _ sdk.Msg = MsgAcknowledgement{} +var _ sdk.Msg = &MsgAcknowledgement{} // NewMsgAcknowledgement constructs a new MsgAcknowledgement func NewMsgAcknowledgement( - packet Packet, ack []byte, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) MsgAcknowledgement { - return MsgAcknowledgement{ + packet Packet, ack []byte, proof commitmenttypes.MerkleProof, proofHeight uint64, signer sdk.AccAddress) *MsgAcknowledgement { + return &MsgAcknowledgement{ Packet: packet, Acknowledgement: ack, Proof: proof, diff --git a/x/ibc/04-channel/types/msgs_test.go b/x/ibc/04-channel/types/msgs_test.go index 8d7d659f839..beaa9645b93 100644 --- a/x/ibc/04-channel/types/msgs_test.go +++ b/x/ibc/04-channel/types/msgs_test.go @@ -79,7 +79,7 @@ func TestMsgTestSuite(t *testing.T) { // TestMsgChannelOpenInit tests ValidateBasic for MsgChannelOpenInit func (suite *MsgTestSuite) TestMsgChannelOpenInit() { - testMsgs := []MsgChannelOpenInit{ + testMsgs := []*MsgChannelOpenInit{ NewMsgChannelOpenInit("testportid", "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // valid msg NewMsgChannelOpenInit(invalidShortPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // too short port id NewMsgChannelOpenInit(invalidLongPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", addr), // too long port id @@ -98,7 +98,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenInit() { } testCases := []struct { - msg MsgChannelOpenInit + msg *MsgChannelOpenInit expPass bool errMsg string }{ @@ -131,7 +131,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenInit() { // TestMsgChannelOpenTry tests ValidateBasic for MsgChannelOpenTry func (suite *MsgTestSuite) TestMsgChannelOpenTry() { - testMsgs := []MsgChannelOpenTry{ + testMsgs := []*MsgChannelOpenTry{ NewMsgChannelOpenTry("testportid", "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // valid msg NewMsgChannelOpenTry(invalidShortPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too short port id NewMsgChannelOpenTry(invalidLongPort, "testchannel", "1.0", ORDERED, connHops, "testcpport", "testcpchannel", "1.0", suite.proof, 1, addr), // too long port id @@ -152,7 +152,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { } testCases := []struct { - msg MsgChannelOpenTry + msg *MsgChannelOpenTry expPass bool errMsg string }{ @@ -187,7 +187,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenTry() { // TestMsgChannelOpenAck tests ValidateBasic for MsgChannelOpenAck func (suite *MsgTestSuite) TestMsgChannelOpenAck() { - testMsgs := []MsgChannelOpenAck{ + testMsgs := []*MsgChannelOpenAck{ NewMsgChannelOpenAck("testportid", "testchannel", "1.0", suite.proof, 1, addr), // valid msg NewMsgChannelOpenAck(invalidShortPort, "testchannel", "1.0", suite.proof, 1, addr), // too short port id NewMsgChannelOpenAck(invalidLongPort, "testchannel", "1.0", suite.proof, 1, addr), // too long port id @@ -201,7 +201,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { } testCases := []struct { - msg MsgChannelOpenAck + msg *MsgChannelOpenAck expPass bool errMsg string }{ @@ -229,7 +229,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenAck() { // TestMsgChannelOpenConfirm tests ValidateBasic for MsgChannelOpenConfirm func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { - testMsgs := []MsgChannelOpenConfirm{ + testMsgs := []*MsgChannelOpenConfirm{ NewMsgChannelOpenConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg NewMsgChannelOpenConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id NewMsgChannelOpenConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id @@ -242,7 +242,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { } testCases := []struct { - msg MsgChannelOpenConfirm + msg *MsgChannelOpenConfirm expPass bool errMsg string }{ @@ -269,7 +269,7 @@ func (suite *MsgTestSuite) TestMsgChannelOpenConfirm() { // TestMsgChannelCloseInit tests ValidateBasic for MsgChannelCloseInit func (suite *MsgTestSuite) TestMsgChannelCloseInit() { - testMsgs := []MsgChannelCloseInit{ + testMsgs := []*MsgChannelCloseInit{ NewMsgChannelCloseInit("testportid", "testchannel", addr), // valid msg NewMsgChannelCloseInit(invalidShortPort, "testchannel", addr), // too short port id NewMsgChannelCloseInit(invalidLongPort, "testchannel", addr), // too long port id @@ -280,7 +280,7 @@ func (suite *MsgTestSuite) TestMsgChannelCloseInit() { } testCases := []struct { - msg MsgChannelCloseInit + msg *MsgChannelCloseInit expPass bool errMsg string }{ @@ -305,7 +305,7 @@ func (suite *MsgTestSuite) TestMsgChannelCloseInit() { // TestMsgChannelCloseConfirm tests ValidateBasic for MsgChannelCloseConfirm func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { - testMsgs := []MsgChannelCloseConfirm{ + testMsgs := []*MsgChannelCloseConfirm{ NewMsgChannelCloseConfirm("testportid", "testchannel", suite.proof, 1, addr), // valid msg NewMsgChannelCloseConfirm(invalidShortPort, "testchannel", suite.proof, 1, addr), // too short port id NewMsgChannelCloseConfirm(invalidLongPort, "testchannel", suite.proof, 1, addr), // too long port id @@ -318,7 +318,7 @@ func (suite *MsgTestSuite) TestMsgChannelCloseConfirm() { } testCases := []struct { - msg MsgChannelCloseConfirm + msg *MsgChannelCloseConfirm expPass bool errMsg string }{ @@ -378,7 +378,7 @@ func TestMsgPacketType(t *testing.T) { // TestMsgPacketValidation tests ValidateBasic for MsgPacket func TestMsgPacketValidation(t *testing.T) { - testMsgs := []MsgPacket{ + testMsgs := []*MsgPacket{ NewMsgPacket(packet, proof, 1, addr1), // valid msg NewMsgPacket(packet, proof, 0, addr1), // proof height is zero NewMsgPacket(packet, invalidProofs2, 1, addr1), // proof contain empty proof @@ -387,7 +387,7 @@ func TestMsgPacketValidation(t *testing.T) { } testCases := []struct { - msg MsgPacket + msg *MsgPacket expPass bool errMsg string }{ @@ -431,7 +431,7 @@ func TestMsgPacketGetSigners(t *testing.T) { // TestMsgTimeout tests ValidateBasic for MsgTimeout func (suite *MsgTestSuite) TestMsgTimeout() { - testMsgs := []MsgTimeout{ + testMsgs := []*MsgTimeout{ NewMsgTimeout(packet, 1, proof, 1, addr), NewMsgTimeout(packet, 1, proof, 0, addr), NewMsgTimeout(packet, 1, proof, 1, emptyAddr), @@ -440,7 +440,7 @@ func (suite *MsgTestSuite) TestMsgTimeout() { } testCases := []struct { - msg MsgTimeout + msg *MsgTimeout expPass bool errMsg string }{ @@ -463,7 +463,7 @@ func (suite *MsgTestSuite) TestMsgTimeout() { // TestMsgAcknowledgement tests ValidateBasic for MsgAcknowledgement func (suite *MsgTestSuite) TestMsgAcknowledgement() { - testMsgs := []MsgAcknowledgement{ + testMsgs := []*MsgAcknowledgement{ NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, addr), NewMsgAcknowledgement(packet, packet.GetData(), proof, 0, addr), NewMsgAcknowledgement(packet, packet.GetData(), proof, 1, emptyAddr), @@ -473,7 +473,7 @@ func (suite *MsgTestSuite) TestMsgAcknowledgement() { } testCases := []struct { - msg MsgAcknowledgement + msg *MsgAcknowledgement expPass bool errMsg string }{ diff --git a/x/ibc/07-tendermint/types/codec.go b/x/ibc/07-tendermint/types/codec.go index 086b23aae43..2ac179d62c6 100644 --- a/x/ibc/07-tendermint/types/codec.go +++ b/x/ibc/07-tendermint/types/codec.go @@ -13,9 +13,9 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(ConsensusState{}, "ibc/client/tendermint/ConsensusState", nil) cdc.RegisterConcrete(Header{}, "ibc/client/tendermint/Header", nil) cdc.RegisterConcrete(Evidence{}, "ibc/client/tendermint/Evidence", nil) - cdc.RegisterConcrete(MsgCreateClient{}, "ibc/client/tendermint/MsgCreateClient", nil) - cdc.RegisterConcrete(MsgUpdateClient{}, "ibc/client/tendermint/MsgUpdateClient", nil) - cdc.RegisterConcrete(MsgSubmitClientMisbehaviour{}, "ibc/client/tendermint/MsgSubmitClientMisbehaviour", nil) + cdc.RegisterConcrete(&MsgCreateClient{}, "ibc/client/tendermint/MsgCreateClient", nil) + cdc.RegisterConcrete(&MsgUpdateClient{}, "ibc/client/tendermint/MsgUpdateClient", nil) + cdc.RegisterConcrete(&MsgSubmitClientMisbehaviour{}, "ibc/client/tendermint/MsgSubmitClientMisbehaviour", nil) SetSubModuleCodec(cdc) } diff --git a/x/ibc/07-tendermint/types/msgs.go b/x/ibc/07-tendermint/types/msgs.go index 3fcc15e1b66..67f4a6aab86 100644 --- a/x/ibc/07-tendermint/types/msgs.go +++ b/x/ibc/07-tendermint/types/msgs.go @@ -23,9 +23,9 @@ const ( ) var ( - _ clientexported.MsgCreateClient = MsgCreateClient{} - _ clientexported.MsgUpdateClient = MsgUpdateClient{} - _ evidenceexported.MsgSubmitEvidence = MsgSubmitClientMisbehaviour{} + _ clientexported.MsgCreateClient = &MsgCreateClient{} + _ clientexported.MsgUpdateClient = &MsgUpdateClient{} + _ evidenceexported.MsgSubmitEvidence = &MsgSubmitClientMisbehaviour{} ) // MsgCreateClient defines a message to create an IBC client @@ -39,6 +39,14 @@ type MsgCreateClient struct { Signer sdk.AccAddress `json:"address" yaml:"address"` } +// this is a constant to satisfy the linter +const TODO = "TODO" + +// dummy implementation of proto.Message +func (msg MsgCreateClient) Reset() {} +func (msg MsgCreateClient) String() string { return TODO } +func (msg MsgCreateClient) ProtoMessage() {} + // NewMsgCreateClient creates a new MsgCreateClient instance func NewMsgCreateClient( id string, header Header, trustLevel tmmath.Fraction, @@ -129,6 +137,11 @@ type MsgUpdateClient struct { Signer sdk.AccAddress `json:"address" yaml:"address"` } +// dummy implementation of proto.Message +func (msg MsgUpdateClient) Reset() {} +func (msg MsgUpdateClient) String() string { return TODO } +func (msg MsgUpdateClient) ProtoMessage() {} + // NewMsgUpdateClient creates a new MsgUpdateClient instance func NewMsgUpdateClient(id string, header Header, signer sdk.AccAddress) MsgUpdateClient { return MsgUpdateClient{ @@ -183,6 +196,11 @@ type MsgSubmitClientMisbehaviour struct { Submitter sdk.AccAddress `json:"submitter" yaml:"submitter"` } +// dummy implementation of proto.Message +func (msg MsgSubmitClientMisbehaviour) Reset() {} +func (msg MsgSubmitClientMisbehaviour) String() string { return TODO } +func (msg MsgSubmitClientMisbehaviour) ProtoMessage() {} + // NewMsgSubmitClientMisbehaviour creates a new MsgSubmitClientMisbehaviour // instance. func NewMsgSubmitClientMisbehaviour(e evidenceexported.Evidence, s sdk.AccAddress) MsgSubmitClientMisbehaviour { diff --git a/x/ibc/09-localhost/types/codec.go b/x/ibc/09-localhost/types/codec.go index 67a9431fa58..a0dff8718cf 100644 --- a/x/ibc/09-localhost/types/codec.go +++ b/x/ibc/09-localhost/types/codec.go @@ -15,7 +15,7 @@ var SubModuleCdc *codec.Codec // RegisterCodec registers the localhost types func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(ClientState{}, "ibc/client/localhost/ClientState", nil) - cdc.RegisterConcrete(MsgCreateClient{}, "ibc/client/localhost/MsgCreateClient", nil) + cdc.RegisterConcrete(&MsgCreateClient{}, "ibc/client/localhost/MsgCreateClient", nil) SetSubModuleCodec(cdc) } diff --git a/x/ibc/09-localhost/types/msgs.go b/x/ibc/09-localhost/types/msgs.go index 8b526f446a0..efd3c89057c 100644 --- a/x/ibc/09-localhost/types/msgs.go +++ b/x/ibc/09-localhost/types/msgs.go @@ -13,17 +13,12 @@ const ( ) var ( - _ clientexported.MsgCreateClient = MsgCreateClient{} + _ clientexported.MsgCreateClient = &MsgCreateClient{} ) -// MsgCreateClient defines a message to create an IBC client -type MsgCreateClient struct { - Signer sdk.AccAddress `json:"address" yaml:"address"` -} - // NewMsgCreateClient creates a new MsgCreateClient instance -func NewMsgCreateClient(signer sdk.AccAddress) MsgCreateClient { - return MsgCreateClient{ +func NewMsgCreateClient(signer sdk.AccAddress) *MsgCreateClient { + return &MsgCreateClient{ Signer: signer, } } diff --git a/x/ibc/09-localhost/types/types.pb.go b/x/ibc/09-localhost/types/types.pb.go new file mode 100644 index 00000000000..2d8fed4c98b --- /dev/null +++ b/x/ibc/09-localhost/types/types.pb.go @@ -0,0 +1,328 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/ibc/09-localhost/types/types.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgCreateClient defines a message to create an IBC client +type MsgCreateClient struct { + Signer github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=signer,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"signer,omitempty"` +} + +func (m *MsgCreateClient) Reset() { *m = MsgCreateClient{} } +func (m *MsgCreateClient) String() string { return proto.CompactTextString(m) } +func (*MsgCreateClient) ProtoMessage() {} +func (*MsgCreateClient) Descriptor() ([]byte, []int) { + return fileDescriptor_a8da40ad8942fbdc, []int{0} +} +func (m *MsgCreateClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateClient.Merge(m, src) +} +func (m *MsgCreateClient) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateClient proto.InternalMessageInfo + +func (m *MsgCreateClient) GetSigner() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Signer + } + return nil +} + +func init() { + proto.RegisterType((*MsgCreateClient)(nil), "cosmos_sdk.ibc.localhost.v1.MsgCreateClient") +} + +func init() { + proto.RegisterFile("x/ibc/09-localhost/types/types.proto", fileDescriptor_a8da40ad8942fbdc) +} + +var fileDescriptor_a8da40ad8942fbdc = []byte{ + // 220 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xa9, 0xd0, 0xcf, 0x4c, + 0x4a, 0xd6, 0x37, 0xb0, 0xd4, 0xcd, 0xc9, 0x4f, 0x4e, 0xcc, 0xc9, 0xc8, 0x2f, 0x2e, 0xd1, 0x2f, + 0xa9, 0x2c, 0x48, 0x2d, 0x86, 0x90, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xd2, 0xc9, 0xf9, + 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, 0x99, 0x49, 0xc9, 0x7a, 0x70, 0xb5, 0x7a, + 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, 0xf1, 0x05, 0x89, 0x45, 0x25, 0x95, 0xfa, + 0x60, 0xf5, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0x08, 0x16, 0xc4, 0x10, 0xa5, 0x18, 0x2e, 0x7e, 0xdf, + 0xe2, 0x74, 0xe7, 0xa2, 0xd4, 0xc4, 0x92, 0x54, 0xe7, 0x9c, 0xcc, 0xd4, 0xbc, 0x12, 0x21, 0x4f, + 0x2e, 0xb6, 0xe2, 0xcc, 0xf4, 0xbc, 0xd4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x1e, 0x27, 0xc3, + 0x5f, 0xf7, 0xe4, 0x75, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, + 0xd6, 0x42, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xa8, 0xab, 0x1c, 0x93, 0x93, 0x1d, 0x53, 0x52, 0x8a, + 0x52, 0x8b, 0x8b, 0x83, 0xa0, 0x06, 0x38, 0xf9, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, + 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, + 0x1c, 0x43, 0x94, 0x29, 0x5e, 0x03, 0x71, 0xf9, 0x3f, 0x89, 0x0d, 0xec, 0x6a, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x9c, 0xe5, 0xb5, 0xd4, 0x22, 0x01, 0x00, 0x00, +} + +func (m *MsgCreateClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreateClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = append(m.Signer[:0], dAtA[iNdEx:postIndex]...) + if m.Signer == nil { + m.Signer = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/09-localhost/types/types.proto b/x/ibc/09-localhost/types/types.proto new file mode 100644 index 00000000000..087ec3b8c6f --- /dev/null +++ b/x/ibc/09-localhost/types/types.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package cosmos_sdk.ibc.localhost.v1; + +import "third_party/proto/gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types"; + +// MsgCreateClient defines a message to create an IBC client +message MsgCreateClient { + bytes signer = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} diff --git a/x/ibc/ante/ante.go b/x/ibc/ante/ante.go index 3e7e7f1fe23..1a6154084e4 100644 --- a/x/ibc/ante/ante.go +++ b/x/ibc/ante/ante.go @@ -31,11 +31,11 @@ func (pvr ProofVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim switch msg := msg.(type) { case clientexported.MsgUpdateClient: _, err = pvr.clientKeeper.UpdateClient(ctx, msg.GetClientID(), msg.GetHeader()) - case channel.MsgPacket: + case *channel.MsgPacket: _, err = pvr.channelKeeper.RecvPacket(ctx, msg.Packet, msg.Proof, msg.ProofHeight) - case channel.MsgAcknowledgement: + case *channel.MsgAcknowledgement: _, err = pvr.channelKeeper.AcknowledgePacket(ctx, msg.Packet, msg.Acknowledgement, msg.Proof, msg.ProofHeight) - case channel.MsgTimeout: + case *channel.MsgTimeout: _, err = pvr.channelKeeper.TimeoutPacket(ctx, msg.Packet, msg.Proof, msg.ProofHeight, msg.NextSequenceRecv) default: // don't emit sender event for other msg types diff --git a/x/ibc/handler.go b/x/ibc/handler.go index acb34031c71..68d74b0f16b 100644 --- a/x/ibc/handler.go +++ b/x/ibc/handler.go @@ -24,20 +24,20 @@ func NewHandler(k Keeper) sdk.Handler { return &sdk.Result{}, nil // IBC connection msgs - case connection.MsgConnectionOpenInit: + case *connection.MsgConnectionOpenInit: return connection.HandleMsgConnectionOpenInit(ctx, k.ConnectionKeeper, msg) - case connection.MsgConnectionOpenTry: + case *connection.MsgConnectionOpenTry: return connection.HandleMsgConnectionOpenTry(ctx, k.ConnectionKeeper, msg) - case connection.MsgConnectionOpenAck: + case *connection.MsgConnectionOpenAck: return connection.HandleMsgConnectionOpenAck(ctx, k.ConnectionKeeper, msg) - case connection.MsgConnectionOpenConfirm: + case *connection.MsgConnectionOpenConfirm: return connection.HandleMsgConnectionOpenConfirm(ctx, k.ConnectionKeeper, msg) // IBC channel msgs - case channel.MsgChannelOpenInit: + case *channel.MsgChannelOpenInit: // Lookup module by port capability module, portCap, err := k.PortKeeper.LookupModuleByPort(ctx, msg.PortID) if err != nil { @@ -60,7 +60,7 @@ func NewHandler(k Keeper) sdk.Handler { return res, nil - case channel.MsgChannelOpenTry: + case *channel.MsgChannelOpenTry: // Lookup module by port capability module, portCap, err := k.PortKeeper.LookupModuleByPort(ctx, msg.PortID) if err != nil { @@ -82,7 +82,7 @@ func NewHandler(k Keeper) sdk.Handler { return res, nil - case channel.MsgChannelOpenAck: + case *channel.MsgChannelOpenAck: // Lookup module by channel capability module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortID, msg.ChannelID) if err != nil { @@ -100,7 +100,7 @@ func NewHandler(k Keeper) sdk.Handler { } return channel.HandleMsgChannelOpenAck(ctx, k.ChannelKeeper, cap, msg) - case channel.MsgChannelOpenConfirm: + case *channel.MsgChannelOpenConfirm: // Lookup module by channel capability module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortID, msg.ChannelID) if err != nil { @@ -118,7 +118,7 @@ func NewHandler(k Keeper) sdk.Handler { } return channel.HandleMsgChannelOpenConfirm(ctx, k.ChannelKeeper, cap, msg) - case channel.MsgChannelCloseInit: + case *channel.MsgChannelCloseInit: // Lookup module by channel capability module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortID, msg.ChannelID) if err != nil { @@ -136,7 +136,7 @@ func NewHandler(k Keeper) sdk.Handler { } return channel.HandleMsgChannelCloseInit(ctx, k.ChannelKeeper, cap, msg) - case channel.MsgChannelCloseConfirm: + case *channel.MsgChannelCloseConfirm: // Lookup module by channel capability module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortID, msg.ChannelID) if err != nil { @@ -155,7 +155,7 @@ func NewHandler(k Keeper) sdk.Handler { return channel.HandleMsgChannelCloseConfirm(ctx, k.ChannelKeeper, cap, msg) // IBC packet msgs get routed to the appropriate module callback - case channel.MsgPacket: + case *channel.MsgPacket: // Lookup module by channel capability module, _, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) if err != nil { @@ -169,7 +169,7 @@ func NewHandler(k Keeper) sdk.Handler { } return cbs.OnRecvPacket(ctx, msg.Packet) - case channel.MsgAcknowledgement: + case *channel.MsgAcknowledgement: // Lookup module by channel capability module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) if err != nil { @@ -195,7 +195,7 @@ func NewHandler(k Keeper) sdk.Handler { return res, nil - case channel.MsgTimeout: + case *channel.MsgTimeout: // Lookup module by channel capability module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) if err != nil { diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index cc82ebd3399..f8cdb3e17aa 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -75,7 +75,7 @@ func TestSlashingMsgs(t *testing.T) { require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddress) require.Equal(t, sdk.Bonded, validator.Status) require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) - unjailMsg := slashing.MsgUnjail{ValidatorAddr: sdk.ValAddress(validator.GetConsPubKey().Address())} + unjailMsg := &slashing.MsgUnjail{ValidatorAddr: sdk.ValAddress(validator.GetConsPubKey().Address())} checkValidatorSigningInfo(t, app, sdk.ConsAddress(addr1), true) diff --git a/x/slashing/handler.go b/x/slashing/handler.go index 91d3c49d1e4..c4a5b9f12b9 100644 --- a/x/slashing/handler.go +++ b/x/slashing/handler.go @@ -12,7 +12,7 @@ func NewHandler(k Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case MsgUnjail: + case *MsgUnjail: return handleMsgUnjail(ctx, msg, k) default: @@ -23,7 +23,7 @@ func NewHandler(k Keeper) sdk.Handler { // Validators must submit a transaction to unjail itself after // having been jailed (and thus unbonded) for downtime -func handleMsgUnjail(ctx sdk.Context, msg MsgUnjail, k Keeper) (*sdk.Result, error) { +func handleMsgUnjail(ctx sdk.Context, msg *MsgUnjail, k Keeper) (*sdk.Result, error) { err := k.Unjail(ctx, msg.ValidatorAddr) if err != nil { return nil, err diff --git a/x/slashing/keeper/test_common.go b/x/slashing/keeper/test_common.go index 9d76664a53e..fd8cbdb4dd7 100644 --- a/x/slashing/keeper/test_common.go +++ b/x/slashing/keeper/test_common.go @@ -26,7 +26,7 @@ func TestParams() types.Params { return params } -func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator { +func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) *staking.MsgCreateValidator { commission := staking.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) return staking.NewMsgCreateValidator( @@ -35,7 +35,7 @@ func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt ) } -func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, delAmount sdk.Int) staking.MsgDelegate { +func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, delAmount sdk.Int) *staking.MsgDelegate { amount := sdk.NewCoin(sdk.DefaultBondDenom, delAmount) return staking.NewMsgDelegate(delAddr, valAddr, amount) } diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 2d257b39ab0..088c2977c1e 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -7,7 +7,7 @@ import ( // RegisterCodec registers concrete types on codec func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgUnjail{}, "cosmos-sdk/MsgUnjail", nil) + cdc.RegisterConcrete(&MsgUnjail{}, "cosmos-sdk/MsgUnjail", nil) } var ( diff --git a/x/slashing/types/msg.go b/x/slashing/types/msg.go index 7b7d1efb64a..e67a849a2fb 100644 --- a/x/slashing/types/msg.go +++ b/x/slashing/types/msg.go @@ -13,8 +13,8 @@ const ( var _ sdk.Msg = &MsgUnjail{} // NewMsgUnjail creates a new MsgUnjail instance -func NewMsgUnjail(validatorAddr sdk.ValAddress) MsgUnjail { - return MsgUnjail{ +func NewMsgUnjail(validatorAddr sdk.ValAddress) *MsgUnjail { + return &MsgUnjail{ ValidatorAddr: validatorAddr, } } diff --git a/x/staking/common_test.go b/x/staking/common_test.go index c897cd019d3..772a936ff6b 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -25,13 +25,13 @@ var ( PKs = simapp.CreateTestPubKeys(500) ) -func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) staking.MsgCreateValidator { +func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey crypto.PubKey, amt sdk.Int) *staking.MsgCreateValidator { return types.NewMsgCreateValidator( address, pubKey, sdk.NewCoin(sdk.DefaultBondDenom, amt), staking.Description{}, commissionRates, sdk.OneInt(), ) } -func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt sdk.Int) staking.MsgDelegate { +func NewTestMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt sdk.Int) *staking.MsgDelegate { amount := sdk.NewCoin(sdk.DefaultBondDenom, amt) return staking.NewMsgDelegate(delAddr, valAddr, amount) } diff --git a/x/staking/handler.go b/x/staking/handler.go index d75deea5e91..c7157d30b97 100644 --- a/x/staking/handler.go +++ b/x/staking/handler.go @@ -18,19 +18,19 @@ func NewHandler(k keeper.Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case types.MsgCreateValidator: + case *types.MsgCreateValidator: return handleMsgCreateValidator(ctx, msg, k) - case types.MsgEditValidator: + case *types.MsgEditValidator: return handleMsgEditValidator(ctx, msg, k) - case types.MsgDelegate: + case *types.MsgDelegate: return handleMsgDelegate(ctx, msg, k) - case types.MsgBeginRedelegate: + case *types.MsgBeginRedelegate: return handleMsgBeginRedelegate(ctx, msg, k) - case types.MsgUndelegate: + case *types.MsgUndelegate: return handleMsgUndelegate(ctx, msg, k) default: @@ -42,7 +42,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler { // These functions assume everything has been authenticated, // now we just perform action and save -func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgCreateValidator(ctx sdk.Context, msg *types.MsgCreateValidator, k keeper.Keeper) (*sdk.Result, error) { // check to see if the pubkey or sender has been registered before if _, found := k.GetValidator(ctx, msg.ValidatorAddress); found { return nil, ErrValidatorOwnerExists @@ -121,7 +121,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgEditValidator(ctx sdk.Context, msg *types.MsgEditValidator, k keeper.Keeper) (*sdk.Result, error) { // validator must already be registered validator, found := k.GetValidator(ctx, msg.ValidatorAddress) if !found { @@ -178,7 +178,7 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgDelegate(ctx sdk.Context, msg *types.MsgDelegate, k keeper.Keeper) (*sdk.Result, error) { validator, found := k.GetValidator(ctx, msg.ValidatorAddress) if !found { return nil, ErrNoValidatorFound @@ -210,7 +210,7 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper) return &sdk.Result{Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgUndelegate(ctx sdk.Context, msg *types.MsgUndelegate, k keeper.Keeper) (*sdk.Result, error) { shares, err := k.ValidateUnbondAmount( ctx, msg.DelegatorAddress, msg.ValidatorAddress, msg.Amount.Amount, ) @@ -250,7 +250,7 @@ func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keep return &sdk.Result{Data: completionTimeBz, Events: ctx.EventManager().ABCIEvents()}, nil } -func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k keeper.Keeper) (*sdk.Result, error) { +func handleMsgBeginRedelegate(ctx sdk.Context, msg *types.MsgBeginRedelegate, k keeper.Keeper) (*sdk.Result, error) { shares, err := k.ValidateUnbondAmount( ctx, msg.DelegatorAddress, msg.ValidatorSrcAddress, msg.Amount.Amount, ) diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index d6e4811e944..bc33edd5eee 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -8,11 +8,11 @@ import ( // RegisterCodec registers the necessary x/staking interfaces and concrete types // on the provided Amino codec. These types are used for Amino JSON serialization. func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil) - cdc.RegisterConcrete(MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil) - cdc.RegisterConcrete(MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil) - cdc.RegisterConcrete(MsgUndelegate{}, "cosmos-sdk/MsgUndelegate", nil) - cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil) + cdc.RegisterConcrete(&MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil) + cdc.RegisterConcrete(&MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil) + cdc.RegisterConcrete(&MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil) + cdc.RegisterConcrete(&MsgUndelegate{}, "cosmos-sdk/MsgUndelegate", nil) + cdc.RegisterConcrete(&MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil) } var ( diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 4afc2e9ed51..10a9373eb5e 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -31,13 +31,13 @@ var ( func NewMsgCreateValidator( valAddr sdk.ValAddress, pubKey crypto.PubKey, selfDelegation sdk.Coin, description Description, commission CommissionRates, minSelfDelegation sdk.Int, -) MsgCreateValidator { +) *MsgCreateValidator { var pkStr string if pubKey != nil { pkStr = sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pubKey) } - return MsgCreateValidator{ + return &MsgCreateValidator{ Description: description, DelegatorAddress: sdk.AccAddress(valAddr), ValidatorAddress: valAddr, @@ -122,8 +122,8 @@ func (msg MsgCreateValidator) ValidateBasic() error { } // NewMsgEditValidator creates a new MsgEditValidator instance -func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRate *sdk.Dec, newMinSelfDelegation *sdk.Int) MsgEditValidator { - return MsgEditValidator{ +func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRate *sdk.Dec, newMinSelfDelegation *sdk.Int) *MsgEditValidator { + return &MsgEditValidator{ Description: description, CommissionRate: newRate, ValidatorAddress: valAddr, @@ -172,8 +172,8 @@ func (msg MsgEditValidator) ValidateBasic() error { } // NewMsgDelegate creates a new MsgDelegate instance. -func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgDelegate { - return MsgDelegate{ +func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgDelegate { + return &MsgDelegate{ DelegatorAddress: delAddr, ValidatorAddress: valAddr, Amount: amount, @@ -217,8 +217,8 @@ func (msg MsgDelegate) ValidateBasic() error { // NewMsgBeginRedelegate creates a new MsgBeginRedelegate instance. func NewMsgBeginRedelegate( delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount sdk.Coin, -) MsgBeginRedelegate { - return MsgBeginRedelegate{ +) *MsgBeginRedelegate { + return &MsgBeginRedelegate{ DelegatorAddress: delAddr, ValidatorSrcAddress: valSrcAddr, ValidatorDstAddress: valDstAddr, @@ -265,8 +265,8 @@ func (msg MsgBeginRedelegate) ValidateBasic() error { } // NewMsgUndelegate creates a new MsgUndelegate instance. -func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgUndelegate { - return MsgUndelegate{ +func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgUndelegate { + return &MsgUndelegate{ DelegatorAddress: delAddr, ValidatorAddress: valAddr, Amount: amount,