diff --git a/ibc_module.go b/ibc_module.go index 192f846..93daccb 100644 --- a/ibc_module.go +++ b/ibc_module.go @@ -1,7 +1,6 @@ package nfttransfer import ( - "fmt" "math" "strings" @@ -236,7 +235,7 @@ func (im IBCModule) OnAcknowledgementPacket( sdk.NewAttribute(types.AttributeKeyReceiver, data.Receiver), sdk.NewAttribute(types.AttributeKeyClassID, data.ClassId), sdk.NewAttribute(types.AttributeKeyTokenIDs, strings.Join(data.TokenIds, ",")), - sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success())), + sdk.NewAttribute(types.AttributeKeyAck, ack.String()), ), ) diff --git a/keeper/grpc_query.go b/keeper/grpc_query.go index d2daa10..d510246 100644 --- a/keeper/grpc_query.go +++ b/keeper/grpc_query.go @@ -27,7 +27,7 @@ func (k Keeper) ClassTrace(c context.Context, hash, err := types.ParseHexHash(strings.TrimPrefix(req.Hash, "ibc/")) if err != nil { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", hash.String(), err)) + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid denom trace hash: %s, error: %s", req.Hash, err)) } ctx := sdk.UnwrapSDKContext(c) diff --git a/keeper/relay.go b/keeper/relay.go index acdb32a..5c51f66 100644 --- a/keeper/relay.go +++ b/keeper/relay.go @@ -179,8 +179,8 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d return err } if types.IsAwayFromOrigin(packet.GetSourcePort(), packet.GetSourceChannel(), data.ClassId) { - for _, tokenID := range data.TokenIds { - if err := k.nftKeeper.Transfer(ctx, voucherClassID, tokenID, "", sender); err != nil { + for i, tokenID := range data.TokenIds { + if err := k.nftKeeper.Transfer(ctx, voucherClassID, tokenID, types.GetIfExist(i, data.TokenData), sender); err != nil { return err } } @@ -260,7 +260,7 @@ func (k Keeper) createOutgoingPacket(ctx sdk.Context, if isAwayFromOrigin { // create the escrow address for the tokens escrowAddress := types.GetEscrowAddress(sourcePort, sourceChannel) - if err := k.nftKeeper.Transfer(ctx, classID, tokenID, "", escrowAddress); err != nil { + if err := k.nftKeeper.Transfer(ctx, classID, tokenID, nft.GetData(), escrowAddress); err != nil { return channeltypes.Packet{}, err } } else { diff --git a/types/events.go b/types/events.go index 146adaa..5d413ab 100644 --- a/types/events.go +++ b/types/events.go @@ -12,6 +12,7 @@ const ( AttributeKeyReceiver = "receiver" AttributeKeyClassID = "classID" AttributeKeyTokenIDs = "tokenIDs" + AttributeKeyAck = "acknowledgement" AttributeKeyAckSuccess = "success" AttributeKeyAckError = "error" AttributeKeyTraceHash = "trace_hash" diff --git a/types/trace.go b/types/trace.go index d3d1cfb..3a4fdec 100644 --- a/types/trace.go +++ b/types/trace.go @@ -17,16 +17,15 @@ import ( // ParseHexHash parses a hex hash in string format to bytes and validates its correctness. func ParseHexHash(hexHash string) (tmbytes.HexBytes, error) { + if strings.TrimSpace(hexHash) == "" { + return nil, fmt.Errorf("empty hex hash") + } hash, err := hex.DecodeString(hexHash) if err != nil { return nil, err } - if err := tmtypes.ValidateHash(hash); err != nil { - return nil, err - } - - return hash, nil + return hash, tmtypes.ValidateHash(hash) } // GetClassPrefix returns the receiving class prefix