-
Notifications
You must be signed in to change notification settings - Fork 647
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
Better OnAcknowledgementPacket handling #1114
Comments
For reference, this is currently required to handle Acknowledgements - this differs from my interpretation of the docs:
|
Nice catch and thanks for opening the issue. The docs are incomplete/incorrect. This: if err := proto.Unmarshal(ack.Acknowledgement(), txMsgData); err != nil { should be if err := proto.Unmarshal(ack.Result, txMsgData); err != nil { like you reference.
IBC modules typically have access to a keeper (see that the ica demo repo does). It is a little clumsy, but you can move this code into a keeper.OnAcknowledgementPacket() to get access to the codec. This explanation should also be added to the docs (although I guess using json.Unmarshal should be fine?) |
@joe-bowman we have also tried this ourselves now (for SDK 0.45.x) in the interchain-account-demo repo, in case you want to have a look. |
Perfect, thanks for your help gents :)
…On Wed, 16 Mar 2022 at 11:44, Carlos Rodriguez ***@***.***> wrote:
@joe-bowman <https://github.com/joe-bowman> we have also tried this
ourselves now (for SDK 0.45.x) in the interchain-account-demo repo
<https://github.com/cosmos/interchain-accounts-demo/pull/88/files>, in
case you want to have a look.
—
Reply to this email directly, view it on GitHub
<#1114 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABA7QYDHVK5MVZWUYXPHP6DVAHCSLANCNFSM5QS3JFJQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Summary
The docs at https://github.com/cosmos/ibc-go/blob/main/docs/apps/interchain-accounts/auth-modules.md suggest that decoding the Acknowledgement is as simple as:
(N.B.
channeltypes
here refers github.com/cosmos/ibc-go/v3/modules/core/04-channel/types
)However, the
acknowledgement
byte slice that is referred to is not ansdk.TxMsgData
but the JSON-encodedResponse
field fromchanneltypes.Acknowledgement
- either achanneltypes.Acknowledgement_Result
or channeltypes.Acknowledgement_Error`.This needs to be unmarshalled from JSON (cannot be done using the Keeper's Codec; so unintuitively we have to use
json.Unmarshal
- unless there is a better way?) before we canproto.Unmarshal
the actual bytestring the docs allude to.Problem Definition
Docs / spec do not reflect reality.
Proposal
Not sure - but docs/spec should reflect reality.
The manual unmarshalling of the Acknowledgement struct feels clumsy - maybe there ought to be a
NewAcknowledgementFromResponse()
helper in channeltypes (or have this handled internally and haveOnAcknowledgementPacket
acknowledgement
argument of typechanneltypes.Acknowledgement
so we just have to calledGetResult()
orGetError()
as appropriate).For Admin Use
The text was updated successfully, but these errors were encountered: