diff --git a/README.md b/README.md index 4f9968001..ce4cab7e2 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ The documentation is available in [docs](docs) directory. If you are a developer * [Crescent Official Docs](https://docs.crescent.network/) * [Swagger API Docs](https://app.swaggerhub.com/apis-docs/crescent/crescent/2.0.0) + + ## Community * [Official Website](https://crescent.network/) diff --git a/docs/cli/claim.md b/docs/cli/claim.md index 40a1000b7..4fcee93c6 100644 --- a/docs/cli/claim.md +++ b/docs/cli/claim.md @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis -This document provides a high-level overview of how the command line (CLI) interface works for the `claim` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`. +This document provides a high-level overview of how the command line (CLI) interface works for the `claim` module. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/docs/cli/farming.md b/docs/cli/farming.md index 9a369ca56..0259e4d62 100644 --- a/docs/cli/farming.md +++ b/docs/cli/farming.md @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis -This document provides a high-level overview of how the command line (CLI) interface works for the `farming` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`. +This document provides a high-level overview of how the command line (CLI) interface works for the `farming` module. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/docs/cli/liquidfarming.md b/docs/cli/liquidfarming.md index 1034b5d86..1537214db 100644 --- a/docs/cli/liquidfarming.md +++ b/docs/cli/liquidfarming.md @@ -8,9 +8,6 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis This document provides a high-level overview of how the command line (CLI) interface works for the `liquidfarming` module. -To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). -If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. -Run this command under the project root directory `$ ignite chain serve -c config-test.yml`. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/docs/cli/liquidity.md b/docs/cli/liquidity.md index 6cdfd78ff..f46d3b713 100644 --- a/docs/cli/liquidity.md +++ b/docs/cli/liquidity.md @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis -This document provides a high-level overview of how the command line (CLI) interface works for the `liquidity` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`. +This document provides a high-level overview of how the command line (CLI) interface works for the `liquidity` module. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/docs/cli/liquidstaking.md b/docs/cli/liquidstaking.md index af2b8757c..450d5f327 100644 --- a/docs/cli/liquidstaking.md +++ b/docs/cli/liquidstaking.md @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis -This document provides a high-level overview of how the command line (CLI) interface works for the `liquidstaking` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`. +This document provides a high-level overview of how the command line (CLI) interface works for the `liquidstaking` module. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/docs/cli/lpfarm.md b/docs/cli/lpfarm.md index d483a6347..0f857f1ad 100644 --- a/docs/cli/lpfarm.md +++ b/docs/cli/lpfarm.md @@ -8,11 +8,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis This document provides a high-level overview of how the command line (CLI) -interface works for the `lpfarm` module. To set up a local testing environment, it requires the latest -[Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, -see [this guide](https://docs.ignite.com/guide/install.html) to install it. Run this command under the project root -directory -`$ ignite chain serve -v -c config-test.yml`. +interface works for the `lpfarm` module. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/docs/cli/marketmaker.md b/docs/cli/marketmaker.md index 60403e66d..aaa338ce3 100644 --- a/docs/cli/marketmaker.md +++ b/docs/cli/marketmaker.md @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work ## Synopsis -This document provides a high-level overview of how the command line (CLI) interface works for the `marketmaker` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/guide/install.html) to install it. Run this command under the project root directory `$ ignite chain serve -v -c config-test.yml`. +This document provides a high-level overview of how the command line (CLI) interface works for the `marketmaker` module. Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document. diff --git a/proto/crescent/lpfarm/v1beta1/tx.proto b/proto/crescent/lpfarm/v1beta1/tx.proto index ab365170a..ed670c657 100644 --- a/proto/crescent/lpfarm/v1beta1/tx.proto +++ b/proto/crescent/lpfarm/v1beta1/tx.proto @@ -12,6 +12,7 @@ option (gogoproto.goproto_getters_all) = false; service Msg { rpc CreatePrivatePlan(MsgCreatePrivatePlan) returns (MsgCreatePrivatePlanResponse); + rpc TerminatePrivatePlan(MsgTerminatePrivatePlan) returns (MsgTerminatePrivatePlanResponse); rpc Farm(MsgFarm) returns (MsgFarmResponse); rpc Unfarm(MsgUnfarm) returns (MsgUnfarmResponse); rpc Harvest(MsgHarvest) returns (MsgHarvestResponse); @@ -30,6 +31,13 @@ message MsgCreatePrivatePlanResponse { string farming_pool_address = 2; } +message MsgTerminatePrivatePlan { + string creator = 1; + uint64 plan_id = 2; +} + +message MsgTerminatePrivatePlanResponse {} + message MsgFarm { string farmer = 1; cosmos.base.v1beta1.Coin coin = 2 [(gogoproto.nullable) = false]; diff --git a/x/lpfarm/client/cli/tx.go b/x/lpfarm/client/cli/tx.go index 905f6dc84..e526aa1dc 100644 --- a/x/lpfarm/client/cli/tx.go +++ b/x/lpfarm/client/cli/tx.go @@ -31,6 +31,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand( NewCreatePrivatePlanCmd(), + NewTerminatePrivatePlanCmd(), NewFarmCmd(), NewUnfarmCmd(), NewHarvestCmd(), @@ -117,6 +118,42 @@ $ %s tx %s create-private-plan "New Farming Plan" 2022-01-01T00:00:00Z 2023-01-0 return cmd } +func NewTerminatePrivatePlanCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "terminate-private-plan [plan-id]", + Args: cobra.ExactArgs(1), + Short: "Terminate a private farming plan", + Long: strings.TrimSpace( + fmt.Sprintf(`Terminate a private farming plan. +The plan's termination address must be same with the message sender(original plan creator). + +Example: +$ %s tx %s terminate-private-plan 1 --from mykey +`, + version.AppName, types.ModuleName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + planId, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("invalid plan id: %w", err) + } + + msg := types.NewMsgTerminatePrivatePlan(clientCtx.GetFromAddress(), planId) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + func NewFarmCmd() *cobra.Command { cmd := &cobra.Command{ Use: "farm [coin]", diff --git a/x/lpfarm/handler.go b/x/lpfarm/handler.go index e3fdb39cc..bd895f18f 100644 --- a/x/lpfarm/handler.go +++ b/x/lpfarm/handler.go @@ -20,6 +20,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgCreatePrivatePlan: res, err := msgServer.CreatePrivatePlan(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgTerminatePrivatePlan: + res, err := msgServer.TerminatePrivatePlan(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgFarm: res, err := msgServer.Farm(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) diff --git a/x/lpfarm/keeper/msg_server.go b/x/lpfarm/keeper/msg_server.go index 19929bd38..dd980d1b8 100644 --- a/x/lpfarm/keeper/msg_server.go +++ b/x/lpfarm/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/crescent-network/crescent/v4/x/lpfarm/types" ) @@ -41,6 +42,30 @@ func (k msgServer) CreatePrivatePlan(goCtx context.Context, msg *types.MsgCreate }, nil } +// TerminatePrivatePlan defines a method to terminate a private plan. +func (k msgServer) TerminatePrivatePlan(goCtx context.Context, msg *types.MsgTerminatePrivatePlan) (*types.MsgTerminatePrivatePlanResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + plan, found := k.GetPlan(ctx, msg.PlanId) + if !found { + return nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "plan not found: %d", msg.PlanId) + } + if !plan.IsPrivate { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "cannot terminate public plan") + } + if plan.TerminationAddress != msg.Creator { + return nil, sdkerrors.Wrapf( + sdkerrors.ErrUnauthorized, + "plan's termination address must be same with the sender's address") + } + + if err := k.Keeper.TerminatePlan(ctx, plan); err != nil { + return nil, err + } + + return &types.MsgTerminatePrivatePlanResponse{}, nil +} + // Farm defines a method for farming coins. func (k msgServer) Farm(goCtx context.Context, msg *types.MsgFarm) (*types.MsgFarmResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/lpfarm/keeper/plan_test.go b/x/lpfarm/keeper/plan_test.go index c7ca96fd6..3fdca5971 100644 --- a/x/lpfarm/keeper/plan_test.go +++ b/x/lpfarm/keeper/plan_test.go @@ -2,8 +2,10 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" utils "github.com/crescent-network/crescent/v4/types" + "github.com/crescent-network/crescent/v4/x/lpfarm/keeper" "github.com/crescent-network/crescent/v4/x/lpfarm/types" ) @@ -61,6 +63,55 @@ func (s *KeeperTestSuite) TestCreatePrivatePlan_PairNotFound() { err, "pair 2 not found: not found") } +func (s *KeeperTestSuite) TestTerminatePrivatePlan() { + s.createPairWithLastPrice("denom1", "denom2", sdk.NewDec(1)) + s.createPool(1, utils.ParseCoins("100_000000denom1,100_000000denom2")) + + creatorAddr := utils.TestAddress(1) + s.fundAddr(creatorAddr, s.keeper.GetPrivatePlanCreationFee(s.ctx)) + plan, err := s.keeper.CreatePrivatePlan( + s.ctx, creatorAddr, "", []types.RewardAllocation{ + types.NewPairRewardAllocation(1, utils.ParseCoins("100_000000stake")), + }, sampleStartTime, sampleEndTime) + s.Require().NoError(err) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("10000_000000stake")) + + s.farm(utils.TestAddress(2), utils.ParseCoin("1000000pool1")) + + s.nextBlock() + s.nextBlock() + s.nextBlock() + + balancesBefore := s.getBalances(creatorAddr) + remainingFarmingRewards := s.getBalances(plan.GetFarmingPoolAddress()) + + msgServer := keeper.NewMsgServerImpl(s.keeper) + msg := types.NewMsgTerminatePrivatePlan(creatorAddr, 1) + _, err = msgServer.TerminatePrivatePlan(sdk.WrapSDKContext(s.ctx), msg) + s.Require().NoError(err) + + s.assertEq(sdk.Coins{}, s.getBalances(plan.GetFarmingPoolAddress())) + s.assertEq(balancesBefore.Add(remainingFarmingRewards...), s.getBalances(creatorAddr)) +} + +func (s *KeeperTestSuite) TestTerminatePrivatePlan_Unauthorized() { + s.createPairWithLastPrice("denom1", "denom2", sdk.NewDec(1)) + + creatorAddr := utils.TestAddress(1) + s.fundAddr(creatorAddr, s.keeper.GetPrivatePlanCreationFee(s.ctx)) + plan, err := s.keeper.CreatePrivatePlan( + s.ctx, creatorAddr, "", []types.RewardAllocation{ + types.NewPairRewardAllocation(1, utils.ParseCoins("100_000000stake")), + }, sampleStartTime, sampleEndTime) + s.Require().NoError(err) + s.fundAddr(plan.GetFarmingPoolAddress(), utils.ParseCoins("10000_000000stake")) + + msgServer := keeper.NewMsgServerImpl(s.keeper) + msg := types.NewMsgTerminatePrivatePlan(utils.TestAddress(2), 1) + _, err = msgServer.TerminatePrivatePlan(sdk.WrapSDKContext(s.ctx), msg) + s.Require().ErrorIs(err, sdkerrors.ErrUnauthorized) +} + func (s *KeeperTestSuite) TestAllocateRewards_NoFarmer() { s.createPairWithLastPrice("denom1", "denom2", sdk.NewDec(1)) s.createPool(1, utils.ParseCoins("100_000000denom1,100_000000denom2")) diff --git a/x/lpfarm/simulation/operations.go b/x/lpfarm/simulation/operations.go index 01e5fe158..607b86ae5 100644 --- a/x/lpfarm/simulation/operations.go +++ b/x/lpfarm/simulation/operations.go @@ -21,15 +21,17 @@ import ( // Simulation operation weights constants. const ( - OpWeightMsgCreatePrivatePlan = "op_weight_msg_create_private_plan" - OpWeightMsgFarm = "op_weight_msg_farm" - OpWeightMsgUnfarm = "op_weight_msg_unfarm" - OpWeightMsgHarvest = "op_weight_msg_harvest" + OpWeightMsgCreatePrivatePlan = "op_weight_msg_create_private_plan" + OpWeightMsgTerminatePrivatePlan = "op_weight_msg_terminate_private_plan" + OpWeightMsgFarm = "op_weight_msg_farm" + OpWeightMsgUnfarm = "op_weight_msg_unfarm" + OpWeightMsgHarvest = "op_weight_msg_harvest" - DefaultWeightCreatePrivatePlan = 10 - DefaultWeightFarm = 40 - DefaultWeightUnfarm = 50 - DefaultWeightHarvest = 20 + DefaultWeightCreatePrivatePlan = 10 + DefaultWeightTerminatePrivatePlan = 5 + DefaultWeightFarm = 40 + DefaultWeightUnfarm = 50 + DefaultWeightHarvest = 20 ) var ( @@ -43,14 +45,18 @@ func WeightedOperations( ak types.AccountKeeper, bk types.BankKeeper, lk types.LiquidityKeeper, k keeper.Keeper, ) simulation.WeightedOperations { var ( - weightMsgCreatePrivatePlan int - weightMsgFarm int - weightMsgUnfarm int - weightMsgHarvest int + weightMsgCreatePrivatePlan int + weightMsgTerminatePrivatePlan int + weightMsgFarm int + weightMsgUnfarm int + weightMsgHarvest int ) appParams.GetOrGenerate(cdc, OpWeightMsgCreatePrivatePlan, &weightMsgCreatePrivatePlan, nil, func(_ *rand.Rand) { weightMsgCreatePrivatePlan = DefaultWeightCreatePrivatePlan }) + appParams.GetOrGenerate(cdc, OpWeightMsgTerminatePrivatePlan, &weightMsgTerminatePrivatePlan, nil, func(_ *rand.Rand) { + weightMsgTerminatePrivatePlan = DefaultWeightTerminatePrivatePlan + }) appParams.GetOrGenerate(cdc, OpWeightMsgFarm, &weightMsgFarm, nil, func(_ *rand.Rand) { weightMsgFarm = DefaultWeightFarm }) @@ -66,6 +72,10 @@ func WeightedOperations( weightMsgCreatePrivatePlan, SimulateMsgCreatePrivatePlan(ak, bk, lk, k), ), + simulation.NewWeightedOperation( + weightMsgTerminatePrivatePlan, + SimulateMsgTerminatePrivatePlan(ak, bk, k), + ), simulation.NewWeightedOperation( weightMsgFarm, SimulateMsgFarm(ak, bk), @@ -137,6 +147,55 @@ func SimulateMsgCreatePrivatePlan( } } +func SimulateMsgTerminatePrivatePlan( + 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) { + accs = utils.ShuffleSimAccounts(r, accs) + var simAccount simtypes.Account + var planId uint64 + skip := true + for _, simAccount = range accs { + k.IterateAllPlans(ctx, func(plan types.Plan) (stop bool) { + if !plan.IsTerminated && plan.GetTerminationAddress().Equals(simAccount.Address) { + planId = plan.Id + return true + } + return false + }) + if planId > 0 { + skip = false + break + } + } + if skip { + return simtypes.NoOpMsg( + types.ModuleName, types.TypeMsgFarm, "no account to farm"), nil, nil + } + + msg := types.NewMsgTerminatePrivatePlan(simAccount.Address, planId) + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: appparams.MakeTestEncodingConfig().TxConfig, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + AccountKeeper: ak, + Bankkeeper: bk, + ModuleName: types.ModuleName, + CoinsSpentInMsg: bk.SpendableCoins(ctx, simAccount.Address), + } + + return utils.GenAndDeliverTxWithFees(txCtx, gas, fees) + } +} + func SimulateMsgFarm(ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, diff --git a/x/lpfarm/simulation/operations_test.go b/x/lpfarm/simulation/operations_test.go index efdaab118..703d73208 100644 --- a/x/lpfarm/simulation/operations_test.go +++ b/x/lpfarm/simulation/operations_test.go @@ -84,6 +84,30 @@ func (s *SimTestSuite) TestSimulateMsgCreatePrivatePlan() { s.Require().Equal(utils.ParseTime("2022-01-06T00:00:00Z"), msg.EndTime) } +func (s *SimTestSuite) TestSimulateMsgTerminatePrivatePlan() { + r := rand.New(rand.NewSource(0)) + accs := s.getTestingAccounts(r, 1) + + _, err := s.app.LPFarmKeeper.CreatePrivatePlan(s.ctx, accs[0].Address, "", []types.RewardAllocation{ + types.NewDenomRewardAllocation("stake", utils.ParseCoins("100_000000stake")), + }, utils.ParseTime("0001-01-01T00:00:00Z"), utils.ParseTime("9999-12-31T00:00:00Z")) + s.Require().NoError(err) + + op := simulation.SimulateMsgTerminatePrivatePlan(s.app.AccountKeeper, s.app.BankKeeper, s.keeper) + opMsg, futureOps, err := op(r, s.app.BaseApp, s.ctx, accs, "") + s.Require().NoError(err) + s.Require().True(opMsg.OK) + s.Require().Len(futureOps, 0) + + var msg types.MsgTerminatePrivatePlan + types.ModuleCdc.MustUnmarshalJSON(opMsg.Msg, &msg) + + s.Require().Equal(types.TypeMsgTerminatePrivatePlan, msg.Type()) + s.Require().Equal(types.ModuleName, msg.Route()) + s.Require().Equal("cosmos1tp4es44j4vv8m59za3z0tm64dkmlnm8wg2frhc", msg.Creator) + s.Require().Equal(uint64(1), msg.PlanId) +} + func (s *SimTestSuite) TestSimulateMsgFarm() { r := rand.New(rand.NewSource(0)) accs := s.getTestingAccounts(r, 1) diff --git a/x/lpfarm/types/codec.go b/x/lpfarm/types/codec.go index ff134dd58..e6f41890a 100644 --- a/x/lpfarm/types/codec.go +++ b/x/lpfarm/types/codec.go @@ -13,6 +13,7 @@ import ( // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreatePrivatePlan{}, "lpfarm/MsgCreatePrivatePlan", nil) + cdc.RegisterConcrete(&MsgTerminatePrivatePlan{}, "lpfarm/MsgTerminatePrivatePlan", nil) cdc.RegisterConcrete(&MsgFarm{}, "lpfarm/MsgFarm", nil) cdc.RegisterConcrete(&MsgUnfarm{}, "lpfarm/MsgUnfarm", nil) cdc.RegisterConcrete(&MsgHarvest{}, "lpfarm/MsgHarvest", nil) @@ -25,6 +26,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgCreatePrivatePlan{}, + &MsgTerminatePrivatePlan{}, &MsgFarm{}, &MsgUnfarm{}, &MsgHarvest{}, diff --git a/x/lpfarm/types/msgs.go b/x/lpfarm/types/msgs.go index 32dbc148b..422842c52 100644 --- a/x/lpfarm/types/msgs.go +++ b/x/lpfarm/types/msgs.go @@ -9,6 +9,7 @@ import ( var ( _ sdk.Msg = (*MsgCreatePrivatePlan)(nil) + _ sdk.Msg = (*MsgTerminatePrivatePlan)(nil) _ sdk.Msg = (*MsgFarm)(nil) _ sdk.Msg = (*MsgUnfarm)(nil) _ sdk.Msg = (*MsgHarvest)(nil) @@ -16,10 +17,11 @@ var ( // Message types for the module const ( - TypeMsgCreatePrivatePlan = "create_private_plan" - TypeMsgFarm = "farm" - TypeMsgUnfarm = "unfarm" - TypeMsgHarvest = "harvest" + TypeMsgCreatePrivatePlan = "create_private_plan" + TypeMsgTerminatePrivatePlan = "terminate_private_plan" + TypeMsgFarm = "farm" + TypeMsgUnfarm = "unfarm" + TypeMsgHarvest = "harvest" ) // NewMsgCreatePrivatePlan creates a new MsgCreatePrivatePlan. @@ -74,6 +76,48 @@ func (msg MsgCreatePrivatePlan) GetCreatorAddress() sdk.AccAddress { return addr } +// NewMsgTerminatePrivatePlan creates a new MsgTerminatePrivatePlan. +func NewMsgTerminatePrivatePlan( + creatorAddr sdk.AccAddress, planId uint64) *MsgTerminatePrivatePlan { + return &MsgTerminatePrivatePlan{ + Creator: creatorAddr.String(), + PlanId: planId, + } +} + +func (msg MsgTerminatePrivatePlan) Route() string { return RouterKey } +func (msg MsgTerminatePrivatePlan) Type() string { return TypeMsgTerminatePrivatePlan } + +func (msg MsgTerminatePrivatePlan) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgTerminatePrivatePlan) GetSigners() []sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{addr} +} + +func (msg MsgTerminatePrivatePlan) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address: %v", err) + } + if msg.PlanId == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "plan id must not be 0") + } + return nil +} + +func (msg MsgTerminatePrivatePlan) GetCreatorAddress() sdk.AccAddress { + addr, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return addr +} + // NewMsgFarm creates a new MsgFarm. func NewMsgFarm(farmerAddr sdk.AccAddress, coin sdk.Coin) *MsgFarm { return &MsgFarm{ diff --git a/x/lpfarm/types/tx.pb.go b/x/lpfarm/types/tx.pb.go index e57da10f3..199a6fc69 100644 --- a/x/lpfarm/types/tx.pb.go +++ b/x/lpfarm/types/tx.pb.go @@ -113,6 +113,80 @@ func (m *MsgCreatePrivatePlanResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreatePrivatePlanResponse proto.InternalMessageInfo +type MsgTerminatePrivatePlan struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + PlanId uint64 `protobuf:"varint,2,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` +} + +func (m *MsgTerminatePrivatePlan) Reset() { *m = MsgTerminatePrivatePlan{} } +func (m *MsgTerminatePrivatePlan) String() string { return proto.CompactTextString(m) } +func (*MsgTerminatePrivatePlan) ProtoMessage() {} +func (*MsgTerminatePrivatePlan) Descriptor() ([]byte, []int) { + return fileDescriptor_cf380b18e59baef2, []int{2} +} +func (m *MsgTerminatePrivatePlan) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTerminatePrivatePlan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTerminatePrivatePlan.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 *MsgTerminatePrivatePlan) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTerminatePrivatePlan.Merge(m, src) +} +func (m *MsgTerminatePrivatePlan) XXX_Size() int { + return m.Size() +} +func (m *MsgTerminatePrivatePlan) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTerminatePrivatePlan.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTerminatePrivatePlan proto.InternalMessageInfo + +type MsgTerminatePrivatePlanResponse struct { +} + +func (m *MsgTerminatePrivatePlanResponse) Reset() { *m = MsgTerminatePrivatePlanResponse{} } +func (m *MsgTerminatePrivatePlanResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTerminatePrivatePlanResponse) ProtoMessage() {} +func (*MsgTerminatePrivatePlanResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cf380b18e59baef2, []int{3} +} +func (m *MsgTerminatePrivatePlanResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTerminatePrivatePlanResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTerminatePrivatePlanResponse.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 *MsgTerminatePrivatePlanResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTerminatePrivatePlanResponse.Merge(m, src) +} +func (m *MsgTerminatePrivatePlanResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTerminatePrivatePlanResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTerminatePrivatePlanResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTerminatePrivatePlanResponse proto.InternalMessageInfo + type MsgFarm struct { Farmer string `protobuf:"bytes,1,opt,name=farmer,proto3" json:"farmer,omitempty"` Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin"` @@ -122,7 +196,7 @@ func (m *MsgFarm) Reset() { *m = MsgFarm{} } func (m *MsgFarm) String() string { return proto.CompactTextString(m) } func (*MsgFarm) ProtoMessage() {} func (*MsgFarm) Descriptor() ([]byte, []int) { - return fileDescriptor_cf380b18e59baef2, []int{2} + return fileDescriptor_cf380b18e59baef2, []int{4} } func (m *MsgFarm) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -159,7 +233,7 @@ func (m *MsgFarmResponse) Reset() { *m = MsgFarmResponse{} } func (m *MsgFarmResponse) String() string { return proto.CompactTextString(m) } func (*MsgFarmResponse) ProtoMessage() {} func (*MsgFarmResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cf380b18e59baef2, []int{3} + return fileDescriptor_cf380b18e59baef2, []int{5} } func (m *MsgFarmResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -197,7 +271,7 @@ func (m *MsgUnfarm) Reset() { *m = MsgUnfarm{} } func (m *MsgUnfarm) String() string { return proto.CompactTextString(m) } func (*MsgUnfarm) ProtoMessage() {} func (*MsgUnfarm) Descriptor() ([]byte, []int) { - return fileDescriptor_cf380b18e59baef2, []int{4} + return fileDescriptor_cf380b18e59baef2, []int{6} } func (m *MsgUnfarm) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -234,7 +308,7 @@ func (m *MsgUnfarmResponse) Reset() { *m = MsgUnfarmResponse{} } func (m *MsgUnfarmResponse) String() string { return proto.CompactTextString(m) } func (*MsgUnfarmResponse) ProtoMessage() {} func (*MsgUnfarmResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cf380b18e59baef2, []int{5} + return fileDescriptor_cf380b18e59baef2, []int{7} } func (m *MsgUnfarmResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -272,7 +346,7 @@ func (m *MsgHarvest) Reset() { *m = MsgHarvest{} } func (m *MsgHarvest) String() string { return proto.CompactTextString(m) } func (*MsgHarvest) ProtoMessage() {} func (*MsgHarvest) Descriptor() ([]byte, []int) { - return fileDescriptor_cf380b18e59baef2, []int{6} + return fileDescriptor_cf380b18e59baef2, []int{8} } func (m *MsgHarvest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -309,7 +383,7 @@ func (m *MsgHarvestResponse) Reset() { *m = MsgHarvestResponse{} } func (m *MsgHarvestResponse) String() string { return proto.CompactTextString(m) } func (*MsgHarvestResponse) ProtoMessage() {} func (*MsgHarvestResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cf380b18e59baef2, []int{7} + return fileDescriptor_cf380b18e59baef2, []int{9} } func (m *MsgHarvestResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -341,6 +415,8 @@ var xxx_messageInfo_MsgHarvestResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgCreatePrivatePlan)(nil), "crescent.lpfarm.v1beta1.MsgCreatePrivatePlan") proto.RegisterType((*MsgCreatePrivatePlanResponse)(nil), "crescent.lpfarm.v1beta1.MsgCreatePrivatePlanResponse") + proto.RegisterType((*MsgTerminatePrivatePlan)(nil), "crescent.lpfarm.v1beta1.MsgTerminatePrivatePlan") + proto.RegisterType((*MsgTerminatePrivatePlanResponse)(nil), "crescent.lpfarm.v1beta1.MsgTerminatePrivatePlanResponse") proto.RegisterType((*MsgFarm)(nil), "crescent.lpfarm.v1beta1.MsgFarm") proto.RegisterType((*MsgFarmResponse)(nil), "crescent.lpfarm.v1beta1.MsgFarmResponse") proto.RegisterType((*MsgUnfarm)(nil), "crescent.lpfarm.v1beta1.MsgUnfarm") @@ -352,49 +428,52 @@ func init() { func init() { proto.RegisterFile("crescent/lpfarm/v1beta1/tx.proto", fileDescriptor_cf380b18e59baef2) } var fileDescriptor_cf380b18e59baef2 = []byte{ - // 663 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0x8e, 0x9b, 0x34, 0x69, 0x27, 0x87, 0xdf, 0x2f, 0xab, 0x88, 0x06, 0x0b, 0x39, 0x91, 0xe1, - 0x10, 0x40, 0xb5, 0xdb, 0x14, 0x38, 0x70, 0x41, 0x6d, 0x25, 0x04, 0x87, 0x48, 0x95, 0x55, 0x50, - 0x05, 0x12, 0xd1, 0xc6, 0xde, 0xba, 0x56, 0x6d, 0xaf, 0xb5, 0xbb, 0x4d, 0xda, 0x67, 0xa8, 0x40, - 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x4e, 0x26, 0x46, 0xe9, 0x6c, 0x62, 0x94, 0x3e, 0x4f, 0x8c, 0xd2, 0x9b, 0x27, 0x97, - 0xe7, 0x9c, 0x89, 0x2e, 0xc7, 0x44, 0x8c, 0x29, 0xdb, 0x2f, 0x12, 0xf6, 0xe8, 0x91, 0x7d, 0x98, - 0xff, 0x6b, 0xa8, 0xd9, 0x0f, 0xab, 0xea, 0x4a, 0x5c, 0xfb, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x2e, - 0xdb, 0x9c, 0x99, 0xe7, 0x06, 0x00, 0x00, + // 708 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0xdb, 0x34, 0x69, 0x6f, 0x16, 0xdf, 0x97, 0x51, 0x44, 0x83, 0x85, 0x9c, 0x60, 0x58, + 0x04, 0x50, 0xed, 0x36, 0x05, 0x84, 0xd8, 0xa0, 0xb6, 0x12, 0x02, 0x89, 0x48, 0x95, 0x55, 0x50, + 0x05, 0x12, 0xd1, 0xc4, 0x9e, 0xba, 0x56, 0x1d, 0x8f, 0x35, 0x33, 0x4d, 0xda, 0x2d, 0x5b, 0x04, + 0xea, 0x73, 0xf0, 0x04, 0x3c, 0x42, 0x97, 0x5d, 0xb2, 0xa2, 0xd0, 0xbe, 0x08, 0x9a, 0xf1, 0x0f, + 0x11, 0x24, 0x69, 0x2b, 0x21, 0xc1, 0xca, 0x9e, 0x7b, 0xcf, 0x39, 0x33, 0xf7, 0xce, 0xb9, 0x36, + 0x34, 0x5d, 0x46, 0xb8, 0x4b, 0x22, 0x61, 0x87, 0xf1, 0x0e, 0x66, 0x7d, 0x7b, 0xb0, 0xd2, 0x23, + 0x02, 0xaf, 0xd8, 0xe2, 0xc0, 0x8a, 0x19, 0x15, 0x14, 0x2d, 0x66, 0x08, 0x2b, 0x41, 0x58, 0x29, +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 0x5d, 0x8a, 0x88, 0x18, 0x52, 0xb6, 0x97, 0x07, 0xec, 0xc1, 0x7d, 0xfb, 0x20, 0xfb, 0x57, 0x2a, + 0x03, 0xf6, 0x4a, 0xea, 0x47, 0xb0, 0xfa, 0x23, 0x00, 0x00, 0xff, 0xff, 0x90, 0xda, 0x9d, 0xf7, + 0xdd, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -410,6 +489,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { CreatePrivatePlan(ctx context.Context, in *MsgCreatePrivatePlan, opts ...grpc.CallOption) (*MsgCreatePrivatePlanResponse, error) + TerminatePrivatePlan(ctx context.Context, in *MsgTerminatePrivatePlan, opts ...grpc.CallOption) (*MsgTerminatePrivatePlanResponse, error) Farm(ctx context.Context, in *MsgFarm, opts ...grpc.CallOption) (*MsgFarmResponse, error) Unfarm(ctx context.Context, in *MsgUnfarm, opts ...grpc.CallOption) (*MsgUnfarmResponse, error) Harvest(ctx context.Context, in *MsgHarvest, opts ...grpc.CallOption) (*MsgHarvestResponse, error) @@ -432,6 +512,15 @@ func (c *msgClient) CreatePrivatePlan(ctx context.Context, in *MsgCreatePrivateP return out, nil } +func (c *msgClient) TerminatePrivatePlan(ctx context.Context, in *MsgTerminatePrivatePlan, opts ...grpc.CallOption) (*MsgTerminatePrivatePlanResponse, error) { + out := new(MsgTerminatePrivatePlanResponse) + err := c.cc.Invoke(ctx, "/crescent.lpfarm.v1beta1.Msg/TerminatePrivatePlan", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) Farm(ctx context.Context, in *MsgFarm, opts ...grpc.CallOption) (*MsgFarmResponse, error) { out := new(MsgFarmResponse) err := c.cc.Invoke(ctx, "/crescent.lpfarm.v1beta1.Msg/Farm", in, out, opts...) @@ -462,6 +551,7 @@ func (c *msgClient) Harvest(ctx context.Context, in *MsgHarvest, opts ...grpc.Ca // MsgServer is the server API for Msg service. type MsgServer interface { CreatePrivatePlan(context.Context, *MsgCreatePrivatePlan) (*MsgCreatePrivatePlanResponse, error) + TerminatePrivatePlan(context.Context, *MsgTerminatePrivatePlan) (*MsgTerminatePrivatePlanResponse, error) Farm(context.Context, *MsgFarm) (*MsgFarmResponse, error) Unfarm(context.Context, *MsgUnfarm) (*MsgUnfarmResponse, error) Harvest(context.Context, *MsgHarvest) (*MsgHarvestResponse, error) @@ -474,6 +564,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreatePrivatePlan(ctx context.Context, req *MsgCreatePrivatePlan) (*MsgCreatePrivatePlanResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreatePrivatePlan not implemented") } +func (*UnimplementedMsgServer) TerminatePrivatePlan(ctx context.Context, req *MsgTerminatePrivatePlan) (*MsgTerminatePrivatePlanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TerminatePrivatePlan not implemented") +} func (*UnimplementedMsgServer) Farm(ctx context.Context, req *MsgFarm) (*MsgFarmResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Farm not implemented") } @@ -506,6 +599,24 @@ func _Msg_CreatePrivatePlan_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Msg_TerminatePrivatePlan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTerminatePrivatePlan) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).TerminatePrivatePlan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/crescent.lpfarm.v1beta1.Msg/TerminatePrivatePlan", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).TerminatePrivatePlan(ctx, req.(*MsgTerminatePrivatePlan)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_Farm_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgFarm) if err := dec(in); err != nil { @@ -568,6 +679,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreatePrivatePlan", Handler: _Msg_CreatePrivatePlan_Handler, }, + { + MethodName: "TerminatePrivatePlan", + Handler: _Msg_TerminatePrivatePlan_Handler, + }, { MethodName: "Farm", Handler: _Msg_Farm_Handler, @@ -687,6 +802,64 @@ func (m *MsgCreatePrivatePlanResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *MsgTerminatePrivatePlan) 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 *MsgTerminatePrivatePlan) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTerminatePrivatePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PlanId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PlanId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTerminatePrivatePlanResponse) 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 *MsgTerminatePrivatePlanResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTerminatePrivatePlanResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgFarm) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -969,6 +1142,31 @@ func (m *MsgCreatePrivatePlanResponse) Size() (n int) { return n } +func (m *MsgTerminatePrivatePlan) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.PlanId != 0 { + n += 1 + sovTx(uint64(m.PlanId)) + } + return n +} + +func (m *MsgTerminatePrivatePlanResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgFarm) Size() (n int) { if m == nil { return 0 @@ -1382,6 +1580,157 @@ func (m *MsgCreatePrivatePlanResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgTerminatePrivatePlan) 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: MsgTerminatePrivatePlan: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTerminatePrivatePlan: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanId", wireType) + } + m.PlanId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgTerminatePrivatePlanResponse) 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: MsgTerminatePrivatePlanResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTerminatePrivatePlanResponse: 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 (m *MsgFarm) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0