diff --git a/integration_tests/test_ica_precompile.py b/integration_tests/test_ica_precompile.py index d747f5130d..312759d980 100644 --- a/integration_tests/test_ica_precompile.py +++ b/integration_tests/test_ica_precompile.py @@ -192,6 +192,7 @@ def submit_msgs_ro(func, str): assert tcontract.caller.getLastAckSeq() == seq balance -= amt ack = tcontract.caller.getLastAck() + assert ack == b"\x12&\n$/cosmos.bank.v1beta1.MsgSendResponse", ack assert ack == tcontract.caller.acknowledgement(seq) assert cli_host.balance(ica_address, denom=denom) == balance seq = 2 @@ -209,4 +210,5 @@ def submit_msgs_ro(func, str): balance -= amt1 assert cli_host.balance(ica_address, denom=denom) == balance ack = tcontract.caller.getLastAck() - assert ack == tcontract.caller.acknowledgement(seq) + expected = b"\x12&\n$/cosmos.bank.v1beta1.MsgSendResponse\x12-\n+/cosmos.staking.v1beta1.MsgDelegateResponse" # noqa: E501 + assert ack == expected, ack diff --git a/x/cronos/keeper/keeper.go b/x/cronos/keeper/keeper.go index cdafb91df1..8a2fa297e8 100644 --- a/x/cronos/keeper/keeper.go +++ b/x/cronos/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/json" "fmt" "math/big" "strings" @@ -282,6 +283,14 @@ func (k Keeper) RegisterOrUpdateTokenMapping(ctx sdk.Context, msg *types.MsgUpda return nil } +type IncentivizedAcknowledgement struct { + AppAcknowledgement []byte `json:"app_acknowledgement"` +} + +type PacketResult struct { + Result []byte `json:"result"` +} + func (k Keeper) onPacketResult( ctx sdk.Context, packet channeltypes.Packet, @@ -296,7 +305,15 @@ func (k Keeper) onPacketResult( } sender := common.BytesToAddress(senderAddr.Bytes()) precompileAddr := common.HexToAddress(contractAddress) - data, err := cronosprecompiles.OnPacketResult(packet.Sequence, sender, acknowledgement) + var ack IncentivizedAcknowledgement + if err := json.Unmarshal(acknowledgement, &ack); err != nil { + return err + } + var res PacketResult + if err := json.Unmarshal(ack.AppAcknowledgement, &res); err != nil { + return err + } + data, err := cronosprecompiles.OnPacketResult(packet.Sequence, sender, res.Result) if err != nil { return err }