Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nit: update err syntax #747

Merged
merged 5 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,15 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e
// refund all fees to refund address
// Use SendCoins rather than the module account send functions since refund address may be a user account or module address.
// if any `SendCoins` call returns an error, we return error and stop iteration
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.ReceiveFee)
if err != nil {
if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.ReceiveFee); err != nil {
refundErr = err
return true
}
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee)
if err != nil {
if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee); err != nil {
refundErr = err
return true
}
err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee)
if err != nil {
if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee); err != nil {
refundErr = err
return true
}
Expand Down
6 changes: 2 additions & 4 deletions modules/apps/29-fee/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee)
}

identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Signer, msg.Relayers)
err := k.EscrowPacketFee(ctx, identifiedPacket)
if err != nil {
if err := k.EscrowPacketFee(ctx, identifiedPacket); err != nil {
return nil, err
}

Expand All @@ -58,8 +57,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee)
func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

err := k.EscrowPacketFee(ctx, &msg.IdentifiedPacketFee)
if err != nil {
if err := k.EscrowPacketFee(ctx, &msg.IdentifiedPacketFee); err != nil {
return nil, err
}

Expand Down
16 changes: 6 additions & 10 deletions modules/apps/29-fee/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@ func NewMsgPayPacketFee(fee Fee, sourcePortId, sourceChannelId, signer string, r
// ValidateBasic performs a basic check of the MsgPayPacketFee fields
func (msg MsgPayPacketFee) ValidateBasic() error {
// validate channelId
err := host.ChannelIdentifierValidator(msg.SourceChannelId)
if err != nil {
if err := host.ChannelIdentifierValidator(msg.SourceChannelId); err != nil {
return err
}

// validate portId
err = host.PortIdentifierValidator(msg.SourcePortId)
if err != nil {
if err := host.PortIdentifierValidator(msg.SourcePortId); err != nil {
return err
}

// signer check
_, err = sdk.AccAddressFromBech32(msg.Signer)
_, err := sdk.AccAddressFromBech32(msg.Signer)
if err != nil {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress")
}
Expand Down Expand Up @@ -117,8 +115,7 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error {
return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress")
}

err = msg.IdentifiedPacketFee.Validate()
if err != nil {
if err = msg.IdentifiedPacketFee.Validate(); err != nil {
return sdkerrors.Wrap(err, "Invalid IdentifiedPacketFee")
}

Expand Down Expand Up @@ -146,12 +143,11 @@ func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, refundAddr

func (fee IdentifiedPacketFee) Validate() error {
// validate PacketId
err := fee.PacketId.Validate()
if err != nil {
if err := fee.PacketId.Validate(); err != nil {
return sdkerrors.Wrap(err, "Invalid PacketId")
}

_, err = sdk.AccAddressFromBech32(fee.RefundAddress)
_, err := sdk.AccAddressFromBech32(fee.RefundAddress)
if err != nil {
return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress")
}
Expand Down