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

chore: adding distribute fee events to ics29 #2975

Merged
merged 7 commits into from
Jan 19, 2023
4 changes: 4 additions & 0 deletions modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func (k Keeper) distributeFee(ctx sdk.Context, receiver, refundAccAddress sdk.Ac
k.Logger(ctx).Error("error refunding fee to the original sender", "refund address", refundAccAddress, "fee", fee)
return // if sending to the refund address fails, no-op
}

EmitDistributeFeeEvent(ctx, refundAccAddress.String(), fee)
} else {
EmitDistributeFeeEvent(ctx, receiver.String(), fee)
}

// write the cache
Expand Down
15 changes: 15 additions & 0 deletions modules/apps/29-fee/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,18 @@ func EmitRegisterCounterpartyPayeeEvent(ctx sdk.Context, relayer, counterpartyPa
),
})
}

// EmitDistributeFeeEvent emits an event containing a distribution fee and receiver address
func EmitDistributeFeeEvent(ctx sdk.Context, receiver string, fee sdk.Coins) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeDistributeFee,
sdk.NewAttribute(types.AttributeKeyReceiver, receiver),
sdk.NewAttribute(types.AttributeKeyFee, fee.String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
),
})
}
3 changes: 3 additions & 0 deletions modules/apps/29-fee/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
EventTypeIncentivizedPacket = "incentivized_ibc_packet"
EventTypeRegisterPayee = "register_payee"
EventTypeRegisterCounterpartyPayee = "register_counterparty_payee"
EventTypeDistributeFee = "distribute_fee"

AttributeKeyRecvFee = "recv_fee"
AttributeKeyAckFee = "ack_fee"
Expand All @@ -13,4 +14,6 @@ const (
AttributeKeyRelayer = "relayer"
AttributeKeyPayee = "payee"
AttributeKeyCounterpartyPayee = "counterparty_payee"
AttributeKeyReceiver = "receiver"
AttributeKeyFee = "fee"
)