Skip to content

Commit

Permalink
Remove all event for ibc-transfer apart from amount and denom
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 committed Nov 3, 2022
1 parent b5bd99b commit a67f56f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 44 deletions.
16 changes: 0 additions & 16 deletions modules/apps/transfer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package keeper

import (
"context"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
)

var _ types.MsgServer = Keeper{}
Expand Down Expand Up @@ -39,26 +36,13 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.

k.Logger(ctx).Info("IBC fungible token transfer", "token", msg.Token.Denom, "amount", msg.Token.Amount.String(), "sender", msg.Sender, "receiver", msg.Receiver)

// Get destination channel and port for emitting events
channel, found := k.channelKeeper.GetChannel(ctx, msg.SourcePort, msg.SourceChannel)
if !found {
return nil, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", msg.SourcePort, msg.SourceChannel)
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeTransfer,
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender),
sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver),
sdk.NewAttribute(types.AttributeKeyAmount, msg.Token.Amount.String()),
sdk.NewAttribute(types.AttributeKeyDenom, msg.Token.Denom),
sdk.NewAttribute(types.AttributeKeySrcPort, msg.SourcePort),
sdk.NewAttribute(types.AttributeKeySrcChannel, msg.SourceChannel),
sdk.NewAttribute(types.AttributeKeyDstPort, channel.GetCounterparty().GetPortID()),
sdk.NewAttribute(types.AttributeKeyDstChannel, channel.GetCounterparty().GetChannelID()),
sdk.NewAttribute(types.AttributeKeyTimeoutHeight, msg.TimeoutHeight.String()),
sdk.NewAttribute(types.AttributeKeyTimeoutTimestamp, fmt.Sprintf("%d", msg.TimeoutTimestamp)),
sdk.NewAttribute(types.AttributeKeyMemo, msg.Memo),
),
sdk.NewEvent(
sdk.EventTypeMessage,
Expand Down
15 changes: 4 additions & 11 deletions modules/apps/transfer/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,10 @@ func (suite *KeeperTestSuite) TestMsgTransfer() {

expEvents := map[string]map[string]string{
"ibc_transfer": {
"sender": suite.chainA.SenderAccount.GetAddress().String(),
"receiver": suite.chainB.SenderAccount.GetAddress().String(),
"amount": coin.Amount.String(),
"denom": coin.Denom,
"src_port": path.EndpointA.ChannelConfig.PortID,
"src_channel": path.EndpointA.ChannelID,
"dst_port": path.EndpointB.ChannelConfig.PortID,
"dst_channel": path.EndpointB.ChannelID,
"timeout_height": suite.chainB.GetTimeoutHeight().String(),
"timeout_timestamp": "0",
"memo": "memo",
"sender": suite.chainA.SenderAccount.GetAddress().String(),
"receiver": suite.chainB.SenderAccount.GetAddress().String(),
"amount": coin.Amount.String(),
"denom": coin.Denom,
},
}

Expand Down
28 changes: 11 additions & 17 deletions modules/apps/transfer/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@ const (
EventTypeChannelClose = "channel_closed"
EventTypeDenomTrace = "denomination_trace"

AttributeKeyReceiver = "receiver"
AttributeKeyDenom = "denom"
AttributeKeyAmount = "amount"
AttributeKeyRefundReceiver = "refund_receiver"
AttributeKeyRefundDenom = "refund_denom"
AttributeKeyRefundAmount = "refund_amount"
AttributeKeyAckSuccess = "success"
AttributeKeyAck = "acknowledgement"
AttributeKeyAckError = "error"
AttributeKeyTraceHash = "trace_hash"
AttributeKeyMemo = "memo"
AttributeKeySrcPort = "src_port"
AttributeKeySrcChannel = "src_channel"
AttributeKeyDstPort = "dst_port"
AttributeKeyDstChannel = "dst_channel"
AttributeKeyTimeoutHeight = "timeout_height"
AttributeKeyTimeoutTimestamp = "timeout_timestamp"
AttributeKeyReceiver = "receiver"
AttributeKeyDenom = "denom"
AttributeKeyAmount = "amount"
AttributeKeyRefundReceiver = "refund_receiver"
AttributeKeyRefundDenom = "refund_denom"
AttributeKeyRefundAmount = "refund_amount"
AttributeKeyAckSuccess = "success"
AttributeKeyAck = "acknowledgement"
AttributeKeyAckError = "error"
AttributeKeyTraceHash = "trace_hash"
AttributeKeyMemo = "memo"
)

0 comments on commit a67f56f

Please sign in to comment.