Skip to content

Commit

Permalink
test json change
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Sep 13, 2023
1 parent aec1d73 commit 203654b
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions x/ibchooks/wasm_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,22 @@ func (h WasmHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdktype
// This should never match anything, but we want to satisfy the github code scanning flag.
sanitizedSourceChannel := strings.ReplaceAll(packet.SourceChannel, "\"", "")

sudoMsg := []byte(fmt.Sprintf(
`{"ibc_lifecycle_complete": {"ibc_ack": {"channel": "%s", "sequence": %d, "ack": %s, "success": %s}}}`,
sanitizedSourceChannel, packet.Sequence, ackAsJSON, success))
ibcLifecycleComplete := IbcLifecycleCompleteSuccess{
IbcAck{
Channel: sanitizedSourceChannel,
Sequence: packet.Sequence,
Ack: string(ackAsJSON),
Success: success,
},
}
sudoMsg, err := json.Marshal(ibcLifecycleComplete)
if err != nil {
return sdkerrors.Wrap(err, "Ack callback error")
}

// sudoMsg := []byte(fmt.Sprintf(
// `{"ibc_lifecycle_complete": {"ibc_ack": {"channel": "%s", "sequence": %d, "ack": %s, "success": %s}}}`,
// sanitizedSourceChannel, packet.Sequence, ackAsJSON, success))
_, err = h.ContractKeeper.Sudo(ctx, contractAddr, sudoMsg)
if err != nil {
// error processing the callback
Expand All @@ -349,6 +362,17 @@ func (h WasmHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdktype
return nil
}

type IbcAck struct {
Channel string `json:"channel"`
Sequence uint64 `json:"sequence"`
Ack string `json:"ack"`
Success string `json:"success"`
}

type IbcLifecycleCompleteSuccess struct {
IbcAck IbcAck `json:"ibc_ack"`
}

func (h WasmHooks) OnTimeoutPacketOverride(im IBCMiddleware, ctx sdktypes.Context, packet channeltypes.Packet, relayer sdktypes.AccAddress) error {
err := im.App.OnTimeoutPacket(ctx, packet, relayer)
if err != nil {
Expand Down

0 comments on commit 203654b

Please sign in to comment.