-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathevents.go
25 lines (22 loc) · 950 Bytes
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package keeper
import (
"strings"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-apps/modules/rate-limiting/v8/types"
)
// If the rate limit is exceeded or the denom is blacklisted, we emit an event
func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, direction types.PacketDirection, amount sdkmath.Int, err error) {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTransferDenied,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(types.AttributeKeyReason, reason),
sdk.NewAttribute(types.AttributeKeyAction, strings.ToLower(direction.String())), // packet_send or packet_recv
sdk.NewAttribute(types.AttributeKeyDenom, denom),
sdk.NewAttribute(types.AttributeKeyChannel, channelId),
sdk.NewAttribute(types.AttributeKeyAmount, amount.String()),
sdk.NewAttribute(types.AttributeKeyError, err.Error()),
),
)
}