Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
chore: logging response data from 0.46 sdk (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Aug 23, 2022
1 parent 83bdc4a commit cd7c200
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 12 additions & 5 deletions x/inter-tx/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/interchain-accounts/x/inter-tx/keeper"

channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
Expand Down Expand Up @@ -123,14 +124,16 @@ func (im IBCModule) OnAcknowledgementPacket(
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal ICS-27 packet acknowledgement: %v", err)
}

txMsgData := &sdk.TxMsgData{}
if err := proto.Unmarshal(ack.GetResult(), txMsgData); err != nil {
var txMsgData sdk.TxMsgData
if err := proto.Unmarshal(ack.GetResult(), &txMsgData); err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal ICS-27 tx message data: %v", err)
}

switch len(txMsgData.Data) {
case 0:
// TODO: handle for sdk 0.46.x
for _, msgResp := range txMsgData.GetMsgResponses() {
im.keeper.Logger(ctx).Info("msg response in ICS-27 packet", "response", msgResp.GoString(), "typeURL", msgResp.GetTypeUrl())
}
return nil
default:
for _, msgData := range txMsgData.Data {
Expand Down Expand Up @@ -175,9 +178,13 @@ func handleMsgData(ctx sdk.Context, msgData *sdk.MsgData) (string, error) {
}

return msgResponse.String(), nil
case sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}):
msgResponse := &stakingtypes.MsgDelegateResponse{}
if err := proto.Unmarshal(msgData.Data, msgResponse); err != nil {
return "", sdkerrors.Wrapf(sdkerrors.ErrJSONUnmarshal, "cannot unmarshal delegate response message: %s", err.Error())
}

// TODO: handle other messages

return msgResponse.String(), nil
default:
return "", nil
}
Expand Down
3 changes: 1 addition & 2 deletions x/inter-tx/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/tendermint/tendermint/libs/log"

icacontrollerkeeper "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/keeper"
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
"github.com/cosmos/interchain-accounts/x/inter-tx/types"
)

Expand All @@ -36,7 +35,7 @@ func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, iaKeeper icacontro

// Logger returns the application logger, scoped to the associated module
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", host.ModuleName, types.ModuleName))
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}

// ClaimCapability claims the channel capability passed via the OnOpenChanInit callback
Expand Down

0 comments on commit cd7c200

Please sign in to comment.