Skip to content

Commit

Permalink
move wasm structs to type... still needs some reworking to correct json
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Sep 13, 2023
1 parent d2645b8 commit be12a87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 20 additions & 0 deletions x/ibchooks/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ func UnmarshalIBCAck(bz []byte) (*IBCAck, error) {
return &ack, 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"`
}

type IbcTimeout struct {
Channel string `json:"channel"`
Sequence uint64 `json:"sequence"`
}

type IbcLifecycleComplete struct {
IbcTimeout IbcTimeout `json:"ibc_timeout"`
}

type MarkerMemo struct {
Marker MarkerPayload `json:"marker"`
}
Expand Down
24 changes: 2 additions & 22 deletions x/ibchooks/wasm_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ 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, "\"", "")

ibcLifecycleComplete := IbcLifecycleCompleteSuccess{
IbcAck{
ibcLifecycleComplete := types.IbcLifecycleCompleteSuccess{
IbcAck: types.IbcAck{
Channel: sanitizedSourceChannel,
Sequence: packet.Sequence,
Ack: string(ackAsJSON),
Expand All @@ -362,17 +362,6 @@ 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 Expand Up @@ -422,15 +411,6 @@ func (h WasmHooks) OnTimeoutPacketOverride(im IBCMiddleware, ctx sdktypes.Contex
return nil
}

type IbcTimeout struct {
Channel string `json:"channel"`
Sequence uint64 `json:"sequence"`
}

type IbcLifecycleComplete struct {
IbcTimeout IbcTimeout `json:"ibc_timeout"`
}

// NewEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the
// details of the error.
func NewEmitErrorAcknowledgement(ctx sdktypes.Context, err error, errorContexts ...string) channeltypes.Acknowledgement {
Expand Down

0 comments on commit be12a87

Please sign in to comment.