Skip to content

Commit

Permalink
refactor: remove processed key and handling code (#216) (#219)
Browse files Browse the repository at this point in the history
* refactor: remove processed key and handling code

* refactor: ensure the underlying apps `OnRecvPacket` callback is invoked

* docs: fix broken link to Defund-Labs interquery.

I cannot find a link to the code so this now links to the spec

(cherry picked from commit 8cb681e)

Co-authored-by: Justin Tieri <37750742+jtieri@users.noreply.github.com>
  • Loading branch information
mergify[bot] and jtieri authored Sep 4, 2024
1 parent e5b0435 commit b06a093
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Modules and middleware developed by other awesome teams in the ecosystem:
| Name | Type | Stakeholders | Description |
| ---- | ---- | ------------ | ----------- |
| [Interchain KV Queries](https://github.com/ingenuity-build/interchain-queries) | Module | [Ingenuity](https://github.com/ingenuity-build) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. |
| [query](https://github.com/defund-labs/defund/tree/main/x/query) | Module | [Defund Labs](https://github.com/defund-labs) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. Similar to the interchain-queries application in the row above but without callbacks. |
| [query](https://github.com/defund-labs/interquery) | Module | [Defund Labs](https://github.com/defund-labs) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. Similar to the interchain-queries application in the row above but without callbacks. |
| [NFT Transfer (ICS 721)](https://github.com/bianjieai/nft-transfer) | Module | [Bianjieai](https://github.com/bianjieai) | An application that enables cross chain NFT transfer. |
| [recovery](https://github.com/evmos/evmos/tree/main/x/recovery) | Middleware | [Evmos](https://github.com/evmos) | Middleware enabling the recovery of tokens sent to unsupported addresses. |
| [ibc-rate-limit](https://github.com/osmosis-labs/osmosis/tree/main/x/ibc-rate-limit) | Middleware | [Osmosis Labs](https://github.com/osmosis-labs) | Middleware that limits the in or out flow of an asset in a certain time period to minimise the risks of cross chain token transfers. This is implemented as a middleware wrapping ICS20 with the rate limiting logic implemented by cosmwasm contracts. |
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ func (im IBCMiddleware) OnRecvPacket(
metadata := m.Forward

goCtx := ctx.Context()
processed := getBoolFromAny(goCtx.Value(types.ProcessedKey{}))
nonrefundable := getBoolFromAny(goCtx.Value(types.NonrefundableKey{}))
disableDenomComposition := getBoolFromAny(goCtx.Value(types.DisableDenomCompositionKey{}))

Expand All @@ -214,14 +213,9 @@ func (im IBCMiddleware) OnRecvPacket(
return newErrorAcknowledgement(fmt.Errorf("failed to construct override receiver: %w", err))
}

// if this packet has been handled by another middleware in the stack there may be no need to call into the
// underlying app, otherwise the transfer module's OnRecvPacket callback could be invoked more than once
// which would mint/burn vouchers more than once
if !processed {
if err := im.receiveFunds(ctx, packet, data, overrideReceiver, relayer); err != nil {
logger.Error("packetForwardMiddleware OnRecvPacket error receiving packet", "error", err)
return newErrorAcknowledgement(fmt.Errorf("error receiving packet: %w", err))
}
if err := im.receiveFunds(ctx, packet, data, overrideReceiver, relayer); err != nil {
logger.Error("packetForwardMiddleware OnRecvPacket error receiving packet", "error", err)
return newErrorAcknowledgement(fmt.Errorf("error receiving packet: %w", err))
}

// if this packet's token denom is already the base denom for some native token on this chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const (
type (
NonrefundableKey struct{}
DisableDenomCompositionKey struct{}
ProcessedKey struct{}
)

func RefundPacketKey(channelID, portID string, sequence uint64) []byte {
Expand Down

0 comments on commit b06a093

Please sign in to comment.