Skip to content

Commit

Permalink
ics29:feat: emit event escrow (#914)
Browse files Browse the repository at this point in the history
* feat: emit EventTypeSendIncentivizedPacket event on EscrowPacket

* fix: string conversion

* refactor: add helper fn for emit event

* chore: godoc

* nit: use .String())
  • Loading branch information
seantking authored Feb 17, 2022
1 parent ff15335 commit d8b9821
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedP
identifiedFees := types.NewIdentifiedPacketFees(packetFees)
k.SetFeesInEscrow(ctx, identifiedFee.PacketId, identifiedFees)

EmitIncentivizedPacket(ctx, identifiedFee)

return nil
}

Expand Down
25 changes: 25 additions & 0 deletions modules/apps/29-fee/keeper/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package keeper

import (
"fmt"

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

"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
)

// EmitIncentivizedPacket emits an event so that relayers know an incentivized packet is ready to be relayed
func EmitIncentivizedPacket(ctx sdk.Context, identifiedFee types.IdentifiedPacketFee) {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeIncentivizedPacket,
sdk.NewAttribute(channeltypes.AttributeKeyPortID, identifiedFee.PacketId.PortId),
sdk.NewAttribute(channeltypes.AttributeKeyChannelID, identifiedFee.PacketId.ChannelId),
sdk.NewAttribute(channeltypes.AttributeKeySequence, fmt.Sprint(identifiedFee.PacketId.Sequence)),
sdk.NewAttribute(types.AttributeKeyRecvFee, identifiedFee.Fee.RecvFee.String()),
sdk.NewAttribute(types.AttributeKeyAckFee, identifiedFee.Fee.AckFee.String()),
sdk.NewAttribute(types.AttributeKeyTimeoutFee, identifiedFee.Fee.TimeoutFee.String()),
),
)
}
4 changes: 3 additions & 1 deletion modules/apps/29-fee/types/events.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package types

// 29-fee events
const ()
const (
EventTypeIncentivizedPacket = "incentivized_ibc_packet"
)
4 changes: 4 additions & 0 deletions modules/apps/29-fee/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (

// ForwardRelayerPrefix is the key prefix for forward relayer addresses stored in state for async acknowledgements
ForwardRelayerPrefix = "forwardRelayer"

AttributeKeyRecvFee = "recv_fee"
AttributeKeyAckFee = "ack_fee"
AttributeKeyTimeoutFee = "timeout_fee"
)

// FeeEnabledKey returns the key that stores a flag to determine if fee logic should
Expand Down

0 comments on commit d8b9821

Please sign in to comment.