Skip to content

Commit 4fe874e

Browse files
fixes for the documentation about handling ack for SDK <= 0.45 (#1122)
* fixes for documentation * review comment Co-authored-by: Carlos Rodriguez <crodveg@gmail.com>
1 parent 13bc4a0 commit 4fe874e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

docs/apps/interchain-accounts/auth-modules.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,13 @@ If the controller chain is connected to a host chain using the host module on ib
220220

221221
Begin by unmarshaling the acknowledgement into sdk.TxMsgData:
222222
```go
223+
var ack channeltypes.Acknowledgement
224+
if err := channeltypes.SubModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil {
225+
return err
226+
}
227+
223228
txMsgData := &sdk.TxMsgData{}
224-
if err := proto.Unmarshal(ack.Acknowledgement(), txMsgData); err != nil {
229+
if err := proto.Unmarshal(ack.GetResult(), txMsgData); err != nil {
225230
return err
226231
}
227232
```
@@ -232,6 +237,8 @@ The auth module should interpret the txMsgData.Data as follows:
232237
```go
233238
switch len(txMsgData.Data) {
234239
case 0:
240+
// see documentation below for SDK 0.46.x or greater
241+
default:
235242
for _, msgData := range txMsgData.Data {
236243
if err := handler(msgData); err != nil {
237244
return err
@@ -246,24 +253,24 @@ A router could be used, or more simply a switch statement.
246253

247254
```go
248255
func handler(msgData sdk.MsgData) error {
249-
switch msgData.TypeURL {
250-
case banktypes.MsgSend:
256+
switch msgData.MsgType {
257+
case sdk.MsgTypeURL(&banktypes.MsgSend{}):
251258
msgResponse := &banktypes.MsgSendResponse{}
252259
if err := proto.Unmarshal(msgData.Data, msgResponse}; err != nil {
253260
return err
254261
}
255262

256263
handleBankSendMsg(msgResponse)
257264

258-
case stakingtypes.MsgDelegate:
265+
case sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}):
259266
msgResponse := &stakingtypes.MsgDelegateResponse{}
260267
if err := proto.Unmarshal(msgData.Data, msgResponse}; err != nil {
261268
return err
262269
}
263270

264271
handleStakingDelegateMsg(msgResponse)
265272

266-
case transfertypes.MsgTransfer:
273+
case sdk.MsgTypeURL(&transfertypes.MsgTransfer{}):
267274
msgResponse := &transfertypes.MsgTransferResponse{}
268275
if err := proto.Unmarshal(msgData.Data, msgResponse}; err != nil {
269276
return err
@@ -281,8 +288,8 @@ The auth module should interpret the txMsgData.Responses as follows:
281288

282289
```go
283290
...
284-
// switch statement from above continued
285-
default:
291+
// switch statement from above
292+
case 0:
286293
for _, any := range txMsgData.MsgResponses {
287294
if err := handleAny(any); err != nil {
288295
return err

0 commit comments

Comments
 (0)