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

Fee Middleware: Packet Callbacks #262

Closed
AdityaSripal opened this issue Jul 15, 2021 · 1 comment
Closed

Fee Middleware: Packet Callbacks #262

AdityaSripal opened this issue Jul 15, 2021 · 1 comment
Assignees
Labels

Comments

@AdityaSripal
Copy link
Member

No description provided.

@AdityaSripal
Copy link
Member Author

AdityaSripal commented Sep 20, 2021

// OnRecvPacket implements the IBCModule interface.
func (am AppModule) OnRecvPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	relayer sdk.AccAddress,
) ibcexported.Acknowledgement {
	// TODO: Implement fee specific logic if fee is enabled for the given channel
	ack := am.app.OnRecvPacket(ctx, packet, relayer)
        if !IsFeeEnabled() {
              return ack
        }
        return constructIncentivizedAck(ack, relayer)
}

// OnAcknowledgementPacket implements the IBCModule interface
func (am AppModule) OnAcknowledgementPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	acknowledgement []byte,
	relayer sdk.AccAddress,
) error {
	// TODO: Implement fee specific logic if fee is enabled for the given channel
	if am.keeper.IsFeeEnabled(packet.DestPort, packet.DestChannel) {
		incentivized_ack := unmarshal(acknowledgment)
		recvRelayer = getRecvRelayer(incentivized_ack)
		recvFee := am.keeper.GetRecvFee(packet.DestPort, packet.DestChannel, packet.Sequence) // Sean creates this method
		send(recvFee, recvRelayer) // from escrow address
		// similar GetAckFee method
		ackFee := am.keeper.GetAckFee(packet.DestPort, packet.DestChannel, packet.Sequence) // Sean creates this method
		send(ackFee, relayer)
		refund(timeoutFee)
	}
	return am.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
}

// OnTimeoutPacket implements the IBCModule interface
func (am AppModule) OnTimeoutPacket(
	ctx sdk.Context,
	packet channeltypes.Packet,
	relayer sdk.AccAddress,
) error {
	// TODO: Implement fee specific logic if fee is enabled for the given channel
	if am.keeper.IsFeeEnabled() {
		timeoutFee := am.keeper.GetTimeoutFee(packet.DestPort, packet.DestChannel, packet.Sequence) // Sean creates this method
		send(timeoutFee, relayer)
		recvFee := am.keeper.GetRecvFee(packet.DestPort, packet.DestChannel, packet.Sequence) // Sean creates this method
		ackFee := am.keeper.GetAckFee(packet.DestPort, packet.DestChannel, packet.Sequence) // Sean creates this method
		refund(ackFee)
		refund(recvFee)
	}
	return am.app.OnTimeoutPacket(ctx, packet, relayer)
}

@seantking seantking removed their assignment Dec 1, 2021
CosmosCar pushed a commit to caelus-labs/ibc-go that referenced this issue Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

5 participants