Skip to content

Commit

Permalink
remove usage of new coin with empty denom bz it triggers incorrect denom
Browse files Browse the repository at this point in the history
  • Loading branch information
RustNinja committed Apr 28, 2024
1 parent 58ec4cc commit 14e56e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions custom/ibc-transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions custom/ibc-transfer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 14e56e7

Please sign in to comment.