Skip to content

Commit

Permalink
base64 payload decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
luckychess committed Nov 19, 2024
1 parent a285044 commit 3e8361e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions x/gmp/module_ibc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gmp

import (
"encoding/base64"
"encoding/json"
"fmt"

Expand Down Expand Up @@ -210,6 +211,13 @@ func (im IBCModule) OnRecvPacket(
return nil //?
case TypeGeneralMessageWithToken:
ctx.Logger().Info(fmt.Sprintf("Got general message with token: %v", msg))
decodedPayload := make([]byte, base64.StdEncoding.DecodedLen(len(msg.Payload)))
_, err = base64.StdEncoding.Decode(msg.Payload, decodedPayload)
if err != nil {
ctx.Logger().Info(fmt.Sprintf("failed to decode base64 payload: %s", err.Error()))
return channeltypes.NewErrorAcknowledgement(cosmossdkerrors.Wrapf(transfertypes.ErrInvalidMemo, "unable to decode payload (%s)", err.Error()))
}

payloadType, err := abi.NewType("string", "string", nil)
if err != nil {
ctx.Logger().Info(fmt.Sprintf("failed to create reflection: %s", err.Error()))
Expand Down

0 comments on commit 3e8361e

Please sign in to comment.