Skip to content

Commit

Permalink
cleanup. added bridging fee event
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed May 23, 2024
1 parent 906015d commit 627a937
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 44 deletions.
6 changes: 6 additions & 0 deletions x/bridging_fee/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package bridging_fee

const (
EventTypeBridgingFee = "bridging_fee"
AttributeKeyFee = "fee"
)
52 changes: 8 additions & 44 deletions x/bridging_fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ func NewIBCMiddleware(transfer transfer.IBCModule, channelKeeper porttypes.ICS4W
}

func (im BridgingFeeMiddleware) GetBridgingFee(ctx sdk.Context) sdk.Dec {
// FIXME: move to param
// return sdk.NewDecWithPrec(1, 1) // 10%
return im.delayedAckKeeper.BridgingFee(ctx)
}

Expand Down Expand Up @@ -98,51 +96,17 @@ func (im *BridgingFeeMiddleware) OnRecvPacket(ctx sdk.Context, packet channeltyp
fee = sdk.ZeroInt()
} else {
logger.Debug("Charged bridging fee", "fee", fee)
// FIXME: Emit events for bridging fee
ctx.EventManager().EmitEvent(
sdk.NewEvent(
EventTypeBridgingFee,
sdk.NewAttribute(AttributeKeyFee, fee.String()),
sdk.NewAttribute(sdk.AttributeKeySender, transferPacketData.Sender),
),
)
}

// transfer the remaining amount
transferPacketData.Amount = transferAmount.Sub(fee).String()
packet.Data = transferPacketData.GetBytes()
return im.IBCModule.OnRecvPacket(ctx, packet, relayer)
}

// /* -------------------------- unmodified interfaces ------------------------- */
// // OnChanCloseConfirm implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID string, channelID string) error {
// return im.transfer.OnChanCloseConfirm(ctx, portID, channelID)
// }

// // OnChanCloseInit implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnChanCloseInit(ctx sdk.Context, portID string, channelID string) error {
// return im.transfer.OnChanCloseInit(ctx, portID, channelID)
// }

// // OnChanOpenAck implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyChannelID string, counterpartyVersion string) error {
// return im.transfer.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
// }

// // OnChanOpenConfirm implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnChanOpenConfirm(ctx sdk.Context, portID string, channelID string) error {
// return im.transfer.OnChanOpenConfirm(ctx, portID, channelID)
// }

// // OnChanOpenInit implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnChanOpenInit(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) (string, error) {
// return im.transfer.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version)
// }

// // OnChanOpenTry implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnChanOpenTry(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string) (version string, err error) {
// return im.transfer.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion)
// }

// // OnAcknowledgementPacket implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error {
// return im.transfer.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
// }

// // OnTimeoutPacket implements types.Middleware.
// func (im *BridgingFeeMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error {
// return im.transfer.OnTimeoutPacket(ctx, packet, relayer)
// }

0 comments on commit 627a937

Please sign in to comment.