From f39bfedb87ccbd498c40f8e4684548d2e7065c45 Mon Sep 17 00:00:00 2001 From: kenta-elys Date: Tue, 26 Sep 2023 10:11:23 +0000 Subject: [PATCH] chore: add more unit tests in vesting --- app/app.go | 1 + docs/static/openapi.yml | 2 + proto/elys/commitment/tx.proto | 27 +- testutil/keeper/commitment.go | 5 + x/amm/keeper/keeper.go | 10 +- x/commitment/client/cli/tx.go | 1 + .../client/cli/tx_update_vesting_info.go | 137 ++++ .../client/cli/tx_update_vesting_info_test.go | 50 ++ x/commitment/keeper/epoch_hooks.go | 2 +- x/commitment/keeper/keeper.go | 3 + x/commitment/keeper/msg_server_cancel_vest.go | 2 +- .../keeper/msg_server_cancel_vest_test.go | 1 + .../keeper/msg_server_uncommit_tokens.go | 2 +- .../keeper/msg_server_update_vesting_info.go | 59 ++ .../msg_server_update_vesting_info_test.go | 92 +++ x/commitment/keeper/msg_server_vest.go | 2 +- x/commitment/keeper/msg_server_vest_now.go | 2 +- .../keeper/msg_server_vest_now_test.go | 1 + x/commitment/keeper/msg_server_vest_test.go | 83 +++ x/commitment/keeper/params.go | 8 +- x/commitment/keeper/params_test.go | 11 +- x/commitment/module_simulation.go | 15 + .../simulation/update_vesting_info.go | 29 + x/commitment/types/codec.go | 4 + x/commitment/types/interfaces.go | 2 +- .../types/message_update_vesting_info.go | 51 ++ .../types/message_update_vesting_info_test.go | 40 + x/commitment/types/tx.pb.go | 704 +++++++++++++++++- 28 files changed, 1289 insertions(+), 57 deletions(-) create mode 100644 x/commitment/client/cli/tx_update_vesting_info.go create mode 100644 x/commitment/client/cli/tx_update_vesting_info_test.go create mode 100644 x/commitment/keeper/msg_server_update_vesting_info.go create mode 100644 x/commitment/keeper/msg_server_update_vesting_info_test.go create mode 100644 x/commitment/simulation/update_vesting_info.go create mode 100644 x/commitment/types/message_update_vesting_info.go create mode 100644 x/commitment/types/message_update_vesting_info_test.go diff --git a/app/app.go b/app/app.go index 5e1252ee3..d1f55b11d 100644 --- a/app/app.go +++ b/app/app.go @@ -690,6 +690,7 @@ func NewElysApp( app.BankKeeper, app.StakingKeeper, app.AssetprofileKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.AccountedPoolKeeper = *accountedpoolmodulekeeper.NewKeeper( diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index aed809ee4..40e22c878 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -78582,6 +78582,8 @@ definitions: type: object elys.commitment.MsgUncommitTokensResponse: type: object + elys.commitment.MsgUpdateVestingInfoResponse: + type: object elys.commitment.MsgVestNowResponse: type: object elys.commitment.MsgVestResponse: diff --git a/proto/elys/commitment/tx.proto b/proto/elys/commitment/tx.proto index 96ef76dd2..b437c9228 100644 --- a/proto/elys/commitment/tx.proto +++ b/proto/elys/commitment/tx.proto @@ -8,13 +8,14 @@ option go_package = "github.com/elys-network/elys/x/commitment/types"; // Msg defines the Msg service. service Msg { - rpc CommitTokens (MsgCommitTokens ) returns (MsgCommitTokensResponse ); - rpc UncommitTokens (MsgUncommitTokens) returns (MsgUncommitTokensResponse); - rpc WithdrawTokens (MsgWithdrawTokens) returns (MsgWithdrawTokensResponse); - rpc DepositTokens (MsgDepositTokens ) returns (MsgDepositTokensResponse ); - rpc Vest (MsgVest ) returns (MsgVestResponse ); - rpc CancelVest (MsgCancelVest ) returns (MsgCancelVestResponse ); - rpc VestNow (MsgVestNow ) returns (MsgVestNowResponse ); + rpc CommitTokens (MsgCommitTokens ) returns (MsgCommitTokensResponse ); + rpc UncommitTokens (MsgUncommitTokens ) returns (MsgUncommitTokensResponse ); + rpc WithdrawTokens (MsgWithdrawTokens ) returns (MsgWithdrawTokensResponse ); + rpc DepositTokens (MsgDepositTokens ) returns (MsgDepositTokensResponse ); + rpc Vest (MsgVest ) returns (MsgVestResponse ); + rpc CancelVest (MsgCancelVest ) returns (MsgCancelVestResponse ); + rpc VestNow (MsgVestNow ) returns (MsgVestNowResponse ); + rpc UpdateVestingInfo (MsgUpdateVestingInfo) returns (MsgUpdateVestingInfoResponse); } message MsgCommitTokens { string creator = 1; @@ -72,3 +73,15 @@ message MsgVestNow { message MsgVestNowResponse {} +message MsgUpdateVestingInfo { + string authority = 1; + string baseDenom = 2; + string vestingDenom = 3; + string epochIdentifier = 4; + string numEpochs = 5; + string vestNowFactor = 6; + string numMaxVestings = 7; +} + +message MsgUpdateVestingInfoResponse {} + diff --git a/testutil/keeper/commitment.go b/testutil/keeper/commitment.go index 2810f95ce..fbb32b037 100644 --- a/testutil/keeper/commitment.go +++ b/testutil/keeper/commitment.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/elys-network/elys/x/commitment/keeper" "github.com/elys-network/elys/x/commitment/types" @@ -36,6 +37,9 @@ func CommitmentKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { memStoreKey, "CommitmentParams", ) + + govAddress := sdk.AccAddress(address.Module("gov")) + k := keeper.NewKeeper( cdc, storeKey, @@ -44,6 +48,7 @@ func CommitmentKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + govAddress.String(), ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/amm/keeper/keeper.go b/x/amm/keeper/keeper.go index c2f72f49b..599f4c3b4 100644 --- a/x/amm/keeper/keeper.go +++ b/x/amm/keeper/keeper.go @@ -54,11 +54,11 @@ func NewKeeper( transientStoreKey: transientStoreKey, paramstore: ps, - bankKeeper: bankKeeper, - accountKeeper: accountKeeper, - oracleKeeper: oracleKeeper, - commitmentKeeper: commitmentKeeper, - apKeeper: apKeeper, + bankKeeper: bankKeeper, + accountKeeper: accountKeeper, + oracleKeeper: oracleKeeper, + commitmentKeeper: commitmentKeeper, + apKeeper: apKeeper, accountedPoolKeeper: accountedPoolKeeper, } } diff --git a/x/commitment/client/cli/tx.go b/x/commitment/client/cli/tx.go index 29547883d..3632e9422 100644 --- a/x/commitment/client/cli/tx.go +++ b/x/commitment/client/cli/tx.go @@ -37,6 +37,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdVest()) cmd.AddCommand(CmdCancelVest()) cmd.AddCommand(CmdVestNow()) + cmd.AddCommand(CmdUpdateVestingInfo()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/commitment/client/cli/tx_update_vesting_info.go b/x/commitment/client/cli/tx_update_vesting_info.go new file mode 100644 index 000000000..741b9123d --- /dev/null +++ b/x/commitment/client/cli/tx_update_vesting_info.go @@ -0,0 +1,137 @@ +package cli + +import ( + "errors" + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/elys-network/elys/x/commitment/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdUpdateVestingInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-vesting-info", + Short: "Broadcast message update-vesting-info", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + title, err := cmd.Flags().GetString(cli.FlagTitle) + if err != nil { + return err + } + + summary, err := cmd.Flags().GetString(cli.FlagSummary) + if err != nil { + return err + } + + metadata, err := cmd.Flags().GetString(cli.FlagMetadata) + if err != nil { + return err + } + + argBaseDenom, err := cmd.Flags().GetString("base-denom") + if err != nil { + return err + } + + argVestingDenom, err := cmd.Flags().GetString("vesting-denom") + if err != nil { + return err + } + + argEpochIdentifier, err := cmd.Flags().GetString("epoch-identifier") + if err != nil { + return err + } + + argNumEpochs, err := cmd.Flags().GetString("num-epochs") + if err != nil { + return err + } + + argVestNowFactor, err := cmd.Flags().GetString("vest-now-factor") + if err != nil { + return err + } + + argNumMaxVestings, err := cmd.Flags().GetString("num-max-vestings") + if err != nil { + return err + } + + signer := clientCtx.GetFromAddress() + if signer == nil { + return errors.New("signer address is missing") + } + + govAddress := sdk.AccAddress(address.Module("gov")) + msg := types.NewMsgUpdateVestingInfo( + govAddress.String(), + argBaseDenom, + argVestingDenom, + argEpochIdentifier, + argNumEpochs, + argVestNowFactor, + argNumMaxVestings, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + + depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) + if err != nil { + return err + } + + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + govMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{msg}, deposit, signer.String(), metadata, title, summary) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), govMsg) + }, + } + + cmd.Flags().String("base-denom", "", "base denom (string)") + cmd.Flags().String("vesting-denom", "", "vesting-denom (string)") + cmd.Flags().String("epoch-identifier", "", "epoch-identifier (string)") + cmd.Flags().String("num-epochs", "", "num-epochs (int64)") + cmd.Flags().String("vest-now-factor", "", "vest-now-factor (decimal)") + cmd.Flags().String("num-max-vestings", "", "num-max-vestings (int64)") + cmd.Flags().String(cli.FlagTitle, "", "title of proposal") + cmd.Flags().String(cli.FlagSummary, "", "summary of proposal") + cmd.Flags().String(cli.FlagMetadata, "", "metadata of proposal") + cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") + _ = cmd.MarkFlagRequired("base-denom") + _ = cmd.MarkFlagRequired("vesting-denom") + _ = cmd.MarkFlagRequired("epoch-identifier") + _ = cmd.MarkFlagRequired("num-epochs") + _ = cmd.MarkFlagRequired("vest-now-factor") + _ = cmd.MarkFlagRequired("num-max-vestings") + _ = cmd.MarkFlagRequired(cli.FlagTitle) + _ = cmd.MarkFlagRequired(cli.FlagSummary) + _ = cmd.MarkFlagRequired(cli.FlagMetadata) + _ = cmd.MarkFlagRequired(cli.FlagDeposit) + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/commitment/client/cli/tx_update_vesting_info_test.go b/x/commitment/client/cli/tx_update_vesting_info_test.go new file mode 100644 index 000000000..de1b56425 --- /dev/null +++ b/x/commitment/client/cli/tx_update_vesting_info_test.go @@ -0,0 +1,50 @@ +package cli_test + +import ( + "strconv" + "testing" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + + "github.com/elys-network/elys/testutil/network" + "github.com/elys-network/elys/x/commitment/client/cli" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func setupNetwork(t *testing.T) *network.Network { + t.Helper() + + cfg := network.DefaultConfig() + return network.New(t, cfg) +} + +func TestGovUpdateVestingInfo(t *testing.T) { + net := setupNetwork(t) + ctx := net.Validators[0].ClientCtx + val := net.Validators[0] + + // Use baseURL to make API HTTP requests or use val.RPCClient to make direct + // Tendermint RPC calls. + // ... + + args := []string{ + "--title=test", + "--summary=test", + "--metadata=test", + "--deposit=1000000uelys", + "--base-denom=ueden", + "--vesting-denom=uelys", + "--epoch-identifier=day", + "--num-epochs=100", + "--vest-now-factor=1", + "--num-max-vestings=10", + "--from=" + val.Address.String(), + "-y", + } + + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateVestingInfo(), args) + require.NoError(t, err) +} diff --git a/x/commitment/keeper/epoch_hooks.go b/x/commitment/keeper/epoch_hooks.go index ca6382b04..043a7c871 100644 --- a/x/commitment/keeper/epoch_hooks.go +++ b/x/commitment/keeper/epoch_hooks.go @@ -14,7 +14,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ int64) // Future Improvement: check all VestingInfos and get all VestingTokens by denom // so we can iterate different denoms in different EpochIdentifiers - vestingInfo := k.GetVestingInfo(ctx, ptypes.Eden) + vestingInfo, _ := k.GetVestingInfo(ctx, ptypes.Eden) if vestingInfo != nil { if epochIdentifier == vestingInfo.EpochIdentifier { k.Logger(ctx).Info("Vesting tokens for vestingInfo", vestingInfo) diff --git a/x/commitment/keeper/keeper.go b/x/commitment/keeper/keeper.go index 5dec66768..a68421ac7 100644 --- a/x/commitment/keeper/keeper.go +++ b/x/commitment/keeper/keeper.go @@ -56,6 +56,7 @@ type ( bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper apKeeper types.AssetProfileKeeper + authority string } ) @@ -68,6 +69,7 @@ func NewKeeper( bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, apKeeper types.AssetProfileKeeper, + authority string, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -83,6 +85,7 @@ func NewKeeper( bankKeeper: bankKeeper, stakingKeeper: stakingKeeper, apKeeper: apKeeper, + authority: authority, } } diff --git a/x/commitment/keeper/msg_server_cancel_vest.go b/x/commitment/keeper/msg_server_cancel_vest.go index b53a9aecc..8a9a54ded 100644 --- a/x/commitment/keeper/msg_server_cancel_vest.go +++ b/x/commitment/keeper/msg_server_cancel_vest.go @@ -12,7 +12,7 @@ import ( func (k msgServer) CancelVest(goCtx context.Context, msg *types.MsgCancelVest) (*types.MsgCancelVestResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - vestingInfo := k.GetVestingInfo(ctx, msg.Denom) + vestingInfo, _ := k.GetVestingInfo(ctx, msg.Denom) if vestingInfo == nil { return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom: %s", msg.Denom) diff --git a/x/commitment/keeper/msg_server_cancel_vest_test.go b/x/commitment/keeper/msg_server_cancel_vest_test.go index 8781f5cf8..983519cef 100644 --- a/x/commitment/keeper/msg_server_cancel_vest_test.go +++ b/x/commitment/keeper/msg_server_cancel_vest_test.go @@ -30,6 +30,7 @@ func TestCancelVest(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } diff --git a/x/commitment/keeper/msg_server_uncommit_tokens.go b/x/commitment/keeper/msg_server_uncommit_tokens.go index 53023c630..f10a1238b 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens.go @@ -63,7 +63,7 @@ func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitT if msg.Denom == ptypes.Eden { k.EdenUncommitted(ctx, msg.Creator, sdk.NewCoin(msg.Denom, msg.Amount)) } - + // Emit blockchain event ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/commitment/keeper/msg_server_update_vesting_info.go b/x/commitment/keeper/msg_server_update_vesting_info.go new file mode 100644 index 000000000..00cc45cb5 --- /dev/null +++ b/x/commitment/keeper/msg_server_update_vesting_info.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "context" + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/elys-network/elys/x/commitment/types" +) + +func (k msgServer) UpdateVestingInfo(goCtx context.Context, msg *types.MsgUpdateVestingInfo) (*types.MsgUpdateVestingInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if k.authority != msg.Authority { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + numEpochs, err := strconv.ParseInt(msg.NumEpochs, 10, 64) + if err != nil { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidProposalMsg, "invalid proposal; %s", msg.NumEpochs) + } + + vestNowFactor, err := strconv.ParseInt(msg.VestNowFactor, 10, 64) + if err != nil { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidProposalMsg, "invalid proposal; %s", msg.VestNowFactor) + } + + maxVestings, err := strconv.ParseInt(msg.NumMaxVestings, 10, 64) + if err != nil { + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidProposalMsg, "invalid proposal; %s", msg.NumMaxVestings) + } + + params := k.GetParams(ctx) + vestingInfo, index := k.GetVestingInfo(ctx, msg.BaseDenom) + if vestingInfo == nil { + vestingInfo = &types.VestingInfo{ + BaseDenom: msg.BaseDenom, + VestingDenom: msg.VestingDenom, + EpochIdentifier: msg.EpochIdentifier, + NumEpochs: numEpochs, + VestNowFactor: sdk.NewInt(vestNowFactor), + NumMaxVestings: maxVestings, + } + params.VestingInfos = append(params.VestingInfos, vestingInfo) + } else { + params.VestingInfos[index].BaseDenom = msg.BaseDenom + params.VestingInfos[index].VestingDenom = msg.VestingDenom + params.VestingInfos[index].EpochIdentifier = msg.EpochIdentifier + params.VestingInfos[index].NumEpochs = numEpochs + params.VestingInfos[index].VestNowFactor = sdk.NewInt(vestNowFactor) + params.VestingInfos[index].NumMaxVestings = maxVestings + } + + // store params + k.SetParams(ctx, params) + return &types.MsgUpdateVestingInfoResponse{}, nil +} diff --git a/x/commitment/keeper/msg_server_update_vesting_info_test.go b/x/commitment/keeper/msg_server_update_vesting_info_test.go new file mode 100644 index 000000000..66683811e --- /dev/null +++ b/x/commitment/keeper/msg_server_update_vesting_info_test.go @@ -0,0 +1,92 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/elys-network/elys/app" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + "github.com/elys-network/elys/x/commitment/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestAddVestingInfo(t *testing.T) { + app := app.InitElysTestApp(true) + + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + // Create a test context and keeper + keeper := app.CommitmentKeeper + msgServer := commitmentkeeper.NewMsgServerImpl(keeper) + + govAddress := sdk.AccAddress(address.Module("gov")) + + // Define the test data + signer := govAddress.String() + + // Call the Update Vesting Info function + msg := types.MsgUpdateVestingInfo{ + Authority: signer, + BaseDenom: "test_denom", + VestingDenom: "test_denom", + EpochIdentifier: "day", + NumEpochs: "10", + VestNowFactor: "10", + NumMaxVestings: "10", + } + _, err := msgServer.UpdateVestingInfo(ctx, &msg) + require.NoError(t, err) + + // Check if the vesting info has been added to the store + vestingInfo, _ := keeper.GetVestingInfo(ctx, "test_denom") + assert.Equal(t, vestingInfo.BaseDenom, "test_denom", "Incorrect denom") +} + +func TestUpdateVestingInfo(t *testing.T) { + app := app.InitElysTestApp(true) + + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + // Create a test context and keeper + keeper := app.CommitmentKeeper + msgServer := commitmentkeeper.NewMsgServerImpl(keeper) + + govAddress := sdk.AccAddress(address.Module("gov")) + + // Define the test data + signer := govAddress.String() + vestingInfo := &types.VestingInfo{ + BaseDenom: "test_denom", + VestingDenom: "test_denom", + EpochIdentifier: "month", + NumEpochs: 10, + VestNowFactor: sdk.NewInt(10), + NumMaxVestings: 10, + } + + params := keeper.GetParams(ctx) + params.VestingInfos = append(params.VestingInfos, vestingInfo) + keeper.SetParams(ctx, params) + + vestingInfo, _ = keeper.GetVestingInfo(ctx, "test_denom") + assert.Equal(t, vestingInfo.BaseDenom, "test_denom", "Incorrect denom") + + // Call the UncommitTokens function + msg := types.MsgUpdateVestingInfo{ + Authority: signer, + BaseDenom: "test_denom", + VestingDenom: "test_denom", + EpochIdentifier: "day", + NumEpochs: "10", + VestNowFactor: "10", + NumMaxVestings: "10", + } + _, err := msgServer.UpdateVestingInfo(ctx, &msg) + require.NoError(t, err) + + // Check if the committed tokens have been added to the store + vestingInfo, _ = keeper.GetVestingInfo(ctx, "test_denom") + assert.Equal(t, vestingInfo.EpochIdentifier, "day", "Incorrect epoch identifier") +} diff --git a/x/commitment/keeper/msg_server_vest.go b/x/commitment/keeper/msg_server_vest.go index 02471b4c1..327ab46b7 100644 --- a/x/commitment/keeper/msg_server_vest.go +++ b/x/commitment/keeper/msg_server_vest.go @@ -12,7 +12,7 @@ import ( func (k msgServer) Vest(goCtx context.Context, msg *types.MsgVest) (*types.MsgVestResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - vestingInfo := k.GetVestingInfo(ctx, msg.Denom) + vestingInfo, _ := k.GetVestingInfo(ctx, msg.Denom) if vestingInfo == nil { return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom: %s", msg.Denom) diff --git a/x/commitment/keeper/msg_server_vest_now.go b/x/commitment/keeper/msg_server_vest_now.go index 378465b4c..42e9b474c 100644 --- a/x/commitment/keeper/msg_server_vest_now.go +++ b/x/commitment/keeper/msg_server_vest_now.go @@ -11,7 +11,7 @@ import ( func (k msgServer) VestNow(goCtx context.Context, msg *types.MsgVestNow) (*types.MsgVestNowResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - vestingInfo := k.GetVestingInfo(ctx, msg.Denom) + vestingInfo, _ := k.GetVestingInfo(ctx, msg.Denom) if vestingInfo == nil { return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom: %s", msg.Denom) diff --git a/x/commitment/keeper/msg_server_vest_now_test.go b/x/commitment/keeper/msg_server_vest_now_test.go index 876528c01..d83781457 100644 --- a/x/commitment/keeper/msg_server_vest_now_test.go +++ b/x/commitment/keeper/msg_server_vest_now_test.go @@ -38,6 +38,7 @@ func TestVestNow(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } diff --git a/x/commitment/keeper/msg_server_vest_test.go b/x/commitment/keeper/msg_server_vest_test.go index e1111347a..257710db4 100644 --- a/x/commitment/keeper/msg_server_vest_test.go +++ b/x/commitment/keeper/msg_server_vest_test.go @@ -6,6 +6,7 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/elys-network/elys/app" commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" "github.com/elys-network/elys/x/commitment/types" @@ -37,6 +38,7 @@ func TestVest(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } @@ -104,3 +106,84 @@ func TestVest(t *testing.T) { committedToken = newCommitments.GetCommittedAmountForDenom(vestMsg.Denom) require.Equal(t, sdk.NewInt(0), committedToken, "committed tokens were not updated correctly") } + +func TestExceedVesting(t *testing.T) { + app := app.InitElysTestApp(true) + + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + // Create a test context and keeper + keeper := app.CommitmentKeeper + + msgServer := commitmentkeeper.NewMsgServerImpl(keeper) + + // Create a new account + creator, _ := sdk.AccAddressFromBech32("cosmos1xv9tklw7d82sezh9haa573wufgy59vmwe6xxe5") + acc := app.AccountKeeper.GetAccount(ctx, creator) + if acc == nil { + acc = app.AccountKeeper.NewAccountWithAddress(ctx, creator) + app.AccountKeeper.SetAccount(ctx, acc) + } + + vestingInfos := []*types.VestingInfo{ + { + BaseDenom: ptypes.Eden, + VestingDenom: ptypes.Elys, + EpochIdentifier: "tenseconds", + NumEpochs: 10, + VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 1, + }, + } + + params := types.Params{ + VestingInfos: vestingInfos, + } + + keeper.SetParams(ctx, params) + + // Create a vesting message + vestMsg := &types.MsgVest{ + Creator: creator.String(), + Denom: ptypes.Eden, + Amount: sdk.NewInt(100), + } + + // Set up the commitments for the creator + commitments := types.Commitments{ + Creator: creator.String(), + CommittedTokens: []*types.CommittedTokens{ + { + Denom: ptypes.Eden, + Amount: sdk.NewInt(50), + }, + }, + UncommittedTokens: []*types.UncommittedTokens{ + { + Denom: ptypes.Eden, + Amount: sdk.NewInt(150), + }, + }, + } + keeper.SetCommitments(ctx, commitments) + + // Execute the Vest function + _, err := msgServer.Vest(ctx, vestMsg) + require.NoError(t, err) + + // Check if the vesting tokens were added to commitments + newCommitments, found := keeper.GetCommitments(ctx, vestMsg.Creator) + require.True(t, found, "commitments not found") + require.Len(t, newCommitments.VestingTokens, 1, "vesting tokens were not added") + + // Check if the uncommitted tokens were updated correctly + uncommittedToken := newCommitments.GetUncommittedAmountForDenom(vestMsg.Denom) + require.Equal(t, sdk.NewInt(50), uncommittedToken, "uncommitted tokens were not updated correctly") + + // Check if the committed tokens were updated correctly + committedToken := newCommitments.GetCommittedAmountForDenom(vestMsg.Denom) + require.Equal(t, sdk.NewInt(50), committedToken, "committed tokens were not updated correctly") + + // Execute the Vest again and it should endfunction + _, err = msgServer.Vest(ctx, vestMsg) + require.EqualError(t, err, sdkerrors.Wrapf(types.ErrExceedMaxVestings, "creator: %s", vestMsg.Creator).Error(), "exceed vesting not worked properly") +} diff --git a/x/commitment/keeper/params.go b/x/commitment/keeper/params.go index 8766b22c9..314ceb2ec 100644 --- a/x/commitment/keeper/params.go +++ b/x/commitment/keeper/params.go @@ -18,14 +18,14 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { } // GetVestingDenom returns the vesting denom for the given base denom -func (k Keeper) GetVestingInfo(ctx sdk.Context, baseDenom string) *types.VestingInfo { +func (k Keeper) GetVestingInfo(ctx sdk.Context, baseDenom string) (*types.VestingInfo, int) { params := k.GetParams(ctx) - for _, vestingInfo := range params.VestingInfos { + for i, vestingInfo := range params.VestingInfos { if vestingInfo.BaseDenom == baseDenom { - return vestingInfo + return vestingInfo, i } } - return nil + return nil, 0 } diff --git a/x/commitment/keeper/params_test.go b/x/commitment/keeper/params_test.go index 48bccb4f3..616769840 100644 --- a/x/commitment/keeper/params_test.go +++ b/x/commitment/keeper/params_test.go @@ -27,6 +27,7 @@ func TestGetParams(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } @@ -48,6 +49,7 @@ func TestEncodeDecodeParams(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } @@ -80,6 +82,7 @@ func TestGetParamsNew(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } @@ -110,6 +113,7 @@ func TestGetVestingInfo(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, { BaseDenom: "test", @@ -117,6 +121,7 @@ func TestGetVestingInfo(t *testing.T) { EpochIdentifier: "tenseconds", NumEpochs: 10, VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, }, } @@ -127,17 +132,17 @@ func TestGetVestingInfo(t *testing.T) { k.SetParams(ctx, params) // Test GetVestingInfo with existing base denom - vestingInfo := k.GetVestingInfo(ctx, ptypes.Eden) + vestingInfo, _ := k.GetVestingInfo(ctx, ptypes.Eden) require.NotNil(t, vestingInfo) require.Equal(t, ptypes.Eden, vestingInfo.BaseDenom) require.Equal(t, ptypes.Elys, vestingInfo.VestingDenom) // Test GetVestingInfo with non-existing base denom - vestingInfo = k.GetVestingInfo(ctx, "nonexistent") + vestingInfo, _ = k.GetVestingInfo(ctx, "nonexistent") require.Nil(t, vestingInfo) // Test GetVestingInfo with another existing base denom - vestingInfo = k.GetVestingInfo(ctx, "test") + vestingInfo, _ = k.GetVestingInfo(ctx, "test") require.NotNil(t, vestingInfo) require.Equal(t, "test", vestingInfo.BaseDenom) require.Equal(t, "test_vesting", vestingInfo.VestingDenom) diff --git a/x/commitment/module_simulation.go b/x/commitment/module_simulation.go index e9604465f..e5832ad02 100644 --- a/x/commitment/module_simulation.go +++ b/x/commitment/module_simulation.go @@ -50,6 +50,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgVestNow int = 100 + opWeightMsgUpdateVestingInfo = "op_weight_msg_update_vesting_info" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateVestingInfo int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -155,6 +159,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp commitmentsimulation.SimulateMsgVestNow(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgUpdateVestingInfo int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateVestingInfo, &weightMsgUpdateVestingInfo, nil, + func(_ *rand.Rand) { + weightMsgUpdateVestingInfo = defaultWeightMsgUpdateVestingInfo + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateVestingInfo, + commitmentsimulation.SimulateMsgUpdateVestingInfo(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/commitment/simulation/update_vesting_info.go b/x/commitment/simulation/update_vesting_info.go new file mode 100644 index 000000000..258ad9b26 --- /dev/null +++ b/x/commitment/simulation/update_vesting_info.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/elys-network/elys/x/commitment/keeper" + "github.com/elys-network/elys/x/commitment/types" +) + +func SimulateMsgUpdateVestingInfo( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUpdateVestingInfo{ + Authority: simAccount.Address.String(), + } + + // TODO: Handling the UpdateVestingInfo simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "UpdateVestingInfo simulation not implemented"), nil, nil + } +} diff --git a/x/commitment/types/codec.go b/x/commitment/types/codec.go index e1f27b92d..13146e693 100644 --- a/x/commitment/types/codec.go +++ b/x/commitment/types/codec.go @@ -15,6 +15,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgVest{}, "commitment/Vest", nil) cdc.RegisterConcrete(&MsgCancelVest{}, "commitment/CancelVest", nil) cdc.RegisterConcrete(&MsgVestNow{}, "commitment/VestNow", nil) + cdc.RegisterConcrete(&MsgUpdateVestingInfo{}, "commitment/UpdateVestingInfo", nil) // this line is used by starport scaffolding # 2 } @@ -40,6 +41,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgVestNow{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateVestingInfo{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/commitment/types/interfaces.go b/x/commitment/types/interfaces.go index 9247e744c..f43c1f013 100644 --- a/x/commitment/types/interfaces.go +++ b/x/commitment/types/interfaces.go @@ -6,7 +6,7 @@ import sdk "github.com/cosmos/cosmos-sdk/types" type CommitmentHooks interface { // Token commitment changed CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Coin) - + // Eden uncommitted EdenUncommitted(ctx sdk.Context, creator string, amount sdk.Coin) } diff --git a/x/commitment/types/message_update_vesting_info.go b/x/commitment/types/message_update_vesting_info.go new file mode 100644 index 000000000..78769ebf0 --- /dev/null +++ b/x/commitment/types/message_update_vesting_info.go @@ -0,0 +1,51 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateVestingInfo = "update_vesting_info" + +var _ sdk.Msg = &MsgUpdateVestingInfo{} + +func NewMsgUpdateVestingInfo(creator string, baseDenom string, vestingDenom string, epochIdentifier string, numEpochs string, vestNowFactor string, numMaxVestings string) *MsgUpdateVestingInfo { + return &MsgUpdateVestingInfo{ + Authority: creator, + BaseDenom: baseDenom, + VestingDenom: vestingDenom, + EpochIdentifier: epochIdentifier, + NumEpochs: numEpochs, + VestNowFactor: vestNowFactor, + NumMaxVestings: numMaxVestings, + } +} + +func (msg *MsgUpdateVestingInfo) Route() string { + return RouterKey +} + +func (msg *MsgUpdateVestingInfo) Type() string { + return TypeMsgUpdateVestingInfo +} + +func (msg *MsgUpdateVestingInfo) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateVestingInfo) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateVestingInfo) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/commitment/types/message_update_vesting_info_test.go b/x/commitment/types/message_update_vesting_info_test.go new file mode 100644 index 000000000..092909f60 --- /dev/null +++ b/x/commitment/types/message_update_vesting_info_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/elys-network/elys/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgUpdateVestingInfo_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateVestingInfo + err error + }{ + { + name: "invalid address", + msg: MsgUpdateVestingInfo{ + Authority: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateVestingInfo{ + Authority: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/commitment/types/tx.pb.go b/x/commitment/types/tx.pb.go index 817d3e7bf..e315425b9 100644 --- a/x/commitment/types/tx.pb.go +++ b/x/commitment/types/tx.pb.go @@ -652,6 +652,134 @@ func (m *MsgVestNowResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgVestNowResponse proto.InternalMessageInfo +type MsgUpdateVestingInfo struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + BaseDenom string `protobuf:"bytes,2,opt,name=baseDenom,proto3" json:"baseDenom,omitempty"` + VestingDenom string `protobuf:"bytes,3,opt,name=vestingDenom,proto3" json:"vestingDenom,omitempty"` + EpochIdentifier string `protobuf:"bytes,4,opt,name=epochIdentifier,proto3" json:"epochIdentifier,omitempty"` + NumEpochs string `protobuf:"bytes,5,opt,name=numEpochs,proto3" json:"numEpochs,omitempty"` + VestNowFactor string `protobuf:"bytes,6,opt,name=vestNowFactor,proto3" json:"vestNowFactor,omitempty"` + NumMaxVestings string `protobuf:"bytes,7,opt,name=numMaxVestings,proto3" json:"numMaxVestings,omitempty"` +} + +func (m *MsgUpdateVestingInfo) Reset() { *m = MsgUpdateVestingInfo{} } +func (m *MsgUpdateVestingInfo) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateVestingInfo) ProtoMessage() {} +func (*MsgUpdateVestingInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_eda78aafe7eb119c, []int{14} +} +func (m *MsgUpdateVestingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateVestingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateVestingInfo.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 *MsgUpdateVestingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateVestingInfo.Merge(m, src) +} +func (m *MsgUpdateVestingInfo) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateVestingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateVestingInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateVestingInfo proto.InternalMessageInfo + +func (m *MsgUpdateVestingInfo) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateVestingInfo) GetBaseDenom() string { + if m != nil { + return m.BaseDenom + } + return "" +} + +func (m *MsgUpdateVestingInfo) GetVestingDenom() string { + if m != nil { + return m.VestingDenom + } + return "" +} + +func (m *MsgUpdateVestingInfo) GetEpochIdentifier() string { + if m != nil { + return m.EpochIdentifier + } + return "" +} + +func (m *MsgUpdateVestingInfo) GetNumEpochs() string { + if m != nil { + return m.NumEpochs + } + return "" +} + +func (m *MsgUpdateVestingInfo) GetVestNowFactor() string { + if m != nil { + return m.VestNowFactor + } + return "" +} + +func (m *MsgUpdateVestingInfo) GetNumMaxVestings() string { + if m != nil { + return m.NumMaxVestings + } + return "" +} + +type MsgUpdateVestingInfoResponse struct { +} + +func (m *MsgUpdateVestingInfoResponse) Reset() { *m = MsgUpdateVestingInfoResponse{} } +func (m *MsgUpdateVestingInfoResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateVestingInfoResponse) ProtoMessage() {} +func (*MsgUpdateVestingInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_eda78aafe7eb119c, []int{15} +} +func (m *MsgUpdateVestingInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateVestingInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateVestingInfoResponse.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 *MsgUpdateVestingInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateVestingInfoResponse.Merge(m, src) +} +func (m *MsgUpdateVestingInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateVestingInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateVestingInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateVestingInfoResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCommitTokens)(nil), "elys.commitment.MsgCommitTokens") proto.RegisterType((*MsgCommitTokensResponse)(nil), "elys.commitment.MsgCommitTokensResponse") @@ -667,43 +795,54 @@ func init() { proto.RegisterType((*MsgCancelVestResponse)(nil), "elys.commitment.MsgCancelVestResponse") proto.RegisterType((*MsgVestNow)(nil), "elys.commitment.MsgVestNow") proto.RegisterType((*MsgVestNowResponse)(nil), "elys.commitment.MsgVestNowResponse") + proto.RegisterType((*MsgUpdateVestingInfo)(nil), "elys.commitment.MsgUpdateVestingInfo") + proto.RegisterType((*MsgUpdateVestingInfoResponse)(nil), "elys.commitment.MsgUpdateVestingInfoResponse") } func init() { proto.RegisterFile("elys/commitment/tx.proto", fileDescriptor_eda78aafe7eb119c) } var fileDescriptor_eda78aafe7eb119c = []byte{ - // 494 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xc7, 0x33, 0xb6, 0x36, 0xf8, 0xb0, 0xd6, 0x0e, 0x91, 0x6e, 0xa7, 0xb0, 0x8d, 0x11, 0x4a, - 0x15, 0xba, 0x0b, 0xfa, 0x0d, 0xa2, 0x08, 0x45, 0xb6, 0x87, 0x50, 0x15, 0x0a, 0x82, 0xe9, 0x66, - 0x98, 0x86, 0x74, 0xe7, 0x85, 0x9d, 0x29, 0x69, 0x8f, 0x82, 0x20, 0xea, 0xc5, 0x8f, 0xd5, 0x63, - 0x8f, 0xe2, 0xa1, 0x48, 0x72, 0xf4, 0x4b, 0xc8, 0x6c, 0xb2, 0xd3, 0xcc, 0x76, 0xdb, 0x1c, 0xd3, - 0xd3, 0xee, 0xf0, 0xff, 0xbf, 0xf7, 0x7e, 0xec, 0xbe, 0xf7, 0x06, 0x3c, 0x7e, 0x7c, 0xa6, 0xc2, - 0x18, 0x93, 0xa4, 0xab, 0x13, 0x2e, 0x75, 0xa8, 0x4f, 0x83, 0x7e, 0x8a, 0x1a, 0xe9, 0x8a, 0x51, - 0x82, 0x2b, 0x85, 0xd5, 0x04, 0x0a, 0xcc, 0xb4, 0xd0, 0xbc, 0x8d, 0x6d, 0x8d, 0xef, 0x04, 0x56, - 0x22, 0x25, 0x5e, 0x67, 0xbe, 0x7d, 0xec, 0x71, 0xa9, 0xa8, 0x07, 0xd5, 0x38, 0xe5, 0x6d, 0x8d, - 0xa9, 0x47, 0xea, 0x64, 0xfb, 0x41, 0x2b, 0x3f, 0xd2, 0xb7, 0xb0, 0xd4, 0x4e, 0xf0, 0x44, 0x6a, - 0xef, 0x9e, 0x11, 0x9a, 0xc1, 0xf9, 0xe5, 0x66, 0xe5, 0xcf, 0xe5, 0xe6, 0x96, 0xe8, 0xea, 0xa3, - 0x93, 0x43, 0x53, 0x2e, 0x8c, 0x51, 0x25, 0xa8, 0x26, 0x8f, 0x1d, 0xd5, 0xe9, 0x85, 0xfa, 0xac, - 0xcf, 0x55, 0xb0, 0x2b, 0x75, 0x6b, 0x12, 0x4d, 0x6b, 0x70, 0xbf, 0xc3, 0x25, 0x26, 0xde, 0x42, - 0x96, 0x7f, 0x7c, 0x68, 0xac, 0xc3, 0x5a, 0x01, 0xa5, 0xc5, 0x55, 0x1f, 0xa5, 0xe2, 0x8d, 0x9f, - 0x04, 0x56, 0x23, 0x25, 0xde, 0xcb, 0xf8, 0x2e, 0x80, 0x6e, 0xc0, 0xfa, 0x35, 0x98, 0x22, 0xea, - 0xc7, 0xae, 0x3e, 0xea, 0xa4, 0xed, 0xc1, 0x9d, 0x40, 0x75, 0x61, 0x2c, 0xea, 0x0f, 0x02, 0x8f, - 0x23, 0x25, 0xde, 0xf0, 0x3e, 0xaa, 0xb9, 0x7f, 0x54, 0x06, 0x5e, 0x91, 0xc5, 0x82, 0x7e, 0x21, - 0x50, 0x8d, 0x94, 0xf8, 0xc0, 0x95, 0x9e, 0x1b, 0xdf, 0x6a, 0x36, 0x28, 0x06, 0xc1, 0x62, 0x7d, - 0x23, 0xb0, 0x6c, 0x3a, 0xb6, 0x2d, 0x63, 0x7e, 0x3c, 0x57, 0xb8, 0x35, 0x78, 0xe2, 0x80, 0x58, - 0xc4, 0xaf, 0x04, 0x60, 0x82, 0xbd, 0x87, 0x83, 0xb9, 0xf1, 0xd5, 0x80, 0x5e, 0x51, 0xe4, 0x70, - 0x2f, 0xff, 0x2d, 0xc2, 0x42, 0xa4, 0x04, 0x3d, 0x80, 0x87, 0xce, 0x02, 0xaa, 0x07, 0x85, 0xe5, - 0x15, 0x14, 0xf6, 0x02, 0xdb, 0x9e, 0xe5, 0xc8, 0x6b, 0xd0, 0xcf, 0xf0, 0xa8, 0xb0, 0x35, 0x1a, - 0x65, 0xb1, 0xae, 0x87, 0xbd, 0x98, 0xed, 0x99, 0xae, 0x50, 0x18, 0xf6, 0xd2, 0x0a, 0xae, 0xa7, - 0xbc, 0x42, 0xf9, 0x9c, 0xd2, 0x4f, 0xb0, 0xec, 0xce, 0xe8, 0xd3, 0xb2, 0x60, 0xc7, 0xc2, 0x9e, - 0xcf, 0xb4, 0xd8, 0xf4, 0x4d, 0x58, 0x1c, 0x37, 0x6f, 0x59, 0x88, 0x51, 0x58, 0xfd, 0x26, 0xc5, - 0xe6, 0xd8, 0x07, 0x98, 0x1a, 0x03, 0xbf, 0xf4, 0xf7, 0x58, 0x9d, 0x6d, 0xdd, 0xae, 0xdb, 0xac, - 0xef, 0xa0, 0x9a, 0x77, 0xee, 0xc6, 0x4d, 0x08, 0x7b, 0x38, 0x60, 0xcf, 0x6e, 0x11, 0xf3, 0x64, - 0xcd, 0xdd, 0xf3, 0xa1, 0x4f, 0x2e, 0x86, 0x3e, 0xf9, 0x3b, 0xf4, 0xc9, 0xaf, 0x91, 0x5f, 0xb9, - 0x18, 0xf9, 0x95, 0xdf, 0x23, 0xbf, 0x72, 0x10, 0x4e, 0xf5, 0xb8, 0x49, 0xb4, 0x23, 0xb9, 0x1e, - 0x60, 0xda, 0xcb, 0x0e, 0xe1, 0xa9, 0x73, 0xbf, 0x9a, 0x86, 0x3f, 0x5c, 0xca, 0x2e, 0xcf, 0x57, - 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xb2, 0x8f, 0xe5, 0xbd, 0x7f, 0x07, 0x00, 0x00, + // 637 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xcb, 0x6a, 0xdb, 0x40, + 0x14, 0x86, 0xad, 0xdc, 0x4c, 0x0e, 0xb9, 0x34, 0x83, 0x4b, 0x14, 0x25, 0x28, 0xa9, 0xda, 0x86, + 0xb4, 0x10, 0x09, 0xda, 0x37, 0x70, 0xdd, 0x80, 0x29, 0xca, 0xc2, 0xa4, 0x2d, 0x04, 0x0a, 0x95, + 0xe5, 0x89, 0x2c, 0x1c, 0xcd, 0x08, 0xcd, 0x38, 0xb6, 0x97, 0x85, 0x42, 0xe9, 0x65, 0xd1, 0xc7, + 0xca, 0x32, 0xab, 0x52, 0xba, 0x08, 0xc5, 0x7e, 0x91, 0x32, 0x92, 0x3d, 0xb6, 0x14, 0x25, 0xee, + 0xce, 0x59, 0x25, 0x73, 0xfe, 0x7f, 0xce, 0xf9, 0x34, 0xf2, 0xfc, 0x08, 0x54, 0x7c, 0xde, 0x63, + 0x96, 0x4b, 0x83, 0xc0, 0xe7, 0x01, 0x26, 0xdc, 0xe2, 0x5d, 0x33, 0x8c, 0x28, 0xa7, 0x68, 0x5d, + 0x28, 0xe6, 0x58, 0xd1, 0x4a, 0x1e, 0xf5, 0x68, 0xac, 0x59, 0xe2, 0xbf, 0xc4, 0x66, 0x7c, 0x55, + 0x60, 0xdd, 0x66, 0xde, 0xab, 0xd8, 0x77, 0x42, 0x5b, 0x98, 0x30, 0xa4, 0x42, 0xd1, 0x8d, 0xb0, + 0xc3, 0x69, 0xa4, 0x2a, 0x7b, 0xca, 0xc1, 0x72, 0x6d, 0xb4, 0x44, 0x47, 0xb0, 0xe4, 0x04, 0xb4, + 0x4d, 0xb8, 0x3a, 0x27, 0x84, 0xb2, 0x79, 0x79, 0xbd, 0x5b, 0xf8, 0x73, 0xbd, 0xbb, 0xef, 0xf9, + 0xbc, 0xd9, 0xae, 0x8b, 0x71, 0x96, 0x4b, 0x59, 0x40, 0xd9, 0xf0, 0xcf, 0x21, 0x6b, 0xb4, 0x2c, + 0xde, 0x0b, 0x31, 0x33, 0xab, 0x84, 0xd7, 0x86, 0xbb, 0x51, 0x09, 0x16, 0x1b, 0x98, 0xd0, 0x40, + 0x9d, 0x8f, 0xfb, 0x27, 0x0b, 0x63, 0x0b, 0x36, 0x33, 0x28, 0x35, 0xcc, 0x42, 0x4a, 0x18, 0x36, + 0xbe, 0x2b, 0xb0, 0x61, 0x33, 0xef, 0x2d, 0x71, 0xef, 0x03, 0xe8, 0x36, 0x6c, 0xdd, 0x80, 0xc9, + 0xa2, 0xbe, 0xf7, 0x79, 0xb3, 0x11, 0x39, 0x9d, 0x7b, 0x81, 0x9a, 0x86, 0x91, 0xa8, 0xdf, 0x14, + 0x78, 0x60, 0x33, 0xaf, 0x82, 0x43, 0xca, 0x66, 0x7e, 0xa8, 0x1a, 0xa8, 0x59, 0x16, 0x09, 0xfa, + 0x49, 0x81, 0xa2, 0xcd, 0xbc, 0x77, 0x98, 0xf1, 0x99, 0xf1, 0x6d, 0xc4, 0x17, 0x45, 0x20, 0x48, + 0xac, 0x2f, 0x0a, 0xac, 0x8a, 0x5f, 0xac, 0x43, 0x5c, 0x7c, 0x3e, 0x53, 0xb8, 0x4d, 0x78, 0x98, + 0x02, 0x91, 0x88, 0x9f, 0x15, 0x80, 0x21, 0xf6, 0x31, 0xed, 0xcc, 0x8c, 0xaf, 0x04, 0x68, 0x4c, + 0x21, 0xe1, 0x7e, 0xcc, 0x41, 0x49, 0x5c, 0xa4, 0xb0, 0xe1, 0x70, 0x2c, 0x44, 0x9f, 0x78, 0x55, + 0x72, 0x46, 0xd1, 0x0e, 0x2c, 0x3b, 0x6d, 0xde, 0xa4, 0x91, 0xcf, 0x7b, 0x43, 0xd0, 0x71, 0x41, + 0xa8, 0x75, 0x87, 0xe1, 0x4a, 0x3c, 0x66, 0x2e, 0x51, 0x65, 0x01, 0x19, 0xb0, 0x72, 0x91, 0xb4, + 0xaa, 0x4c, 0x70, 0xa4, 0x6a, 0xe8, 0x00, 0xd6, 0x71, 0x48, 0xdd, 0x66, 0xb5, 0x81, 0x09, 0xf7, + 0xcf, 0x7c, 0x1c, 0xa9, 0x0b, 0xb1, 0x2d, 0x5b, 0x16, 0xb3, 0x48, 0x3b, 0x78, 0x2d, 0xaa, 0x4c, + 0x5d, 0x4c, 0x66, 0xc9, 0x02, 0x7a, 0x02, 0xab, 0x17, 0xc9, 0x33, 0x1d, 0x39, 0xae, 0x38, 0xd4, + 0xa5, 0xd8, 0x91, 0x2e, 0xa2, 0x7d, 0x58, 0x23, 0xed, 0xc0, 0x76, 0xba, 0xc3, 0x47, 0x64, 0x6a, + 0x31, 0xb6, 0x65, 0xaa, 0x86, 0x0e, 0x3b, 0x79, 0xa7, 0x31, 0x3a, 0xae, 0x17, 0xbf, 0x16, 0x61, + 0xde, 0x66, 0x1e, 0x3a, 0x85, 0x95, 0x54, 0x5e, 0xef, 0x99, 0x99, 0xac, 0x37, 0x33, 0x31, 0xaa, + 0x1d, 0x4c, 0x73, 0x8c, 0x66, 0xa0, 0x8f, 0xb0, 0x96, 0x09, 0x59, 0x23, 0x6f, 0x6f, 0xda, 0xa3, + 0x3d, 0x9f, 0xee, 0x99, 0x9c, 0x90, 0xc9, 0xc6, 0xdc, 0x09, 0x69, 0x4f, 0xfe, 0x84, 0xfc, 0x58, + 0x43, 0x1f, 0x60, 0x35, 0x1d, 0x69, 0x8f, 0xf2, 0x36, 0xa7, 0x2c, 0xda, 0xb3, 0xa9, 0x16, 0xd9, + 0xbe, 0x0c, 0x0b, 0xc9, 0x5d, 0xcf, 0xdb, 0x22, 0x14, 0x6d, 0xef, 0x36, 0x45, 0xf6, 0x38, 0x01, + 0x98, 0x48, 0x0d, 0x3d, 0xf7, 0xf5, 0x48, 0x5d, 0xdb, 0xbf, 0x5b, 0x97, 0x5d, 0xdf, 0x40, 0x71, + 0x74, 0xd1, 0xb7, 0x6f, 0x43, 0x38, 0xa6, 0x1d, 0xed, 0xf1, 0x1d, 0xa2, 0x6c, 0xe6, 0xc3, 0xc6, + 0xcd, 0x8b, 0xf9, 0x34, 0xf7, 0x45, 0x67, 0x6d, 0xda, 0xe1, 0x7f, 0xd9, 0x46, 0xa3, 0xca, 0xd5, + 0xcb, 0xbe, 0xae, 0x5c, 0xf5, 0x75, 0xe5, 0x6f, 0x5f, 0x57, 0x7e, 0x0e, 0xf4, 0xc2, 0xd5, 0x40, + 0x2f, 0xfc, 0x1e, 0xe8, 0x85, 0x53, 0x6b, 0x22, 0x7d, 0x44, 0xcb, 0x43, 0x82, 0x79, 0x87, 0x46, + 0xad, 0x78, 0x61, 0x75, 0x53, 0x5f, 0x3e, 0x22, 0x8a, 0xea, 0x4b, 0xf1, 0x67, 0xcd, 0xcb, 0x7f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x0f, 0x5c, 0x45, 0x19, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -725,6 +864,7 @@ type MsgClient interface { Vest(ctx context.Context, in *MsgVest, opts ...grpc.CallOption) (*MsgVestResponse, error) CancelVest(ctx context.Context, in *MsgCancelVest, opts ...grpc.CallOption) (*MsgCancelVestResponse, error) VestNow(ctx context.Context, in *MsgVestNow, opts ...grpc.CallOption) (*MsgVestNowResponse, error) + UpdateVestingInfo(ctx context.Context, in *MsgUpdateVestingInfo, opts ...grpc.CallOption) (*MsgUpdateVestingInfoResponse, error) } type msgClient struct { @@ -798,6 +938,15 @@ func (c *msgClient) VestNow(ctx context.Context, in *MsgVestNow, opts ...grpc.Ca return out, nil } +func (c *msgClient) UpdateVestingInfo(ctx context.Context, in *MsgUpdateVestingInfo, opts ...grpc.CallOption) (*MsgUpdateVestingInfoResponse, error) { + out := new(MsgUpdateVestingInfoResponse) + err := c.cc.Invoke(ctx, "/elys.commitment.Msg/UpdateVestingInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CommitTokens(context.Context, *MsgCommitTokens) (*MsgCommitTokensResponse, error) @@ -807,6 +956,7 @@ type MsgServer interface { Vest(context.Context, *MsgVest) (*MsgVestResponse, error) CancelVest(context.Context, *MsgCancelVest) (*MsgCancelVestResponse, error) VestNow(context.Context, *MsgVestNow) (*MsgVestNowResponse, error) + UpdateVestingInfo(context.Context, *MsgUpdateVestingInfo) (*MsgUpdateVestingInfoResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -834,6 +984,9 @@ func (*UnimplementedMsgServer) CancelVest(ctx context.Context, req *MsgCancelVes func (*UnimplementedMsgServer) VestNow(ctx context.Context, req *MsgVestNow) (*MsgVestNowResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VestNow not implemented") } +func (*UnimplementedMsgServer) UpdateVestingInfo(ctx context.Context, req *MsgUpdateVestingInfo) (*MsgUpdateVestingInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateVestingInfo not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -965,6 +1118,24 @@ func _Msg_VestNow_Handler(srv interface{}, ctx context.Context, dec func(interfa return interceptor(ctx, in, info, handler) } +func _Msg_UpdateVestingInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateVestingInfo) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateVestingInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.commitment.Msg/UpdateVestingInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateVestingInfo(ctx, req.(*MsgUpdateVestingInfo)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.commitment.Msg", HandlerType: (*MsgServer)(nil), @@ -997,6 +1168,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "VestNow", Handler: _Msg_VestNow_Handler, }, + { + MethodName: "UpdateVestingInfo", + Handler: _Msg_UpdateVestingInfo_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/commitment/tx.proto", @@ -1492,6 +1667,101 @@ func (m *MsgVestNowResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateVestingInfo) 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 *MsgUpdateVestingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateVestingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NumMaxVestings) > 0 { + i -= len(m.NumMaxVestings) + copy(dAtA[i:], m.NumMaxVestings) + i = encodeVarintTx(dAtA, i, uint64(len(m.NumMaxVestings))) + i-- + dAtA[i] = 0x3a + } + if len(m.VestNowFactor) > 0 { + i -= len(m.VestNowFactor) + copy(dAtA[i:], m.VestNowFactor) + i = encodeVarintTx(dAtA, i, uint64(len(m.VestNowFactor))) + i-- + dAtA[i] = 0x32 + } + if len(m.NumEpochs) > 0 { + i -= len(m.NumEpochs) + copy(dAtA[i:], m.NumEpochs) + i = encodeVarintTx(dAtA, i, uint64(len(m.NumEpochs))) + i-- + dAtA[i] = 0x2a + } + if len(m.EpochIdentifier) > 0 { + i -= len(m.EpochIdentifier) + copy(dAtA[i:], m.EpochIdentifier) + i = encodeVarintTx(dAtA, i, uint64(len(m.EpochIdentifier))) + i-- + dAtA[i] = 0x22 + } + if len(m.VestingDenom) > 0 { + i -= len(m.VestingDenom) + copy(dAtA[i:], m.VestingDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.VestingDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.BaseDenom) > 0 { + i -= len(m.BaseDenom) + copy(dAtA[i:], m.BaseDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.BaseDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateVestingInfoResponse) 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 *MsgUpdateVestingInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateVestingInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1699,6 +1969,52 @@ func (m *MsgVestNowResponse) Size() (n int) { return n } +func (m *MsgUpdateVestingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BaseDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.VestingDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.EpochIdentifier) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NumEpochs) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.VestNowFactor) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NumMaxVestings) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateVestingInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3091,6 +3407,330 @@ func (m *MsgVestNowResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateVestingInfo) 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 ErrIntOverflowTx + } + 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: MsgUpdateVestingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateVestingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BaseDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VestingDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochIdentifier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EpochIdentifier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumEpochs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NumEpochs = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VestNowFactor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VestNowFactor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumMaxVestings", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NumMaxVestings = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateVestingInfoResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateVestingInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateVestingInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0