44 "context"
55 "fmt"
66
7+ "cosmossdk.io/core/event"
8+
79 sdk "github.com/cosmos/cosmos-sdk/types"
810
911 "github.com/cosmos/ibc-go/v9/modules/apps/29-fee/types"
@@ -12,7 +14,7 @@ import (
1214
1315// emitIncentivizedPacketEvent emits an event containing information on the total amount of fees incentivizing
1416// a specific packet. It should be emitted on every fee escrowed for the given packetID.
15- func emitIncentivizedPacketEvent (ctx context.Context , packetID channeltypes.PacketId , packetFees types.PacketFees ) {
17+ func ( k Keeper ) emitIncentivizedPacketEvent (ctx context.Context , packetID channeltypes.PacketId , packetFees types.PacketFees ) error {
1618 var (
1719 totalRecvFees sdk.Coins
1820 totalAckFees sdk.Coins
@@ -27,70 +29,71 @@ func emitIncentivizedPacketEvent(ctx context.Context, packetID channeltypes.Pack
2729 totalTimeoutFees = totalTimeoutFees .Add (fee .Fee .TimeoutFee ... )
2830 }
2931 }
30- sdkCtx := sdk .UnwrapSDKContext (ctx ) // TODO: https://github.com/cosmos/ibc-go/issues/7223
31- sdkCtx .EventManager ().EmitEvents (sdk.Events {
32- sdk .NewEvent (
33- types .EventTypeIncentivizedPacket ,
34- sdk .NewAttribute (channeltypes .AttributeKeyPortID , packetID .PortId ),
35- sdk .NewAttribute (channeltypes .AttributeKeyChannelID , packetID .ChannelId ),
36- sdk .NewAttribute (channeltypes .AttributeKeySequence , fmt .Sprint (packetID .Sequence )),
37- sdk .NewAttribute (types .AttributeKeyRecvFee , totalRecvFees .String ()),
38- sdk .NewAttribute (types .AttributeKeyAckFee , totalAckFees .String ()),
39- sdk .NewAttribute (types .AttributeKeyTimeoutFee , totalTimeoutFees .String ()),
40- ),
41- sdk .NewEvent (
42- sdk .EventTypeMessage ,
43- sdk .NewAttribute (sdk .AttributeKeyModule , types .ModuleName ),
44- ),
45- })
32+
33+ if err := k .EventService .EventManager (ctx ).EmitKV (
34+ types .EventTypeIncentivizedPacket ,
35+ event .NewAttribute (channeltypes .AttributeKeyPortID , packetID .PortId ),
36+ event .NewAttribute (channeltypes .AttributeKeyChannelID , packetID .ChannelId ),
37+ event .NewAttribute (channeltypes .AttributeKeySequence , fmt .Sprint (packetID .Sequence )),
38+ event .NewAttribute (types .AttributeKeyRecvFee , totalRecvFees .String ()),
39+ event .NewAttribute (types .AttributeKeyAckFee , totalAckFees .String ()),
40+ event .NewAttribute (types .AttributeKeyTimeoutFee , totalTimeoutFees .String ()),
41+ ); err != nil {
42+ return err
43+ }
44+
45+ return k .EventService .EventManager (ctx ).EmitKV (
46+ sdk .EventTypeMessage ,
47+ event .NewAttribute (sdk .AttributeKeyModule , types .ModuleName ),
48+ )
4649}
4750
4851// emitRegisterPayeeEvent emits an event containing information of a registered payee for a relayer on a particular channel
49- func emitRegisterPayeeEvent (ctx context.Context , relayer , payee , channelID string ) {
50- sdkCtx := sdk . UnwrapSDKContext (ctx ) // TODO: https://github.com/cosmos/ibc-go/issues/7223
51- sdkCtx . EventManager (). EmitEvents (sdk. Events {
52- sdk . NewEvent (
53- types .EventTypeRegisterPayee ,
54- sdk .NewAttribute (types .AttributeKeyRelayer , relayer ),
55- sdk . NewAttribute ( types . AttributeKeyPayee , payee ),
56- sdk . NewAttribute ( types . AttributeKeyChannelID , channelID ),
57- ),
58- sdk . NewEvent (
59- sdk . EventTypeMessage ,
60- sdk .NewAttribute ( sdk . AttributeKeyModule , types . ModuleName ) ,
61- ),
62- } )
52+ func ( k Keeper ) emitRegisterPayeeEvent (ctx context.Context , relayer , payee , channelID string ) error {
53+ if err := k . EventService . EventManager (ctx ). EmitKV (
54+ types . EventTypeRegisterPayee ,
55+ event . NewAttribute ( types . AttributeKeyRelayer , relayer ),
56+ event . NewAttribute ( types .AttributeKeyPayee , payee ) ,
57+ event .NewAttribute (types .AttributeKeyChannelID , channelID ),
58+ ); err != nil {
59+ return err
60+ }
61+
62+ return k . EventService . EventManager ( ctx ). EmitKV (
63+ sdk .EventTypeMessage ,
64+ event . NewAttribute ( sdk . AttributeKeyModule , types . ModuleName ),
65+ )
6366}
6467
6568// emitRegisterCounterpartyPayeeEvent emits an event containing information of a registered counterparty payee for a relayer on a particular channel
66- func emitRegisterCounterpartyPayeeEvent (ctx context.Context , relayer , counterpartyPayee , channelID string ) {
67- sdkCtx := sdk . UnwrapSDKContext (ctx ) // TODO: https://github.com/cosmos/ibc-go/issues/7223
68- sdkCtx . EventManager (). EmitEvents (sdk. Events {
69- sdk . NewEvent (
70- types .EventTypeRegisterCounterpartyPayee ,
71- sdk .NewAttribute (types .AttributeKeyRelayer , relayer ),
72- sdk . NewAttribute ( types . AttributeKeyCounterpartyPayee , counterpartyPayee ),
73- sdk . NewAttribute ( types . AttributeKeyChannelID , channelID ),
74- ),
75- sdk . NewEvent (
76- sdk . EventTypeMessage ,
77- sdk .NewAttribute ( sdk . AttributeKeyModule , types . ModuleName ) ,
78- ),
79- } )
69+ func ( k Keeper ) emitRegisterCounterpartyPayeeEvent (ctx context.Context , relayer , counterpartyPayee , channelID string ) error {
70+ if err := k . EventService . EventManager (ctx ). EmitKV (
71+ types . EventTypeRegisterCounterpartyPayee ,
72+ event . NewAttribute ( types . AttributeKeyRelayer , relayer ),
73+ event . NewAttribute ( types .AttributeKeyCounterpartyPayee , counterpartyPayee ) ,
74+ event .NewAttribute (types .AttributeKeyChannelID , channelID ),
75+ ); err != nil {
76+ return err
77+ }
78+
79+ return k . EventService . EventManager ( ctx ). EmitKV (
80+ sdk .EventTypeMessage ,
81+ event . NewAttribute ( sdk . AttributeKeyModule , types . ModuleName ),
82+ )
8083}
8184
8285// emitDistributeFeeEvent emits an event containing a distribution fee and receiver address
83- func emitDistributeFeeEvent (ctx context.Context , receiver string , fee sdk.Coins ) {
84- sdkCtx := sdk . UnwrapSDKContext (ctx ) // TODO: https://github.com/cosmos/ibc-go/issues/7223
85- sdkCtx . EventManager (). EmitEvents (sdk. Events {
86- sdk . NewEvent (
87- types .EventTypeDistributeFee ,
88- sdk . NewAttribute ( types . AttributeKeyReceiver , receiver ),
89- sdk . NewAttribute ( types . AttributeKeyFee , fee . String ()),
90- ),
91- sdk . NewEvent (
92- sdk . EventTypeMessage ,
93- sdk .NewAttribute ( sdk . AttributeKeyModule , types . ModuleName ) ,
94- ),
95- } )
86+ func ( k Keeper ) emitDistributeFeeEvent (ctx context.Context , receiver string , fee sdk.Coins ) error {
87+ if err := k . EventService . EventManager (ctx ). EmitKV (
88+ types . EventTypeDistributeFee ,
89+ event . NewAttribute ( types . AttributeKeyReceiver , receiver ),
90+ event . NewAttribute ( types .AttributeKeyFee , fee . String ()) ,
91+ ); err != nil {
92+ return err
93+ }
94+
95+ return k . EventService . EventManager ( ctx ). EmitKV (
96+ sdk .EventTypeMessage ,
97+ event . NewAttribute ( sdk . AttributeKeyModule , types . ModuleName ),
98+ )
9699}
0 commit comments