From 4cc6272d7824c1190da84c46ecdee8d7b37cb701 Mon Sep 17 00:00:00 2001 From: Yksirod <103229163+taramakage@users.noreply.github.com> Date: Fri, 20 Oct 2023 09:49:45 +0800 Subject: [PATCH] Revert "fix: solve the problem of "/" parsing error in classID " --- keeper/relay.go | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/keeper/relay.go b/keeper/relay.go index a973641..26d095d 100644 --- a/keeper/relay.go +++ b/keeper/relay.go @@ -167,10 +167,8 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d return err } - voucherClassID, err := k.GetVoucherClassID(ctx, data.ClassId) - if err != nil { - return err - } + classTrace := types.ParseClassTrace(data.ClassId) + voucherClassID := classTrace.IBCClassID() 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 { @@ -341,11 +339,7 @@ func (k Keeper) processReceivedPacket(ctx sdk.Context, packet channeltypes.Packe if err != nil { return err } - - voucherClassID, err := k.GetVoucherClassID(ctx, unprefixedClassID) - if err != nil { - return err - } + voucherClassID := types.ParseClassTrace(unprefixedClassID).IBCClassID() escrowAddress := types.GetEscrowAddress(packet.GetDestPort(), packet.GetDestChannel()) for i, tokenID := range data.TokenIds { @@ -363,24 +357,3 @@ func (k Keeper) processReceivedPacket(ctx sdk.Context, packet channeltypes.Packe } return nil } - -func (k Keeper) GetVoucherClassID(ctx sdk.Context, classID string) (string, error) { - - // If "/" is not included after removing the prefix, - // it means that nft has returned to the initial chain, and the classID after removing the prefix is the real classID - if !strings.Contains(classID, "/") { - return classID, nil - } - - // If "/" is included after removing the prefix, there are two situations: - // 1. The original classID itself contains "/", - // 2. The current nft returns to the relay chain, not the original chain - - // First deal with case 1, if the classID can be found, return the result - if k.nftKeeper.HasClass(ctx, classID) { - return classID, nil - } - - // If not found, generate classID according to classTrace - return types.ParseClassTrace(classID).IBCClassID(), nil -}