Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge v6.5.3 #491

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/upgrades/v6_5_3/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v6_5_3

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_3"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
},
}
23 changes: 23 additions & 0 deletions app/upgrades/v6_5_3/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package v6_5_3

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)
}
}
10 changes: 3 additions & 7 deletions proto/composable/ibctransfermiddleware/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "composable/ibctransfermiddleware/v1beta1/ibctransfermiddleware.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "x/ibctransfermiddleware/types";

Expand Down Expand Up @@ -103,14 +104,9 @@ message MsgAddAllowedIbcToken {
(gogoproto.customname) = "ChannelID"
];

string denom = 3 [
(gogoproto.moretags) = "yaml:\"channel_id\"",
(gogoproto.customname) = "Denom"
];

int64 amount = 4;
cosmos.base.v1beta1.Coin min_fee = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

int64 percentage = 5;
int64 percentage = 4;
}

message MsgAddAllowedIbcTokenResponse {}
Expand Down
24 changes: 11 additions & 13 deletions x/ibctransfermiddleware/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/cosmos/cosmos-sdk/version"
"github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
"github.com/spf13/cobra"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// GetTxCmd returns the tx commands for staking middleware module.
Expand Down Expand Up @@ -75,28 +77,25 @@ func AddIBCFeeConfig() *cobra.Command {

func AddAllowedIbcToken() *cobra.Command {
cmd := &cobra.Command{
Use: "add-allowed-ibc-token [channel] [denom] [amount] [percentage]",
Use: "add-allowed-ibc-token [channel] [percentage] [coin]",
Short: "add allowed ibc token",
Args: cobra.MatchAll(cobra.ExactArgs(4), cobra.OnlyValidArgs),
Example: fmt.Sprintf("%s tx ibctransfermiddleware add-allowed-ibc-token [channel] [denom] [amount] [percentage] (percentage '5' means 1/5 of amount will be taken as fee) ", version.AppName),
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),
RunE: func(cmd *cobra.Command, args []string) error {
channel := args[0]
denom := args[1]
amount := args[2]
percentage := args[3]

clientCtx, err := client.GetClientTxContext(cmd)
percentage := args[1]
coin, err := sdk.ParseCoinNormalized(args[2])
if err != nil {
return err
}

fromAddress := clientCtx.GetFromAddress().String()

amountInt, err := strconv.ParseInt(amount, 10, 64)
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

fromAddress := clientCtx.GetFromAddress().String()

percentageInt, errPercentage := strconv.ParseInt(percentage, 10, 64)
if errPercentage != nil {
return errPercentage
Expand All @@ -105,8 +104,7 @@ func AddAllowedIbcToken() *cobra.Command {
msg := types.NewMsgAddAllowedIbcToken(
fromAddress,
channel,
denom,
amountInt,
coin,
percentageInt,
)

Expand Down
15 changes: 4 additions & 11 deletions x/ibctransfermiddleware/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,14 @@ func (ms msgServer) AddAllowedIbcToken(goCtx context.Context, req *types.MsgAddA
params := ms.Keeper.GetParams(ctx)
channelFee := findChannelParams(params.ChannelFees, req.ChannelID)
if channelFee != nil {
coin := findCoinByDenom(channelFee.AllowedTokens, req.Denom)
coin := findCoinByDenom(channelFee.AllowedTokens, req.MinFee.Denom)
if coin != nil {
coin_c := sdk.Coin{
Denom: req.Denom,
Amount: sdk.NewInt(req.Amount),
}
coin.MinFee = coin_c
coin.MinFee = req.MinFee
coin.Percentage = req.Percentage
} else {
coin_c := sdk.Coin{
Denom: req.Denom,
Amount: sdk.NewInt(req.Amount),
}

coin := &types.CoinItem{
MinFee: coin_c,
MinFee: req.MinFee,
Percentage: req.Percentage,
}
channelFee.AllowedTokens = append(channelFee.AllowedTokens, coin)
Expand Down
6 changes: 2 additions & 4 deletions x/ibctransfermiddleware/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ var _ sdk.Msg = &MsgAddAllowedIbcToken{}
func NewMsgAddAllowedIbcToken(
authority string,
channelID string,
denom string,
amount int64,
minFee sdk.Coin,
percentage int64,
) *MsgAddAllowedIbcToken {
return &MsgAddAllowedIbcToken{
Authority: authority,
ChannelID: channelID,
Denom: denom,
Amount: amount,
MinFee: minFee,
Percentage: percentage,
}
}
Expand Down
Loading
Loading