-
Notifications
You must be signed in to change notification settings - Fork 586
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
imp: add UnmarshalPacketData interface function #3353
Changes from 14 commits
bf93c0e
8c16e8d
3500d06
89f608c
b77cfe6
1db4626
32b74ec
f8298da
f826ddd
ca33576
6bf400e
19ab301
1a1a082
07cc36a
9d9e33a
882dc95
bfb359d
27f2447
d80eb6f
16a8e84
c4987af
d4bae04
9919cb1
06916c5
bec5a03
6781f20
1f04b6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ import ( | |
"github.com/cosmos/ibc-go/v7/modules/core/exported" | ||
) | ||
|
||
var _ porttypes.Middleware = &IBCMiddleware{} | ||
var ( | ||
_ porttypes.Middleware = &IBCMiddleware{} | ||
_ porttypes.PacketDataUnmarshaler = &IBCMiddleware{} | ||
) | ||
|
||
// IBCMiddleware implements the ICS26 callbacks for the fee middleware given the | ||
// fee keeper and the underlying application. | ||
|
@@ -347,3 +350,15 @@ func (im IBCMiddleware) WriteAcknowledgement( | |
func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { | ||
return im.keeper.GetAppVersion(ctx, portID, channelID) | ||
} | ||
|
||
// UnmarshalPacketData attempts to use the underlying app to unmarshal the packet data. | ||
// If the underlying app does not support the PacketDataUnmarshaler interface, an error is returned. | ||
// This function implements the optional PacketDataUnmarshaler interface required for ADR 008 support. | ||
func (im IBCMiddleware) UnmarshalPacketData(bz []byte) (interface{}, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is only necessary if the ADR 8 implementation is higher than ICS 29, which should not be the case. I added the function anyways so we could discuss here whether to keep it or not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I guess its best to keep it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree that it should be kept. Let's remove ordering requirements from our stack whenever possible |
||
unmarshaler, ok := im.app.(porttypes.PacketDataUnmarshaler) | ||
if !ok { | ||
return nil, errorsmod.Wrapf(types.ErrUnsupportedAction, "underlying app does not implement PacketDataUnmarshaler") | ||
} | ||
|
||
return unmarshaler.UnmarshalPacketData(bz) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️