Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
refactor(clean up): general tidy and updating comments
Browse files Browse the repository at this point in the history
  • Loading branch information
seantking committed Mar 25, 2021
1 parent 718c26d commit d342e1e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
16 changes: 7 additions & 9 deletions x/ibc-account/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ func (k Keeper) TryRegisterIBCAccount(ctx sdk.Context, sourcePort, sourceChannel
Data: salt,
}

timeoutHeight := clienttypes.Height{
RevisionNumber: 2,
RevisionHeight: ^uint64(0),
}
timeoutHeight := clienttypes.ZeroHeight()

// timeoutTimestamp is set to be a max number here so that we never recieve a timeout
// ics-27-1 uses ordered channels which can close upon recieving a timeout, which is an undesired effect
const timeoutTimestamp = ^uint64(0)

packet := channeltypes.NewPacket(
Expand All @@ -65,7 +64,7 @@ func (k Keeper) TryRegisterIBCAccount(ctx sdk.Context, sourcePort, sourceChannel
return nil
}

// TryRunTx try to send messages to source channel.
// TryRunTx attemps to send messages to source channel.
func (k Keeper) TryRunTx(ctx sdk.Context, sourcePort, sourceChannel, typ string, data interface{}) ([]byte, error) {
sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel)
if !found {
Expand Down Expand Up @@ -129,11 +128,10 @@ func (k Keeper) createOutgoingPacket(
Data: txBytes,
}

timeoutHeight := clienttypes.Height{
RevisionNumber: 2,
RevisionHeight: ^uint64(0),
}
timeoutHeight := clienttypes.ZeroHeight()

// timeoutTimestamp is set to be a max number here so that we never recieve a timeout
// ics-27-1 uses ordered channels which can close upon recieving a timeout, which is an undesired effect
const timeoutTimestamp = ^uint64(0)

packet := channeltypes.NewPacket(
Expand Down
7 changes: 5 additions & 2 deletions x/inter-tx/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ func RegisterCodec(cdc *codec.LegacyAmino) {

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{})
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterAccount{})
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgSend{},
&MsgRegisterAccount{},
)
}

var (
Expand Down
9 changes: 3 additions & 6 deletions x/inter-tx/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"strings"
)

const (
Expand Down Expand Up @@ -34,7 +35,7 @@ func (MsgRegisterAccount) Type() string {
}

func (msg MsgRegisterAccount) ValidateBasic() error {
if msg.Owner == "" {
if strings.TrimSpace(msg.Owner) == "" {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing sender address")
}

Expand All @@ -58,7 +59,7 @@ var _ sdk.Msg = &MsgSend{}

// NewMsgSend creates a new MsgSend instance
func NewMsgSend(
chainType, port, channel string, sender, toAddress sdk.AccAddress, amount []sdk.Coin,
chainType, port, channel string, sender, toAddress sdk.AccAddress, amount sdk.Coins,
) *MsgSend {
return &MsgSend{
ChainType: chainType,
Expand Down Expand Up @@ -98,10 +99,6 @@ func (msg MsgSend) ValidateBasic() error {
if !msg.Amount.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String())
}

if !msg.Amount.IsAllPositive() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String())
}
return nil
}

Expand Down

0 comments on commit d342e1e

Please sign in to comment.