diff --git a/app/upgrades/v6_5_5/constants.go b/app/upgrades/v6_5_5/constants.go new file mode 100644 index 000000000..1c066a692 --- /dev/null +++ b/app/upgrades/v6_5_5/constants.go @@ -0,0 +1,20 @@ +package v6_5_5 + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/notional-labs/composable/v6/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name for the composable upgrade. + UpgradeName = "v6_5_5" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v6_5_5/upgrade.go b/app/upgrades/v6_5_5/upgrade.go new file mode 100644 index 000000000..2226d99ef --- /dev/null +++ b/app/upgrades/v6_5_5/upgrade.go @@ -0,0 +1,24 @@ +package v6_5_5 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/notional-labs/composable/v6/app/keepers" + + "github.com/notional-labs/composable/v6/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + _ upgrades.BaseAppParamManager, + _ codec.Codec, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/custom/ibc-transfer/keeper/keeper.go b/custom/ibc-transfer/keeper/keeper.go index 4d1fdcbc3..469c2eab1 100644 --- a/custom/ibc-transfer/keeper/keeper.go +++ b/custom/ibc-transfer/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "encoding/json" "fmt" "time" @@ -16,6 +17,7 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper" ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/keeper" + ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types" ) type Keeper struct { @@ -57,6 +59,7 @@ func NewKeeper( func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) params := k.IbcTransfermiddleware.GetParams(ctx) + charge_coin := sdk.NewCoin(msg.Token.Denom, sdk.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { @@ -79,7 +82,16 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. if coin == nil { return nil, fmt.Errorf("token not allowed to be transferred in this channel") } + minFee := coin.MinFee.Amount + priority := GetPriority(msg.Memo) + if priority != nil { + p := findPriority(coin.TxPriorityFee, *priority) + if p != nil && coin.MinFee.Denom == p.PriorityFee.Denom { + minFee = minFee.Add(p.PriorityFee.Amount) + } + } + charge := minFee if charge.GT(msg.Token.Amount) { charge = msg.Token.Amount @@ -103,7 +115,8 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. return nil, err } - send_err := k.bank.SendCoins(ctx, msgSender, feeAddress, sdk.NewCoins(sdk.NewCoin(msg.Token.Denom, charge))) + charge_coin = sdk.NewCoin(msg.Token.Denom, charge) + send_err := k.bank.SendCoins(ctx, msgSender, feeAddress, sdk.NewCoins(charge_coin)) if send_err != nil { return nil, send_err } @@ -114,5 +127,32 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types. msg.Token.Amount = newAmount } } - return k.Keeper.Transfer(goCtx, msg) + ret, err := k.Keeper.Transfer(goCtx, msg) + if err == nil && ret != nil && !charge_coin.IsZero() { + k.IbcTransfermiddleware.SetSequenceFee(ctx, ret.Sequence, charge_coin) + } + return ret, err +} + +func GetPriority(jsonString string) *string { + var data map[string]interface{} + if err := json.Unmarshal([]byte(jsonString), &data); err != nil { + return nil + } + + priority, ok := data["priority"].(string) + if !ok { + return nil + } + + return &priority +} + +func findPriority(priorities []*ibctransfermiddlewaretypes.TxPriorityFee, priority string) *ibctransfermiddlewaretypes.TxPriorityFee { + for _, p := range priorities { + if p.Priority == priority { + return p + } + } + return nil } diff --git a/custom/ibc-transfer/keeper/msg_server.go b/custom/ibc-transfer/keeper/msg_server.go index 89a12355d..7adb3a0a6 100644 --- a/custom/ibc-transfer/keeper/msg_server.go +++ b/custom/ibc-transfer/keeper/msg_server.go @@ -33,6 +33,7 @@ func NewMsgServerImpl(ibcKeeper Keeper, bankKeeper custombankkeeper.Keeper) type func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) params := k.Keeper.IbcTransfermiddleware.GetParams(ctx) + charge_coin := sdk.NewCoin(msg.Token.Denom, sdk.ZeroInt()) if params.ChannelFees != nil && len(params.ChannelFees) > 0 { channelFee := findChannelParams(params.ChannelFees, msg.SourceChannel) if channelFee != nil { @@ -55,7 +56,16 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ if coin == nil { return nil, fmt.Errorf("token not allowed to be transferred in this channel") } + minFee := coin.MinFee.Amount + priority := GetPriority(msg.Memo) + if priority != nil { + p := findPriority(coin.TxPriorityFee, *priority) + if p != nil && coin.MinFee.Denom == p.PriorityFee.Denom { + minFee = minFee.Add(p.PriorityFee.Amount) + } + } + charge := minFee if charge.GT(msg.Token.Amount) { charge = msg.Token.Amount @@ -79,7 +89,8 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ return nil, err } - send_err := k.bank.SendCoins(ctx, msgSender, feeAddress, sdk.NewCoins(sdk.NewCoin(msg.Token.Denom, charge))) + charge_coin = sdk.NewCoin(msg.Token.Denom, charge) + send_err := k.bank.SendCoins(ctx, msgSender, feeAddress, sdk.NewCoins(charge_coin)) if send_err != nil { return nil, send_err } @@ -90,7 +101,11 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ msg.Token.Amount = newAmount } } - return k.msgServer.Transfer(goCtx, msg) + ret, err := k.msgServer.Transfer(goCtx, msg) + if err == nil && ret != nil && !charge_coin.IsZero() { + k.IbcTransfermiddleware.SetSequenceFee(ctx, ret.Sequence, charge_coin) + } + return ret, err } func findChannelParams(channelFees []*ibctransfermiddlewaretypes.ChannelFee, targetChannelID string) *ibctransfermiddlewaretypes.ChannelFee { diff --git a/proto/composable/ibctransfermiddleware/v1beta1/genesis.proto b/proto/composable/ibctransfermiddleware/v1beta1/genesis.proto index 20f491b2c..8ead9ed65 100644 --- a/proto/composable/ibctransfermiddleware/v1beta1/genesis.proto +++ b/proto/composable/ibctransfermiddleware/v1beta1/genesis.proto @@ -4,6 +4,7 @@ package composable.ibctransfermiddleware.v1beta1; import "gogoproto/gogo.proto"; import "composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto"; import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "x/ibctransfermiddleware/types"; @@ -11,4 +12,6 @@ option go_package = "x/ibctransfermiddleware/types"; // GenesisState defines the ibctransfermiddleware module's genesis state. message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; + + repeated cosmos.base.v1beta1.Coin taken_fee_by_ibc_sequence = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/proto/composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto b/proto/composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto index f789dee2f..abbea4ef8 100644 --- a/proto/composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto +++ b/proto/composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto @@ -25,5 +25,11 @@ message ChannelFee{ message CoinItem{ cosmos.base.v1beta1.Coin min_fee = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; int64 percentage = 2; + repeated TxPriorityFee tx_priority_fee = 3; +} + +message TxPriorityFee{ + string priority = 1; + cosmos.base.v1beta1.Coin priority_fee = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/proto/composable/ibctransfermiddleware/v1beta1/tx.proto b/proto/composable/ibctransfermiddleware/v1beta1/tx.proto index 91cd2c351..62747d981 100644 --- a/proto/composable/ibctransfermiddleware/v1beta1/tx.proto +++ b/proto/composable/ibctransfermiddleware/v1beta1/tx.proto @@ -107,6 +107,8 @@ message MsgAddAllowedIbcToken { cosmos.base.v1beta1.Coin min_fee = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; int64 percentage = 4; + + repeated TxPriorityFee tx_priority_fee = 5; } message MsgAddAllowedIbcTokenResponse {} diff --git a/x/ibctransfermiddleware/client/cli/tx.go b/x/ibctransfermiddleware/client/cli/tx.go index c8b86a01e..2db622d66 100644 --- a/x/ibctransfermiddleware/client/cli/tx.go +++ b/x/ibctransfermiddleware/client/cli/tx.go @@ -77,10 +77,10 @@ func AddIBCFeeConfig() *cobra.Command { func AddAllowedIbcToken() *cobra.Command { cmd := &cobra.Command{ - Use: "add-allowed-ibc-token [channel] [percentage] [coin]", + Use: "add-allowed-ibc-token [channel] [percentage] [coin] [Amountlow] [Amountmedium] [Amounthigh] ... [Amountxxx]", Short: "add allowed ibc token", - Args: cobra.MatchAll(cobra.ExactArgs(3), cobra.OnlyValidArgs), - Example: fmt.Sprintf("%s tx ibctransfermiddleware add-allowed-ibc-token [channel] [percentage] [coin] (percentage '5' means 1/5 of amount will be taken as fee) ", version.AppName), + Args: cobra.MatchAll(cobra.RangeArgs(3, 10), cobra.OnlyValidArgs), + Example: fmt.Sprintf("%s tx ibctransfermiddleware add-allowed-ibc-token [channel] [percentage] [coin] .. [1000low] [10000medium] [100000high] ... [1000000xxx] (percentage '5' means 1/5 of amount will be taken as fee) ", version.AppName), RunE: func(cmd *cobra.Command, args []string) error { channel := args[0] percentage := args[1] @@ -88,6 +88,17 @@ func AddAllowedIbcToken() *cobra.Command { if err != nil { return err } + length := len(args) + cc := []*types.TxPriorityFee{} + for i := 3; i < length; i++ { + priority, err := sdk.ParseCoinNormalized(args[i]) + if err != nil { + return err + } + priority_str := priority.Denom + priority.Denom = coin.Denom + cc = append(cc, &types.TxPriorityFee{Priority: priority_str, PriorityFee: priority}) + } clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -106,6 +117,7 @@ func AddAllowedIbcToken() *cobra.Command { channel, coin, percentageInt, + cc, ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/ibctransfermiddleware/keeper/keeper.go b/x/ibctransfermiddleware/keeper/keeper.go index 7dd16c548..597cf30a4 100644 --- a/x/ibctransfermiddleware/keeper/keeper.go +++ b/x/ibctransfermiddleware/keeper/keeper.go @@ -65,6 +65,28 @@ func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { return p } +func (k Keeper) GetSequenceFee(ctx sdk.Context, sequence uint64) (coin sdk.Coin, found bool) { + store := ctx.KVStore(k.storeKey) + + value := store.Get(types.GetSequenceKey(sequence)) + if value == nil { + return sdk.Coin{}, false + } + + fee := types.MustUnmarshalCoin(k.cdc, value) + return fee, true +} + +func (k Keeper) SetSequenceFee(ctx sdk.Context, sequence uint64, coin sdk.Coin) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetSequenceKey(sequence), types.MustMarshalCoin(k.cdc, &coin)) +} + +func (k Keeper) DeleteSequenceFee(ctx sdk.Context, sequence uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.GetSequenceKey(sequence)) +} + func (k Keeper) GetCoin(ctx sdk.Context, targetChannelID, denom string) *types.CoinItem { params := k.GetParams(ctx) channelFee := findChannelParams(params.ChannelFees, targetChannelID) diff --git a/x/ibctransfermiddleware/keeper/msg_server.go b/x/ibctransfermiddleware/keeper/msg_server.go index dbe7b0f76..e9f38ddc5 100644 --- a/x/ibctransfermiddleware/keeper/msg_server.go +++ b/x/ibctransfermiddleware/keeper/msg_server.go @@ -105,11 +105,12 @@ func (ms msgServer) AddAllowedIbcToken(goCtx context.Context, req *types.MsgAddA if coin != nil { coin.MinFee = req.MinFee coin.Percentage = req.Percentage + coin.TxPriorityFee = req.TxPriorityFee } else { - coin := &types.CoinItem{ - MinFee: req.MinFee, - Percentage: req.Percentage, + MinFee: req.MinFee, + Percentage: req.Percentage, + TxPriorityFee: req.TxPriorityFee, } channelFee.AllowedTokens = append(channelFee.AllowedTokens, coin) } diff --git a/x/ibctransfermiddleware/types/genesis.pb.go b/x/ibctransfermiddleware/types/genesis.pb.go index d75c5c1bd..9b115b6e1 100644 --- a/x/ibctransfermiddleware/types/genesis.pb.go +++ b/x/ibctransfermiddleware/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -26,7 +27,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the ibctransfermiddleware module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + TakenFeeByIbcSequence []types.Coin `protobuf:"bytes,2,rep,name=taken_fee_by_ibc_sequence,json=takenFeeByIbcSequence,proto3" json:"taken_fee_by_ibc_sequence"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -69,6 +71,13 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetTakenFeeByIbcSequence() []types.Coin { + if m != nil { + return m.TakenFeeByIbcSequence + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "composable.ibctransfermiddleware.v1beta1.GenesisState") } @@ -78,21 +87,27 @@ func init() { } var fileDescriptor_ab9a6edd8a683ba6 = []byte{ - // 213 bytes of a gzipped File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b8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0xb6, 0x02, 0x87, 0x4f, 0x4a, 0x2a, 0x0b, - 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xee, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x64, 0x36, - 0x5f, 0x72, 0x01, 0x00, 0x00, + // 308 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x3d, 0x4b, 0x03, 0x31, + 0x18, 0xc7, 0x2f, 0x2a, 0x05, 0xaf, 0x2e, 0x16, 0x85, 0xb6, 0x60, 0x2c, 0x4e, 0x87, 0x43, 0x62, + 0x2b, 0xe8, 0x7e, 0x8a, 0xe2, 0x22, 0xd2, 0x6e, 0x0e, 0x1e, 0x49, 0xfa, 0xf4, 0x08, 0xf6, 0x92, + 0xf3, 0x12, 0x5f, 0xee, 0x5b, 0xf8, 0x31, 0x1c, 0xfd, 0x04, 0xce, 0x1d, 0x3b, 0x3a, 0x89, 0xdc, + 0x0d, 0x7e, 0x0d, 0xb9, 0x17, 0xec, 0x52, 0xa1, 0x4b, 0x08, 0x09, 0xbf, 0xdf, 0xf3, 0xfc, 0xff, + 0xee, 0x89, 0xd0, 0x51, 0xac, 0x0d, 0xe3, 0x53, 0xa0, 0x92, 0x0b, 0x9b, 0x30, 0x65, 0x26, 0x90, + 0x44, 0x72, 0x3c, 0x9e, 0xc2, 0x33, 0x4b, 0x80, 0x3e, 0xf5, 0x39, 0x58, 0xd6, 0xa7, 0x21, 0x28, + 0x30, 0xd2, 0x90, 0x38, 0xd1, 0x56, 0xb7, 0xbc, 0x05, 0x47, 0x96, 0x72, 0xa4, 0xe6, 0xba, 0x3b, + 0xa1, 0x0e, 0x75, 0x09, 0xd1, 0xe2, 0x56, 0xf1, 0xdd, 0xf3, 0x95, 0xe7, 0x2e, 0xb7, 0x57, 0x96, + 0x6d, 0x16, 0x49, 0xa5, 0x69, 0x79, 0xd6, 0x4f, 0x58, 0x68, 0x13, 0x69, 0x43, 0x39, 0x33, 0x0b, + 0x87, 0xd0, 0x52, 0x55, 0xff, 0x07, 0x1f, 0xc8, 0xdd, 0xba, 0xac, 0xa2, 0x8c, 0x2c, 0xb3, 0xd0, + 0xba, 0x76, 0x1b, 0x31, 0x4b, 0x58, 0x64, 0xda, 0xa8, 0x87, 0xbc, 0xe6, 0xe0, 0x88, 0xac, 0x1a, + 0x8d, 0xdc, 0x94, 0x9c, 0xbf, 0x31, 0xfb, 0xda, 0x77, 0x86, 0xb5, 0xa5, 0x75, 0xe7, 0x76, 0x2c, + 0xbb, 0x07, 0x15, 0x4c, 0x00, 0x02, 0x9e, 0x06, 0x92, 0x8b, 0xc0, 0xc0, 0xc3, 0x23, 0x28, 0x01, + 0xed, 0xb5, 0xde, 0xba, 0xd7, 0x1c, 0x74, 0x48, 0xb5, 0x24, 0x29, 0x96, 0xfc, 0xb3, 0x9d, 0x69, + 0xa9, 0xfc, 0xcd, 0xc2, 0xf5, 0xf6, 0xf3, 0x7e, 0x88, 0x86, 0xbb, 0xa5, 0xe6, 0x02, 0xc0, 0x4f, + 0xaf, 0xb8, 0x18, 0xd5, 0x0a, 0xff, 0x74, 0x96, 0x61, 0x34, 0xcf, 0x30, 0xfa, 0xce, 0x30, 0x7a, + 0xcd, 0xb1, 0x33, 0xcf, 0xb1, 0xf3, 0x99, 0x63, 0xe7, 0x76, 0xef, 0xe5, 0x9f, 0x2a, 0x6d, 0x1a, + 0x83, 0xe1, 0x8d, 0xb2, 0x80, 0xe3, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, 0x69, 0xde, 0x66, + 0xf3, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -115,6 +130,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TakenFeeByIbcSequence) > 0 { + for iNdEx := len(m.TakenFeeByIbcSequence) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TakenFeeByIbcSequence[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -147,6 +176,12 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.TakenFeeByIbcSequence) > 0 { + for _, e := range m.TakenFeeByIbcSequence { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -218,6 +253,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakenFeeByIbcSequence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TakenFeeByIbcSequence = append(m.TakenFeeByIbcSequence, types.Coin{}) + if err := m.TakenFeeByIbcSequence[len(m.TakenFeeByIbcSequence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/ibctransfermiddleware/types/ibctransfermiddleware.pb.go b/x/ibctransfermiddleware/types/ibctransfermiddleware.pb.go index e58115dcd..bc7299bc1 100644 --- a/x/ibctransfermiddleware/types/ibctransfermiddleware.pb.go +++ b/x/ibctransfermiddleware/types/ibctransfermiddleware.pb.go @@ -141,8 +141,9 @@ func (m *ChannelFee) GetMinTimeoutTimestamp() int64 { } type CoinItem struct { - MinFee types.Coin `protobuf:"bytes,1,opt,name=min_fee,json=minFee,proto3" json:"min_fee"` - Percentage int64 `protobuf:"varint,2,opt,name=percentage,proto3" json:"percentage,omitempty"` + MinFee types.Coin `protobuf:"bytes,1,opt,name=min_fee,json=minFee,proto3" json:"min_fee"` + Percentage int64 `protobuf:"varint,2,opt,name=percentage,proto3" json:"percentage,omitempty"` + TxPriorityFee []*TxPriorityFee `protobuf:"bytes,3,rep,name=tx_priority_fee,json=txPriorityFee,proto3" json:"tx_priority_fee,omitempty"` } func (m *CoinItem) Reset() { *m = CoinItem{} } @@ -192,10 +193,70 @@ func (m *CoinItem) GetPercentage() int64 { return 0 } +func (m *CoinItem) GetTxPriorityFee() []*TxPriorityFee { + if m != nil { + return m.TxPriorityFee + } + return nil +} + +type TxPriorityFee struct { + Priority string `protobuf:"bytes,1,opt,name=priority,proto3" json:"priority,omitempty"` + PriorityFee types.Coin `protobuf:"bytes,2,opt,name=priority_fee,json=priorityFee,proto3" json:"priority_fee"` +} + +func (m *TxPriorityFee) Reset() { *m = TxPriorityFee{} } +func (m *TxPriorityFee) String() string { return proto.CompactTextString(m) } +func (*TxPriorityFee) ProtoMessage() {} +func (*TxPriorityFee) Descriptor() ([]byte, []int) { + return fileDescriptor_1193893bc248bc1b, []int{3} +} +func (m *TxPriorityFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxPriorityFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxPriorityFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TxPriorityFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxPriorityFee.Merge(m, src) +} +func (m *TxPriorityFee) XXX_Size() int { + return m.Size() +} +func (m *TxPriorityFee) XXX_DiscardUnknown() { + xxx_messageInfo_TxPriorityFee.DiscardUnknown(m) +} + +var xxx_messageInfo_TxPriorityFee proto.InternalMessageInfo + +func (m *TxPriorityFee) GetPriority() string { + if m != nil { + return m.Priority + } + return "" +} + +func (m *TxPriorityFee) GetPriorityFee() types.Coin { + if m != nil { + return m.PriorityFee + } + return types.Coin{} +} + func init() { proto.RegisterType((*Params)(nil), "composable.ibctransfermiddleware.v1beta1.Params") proto.RegisterType((*ChannelFee)(nil), "composable.ibctransfermiddleware.v1beta1.ChannelFee") proto.RegisterType((*CoinItem)(nil), "composable.ibctransfermiddleware.v1beta1.CoinItem") + proto.RegisterType((*TxPriorityFee)(nil), "composable.ibctransfermiddleware.v1beta1.TxPriorityFee") } func init() { @@ -203,35 +264,39 @@ func init() { } var fileDescriptor_1193893bc248bc1b = []byte{ - // 436 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x41, 0x8b, 0xd4, 0x30, - 0x14, 0xc7, 0x27, 0x3b, 0x32, 0xeb, 0x66, 0x54, 0xb0, 0xae, 0x98, 0x5d, 0x30, 0x0e, 0x73, 0x1a, - 0x04, 0x5b, 0xa6, 0x0a, 0xe2, 0xc1, 0x83, 0xa3, 0x08, 0xde, 0xa4, 0x0e, 0x88, 0x5e, 0x4a, 0xda, - 0xbe, 0xd6, 0x60, 0x93, 0x94, 0x24, 0xee, 0xea, 0xb7, 0xf0, 0x63, 0x78, 0xf4, 0xe0, 0x87, 0xd8, - 0xe3, 0xe2, 0xc9, 0x93, 0xc8, 0xcc, 0xc1, 0xab, 0x1f, 0x41, 0x9a, 0x64, 0x1c, 0x85, 0x15, 0xf4, - 0xd2, 0xe4, 0xbd, 0x5f, 0xff, 0xef, 0xfd, 0x93, 0x3c, 0xfc, 0xa8, 0x54, 0xa2, 0x53, 0x86, 0x15, - 0x2d, 0x24, 0xbc, 0x28, 0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, 0x0b, 0xf2, 0xf9, 0xd3, 0xad, - 0xfd, 0x70, 0xb3, 0x0f, 0x3c, 0x79, 0x66, 0x35, 0x97, 0x4d, 0x86, 0x6b, 0x80, 0x90, 0x89, 0x52, - 0x7c, 0x55, 0x70, 0x99, 0x5b, 0x2e, 0x40, 0xbd, 0xb1, 0x6e, 0x35, 0x96, 0x89, 0x8e, 0x9c, 0x9b, - 0xa0, 0xd9, 0x30, 0xbb, 0x22, 0xb8, 0x5c, 0x7a, 0xb6, 0xdc, 0xa0, 0x29, 0xc7, 0xe7, 0x37, 0x4e, - 0xa2, 0xfb, 0x78, 0xb7, 0xd7, 0xd7, 0x00, 0xee, 0xbc, 0xe3, 0xf4, 0x20, 0x0e, 0x3d, 0xfb, 0xf7, - 0xfb, 0xc3, 0xf9, 0x62, 0xef, 0xe4, 0xeb, 0x8d, 0xc1, 0x87, 0xef, 0x1f, 0x6f, 0xa2, 0x6c, 0x24, - 0xb8, 0xec, 0xaf, 0x8b, 0x62, 0xdc, 0x81, 0x2e, 0x41, 0x5a, 0xd6, 0x00, 0xd9, 0x71, 0x3d, 0x7f, - 0xcb, 0x2c, 0xee, 0x9e, 0xac, 0x28, 0x3a, 0x5d, 0x51, 0xf4, 0x6d, 0x45, 0xd1, 0xfb, 0x35, 0x1d, - 0x9c, 0xae, 0xe9, 0xe0, 0xcb, 0x9a, 0x0e, 0x5e, 0x5e, 0x7f, 0xfb, 0x97, 0xf1, 0xb5, 0xef, 0x3a, - 0x30, 0xc5, 0xc8, 0x0d, 0xc0, 0xed, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x69, 0x03, 0x6b, 0xef, - 0xef, 0x02, 0x00, 0x00, + // 499 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xc1, 0x6f, 0xd3, 0x3e, + 0x14, 0xc7, 0xeb, 0xf6, 0xa7, 0x6e, 0x73, 0xd7, 0x1f, 0xc2, 0x0c, 0x91, 0x55, 0x22, 0x54, 0x3d, + 0x55, 0x48, 0x34, 0x6a, 0x41, 0x9a, 0x38, 0x70, 0xa0, 0x20, 0x10, 0xb7, 0x29, 0x54, 0x42, 0x70, + 0x89, 0x9c, 0xe4, 0x25, 0x58, 0xc4, 0x76, 0x64, 0x9b, 0xad, 0xfb, 0x2f, 0xf8, 0x33, 0x38, 0x72, + 0xe0, 0x8f, 0x98, 0x38, 0x4d, 0x9c, 0x38, 0x21, 0xd4, 0x1e, 0xb8, 0xf2, 0x27, 0xa0, 0x38, 0xee, + 0xba, 0x4a, 0x43, 0xda, 0x2e, 0xb1, 0x9f, 0x3f, 0x79, 0xef, 0xfb, 0xf5, 0x7b, 0x09, 0x7e, 0x9e, + 0x48, 0x5e, 0x4a, 0x4d, 0xe3, 0x02, 0x02, 0x16, 0x27, 0x46, 0x51, 0xa1, 0x33, 0x50, 0x9c, 0xa5, + 0x69, 0x01, 0xc7, 0x54, 0x41, 0x70, 0x34, 0x8e, 0xc1, 0xd0, 0xf1, 0xe5, 0x74, 0x54, 0x2a, 0x69, + 0x24, 0x19, 0xae, 0xab, 0x8c, 0x2e, 0x7f, 0xcf, 0x55, 0xe9, 0xed, 0xe5, 0x32, 0x97, 0x36, 0x29, + 0xa8, 0x76, 0x75, 0x7e, 0x6f, 0x3f, 0x91, 0x9a, 0x4b, 0x1d, 0xd5, 0xa0, 0x0e, 0x1c, 0xf2, 0xeb, + 0x28, 0x88, 0xa9, 0x5e, 0x7b, 0x49, 0x24, 0x13, 0x8e, 0xdf, 0xa4, 0x9c, 0x09, 0x19, 0xd8, 0xa7, + 0x3b, 0xba, 0xe3, 0x52, 0xb8, 0xce, 0x83, 0xa3, 0x71, 0xb5, 0xd4, 0x60, 0x40, 0x71, 0xfb, 0x90, + 0x2a, 0xca, 0x35, 0x79, 0x83, 0x77, 0x93, 0xf7, 0x54, 0x08, 0x28, 0xa2, 0x0c, 0x40, 0x7b, 0xa8, + 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bd, 0x70, 0x42, 0x22, 0x7c, 0xc3, 0xcc, 0xa3, 0x52, 0x31, + 0xa9, 0x98, 0x39, 0xb1, 0x32, 0x2d, 0xdb, 0xb6, 0x83, 0xab, 0xb7, 0x6d, 0x36, 0x3f, 0x74, 0xf9, + 0xd5, 0xf4, 0xba, 0xe6, 0x62, 0x38, 0x30, 0xb8, 0xbb, 0xc1, 0x49, 0x0f, 0x6f, 0xaf, 0xe4, 0xdc, + 0x08, 0xcf, 0x63, 0xf2, 0x12, 0xef, 0x6e, 0x58, 0x69, 0x5e, 0xe3, 0xc6, 0x9d, 0x72, 0x2d, 0x32, + 0x3d, 0x38, 0x5d, 0xf8, 0xe8, 0x6c, 0xe1, 0xa3, 0x5f, 0x0b, 0x1f, 0x7d, 0x5a, 0xfa, 0x8d, 0xb3, + 0xa5, 0xdf, 0xf8, 0xb1, 0xf4, 0x1b, 0xef, 0xee, 0xce, 0xff, 0xf1, 0x5b, 0x9a, 0x93, 0x12, 0x74, + 0xdc, 0xb6, 0x1f, 0xf6, 0xc3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x03, 0x2b, 0x7f, 0xc7, + 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -347,6 +412,20 @@ func (m *CoinItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TxPriorityFee) > 0 { + for iNdEx := len(m.TxPriorityFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TxPriorityFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintIbctransfermiddleware(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } if m.Percentage != 0 { i = encodeVarintIbctransfermiddleware(dAtA, i, uint64(m.Percentage)) i-- @@ -365,6 +444,46 @@ func (m *CoinItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TxPriorityFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TxPriorityFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxPriorityFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PriorityFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintIbctransfermiddleware(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Priority) > 0 { + i -= len(m.Priority) + copy(dAtA[i:], m.Priority) + i = encodeVarintIbctransfermiddleware(dAtA, i, uint64(len(m.Priority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintIbctransfermiddleware(dAtA []byte, offset int, v uint64) int { offset -= sovIbctransfermiddleware(v) base := offset @@ -428,6 +547,27 @@ func (m *CoinItem) Size() (n int) { if m.Percentage != 0 { n += 1 + sovIbctransfermiddleware(uint64(m.Percentage)) } + if len(m.TxPriorityFee) > 0 { + for _, e := range m.TxPriorityFee { + l = e.Size() + n += 1 + l + sovIbctransfermiddleware(uint64(l)) + } + } + return n +} + +func (m *TxPriorityFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Priority) + if l > 0 { + n += 1 + l + sovIbctransfermiddleware(uint64(l)) + } + l = m.PriorityFee.Size() + n += 1 + l + sovIbctransfermiddleware(uint64(l)) return n } @@ -769,6 +909,155 @@ func (m *CoinItem) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxPriorityFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIbctransfermiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxPriorityFee = append(m.TxPriorityFee, &TxPriorityFee{}) + if err := m.TxPriorityFee[len(m.TxPriorityFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipIbctransfermiddleware(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxPriorityFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIbctransfermiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TxPriorityFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxPriorityFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Priority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIbctransfermiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Priority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriorityFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIbctransfermiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthIbctransfermiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriorityFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipIbctransfermiddleware(dAtA[iNdEx:]) diff --git a/x/ibctransfermiddleware/types/keys.go b/x/ibctransfermiddleware/types/keys.go index 353130e94..fde08c421 100644 --- a/x/ibctransfermiddleware/types/keys.go +++ b/x/ibctransfermiddleware/types/keys.go @@ -1,8 +1,17 @@ package types +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/codec" + types "github.com/cosmos/cosmos-sdk/types" +) + // ParamsKey is the key to use for the keeper store. var ( ParamsKey = []byte{0x01} // key for global staking middleware params in the keeper store + + SequenceFeeKey = []byte{0x21} // prefix for sequence fee ) const ( @@ -15,3 +24,28 @@ const ( RouterKey = ModuleName ) + +// GetSequenceKey returns a key prefix for indexing HistoricalInfo objects. +func GetSequenceKey(sequence uint64) []byte { + return append(SequenceFeeKey, []byte(strconv.FormatUint(sequence, 10))...) +} + +func MustMarshalCoin(cdc codec.BinaryCodec, coin *types.Coin) []byte { + return cdc.MustMarshal(coin) +} + +// unmarshal a redelegation from a store value +func MustUnmarshalCoin(cdc codec.BinaryCodec, value []byte) types.Coin { + validator, err := UnmarshalCoin(cdc, value) + if err != nil { + panic(err) + } + + return validator +} + +// unmarshal a redelegation from a store value +func UnmarshalCoin(cdc codec.BinaryCodec, value []byte) (v types.Coin, err error) { + err = cdc.Unmarshal(value, &v) + return v, err +} diff --git a/x/ibctransfermiddleware/types/msg.go b/x/ibctransfermiddleware/types/msg.go index 7634ad065..ccd9431df 100644 --- a/x/ibctransfermiddleware/types/msg.go +++ b/x/ibctransfermiddleware/types/msg.go @@ -101,12 +101,14 @@ func NewMsgAddAllowedIbcToken( channelID string, minFee sdk.Coin, percentage int64, + txPriorityFee []*TxPriorityFee, ) *MsgAddAllowedIbcToken { return &MsgAddAllowedIbcToken{ - Authority: authority, - ChannelID: channelID, - MinFee: minFee, - Percentage: percentage, + Authority: authority, + ChannelID: channelID, + MinFee: minFee, + Percentage: percentage, + TxPriorityFee: txPriorityFee, } } diff --git a/x/ibctransfermiddleware/types/tx.pb.go b/x/ibctransfermiddleware/types/tx.pb.go index d12a72ed3..df5e22149 100644 --- a/x/ibctransfermiddleware/types/tx.pb.go +++ b/x/ibctransfermiddleware/types/tx.pb.go @@ -335,10 +335,11 @@ var xxx_messageInfo_MsgRemoveIBCFeeConfigResponse proto.InternalMessageInfo type MsgAddAllowedIbcToken struct { // authority is the address that controls the module (defaults to x/gov unless // overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` - ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` - MinFee types.Coin `protobuf:"bytes,3,opt,name=min_fee,json=minFee,proto3" json:"min_fee"` - Percentage int64 `protobuf:"varint,4,opt,name=percentage,proto3" json:"percentage,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + MinFee types.Coin `protobuf:"bytes,3,opt,name=min_fee,json=minFee,proto3" json:"min_fee"` + Percentage int64 `protobuf:"varint,4,opt,name=percentage,proto3" json:"percentage,omitempty"` + TxPriorityFee []*TxPriorityFee `protobuf:"bytes,5,rep,name=tx_priority_fee,json=txPriorityFee,proto3" json:"tx_priority_fee,omitempty"` } func (m *MsgAddAllowedIbcToken) Reset() { *m = MsgAddAllowedIbcToken{} } @@ -402,6 +403,13 @@ func (m *MsgAddAllowedIbcToken) GetPercentage() int64 { return 0 } +func (m *MsgAddAllowedIbcToken) GetTxPriorityFee() []*TxPriorityFee { + if m != nil { + return m.TxPriorityFee + } + return nil +} + type MsgAddAllowedIbcTokenResponse struct { } @@ -554,54 +562,57 @@ func init() { } var fileDescriptor_bf5c053de6965bca = []byte{ - // 752 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0x8e, 0x5b, 0x5a, 0x94, 0xab, 0x04, 0xd4, 0xb4, 0x90, 0x46, 0xd4, 0x89, 0x3c, 0x45, 0x95, - 0x48, 0x48, 0x40, 0x54, 0xaa, 0x40, 0x55, 0x7e, 0x50, 0x94, 0x4a, 0x91, 0x50, 0x5a, 0x16, 0x96, - 0xe8, 0x62, 0xbf, 0xb8, 0x16, 0xb9, 0x3b, 0xcb, 0x77, 0xfd, 0x91, 0x0d, 0x31, 0x21, 0x26, 0x16, - 0xd6, 0xae, 0x30, 0x76, 0x60, 0xe2, 0x2f, 0xe8, 0x58, 0xb1, 0xc0, 0x14, 0xa1, 0x74, 0xe8, 0xc6, - 0xd0, 0x1d, 0x09, 0xc5, 0xe7, 0x38, 0x6d, 0xe2, 0x48, 0x4d, 0x3b, 0xd0, 0x25, 0xb6, 0xdf, 0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f, 0x5d, 0xa5, 0x3a, 0xe0, 0xb5, 0xaf, 0x20, 0x35, 0xc4, 0x27, 0x56, 0xc7, - 0x02, 0x1f, 0x06, 0x88, 0xbf, 0xbc, 0x22, 0xc0, 0x39, 0x82, 0x21, 0x36, 0xb0, 0x3a, 0x6e, 0xf7, - 0x03, 0x00, 0x63, 0x12, 0x1c, 0xbd, 0x89, 0xde, 0x77, 0x30, 0x7c, 0x0d, 0x0b, 0x97, 0xd0, 0x60, - 0x90, 0xe6, 0xfa, 0xd5, 0x31, 0x7a, 0x4c, 0xe3, 0x53, 0xef, 0xba, 0x9e, 0x54, 0x58, 0x3e, 0xec, - 0x68, 0xca, 0x51, 0x47, 0x53, 0x7e, 0x77, 0x34, 0xe5, 0xd3, 0xb1, 0x16, 0x39, 0x3a, 0xd6, 0x22, - 0xbf, 0x8e, 0xb5, 0xc8, 0x9b, 0xc5, 0x51, 0xbf, 0xd6, 0xa2, 0xe5, 0x00, 0xaf, 0x4f, 0x7b, 0xff, - 0x4d, 0x1e, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x96, 0xfe, 0x14, 0xbd, 0x09, 0x00, 0x00, + // 789 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xbf, 0x6f, 0xda, 0x5a, + 0x14, 0xc6, 0xe1, 0x91, 0x27, 0x2e, 0x7a, 0x2f, 0x2f, 0x7e, 0xc9, 0x7b, 0x04, 0x35, 0x06, 0x79, + 0x42, 0x91, 0x0a, 0x85, 0x56, 0x8d, 0x14, 0xb5, 0x8a, 0xf8, 0xd1, 0x54, 0x44, 0x42, 0x8a, 0x1c, + 0xba, 0x74, 0x41, 0xc6, 0x3e, 0x38, 0x56, 0xf1, 0xbd, 0x96, 0xef, 0x4d, 0x02, 0x5b, 0xd5, 0xa9, + 0xea, 0xd4, 0xa5, 0x6b, 0xd6, 0x76, 0xcc, 0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f2, 0x86, 0x4d, 0xea, 0x75, 0x93, + 0x91, 0x72, 0x3f, 0x10, 0x5c, 0xc9, 0x5f, 0x9e, 0x68, 0x9d, 0xaf, 0x9a, 0xc0, 0xc6, 0x06, 0xdd, + 0xe7, 0xbf, 0x2c, 0xa2, 0x70, 0x95, 0x1a, 0xe2, 0x47, 0x01, 0xad, 0x06, 0x2f, 0xe1, 0xe2, 0xec, + 0xc6, 0x4c, 0x5b, 0xe4, 0x89, 0xdd, 0x1b, 0x60, 0x4c, 0x59, 0x8e, 0xe2, 0x07, 0x01, 0x2d, 0x8d, + 0x6f, 0xc6, 0x27, 0x73, 0xe1, 0x8f, 0x55, 0x27, 0xca, 0xb7, 0xa9, 0xf6, 0x79, 0x9d, 0x08, 0x48, + 0x0c, 0x58, 0x44, 0xdb, 0x73, 0x81, 0x4f, 0x02, 0x24, 0x9e, 0xdf, 0x12, 0xe0, 0x1a, 0xc1, 0x80, + 0x3d, 0xb3, 0x3d, 0x6f, 0xf7, 0x63, 0x00, 0x73, 0x12, 0x9c, 0x3e, 0x89, 0xee, 0x7f, 0x30, 0x78, + 0x0c, 0x8b, 0x37, 0xd0, 0x60, 0x9c, 0xe6, 0xee, 0xed, 0x31, 0x06, 0x4c, 0x13, 0x91, 0xd7, 0xfd, + 0xa5, 0x57, 0xdc, 0x3c, 0xeb, 0x49, 0xc2, 0x79, 0x4f, 0x12, 0x7e, 0xf4, 0x24, 0xe1, 0xfd, 0x85, + 0x14, 0x3a, 0xbf, 0x90, 0x42, 0xdf, 0x2f, 0xa4, 0xd0, 0xcb, 0xf5, 0x69, 0x9f, 0x03, 0xac, 0x63, + 0x03, 0x6d, 0x2c, 0xba, 0x1f, 0x3f, 0x0f, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x24, 0x32, 0x1d, + 0x8f, 0x1e, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1043,6 +1054,20 @@ func (m *MsgAddAllowedIbcToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TxPriorityFee) > 0 { + for iNdEx := len(m.TxPriorityFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TxPriorityFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } if m.Percentage != 0 { i = encodeVarintTx(dAtA, i, uint64(m.Percentage)) i-- @@ -1278,6 +1303,12 @@ func (m *MsgAddAllowedIbcToken) Size() (n int) { if m.Percentage != 0 { n += 1 + sovTx(uint64(m.Percentage)) } + if len(m.TxPriorityFee) > 0 { + for _, e := range m.TxPriorityFee { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -2015,6 +2046,40 @@ func (m *MsgAddAllowedIbcToken) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxPriorityFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxPriorityFee = append(m.TxPriorityFee, &TxPriorityFee{}) + if err := m.TxPriorityFee[len(m.TxPriorityFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/transfermiddleware/ibc_middleware.go b/x/transfermiddleware/ibc_middleware.go index 0ea26e722..a03ada9af 100644 --- a/x/transfermiddleware/ibc_middleware.go +++ b/x/transfermiddleware/ibc_middleware.go @@ -127,39 +127,22 @@ func (im IBCMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Pac return err } - denom := data.Denom - coin := im.keeper.IbcTransfermiddleware.GetCoin(ctx, packet.SourceChannel, denom) - сhannelFeeAddress := im.keeper.IbcTransfermiddleware.GetChannelFeeAddress(ctx, packet.SourceChannel) - if coin != nil { - amount := data.Amount - transferAmount, ok := sdk.NewIntFromString(amount) - if !ok { - return errors.Wrapf(transfertypes.ErrInvalidAmount, "unable to parse transfer amount: %s", amount) + fee, found := im.keeper.IbcTransfermiddleware.GetSequenceFee(ctx, packet.Sequence) + if found { + сhannelFeeAddress := im.keeper.IbcTransfermiddleware.GetChannelFeeAddress(ctx, packet.SourceChannel) + if сhannelFeeAddress == "" { + return nil } - // calculate the percentage charge - /* - coin.Percentage is 100 that means that we charge 1/100 of the transfer amount - coin.MinFee.Amount is the minimum fee that we charge - the new amount is the transfer amount minus the percentage charge and the minimum fee - transfer amount is a 99/100 of the original amount - so to get the fee we charge transferAmount.QuoRaw(coin.Percentage - 1) + coin.MinFee.Amount - */ - - percentageCharge := sdk.NewInt(0) - if coin.Percentage > 1 { - percentageCharge = transferAmount.QuoRaw(coin.Percentage - 1) - } - percentageCharge = percentageCharge.Add(coin.MinFee.Amount) - fee_address, err := sdk.AccAddressFromBech32(сhannelFeeAddress) if err != nil { - return errors.Wrapf(err, "failed to decode receiver address: %s", сhannelFeeAddress) + return nil } - refund_fee := sdk.NewCoin(denom, percentageCharge) - im.keeper.RefundChannelCosmosFee(ctx, fee_address, sdk.AccAddress(data.Sender), []sdk.Coin{refund_fee}) - + refund_err := im.keeper.RefundChannelCosmosFee(ctx, fee_address, sdk.AccAddress(data.Sender), []sdk.Coin{fee}) + if refund_err == nil { + im.keeper.IbcTransfermiddleware.DeleteSequenceFee(ctx, packet.Sequence) + } } return nil @@ -181,6 +164,8 @@ func (im IBCMiddleware) OnAcknowledgementPacket( return err } + im.keeper.IbcTransfermiddleware.DeleteSequenceFee(ctx, packet.Sequence) + return nil }