From 14e56e7a57b03e94fa7ae5c385be9d73c451c6b7 Mon Sep 17 00:00:00 2001 From: rustdev Date: Sun, 28 Apr 2024 16:13:30 +0100 Subject: [PATCH] remove usage of new coin with empty denom bz it triggers incorrect denom --- custom/ibc-transfer/keeper/keeper.go | 7 +++++-- custom/ibc-transfer/keeper/msg_server.go | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/custom/ibc-transfer/keeper/keeper.go b/custom/ibc-transfer/keeper/keeper.go index 87f7c162..54c1ab6d 100644 --- a/custom/ibc-transfer/keeper/keeper.go +++ b/custom/ibc-transfer/keeper/keeper.go @@ -58,8 +58,9 @@ func NewKeeper( // If the transfer amount is greater than the minimum fee, it will charge the minimum fee and the percentage fee. func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + charge_coin := msg.Token + extra_charge := false params := k.IbcTransfermiddleware.GetParams(ctx) - charge_coin := sdk.NewCoin("", sdk.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { @@ -125,16 +126,18 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. return &types.MsgTransferResponse{}, nil } msg.Token.Amount = newAmount + extra_charge = true } } ret, err := k.Keeper.Transfer(goCtx, msg) - if err == nil && ret != nil && !charge_coin.IsZero() { + if err == nil && ret != nil && extra_charge { k.IbcTransfermiddleware.SetSequenceFee(ctx, ret.Sequence, charge_coin) } return ret, err } func GetPriority(jsonString string) *string { + return nil var data map[string]interface{} if err := json.Unmarshal([]byte(jsonString), &data); err != nil { return nil diff --git a/custom/ibc-transfer/keeper/msg_server.go b/custom/ibc-transfer/keeper/msg_server.go index 2bff42a1..c3e3115e 100644 --- a/custom/ibc-transfer/keeper/msg_server.go +++ b/custom/ibc-transfer/keeper/msg_server.go @@ -31,9 +31,11 @@ func NewMsgServerImpl(ibcKeeper Keeper, bankKeeper custombankkeeper.Keeper) type // If the transfer amount is less than the minimum fee, it will charge the full transfer amount. // If the transfer amount is greater than the minimum fee, it will charge the minimum fee and the percentage fee. func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { + // return k.msgServer.Transfer(goCtx, msg) ctx := sdk.UnwrapSDKContext(goCtx) + charge_coin := msg.Token + extra_charge := false params := k.Keeper.IbcTransfermiddleware.GetParams(ctx) - charge_coin := sdk.NewCoin("", sdk.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { @@ -99,10 +101,11 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ return &types.MsgTransferResponse{}, nil } msg.Token.Amount = newAmount + extra_charge = true } } ret, err := k.msgServer.Transfer(goCtx, msg) - if err == nil && ret != nil && !charge_coin.IsZero() { + if err == nil && ret != nil && extra_charge { k.IbcTransfermiddleware.SetSequenceFee(ctx, ret.Sequence, charge_coin) } return ret, err