Skip to content

Commit

Permalink
Make all IBC Msg types use pointers (#6857)
Browse files Browse the repository at this point in the history
* Make IBC Msg types use pointers

* Fix tests

Co-authored-by: Federico Kunze <[email protected]>
  • Loading branch information
aaronc and fedekunze authored Jul 27, 2020
1 parent 0201b94 commit 20488b4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions x/ibc/02-client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func HandleMsgCreateClient(ctx sdk.Context, k keeper.Keeper, msg exported.MsgCre

switch clientType {
case exported.Tendermint:
tmMsg, ok := msg.(ibctmtypes.MsgCreateClient)
tmMsg, ok := msg.(*ibctmtypes.MsgCreateClient)
if !ok {
return nil, sdkerrors.Wrapf(types.ErrInvalidClientType, "got %T, expected %T", msg, ibctmtypes.MsgCreateClient{})
return nil, sdkerrors.Wrapf(types.ErrInvalidClientType, "got %T, expected %T", msg, &ibctmtypes.MsgCreateClient{})
}
var err error

Expand Down
2 changes: 1 addition & 1 deletion x/ibc/07-tendermint/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type ClientState struct {
}

// InitializeFromMsg creates a tendermint client state from a CreateClientMsg
func InitializeFromMsg(msg MsgCreateClient) (ClientState, error) {
func InitializeFromMsg(msg *MsgCreateClient) (ClientState, error) {
return Initialize(
msg.GetClientID(), msg.TrustLevel,
msg.TrustingPeriod, msg.UnbondingPeriod, msg.MaxClockDrift,
Expand Down
20 changes: 10 additions & 10 deletions x/ibc/07-tendermint/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ type MsgCreateClient struct {
const TODO = "TODO"

// dummy implementation of proto.Message
func (msg MsgCreateClient) Reset() {}
func (msg MsgCreateClient) String() string { return TODO }
func (msg MsgCreateClient) ProtoMessage() {}
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,
trustingPeriod, unbondingPeriod, maxClockDrift time.Duration,
specs []*ics23.ProofSpec, signer sdk.AccAddress,
) MsgCreateClient {
) *MsgCreateClient {

return MsgCreateClient{
return &MsgCreateClient{
ClientID: id,
Header: header,
TrustLevel: trustLevel,
Expand Down Expand Up @@ -157,13 +157,13 @@ type MsgUpdateClient struct {
}

// dummy implementation of proto.Message
func (msg MsgUpdateClient) Reset() {}
func (msg MsgUpdateClient) String() string { return TODO }
func (msg MsgUpdateClient) ProtoMessage() {}
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{
func NewMsgUpdateClient(id string, header Header, signer sdk.AccAddress) *MsgUpdateClient {
return &MsgUpdateClient{
ClientID: id,
Header: header,
Signer: signer,
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/07-tendermint/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (suite *TendermintTestSuite) TestMsgCreateClientValidateBasic() {
invalidHeader.ValidatorSet = nil

cases := []struct {
msg ibctmtypes.MsgCreateClient
msg *ibctmtypes.MsgCreateClient
expPass bool
errMsg string
}{
Expand Down Expand Up @@ -52,7 +52,7 @@ func (suite *TendermintTestSuite) TestMsgUpdateClient() {
signer := sdk.AccAddress(privKey.PubKey().Address())

cases := []struct {
msg ibctmtypes.MsgUpdateClient
msg *ibctmtypes.MsgUpdateClient
expPass bool
errMsg string
}{
Expand Down

0 comments on commit 20488b4

Please sign in to comment.