diff --git a/app/app.go b/app/app.go index 6b067571..bdc2025d 100644 --- a/app/app.go +++ b/app/app.go @@ -88,6 +88,7 @@ import ( farmingparams "github.com/tendermint/farming/app/params" "github.com/tendermint/farming/x/farming" + farmingclient "github.com/tendermint/farming/x/farming/client" farmingkeeper "github.com/tendermint/farming/x/farming/keeper" farmingtypes "github.com/tendermint/farming/x/farming/types" @@ -114,6 +115,7 @@ var ( distr.AppModuleBasic{}, gov.NewAppModuleBasic( paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, + farmingclient.ProposalHandler, // todo: farming proposal handler ), params.AppModuleBasic{}, diff --git a/contrib/devtools/Dockerfile b/contrib/devtools/Dockerfile index 10be4134..e96ccaca 100644 --- a/contrib/devtools/Dockerfile +++ b/contrib/devtools/Dockerfile @@ -6,7 +6,6 @@ ENV GOLANG_PROTOBUF_VERSION=1.3.5 \ GOGO_PROTOBUF_VERSION=1.3.2 \ GRPC_GATEWAY_VERSION=1.14.7 - RUN GO111MODULE=on go get \ github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \ github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \ diff --git a/docs/Explanation/ADR/README.md b/docs/Explanation/ADR/README.md new file mode 100644 index 00000000..66d98d73 --- /dev/null +++ b/docs/Explanation/ADR/README.md @@ -0,0 +1,11 @@ +# Architecture Decision Records (ADR) + +Use this location to record all high-level architecture decisions in the farming module + +## Definitions + +## Rationale + +## Creating new ADR + +## ADR Table of Contents \ No newline at end of file diff --git a/docs/How-To/README.md b/docs/How-To/README.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/How-To/farming_plans.md b/docs/How-To/farming_plans.md new file mode 100644 index 00000000..754322f8 --- /dev/null +++ b/docs/How-To/farming_plans.md @@ -0,0 +1,376 @@ +# Farming Plans + +There are two different types of farming plans in the farming module. Whereas a public farming plan can only be created through governance proposal, a private farming plan can be created with any account or an entity. Read [spec](https://github.com/tendermint/farming/blob/master/x/farming/spec/01_concepts.md) documentation for more information about the plan types. + +In this tutorial, some sample data in JSON structure are provided. We will use command-line interfaces to test the functionality. + +## Table of Contetns + +- [Bootstrap Local Network](#Boostrap) +- [Public Farming Plan](#Public-Farming-Plan) + * [AddPublicFarmingFixedAmountPlan](#AddPublicFarmingFixedAmountPlan) + * [AddPublicFarmingRatioPlan](#AddPublicFarmingRatioPlan) + * [AddMultiplePublicPlans](#AddMultiplePublicPlans) + * [UpdatePublicFarmingFixedAmountPlan](#UpdatePublicFarmingFixedAmountPlan) + * [DeletePublicFarmingFixedAmountPlan](#DeletePublicFarmingFixedAmountPlan) +- [Private Farming Plan](#Private-Farming-Plan) + * [PrivateFarmingFixedAmountPlan](#PrivateFarmingFixedAmountPlan) + * [PrivateFarmingRatioPlan](#PrivateFarmingRatioPlan) +- [REST APIs](#REST-APIs) + +# Bootstrap + +```bash +# Clone the project +git clone https://github.com/tendermint/farming.git +cd cosmos-sdk +make install + +# Configure variables +export BINARY=farmingd +export HOME_1=$HOME/.farmingapp +export CHAIN_ID=localnet +export VALIDATOR_1="struggle panic room apology luggage game screen wing want lazy famous eight robot picture wrap act uphold grab away proud music danger naive opinion" +export USER_1="guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host" +export GENESIS_COINS=10000000000stake,10000000000uatom,10000000000uusd + +# Boostrap +$BINARY init $CHAIN_ID --chain-id $CHAIN_ID +echo $VALIDATOR_1 | $BINARY keys add val1 --keyring-backend test --recover +echo $USER_1 | $BINARY keys add user1 --keyring-backend test --recover +$BINARY add-genesis-account $($BINARY keys show val1 --keyring-backend test -a) $GENESIS_COINS +$BINARY add-genesis-account $($BINARY keys show user1 --keyring-backend test -a) $GENESIS_COINS +$BINARY gentx val1 100000000stake --chain-id $CHAIN_ID --keyring-backend test +$BINARY collect-gentxs + +# Modify app.toml +sed -i '' 's/enable = false/enable = true/g' $HOME_1/config/app.toml +sed -i '' 's/swagger = false/swagger = true/g' $HOME_1/config/app.toml + +# Modify governance proposal for testing purpose +sed -i '' 's%"amount": "10000000"%"amount": "1"%g' $HOME_1/config/genesis.json +sed -i '' 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_1/config/genesis.json +sed -i '' 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_1/config/genesis.json +sed -i '' 's%"voting_period": "172800s"%"voting_period": "60s"%g' $HOME_1/config/genesis.json + +# Start +$BINARY start +``` + +# Public Farming Plan +## AddPublicFarmingFixedAmountPlan + +Create `public-fixed-plan-proposal.json` file in your local directory and copy the below json into the file. + +```json +{ + "title": "Public Farming Plan", + "description": "Are you ready to farm?", + "add_request_proposals": [ + { + "name": "First Public Fixed Amount Plan", + "farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] + } + ] +} +``` + +```bash +# Create public fixed amount plan through governance proposal +farmingd tx gov submit-proposal public-farming-plan public-fixed-plan-proposal.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--deposit 100000stake \ +--broadcast-mode block \ +--yes + +# Vote +# Make sure to change proposal-id for the proposal +farmingd tx gov vote yes \ +--chain-id localnet \ +--from val1 \ +--keyring-backend test \ +--yes +``` + +## AddPublicFarmingRatioPlan + +Create `public-ratio-plan-proposal.json` file in your local directory and copy the below json into the file. + +```json +{ + "title": "Public Farming Plan", + "description": "Are you ready to farm?", + "add_request_proposals": [ + { + "name": "First Public Ratio Plan", + "farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_ratio": "1.000000000000000000" + } + ] +} +``` + +```bash +# Create public ratio plan through governance proposal +farmingd tx gov submit-proposal public-farming-plan public-ratio-plan-proposal.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--deposit 100000stake \ +--broadcast-mode block \ +--yes + +# Vote +# Make sure to change proposal-id for the proposal +farmingd tx gov vote yes \ +--chain-id localnet \ +--from val1 \ +--keyring-backend test \ +--yes +``` + +## AddMultiplePublicPlans + +Create `public-multiple-plans-proposal.json` file in your local directory and copy the below json into the file. + +```json +{ + "title": "Public Farming Plan", + "description": "Are you ready to farm?", + "add_request_proposals": [ + { + "name": "First Public Fixed Amount Plan", + "farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] + }, + { + "name": "First Public Ratio Plan", + "farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_ratio": "1.000000000000000000" + } + ] +} +``` + +```bash +# Create public multiple plans through governance proposal +farmingd tx gov submit-proposal public-farming-plan public-multiple-plans-proposal.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--deposit 100000stake \ +--broadcast-mode block \ +--yes + +# Vote +# Make sure to change proposal-id for the proposal +farmingd tx gov vote yes \ +--chain-id localnet \ +--from val1 \ +--keyring-backend test \ +--yes +``` +## UpdatePublicFarmingFixedAmountPlan + +Create `update-plan-proposal.json` file in your local directory and copy the below json into the file. + +```json +{ + "title": "Update the Farming Plan 1", + "description": "FarmingPoolAddress needs to be changed", + "update_request_proposals": [ + { + "plan_id": 1, + "farming_pool_address": "cosmos13w4ueuk80d3kmwk7ntlhp84fk0arlm3mqf0w08", + "termination_address": "cosmos13w4ueuk80d3kmwk7ntlhp84fk0arlm3mqf0w08", + "staking_coin_weights": [ + { + "denom": "uatom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] + } + ] +} +``` + +```bash +# Update public plan through governance proposal +farmingd tx gov submit-proposal public-farming-plan update-plan-proposal.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--deposit 100000stake \ +--broadcast-mode block \ +--yes + +# Vote +# Make sure to change proposal-id for the proposal +farmingd tx gov vote yes \ +--chain-id localnet \ +--from val1 \ +--keyring-backend test \ +--yes +``` + +## DeletePublicFarmingFixedAmountPlan + +Create `delete-plan-proposal.json` file in your local directory and copy the below json into the file. + +```json +{ + "title": "Delete Public Farming Plan 1", + "description": "This plan is no longer needed", + "delete_request_proposals": [ + { + "plan_id": 1 + } + ] +} +``` + +```bash +# Update public plan through governance proposal +farmingd tx gov submit-proposal public-farming-plan delete-plan-proposal.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--deposit 100000stake \ +--broadcast-mode block \ +--yes + +# Vote +# Make sure to change proposal-id for the proposal +farmingd tx gov vote yes \ +--chain-id localnet \ +--from val1 \ +--keyring-backend test \ +--yes +``` + +# Private Farming Plan + +Create `create-private-fixed-plan.json` file in your local directory and copy the below json into the file. + +## PrivateFarmingFixedAmountPlan + +```json +{ + "name": "This Farming Plan intends to incentivize ATOM HODLERS!", + "staking_coin_weights": [ + { + "denom": "uatom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] +} +``` + +```bash +# Create private fixed amount plan +farmingd tx farming create-private-fixed-plan create-private-fixed-plan.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--yes +``` + +## PrivateFarmingRatioPlan + +Create `create-private-ratio-plan.json` file in your local directory and copy the below json into the file. + +```json +{ + "name": "This Farming Plan intends to incentivize ATOM HODLERS!", + "staking_coin_weights": [ + { + "denom": "uatom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_ratio": "1.000000000000000000" +} +``` + +```bash +# Create private ratio plan +farmingd tx farming create-private-fixed-plan create-private-ratio-plan.json \ +--chain-id localnet \ +--from user1 \ +--keyring-backend test \ +--yes +``` + +## REST APIs + +- http://localhost:1317/cosmos/bank/v1beta1/balances/{ADDRESS} +- http://localhost:1317/cosmos/gov/v1beta1/proposals +- http://localhost:1317/cosmos/farming/v1beta1/plans +- http://localhost:1317/cosmos/tx/v1beta1/txs/{TX_HASH} \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..d7eb5d38 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,9 @@ +# Farming Module Documentation + +## Get Started + +## References + +## Other Resources + +## Contribute diff --git a/docs/Tutorials/README.md b/docs/Tutorials/README.md new file mode 100644 index 00000000..a390cfec --- /dev/null +++ b/docs/Tutorials/README.md @@ -0,0 +1 @@ +## Tutorials diff --git a/proto/tendermint/farming/v1beta1/farming.proto b/proto/tendermint/farming/v1beta1/farming.proto index 5056b786..da32f2cc 100644 --- a/proto/tendermint/farming/v1beta1/farming.proto +++ b/proto/tendermint/farming/v1beta1/farming.proto @@ -51,36 +51,39 @@ message BasePlan { // id specifies index of the farming plan uint64 id = 1; + // name specifies the name for the base plan + string name = 2; + // type specifies the plan type; type 0 is public and 1 is private // public plan must be created through governance proposal and private plan is // created by account - PlanType type = 2; + PlanType type = 3; // farming_pool_address defines the bech32-encoded address of the farming pool - string farming_pool_address = 3 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; + string farming_pool_address = 4 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; // reward_pool_address defines the bech32-encoded address that distributes // reward amount of coins to farmers - string reward_pool_address = 4 [(gogoproto.moretags) = "yaml:\"reward_pool_address\""]; + string reward_pool_address = 5 [(gogoproto.moretags) = "yaml:\"reward_pool_address\""]; // termination_address defines the bech32-encoded address that terminates plan // when the plan ends after the end time, the balance of farming pool address // is transferred to the termination address - string termination_address = 5 [(gogoproto.moretags) = "yaml:\"termination_address\""]; + string termination_address = 6 [(gogoproto.moretags) = "yaml:\"termination_address\""]; // staking_coin_weights specifies coin weights for the plan - repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 6 [ + repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 7 [ (gogoproto.moretags) = "yaml:\"staking_coin_weights\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false ]; // start_time specifies the start time of the plan - google.protobuf.Timestamp start_time = 7 + google.protobuf.Timestamp start_time = 8 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""]; // end_time specifies the end time of the plan - google.protobuf.Timestamp end_time = 8 + google.protobuf.Timestamp end_time = 9 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"end_time\""]; } diff --git a/proto/tendermint/farming/v1beta1/proposal.proto b/proto/tendermint/farming/v1beta1/proposal.proto index 3ffef338..b6dee06c 100644 --- a/proto/tendermint/farming/v1beta1/proposal.proto +++ b/proto/tendermint/farming/v1beta1/proposal.proto @@ -4,20 +4,129 @@ package tendermint.farming.v1beta1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "tendermint/farming/v1beta1/farming.proto"; -import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; option go_package = "github.com/tendermint/farming/x/farming/types"; -// PublicPlanProposal details a proposal for creating a public plan. +// PublicPlanProposal defines a public farming plan governance proposal that receives one of the following requests: +// A request that creates a public farming plan, a request that updates the plan, and a request that deletes the plan. +// For public plan creation, depending on which field is passed, either epoch amount or epoch ratio, it creates a fixed +// amount plan or ratio plan. message PublicPlanProposal { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - string title = 1; + // title specifies the title of the plan + string title = 1; + + // description specifies the description of the plan string description = 2; - // plans specifies the plan interface(s); it can be FixedAmountPlan or - // RatioPlan - repeated google.protobuf.Any plans = 3; + // add_request_proposals specifies AddRequestProposal object + repeated AddRequestProposal add_request_proposals = 3 [(gogoproto.moretags) = "yaml:\"add_request_proposals\""]; + + // update_request_proposals specifies UpdateRequestProposal object + repeated UpdateRequestProposal update_request_proposals = 4 + [(gogoproto.moretags) = "yaml:\"update_request_proposals\""]; + + // delete_request_proposals specifies DeleteRequestProposal object + repeated DeleteRequestProposal delete_request_proposals = 5 + [(gogoproto.moretags) = "yaml:\"delete_request_proposals\""]; +} + +// AddRequestProposal details a proposal for creating a public plan. +message AddRequestProposal { + // name specifies the plan name that describes what plan is for + string name = 1; + + // farming_pool_address defines the bech32-encoded address of the farming pool + string farming_pool_address = 2 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; + + // termination_address defines the bech32-encoded address that terminates plan + // when the plan ends after the end time, the balance of farming pool address + // is transferred to the termination address + string termination_address = 3 [(gogoproto.moretags) = "yaml:\"termination_address\""]; + + // staking_coin_weights specifies coin weights for the plan + repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 4 [ + (gogoproto.moretags) = "yaml:\"staking_coin_weights\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + + // start_time specifies the start time of the plan + google.protobuf.Timestamp start_time = 5 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""]; + + // end_time specifies the end time of the plan + google.protobuf.Timestamp end_time = 6 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"end_time\""]; + + // epoch_amount specifies the distributing amount for each epoch + repeated cosmos.base.v1beta1.Coin epoch_amount = 7 [ + (gogoproto.moretags) = "yaml:\"epoch_amount\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; + + // epoch_ratio specifies the distributing amount by ratio + string epoch_ratio = 8 [ + (gogoproto.moretags) = "yaml:\"epoch_ratio\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// UpdateRequestProposal details a proposal for updating an existing public plan. +message UpdateRequestProposal { + // plan_id specifies index of the farming plan + uint64 plan_id = 1; + + // name specifies the plan name that describes what plan is for + string name = 2; + + // farming_pool_address defines the bech32-encoded address of the farming pool + string farming_pool_address = 3 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; + + // termination_address defines the bech32-encoded address that terminates plan + // when the plan ends after the end time, the balance of farming pool address + // is transferred to the termination address + string termination_address = 4 [(gogoproto.moretags) = "yaml:\"termination_address\""]; + + // staking_coin_weights specifies coin weights for the plan + repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 5 [ + (gogoproto.moretags) = "yaml:\"staking_coin_weights\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + + // start_time specifies the start time of the plan + google.protobuf.Timestamp start_time = 6 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = true, (gogoproto.moretags) = "yaml:\"start_time\""]; + + // end_time specifies the end time of the plan + google.protobuf.Timestamp end_time = 7 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = true, (gogoproto.moretags) = "yaml:\"end_time\""]; + + // epoch_amount specifies the distributing amount for each epoch + repeated cosmos.base.v1beta1.Coin epoch_amount = 8 [ + (gogoproto.moretags) = "yaml:\"epoch_amount\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.nullable) = false + ]; + + // epoch_ratio specifies the distributing amount by ratio + string epoch_ratio = 9 [ + (gogoproto.moretags) = "yaml:\"epoch_ratio\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// DeleteRequestProposal details a proposal for deleting an existing public plan. +message DeleteRequestProposal { + // plan_id specifies index of the farming plan + uint64 plan_id = 1; } diff --git a/proto/tendermint/farming/v1beta1/tx.proto b/proto/tendermint/farming/v1beta1/tx.proto index ea5081e8..c7566ef1 100644 --- a/proto/tendermint/farming/v1beta1/tx.proto +++ b/proto/tendermint/farming/v1beta1/tx.proto @@ -33,26 +33,29 @@ service Msg { message MsgCreateFixedAmountPlan { option (gogoproto.goproto_getters) = false; + // name specifies the name for the plan + string name = 1; + // farming_pool_address defines the bech32-encoded address of the farming pool - string farming_pool_address = 1 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; + string farming_pool_address = 2 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; // staking_coin_weights specifies coins weight for the plan - repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 2 [ + repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 3 [ (gogoproto.moretags) = "yaml:\"staking_coin_weights\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false ]; // start_time specifies the start time of the plan - google.protobuf.Timestamp start_time = 3 + google.protobuf.Timestamp start_time = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""]; // end_time specifies the end time of the plan - google.protobuf.Timestamp end_time = 4 + google.protobuf.Timestamp end_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"end_time\""]; // epoch_amount specifies the distributing amount for each epoch - repeated cosmos.base.v1beta1.Coin epoch_amount = 5 [ + repeated cosmos.base.v1beta1.Coin epoch_amount = 6 [ (gogoproto.moretags) = "yaml:\"epoch_amount\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false @@ -68,26 +71,29 @@ message MsgCreateFixedAmountPlanResponse {} message MsgCreateRatioPlan { option (gogoproto.goproto_getters) = false; + // name specifies the name for the plan + string name = 1; + // farming_pool_address defines the bech32-encoded address of the farming pool - string farming_pool_address = 1 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; + string farming_pool_address = 2 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""]; // staking_coin_weights specifies coins weight for the plan - repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 2 [ + repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 3 [ (gogoproto.moretags) = "yaml:\"staking_coin_weights\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false ]; // start_time specifies the start time of the plan - google.protobuf.Timestamp start_time = 3 + google.protobuf.Timestamp start_time = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""]; // end_time specifies the end time of the plan - google.protobuf.Timestamp end_time = 4 + google.protobuf.Timestamp end_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"end_time\""]; // epoch_ratio specifies the distributing amount by ratio - string epoch_ratio = 5 [ + string epoch_ratio = 6 [ (gogoproto.moretags) = "yaml:\"epoch_ratio\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false diff --git a/x/farming/client/cli/tx.go b/x/farming/client/cli/tx.go index 63a88630..b7b2e467 100644 --- a/x/farming/client/cli/tx.go +++ b/x/farming/client/cli/tx.go @@ -3,14 +3,17 @@ package cli import ( "fmt" "strings" - "time" + + "github.com/spf13/cobra" "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" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/version" - "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/tendermint/farming/x/farming/types" ) @@ -38,14 +41,35 @@ func GetTxCmd() *cobra.Command { func NewCreateFixedAmountPlanCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-fixed-plan", - Aliases: []string{"cf"}, - Args: cobra.ExactArgs(0), - Short: "create fixed amount farming plan", + Use: "create-private-fixed-plan [plan-file]", + Args: cobra.ExactArgs(1), + Short: "create private fixed amount farming plan", Long: strings.TrimSpace( - fmt.Sprintf(`Create fixed amount farming plan. + fmt.Sprintf(`Create private fixed amount farming plan. +The plan details must be provided through a JSON file. + Example: -$ %s tx %s create-fixed-plan --from mykey +$ %s tx %s create-private-fixed-plan --from mykey + +Where plan.json contains: + +{ + "name": "This plan intends to provide incentives for Cosmonauts!", + "staking_coin_weights": [ + { + "denom": "uatom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-24T08:41:21.662422Z", + "end_time": "2022-07-28T08:41:21.662422Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] +} `, version.AppName, types.ModuleName, ), @@ -55,28 +79,29 @@ $ %s tx %s create-fixed-plan --from mykey if err != nil { return err } - planCreator := clientCtx.GetFromAddress() - - fmt.Println("planCreator: ", planCreator) - // TODO: replace dummy data - farmingPoolAddr := sdk.AccAddress{} - stakingCoinWeights := sdk.DecCoins{} - startTime := time.Time{} - endTime := time.Time{} - epochAmount := sdk.Coins{} + plan, err := ParsePrivateFixedPlan(args[0]) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "failed to parse %s file due to %v", args[0], err) + } msg := types.NewMsgCreateFixedAmountPlan( - farmingPoolAddr, - stakingCoinWeights, - startTime, - endTime, - epochAmount, + plan.Name, + clientCtx.GetFromAddress(), + plan.StakingCoinWeights, + plan.StartTime, + plan.EndTime, + plan.EpochAmount, ) + if err = msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } + flags.AddTxFlagsToCmd(cmd) return cmd @@ -84,14 +109,30 @@ $ %s tx %s create-fixed-plan --from mykey func NewCreateRatioPlanCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-ratio-plan", - Aliases: []string{"cr"}, - Args: cobra.ExactArgs(0), - Short: "create ratio farming plan", + Use: "create-private-ratio-plan [plan-file]", + Args: cobra.ExactArgs(1), + Short: "create private ratio farming plan", Long: strings.TrimSpace( - fmt.Sprintf(`Create ratio farming plan. + fmt.Sprintf(`Create private ratio farming plan. +The plan details must be provided through a JSON file. + Example: -$ %s tx %s create-ratio-plan --from mykey +$ %s tx %s create-private-ratio-plan --from mykey + +Where plan.json contains: + +{ + "name": "This plan intends to provide incentives for Cosmonauts!", + "staking_coin_weights": [ + { + "denom": "uatom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_ratio": "1.000000000000000000" +} `, version.AppName, types.ModuleName, ), @@ -101,28 +142,29 @@ $ %s tx %s create-ratio-plan --from mykey if err != nil { return err } - planCreator := clientCtx.GetFromAddress() - - fmt.Println("planCreator: ", planCreator) - // TODO: replace dummy data - farmingPoolAddr := sdk.AccAddress{} - stakingCoinWeights := sdk.DecCoins{} - startTime := time.Time{} - endTime := time.Time{} - epochRatio := sdk.Dec{} + plan, err := ParsePrivateRatioPlan(args[0]) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "failed to parse %s file due to %v", args[0], err) + } msg := types.NewMsgCreateRatioPlan( - farmingPoolAddr, - stakingCoinWeights, - startTime, - endTime, - epochRatio, + plan.Name, + clientCtx.GetFromAddress(), + plan.StakingCoinWeights, + plan.StartTime, + plan.EndTime, + plan.EpochRatio, ) + if err = msg.ValidateBasic(); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } + flags.AddTxFlagsToCmd(cmd) return cmd @@ -227,3 +269,90 @@ $ %s tx %s harvest --from mykey return cmd } + +// GetCmdSubmitPublicPlanProposal implements a command handler for submitting a public farming plan transaction to create, update, delete plan. +func GetCmdSubmitPublicPlanProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "public-farming-plan [proposal-file] [flags]", + Args: cobra.ExactArgs(1), + Short: "Submit a public farming plan", + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a a public farming plan along with an initial deposit. +The proposal details must be supplied via a JSON file. + +Example: +$ %s tx gov submit-proposal public-farming-plan --from= --deposit= + +Where proposal.json contains: + +{ + "title": "Public Farming Plan", + "description": "Are you ready to farm?", + "name": "Cosmos Hub Community Tax", + "add_request_proposals": [ + { + "farming_pool_address": "cosmos1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cshz5xu", + "termination_address": "cosmos1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cshz5xu", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21.662422Z", + "end_time": "2022-07-16T08:41:21.662422Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] + } + ] +} +`, + version.AppName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if 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 + } + + proposal, err := ParsePublicPlanProposal(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + content, err := types.NewPublicPlanProposal(proposal.Title, proposal.Description, + proposal.AddRequestProposals, proposal.UpdateRequestProposals, proposal.DeleteRequestProposals) + if err != nil { + return err + } + + from := clientCtx.GetFromAddress() + + msg, err := gov.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") + + return cmd +} diff --git a/x/farming/client/cli/utils.go b/x/farming/client/cli/utils.go new file mode 100644 index 00000000..fd3d3977 --- /dev/null +++ b/x/farming/client/cli/utils.go @@ -0,0 +1,78 @@ +package cli + +import ( + "encoding/json" + "io/ioutil" + "time" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/tendermint/farming/x/farming/types" +) + +// PrivateFixedPlanRequest defines CLI request for a private fixed plan. +type PrivateFixedPlanRequest struct { + Name string `json:"name"` + StakingCoinWeights sdk.DecCoins `json:"staking_coin_weights"` + StartTime time.Time `json:"start_time"` + EndTime time.Time `json:"end_time"` + EpochAmount sdk.Coins `json:"epoch_amount"` +} + +// PrivateRatioPlanRequest defines CLI request for a private ratio plan. +type PrivateRatioPlanRequest struct { + Name string `json:"name"` + StakingCoinWeights sdk.DecCoins `json:"staking_coin_weights"` + StartTime time.Time `json:"start_time"` + EndTime time.Time `json:"end_time"` + EpochRatio sdk.Dec `json:"epoch_ratio"` +} + +// ParsePrivateFixedPlan reads and parses a PrivateFixedPlanRequest from a file. +func ParsePrivateFixedPlan(file string) (PrivateFixedPlanRequest, error) { + plan := PrivateFixedPlanRequest{} + + contents, err := ioutil.ReadFile(file) + if err != nil { + return plan, err + } + + if err = json.Unmarshal(contents, &plan); err != nil { + return plan, err + } + + return plan, nil +} + +// ParsePrivateRatioPlan reads and parses a PrivateRatioPlanRequest from a file. +func ParsePrivateRatioPlan(file string) (PrivateRatioPlanRequest, error) { + plan := PrivateRatioPlanRequest{} + + contents, err := ioutil.ReadFile(file) + if err != nil { + return plan, err + } + + if err = json.Unmarshal(contents, &plan); err != nil { + return plan, err + } + + return plan, nil +} + +// ParsePublicPlanProposal reads and parses a PublicPlanProposal from a file. +func ParsePublicPlanProposal(cdc codec.JSONCodec, proposalFile string) (types.PublicPlanProposal, error) { + proposal := types.PublicPlanProposal{} + + contents, err := ioutil.ReadFile(proposalFile) + if err != nil { + return proposal, err + } + + if err = cdc.UnmarshalJSON(contents, &proposal); err != nil { + return proposal, err + } + + return proposal, nil +} diff --git a/x/farming/client/cli/utils_test.go b/x/farming/client/cli/utils_test.go new file mode 100644 index 00000000..6b115c6f --- /dev/null +++ b/x/farming/client/cli/utils_test.go @@ -0,0 +1,108 @@ +package cli_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/testutil" + + "github.com/tendermint/farming/app/params" + "github.com/tendermint/farming/x/farming/client/cli" +) + +func TestParsePrivateFixedPlan(t *testing.T) { + okJSON := testutil.WriteToNewTempFile(t, ` +{ + "name": "This plan intends to provide incentives for Cosmonauts!", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21Z", + "end_time": "2022-07-16T08:41:21Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] +} +`) + + plan, err := cli.ParsePrivateFixedPlan(okJSON.Name()) + require.NoError(t, err) + + require.Equal(t, "This plan intends to provide incentives for Cosmonauts!", plan.Name) + require.Equal(t, "1.000000000000000000PoolCoinDenom", plan.StakingCoinWeights.String()) + require.Equal(t, "2021-07-15T08:41:21Z", plan.StartTime.Format(time.RFC3339)) + require.Equal(t, "2022-07-16T08:41:21Z", plan.EndTime.Format(time.RFC3339)) + require.Equal(t, "1uatom", plan.EpochAmount.String()) +} + +func TestParsePrivateRatioPlan(t *testing.T) { + okJSON := testutil.WriteToNewTempFile(t, ` +{ + "name": "This plan intends to provide incentives for Cosmonauts!", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21Z", + "end_time": "2022-07-16T08:41:21Z", + "epoch_ratio": "1.000000000000000000" +} +`) + + plan, err := cli.ParsePrivateRatioPlan(okJSON.Name()) + require.NoError(t, err) + + require.Equal(t, "This plan intends to provide incentives for Cosmonauts!", plan.Name) + require.Equal(t, "1.000000000000000000PoolCoinDenom", plan.StakingCoinWeights.String()) + require.Equal(t, "2021-07-15T08:41:21Z", plan.StartTime.Format(time.RFC3339)) + require.Equal(t, "2022-07-16T08:41:21Z", plan.EndTime.Format(time.RFC3339)) + require.Equal(t, "1.000000000000000000", plan.EpochRatio.String()) +} + +func TestParsePublicPlanProposal(t *testing.T) { + encodingConfig := params.MakeTestEncodingConfig() + + okJSON := testutil.WriteToNewTempFile(t, ` +{ + "title": "Public Farming Plan", + "description": "Are you ready to farm?", + "add_request_proposals": [ + { + "name": "First Public Farming Plan", + "farming_pool_address": "cosmos1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cshz5xu", + "termination_address": "cosmos1mzgucqnfr2l8cj5apvdpllhzt4zeuh2cshz5xu", + "staking_coin_weights": [ + { + "denom": "PoolCoinDenom", + "amount": "1.000000000000000000" + } + ], + "start_time": "2021-07-15T08:41:21Z", + "end_time": "2022-07-16T08:41:21Z", + "epoch_amount": [ + { + "denom": "uatom", + "amount": "1" + } + ] + } + ] +} +`) + + proposal, err := cli.ParsePublicPlanProposal(encodingConfig.Marshaler, okJSON.Name()) + require.NoError(t, err) + + require.Equal(t, "Public Farming Plan", proposal.Title) + require.Equal(t, "Are you ready to farm?", proposal.Description) +} diff --git a/x/farming/client/proposal_handler.go b/x/farming/client/proposal_handler.go index d5703867..a8d00a97 100644 --- a/x/farming/client/proposal_handler.go +++ b/x/farming/client/proposal_handler.go @@ -1,12 +1,13 @@ package client -// import ( -// "github.com/tendermint/farming/x/farming/client/cli" -// "github.com/tendermint/farming/x/farming/client/rest" -// govclient "github.com/cosmos/cosmos-sdk/x/gov/client" -// ) +import ( + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" -// // ProposalHandler is the public plan creation handler. -// var ( -// ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, rest.ProposalRESTHandler) -// ) + "github.com/tendermint/farming/x/farming/client/cli" + "github.com/tendermint/farming/x/farming/client/rest" +) + +// ProposalHandler is the public plan creation handler. +var ( + ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitPublicPlanProposal, rest.ProposalRESTHandler) +) diff --git a/x/farming/client/rest/rest.go b/x/farming/client/rest/rest.go new file mode 100644 index 00000000..fdf6ddf9 --- /dev/null +++ b/x/farming/client/rest/rest.go @@ -0,0 +1,24 @@ +package rest + +import ( + "net/http" + + "github.com/cosmos/cosmos-sdk/client" + govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" +) + +// TODO: not implemented yet; +// although this legacy REST API may not be needed, it needs for ProposalHandler; otherwise it throws panic when starting the chain + +// ProposalRESTHandler returns a ProposalRESTHandler that exposes the farming plan proposal (add/update/delete) REST handler with a given sub-route. +func ProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { + return govrest.ProposalRESTHandler{ + SubRoute: "farming_plan", + Handler: postProposalHandlerFn(clientCtx), + } +} + +func postProposalHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + } +} diff --git a/x/farming/handler.go b/x/farming/handler.go index 03ec28d2..50de9cdb 100644 --- a/x/farming/handler.go +++ b/x/farming/handler.go @@ -46,7 +46,7 @@ func NewPublicPlanProposal(k keeper.Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { case *types.PublicPlanProposal: - return keeper.HandlePublicPlanProposal(ctx, k, c.Plans) + return keeper.HandlePublicPlanProposal(ctx, k, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized farming proposal content type: %T", c) diff --git a/x/farming/handler_test.go b/x/farming/handler_test.go index 0ec86b78..7b3f6537 100644 --- a/x/farming/handler_test.go +++ b/x/farming/handler_test.go @@ -40,6 +40,7 @@ func createTestInput() (*farmingapp.FarmingApp, sdk.Context, []sdk.AccAddress) { func TestMsgCreateFixedAmountPlan(t *testing.T) { app, ctx, addrs := createTestInput() + name := "test" farmingPoolAddr := addrs[0] stakingCoinWeights := sdk.NewDecCoins( sdk.DecCoin{Denom: "testFarmStakingCoinDenom", Amount: sdk.MustNewDecFromStr("1.0")}, @@ -49,6 +50,7 @@ func TestMsgCreateFixedAmountPlan(t *testing.T) { epochAmount := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1))) msg := types.NewMsgCreateFixedAmountPlan( + name, farmingPoolAddr, stakingCoinWeights, startTime, @@ -68,6 +70,7 @@ func TestMsgCreateFixedAmountPlan(t *testing.T) { func TestMsgCreateRatioPlan(t *testing.T) { app, ctx, addrs := createTestInput() + name := "test" farmingPoolAddr := addrs[0] stakingCoinWeights := sdk.NewDecCoins( sdk.DecCoin{Denom: "testFarmStakingCoinDenom", Amount: sdk.MustNewDecFromStr("1.0")}, @@ -77,6 +80,7 @@ func TestMsgCreateRatioPlan(t *testing.T) { epochAmount := sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(1))) msg := types.NewMsgCreateFixedAmountPlan( + name, farmingPoolAddr, stakingCoinWeights, startTime, diff --git a/x/farming/keeper/plan.go b/x/farming/keeper/plan.go index 8c2906b0..c5deec59 100644 --- a/x/farming/keeper/plan.go +++ b/x/farming/keeper/plan.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - gogotypes "github.com/gogo/protobuf/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -174,9 +172,9 @@ func (k Keeper) CreateFixedAmountPlan(ctx sdk.Context, msg *types.MsgCreateFixed params := k.GetParams(ctx) balances := k.bankKeeper.GetAllBalances(ctx, farmingPoolAddrAcc) - _, hasNeg := balances.SafeSub(params.PrivatePlanCreationFee) + diffs, hasNeg := balances.SafeSub(params.PrivatePlanCreationFee) if hasNeg { - return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "insufficient balance to pay private plan creation fee") + return nil, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "lack of %s coins to pay private plan createion fee", diffs.String()) } farmingFeeCollectorAcc, err := sdk.AccAddressFromBech32(params.FarmingFeeCollector) @@ -190,6 +188,7 @@ func (k Keeper) CreateFixedAmountPlan(ctx sdk.Context, msg *types.MsgCreateFixed basePlan := types.NewBasePlan( nextId, + msg.Name, typ, farmingPoolAddrAcc.String(), terminationAddrAcc.String(), @@ -228,9 +227,9 @@ func (k Keeper) CreateRatioPlan(ctx sdk.Context, msg *types.MsgCreateRatioPlan, params := k.GetParams(ctx) balances := k.bankKeeper.GetAllBalances(ctx, farmingPoolAddrAcc) - _, hasNeg := balances.SafeSub(params.PrivatePlanCreationFee) + diffs, hasNeg := balances.SafeSub(params.PrivatePlanCreationFee) if hasNeg { - return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "insufficient balance to pay private plan creation fee") + return nil, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "lack of %s coins to pay private plan createion fee", diffs.String()) } farmingFeeCollectorAcc, err := sdk.AccAddressFromBech32(params.FarmingFeeCollector) @@ -244,6 +243,7 @@ func (k Keeper) CreateRatioPlan(ctx sdk.Context, msg *types.MsgCreateRatioPlan, basePlan := types.NewBasePlan( nextId, + msg.Name, typ, farmingPoolAddrAcc.String(), terminationAddrAcc.String(), @@ -263,7 +263,7 @@ func (k Keeper) CreateRatioPlan(ctx sdk.Context, msg *types.MsgCreateRatioPlan, sdk.NewAttribute(types.AttributeKeyRewardPoolAddress, ratioPlan.RewardPoolAddress), sdk.NewAttribute(types.AttributeKeyStartTime, msg.StartTime.String()), sdk.NewAttribute(types.AttributeKeyEndTime, msg.EndTime.String()), - sdk.NewAttribute(types.AttributeKeyEpochRatio, fmt.Sprint(msg.EpochRatio)), + sdk.NewAttribute(types.AttributeKeyEpochRatio, msg.EpochRatio.String()), ), }) diff --git a/x/farming/keeper/plan_test.go b/x/farming/keeper/plan_test.go index fa411738..294d38b6 100644 --- a/x/farming/keeper/plan_test.go +++ b/x/farming/keeper/plan_test.go @@ -11,8 +11,10 @@ import ( ) func (suite *KeeperTestSuite) TestGetSetNewPlan() { + name := "" farmingPoolAddr := sdk.AccAddress("farmingPoolAddr") terminationAddr := sdk.AccAddress("terminationAddr") + stakingCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000000))) coinWeights := sdk.NewDecCoins( sdk.DecCoin{Denom: "testFarmStakingCoinDenom", Amount: sdk.MustNewDecFromStr("1.0")}, @@ -23,7 +25,7 @@ func (suite *KeeperTestSuite) TestGetSetNewPlan() { startTime := time.Now().UTC() endTime := startTime.AddDate(1, 0, 0) - basePlan := types.NewBasePlan(1, 1, farmingPoolAddr.String(), terminationAddr.String(), coinWeights, startTime, endTime) + basePlan := types.NewBasePlan(1, name, 1, farmingPoolAddr.String(), terminationAddr.String(), coinWeights, startTime, endTime) fixedPlan := types.NewFixedAmountPlan(basePlan, sdk.NewCoins(sdk.NewCoin("testFarmCoinDenom", sdk.NewInt(1000000)))) suite.keeper.SetPlan(suite.ctx, fixedPlan) diff --git a/x/farming/keeper/proposal_handler.go b/x/farming/keeper/proposal_handler.go index a6d385fd..61980b69 100644 --- a/x/farming/keeper/proposal_handler.go +++ b/x/farming/keeper/proposal_handler.go @@ -1,60 +1,227 @@ package keeper import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/tendermint/farming/x/farming/types" ) -// HandlePublicPlanProposal is a handler for executing a fixed amount plan creation proposal. -func HandlePublicPlanProposal(ctx sdk.Context, k Keeper, plansAny []*codectypes.Any) error { - plans, err := types.UnpackPlans(plansAny) - if err != nil { +// HandlePublicPlanProposal is a handler for executing a public plan creation proposal. +func HandlePublicPlanProposal(ctx sdk.Context, k Keeper, proposal *types.PublicPlanProposal) error { + if err := proposal.ValidateBasic(); err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + if proposal.AddRequestProposals != nil { + if err := k.AddPublicPlanProposal(ctx, proposal.AddRequestProposals); err != nil { + return err + } + } + + if proposal.UpdateRequestProposals != nil { + if err := k.UpdatePublicPlanProposal(ctx, proposal.UpdateRequestProposals); err != nil { + return err + } + } + + if proposal.DeleteRequestProposals != nil { + if err := k.DeletePublicPlanProposal(ctx, proposal.DeleteRequestProposals); err != nil { + return err + } + } + + plans := k.GetAllPlans(ctx) + if err := types.ValidateRatioPlans(plans); err != nil { return err } - for _, plan := range plans { - switch p := plan.(type) { - case *types.FixedAmountPlan: + return nil +} + +// AddPublicPlanProposal adds a new public plan once the governance proposal is passed. +func (k Keeper) AddPublicPlanProposal(ctx sdk.Context, proposals []*types.AddRequestProposal) error { + for _, p := range proposals { + farmingPoolAddrAcc, err := sdk.AccAddressFromBech32(p.GetFarmingPoolAddress()) + if err != nil { + return err + } + + if !p.EpochAmount.IsZero() && !p.EpochAmount.IsAnyNegative() { msg := types.NewMsgCreateFixedAmountPlan( - p.GetFarmingPoolAddress(), + p.GetName(), + farmingPoolAddrAcc, p.GetStakingCoinWeights(), p.GetStartTime(), p.GetEndTime(), p.EpochAmount, ) - fixedPlan, err := k.CreateFixedAmountPlan(ctx, msg, types.PlanTypePublic) + plan, err := k.CreateFixedAmountPlan(ctx, msg, types.PlanTypePublic) if err != nil { return err } logger := k.Logger(ctx) - logger.Info("created public fixed amount plan", "fixed_amount_plan", fixedPlan) + logger.Info("created public fixed amount plan", "fixed_amount_plan", plan) - case *types.RatioPlan: + } else if !p.EpochRatio.IsZero() && !p.EpochRatio.IsNegative() && !p.EpochRatio.IsNil() { msg := types.NewMsgCreateRatioPlan( - p.GetFarmingPoolAddress(), + p.GetName(), + farmingPoolAddrAcc, p.GetStakingCoinWeights(), p.GetStartTime(), p.GetEndTime(), p.EpochRatio, ) - ratioPlan, err := k.CreateRatioPlan(ctx, msg, types.PlanTypePublic) + plan, err := k.CreateRatioPlan(ctx, msg, types.PlanTypePublic) if err != nil { return err } logger := k.Logger(ctx) - logger.Info("created public fixed amount plan", "ratio_plan", ratioPlan) + logger.Info("created public ratio amount plan", "ratio_plan", plan) + } + } + + return nil +} + +// UpdatePublicPlanProposal overwrites the plan with the new plan proposal once the governance proposal is passed. +func (k Keeper) UpdatePublicPlanProposal(ctx sdk.Context, proposals []*types.UpdateRequestProposal) error { + for _, p := range proposals { + plan, found := k.GetPlan(ctx, p.GetPlanId()) + if !found { + return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "plan %d is not found", p.GetPlanId()) + } + + switch plan := plan.(type) { + case *types.FixedAmountPlan: + if p.GetFarmingPoolAddress() != "" { + farmingPoolAddrAcc, err := sdk.AccAddressFromBech32(p.GetFarmingPoolAddress()) + if err != nil { + return err + } + if err := plan.SetFarmingPoolAddress(farmingPoolAddrAcc); err != nil { + return err + } + } + + if p.GetTerminationAddress() != "" { + terminationAddrAcc, err := sdk.AccAddressFromBech32(p.GetTerminationAddress()) + if err != nil { + return err + } + if err := plan.SetTerminationAddress(terminationAddrAcc); err != nil { + return err + } + } + + if p.GetStakingCoinWeights() != nil { + if err := plan.SetStakingCoinWeights(p.GetStakingCoinWeights()); err != nil { + return err + } + } + + if p.GetStartTime() != nil { + if err := plan.SetStartTime(*p.GetStartTime()); err != nil { + return err + } + } + + if p.GetEndTime() != nil { + if err := plan.SetEndTime(*p.GetEndTime()); err != nil { + return err + } + } + + if p.GetName() != "" { + plan.Name = p.GetName() + } + + if p.GetEpochAmount() != nil { + plan.EpochAmount = p.GetEpochAmount() + } + + k.SetPlan(ctx, plan) + + logger := k.Logger(ctx) + logger.Info("updated public fixed amount plan", "fixed_amount_plan", plan) + + case *types.RatioPlan: + if p.GetFarmingPoolAddress() != "" { + farmingPoolAddrAcc, err := sdk.AccAddressFromBech32(p.GetFarmingPoolAddress()) + if err != nil { + return err + } + if err := plan.SetFarmingPoolAddress(farmingPoolAddrAcc); err != nil { + return err + } + } + + if p.GetTerminationAddress() != "" { + terminationAddrAcc, err := sdk.AccAddressFromBech32(p.GetTerminationAddress()) + if err != nil { + return err + } + if err := plan.SetTerminationAddress(terminationAddrAcc); err != nil { + return err + } + } + + if p.GetStakingCoinWeights() != nil { + if err := plan.SetStakingCoinWeights(p.GetStakingCoinWeights()); err != nil { + return err + } + } + + if p.GetStartTime() != nil { + if err := plan.SetStartTime(*p.GetStartTime()); err != nil { + return err + } + } + + if p.GetEndTime() != nil { + if err := plan.SetEndTime(*p.GetEndTime()); err != nil { + return err + } + } + + if p.GetName() != "" { + plan.Name = p.GetName() + } + + if !p.EpochRatio.IsZero() { + plan.EpochRatio = p.EpochRatio + } + + k.SetPlan(ctx, plan) + + logger := k.Logger(ctx) + logger.Info("updated public ratio plan", "ratio_plan", plan) default: - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized farming proposal plan type: %T", p) + return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized plan type: %T", p) } } return nil } + +// DeletePublicPlanProposal delets public plan proposal once the governance proposal is passed. +func (k Keeper) DeletePublicPlanProposal(ctx sdk.Context, proposals []*types.DeleteRequestProposal) error { + for _, p := range proposals { + plan, found := k.GetPlan(ctx, p.GetPlanId()) + if !found { + return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "plan %d is not found", p.GetPlanId()) + } + + k.RemovePlan(ctx, plan) + + logger := k.Logger(ctx) + logger.Info("removed public ratio plan", "plan_id", plan.GetId()) + } + + return nil +} diff --git a/x/farming/keeper/reward_test.go b/x/farming/keeper/reward_test.go index 362ff7f9..487c4165 100644 --- a/x/farming/keeper/reward_test.go +++ b/x/farming/keeper/reward_test.go @@ -11,12 +11,12 @@ import ( func (suite *KeeperTestSuite) TestDistributionInfos() { normalPlans := []types.PlanI{ types.NewFixedAmountPlan( - types.NewBasePlan(1, types.PlanTypePrivate, suite.addrs[0].String(), suite.addrs[0].String(), + types.NewBasePlan(1, "", types.PlanTypePrivate, suite.addrs[0].String(), suite.addrs[0].String(), sdk.NewDecCoins(sdk.NewDecCoinFromDec(denom1, sdk.NewDec(1))), mustParseRFC3339("2021-07-27T00:00:00Z"), mustParseRFC3339("2021-07-28T00:00:00Z")), sdk.NewCoins(sdk.NewInt64Coin(denom3, 1000))), types.NewFixedAmountPlan( - types.NewBasePlan(2, types.PlanTypePrivate, suite.addrs[0].String(), suite.addrs[0].String(), + types.NewBasePlan(2, "", types.PlanTypePrivate, suite.addrs[0].String(), suite.addrs[0].String(), sdk.NewDecCoins(sdk.NewDecCoinFromDec(denom1, sdk.NewDec(1))), mustParseRFC3339("2021-07-27T12:00:00Z"), mustParseRFC3339("2021-07-28T12:00:00Z")), sdk.NewCoins(sdk.NewInt64Coin(denom3, 1000))), @@ -32,7 +32,7 @@ func (suite *KeeperTestSuite) TestDistributionInfos() { "insufficient farming pool balances", []types.PlanI{ types.NewFixedAmountPlan( - types.NewBasePlan(1, types.PlanTypePrivate, suite.addrs[0].String(), suite.addrs[0].String(), + types.NewBasePlan(1, "", types.PlanTypePrivate, suite.addrs[0].String(), suite.addrs[0].String(), sdk.NewDecCoins(sdk.NewDecCoinFromDec(denom1, sdk.NewDec(1))), mustParseRFC3339("2021-07-27T00:00:00Z"), mustParseRFC3339("2021-07-30T00:00:00Z")), sdk.NewCoins(sdk.NewInt64Coin(denom3, 10_000_000_000))), diff --git a/x/farming/keeper/staking.go b/x/farming/keeper/staking.go index d58e94bb..960baa1c 100644 --- a/x/farming/keeper/staking.go +++ b/x/farming/keeper/staking.go @@ -203,14 +203,6 @@ func (k Keeper) Stake(ctx sdk.Context, farmer sdk.AccAddress, amount sdk.Coins) k.SetStaking(ctx, staking) k.SetStakingIndex(ctx, staking) - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeStake, - sdk.NewAttribute(types.AttributeKeyFarmer, farmer.String()), - sdk.NewAttribute(types.AttributeKeyStakingCoins, amount.String()), - ), - }) - return staking, nil } @@ -265,14 +257,6 @@ func (k Keeper) Unstake(ctx sdk.Context, farmer sdk.AccAddress, amount sdk.Coins } } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeUnstake, - sdk.NewAttribute(types.AttributeKeyFarmer, farmer.String()), - sdk.NewAttribute(types.AttributeKeyUnstakingCoins, amount.String()), - ), - }) - // We're returning a Staking even if it has deleted. return staking, nil } diff --git a/x/farming/spec/09_proposal.md b/x/farming/spec/09_proposal.md new file mode 100644 index 00000000..652e6fa2 --- /dev/null +++ b/x/farming/spec/09_proposal.md @@ -0,0 +1,89 @@ + + +# Proposal + +The farming module contains the following public plan governance proposal that receives one of the following requests. A request `AddRequestProposal` that creates a public farming plan, a request `UpdateRequestProposal` that updates the plan, and a request `DeleteRequestProposal` that deletes the plan. For most cases, it expects that a single request is used, but note that `PublicPlanProposal` accepts more than a single request to cover broader use cases. Also, + +## PublicPlanProposal + +```go +// PublicPlanProposal defines a public farming plan governance proposal that receives one of the following requests: +// A request that creates a public farming plan, a request that updates the plan, and a request that deletes the plan. +// For public plan creation, depending on which field is passed, either epoch amount or epoch ratio, it creates a fixed amount plan or ratio plan. +type PublicPlanProposal struct { + // title specifies the title of the plan + Title string + // description specifies the description of the plan + Description string + // add_request_proposals specifies AddRequestProposal object + AddRequestProposals []*AddRequestProposal + // update_request_proposals specifies UpdateRequestProposal object + UpdateRequestProposals []*UpdateRequestProposal + // delete_request_proposals specifies DeleteRequestProposal object + DeleteRequestProposals []*DeleteRequestProposal +} +``` + +## AddRequestProposal + +Note that when requesting `AddRequestProposal` depending on which field is passed, either `EpochAmount` or `EpochRatio`, it creates a `FixedAmountPlan` or `RatioPlan`. + +```go +// AddRequestProposal details a proposal for creating a public plan. +type AddRequestProposal struct { + // name specifies the plan name that describes what plan is for + Name string + // farming_pool_address defines the bech32-encoded address of the farming pool + FarmingPoolAddress string + // termination_address defines the bech32-encoded address that terminates plan + // when the plan ends after the end time, the balance of farming pool address + // is transferred to the termination address + TerminationAddress string + // staking_coin_weights specifies coin weights for the plan + StakingCoinWeights sdk.DecCoins + // start_time specifies the start time of the plan + StartTime time.Time + // end_time specifies the end time of the plan + EndTime time.Time + // epoch_amount specifies the distributing amount for each epoch + EpochAmount sdk.Coins + // epoch_ratio specifies the distributing amount by ratio + EpochRatio sdk.Dec +} +``` + +## UpdateRequestProposal + +```go +// UpdateRequestProposal details a proposal for updating an existing public plan. +type UpdateRequestProposal struct { + // plan_id specifies index of the farming plan + PlanId uint64 + // farming_pool_address defines the bech32-encoded address of the farming pool + FarmingPoolAddress string + // termination_address defines the bech32-encoded address that terminates plan + // when the plan ends after the end time, the balance of farming pool address + // is transferred to the termination address + TerminationAddress string + // staking_coin_weights specifies coin weights for the plan + StakingCoinWeights sdk.DecCoins + // start_time specifies the start time of the plan + StartTime time.Time + // end_time specifies the end time of the plan + EndTime time.Time + // epoch_amount specifies the distributing amount for each epoch + EpochAmount sdk.Coins + // epoch_ratio specifies the distributing amount by ratio + EpochRatio sdk.Dec +} +``` + +## DeleteRequestProposal + +```go +// DeleteRequestProposal details a proposal for deleting an existing public plan. +type DeleteRequestProposal struct { + // plan_id specifies index of the farming plan + PlanId uint64 +} +``` \ No newline at end of file diff --git a/x/farming/types/errors.go b/x/farming/types/errors.go index 06b31879..e847d718 100644 --- a/x/farming/types/errors.go +++ b/x/farming/types/errors.go @@ -15,4 +15,6 @@ var ( ErrStakingNotExists = sdkerrors.Register(ModuleName, 8, "staking not exists") ErrRewardNotExists = sdkerrors.Register(ModuleName, 9, "reward not exists") ErrFeeCollectionFailure = sdkerrors.Register(ModuleName, 10, "fee collection failure") + ErrInvalidNameLength = sdkerrors.Register(ModuleName, 11, "invalid name length") + ErrDuplicatePlanName = sdkerrors.Register(ModuleName, 12, "duplicate plan name") ) diff --git a/x/farming/types/farming.pb.go b/x/farming/types/farming.pb.go index 81a5913e..8b499639 100644 --- a/x/farming/types/farming.pb.go +++ b/x/farming/types/farming.pb.go @@ -116,25 +116,27 @@ var xxx_messageInfo_Params proto.InternalMessageInfo type BasePlan struct { // id specifies index of the farming plan Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // name specifies the name for the base plan + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // type specifies the plan type; type 0 is public and 1 is private // public plan must be created through governance proposal and private plan is // created by account - Type PlanType `protobuf:"varint,2,opt,name=type,proto3,enum=cosmos.farming.v1beta1.PlanType" json:"type,omitempty"` + Type PlanType `protobuf:"varint,3,opt,name=type,proto3,enum=cosmos.farming.v1beta1.PlanType" json:"type,omitempty"` // farming_pool_address defines the bech32-encoded address of the farming pool - FarmingPoolAddress string `protobuf:"bytes,3,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` + FarmingPoolAddress string `protobuf:"bytes,4,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` // reward_pool_address defines the bech32-encoded address that distributes // reward amount of coins to farmers - RewardPoolAddress string `protobuf:"bytes,4,opt,name=reward_pool_address,json=rewardPoolAddress,proto3" json:"reward_pool_address,omitempty" yaml:"reward_pool_address"` + RewardPoolAddress string `protobuf:"bytes,5,opt,name=reward_pool_address,json=rewardPoolAddress,proto3" json:"reward_pool_address,omitempty" yaml:"reward_pool_address"` // termination_address defines the bech32-encoded address that terminates plan // when the plan ends after the end time, the balance of farming pool address // is transferred to the termination address - TerminationAddress string `protobuf:"bytes,5,opt,name=termination_address,json=terminationAddress,proto3" json:"termination_address,omitempty" yaml:"termination_address"` + TerminationAddress string `protobuf:"bytes,6,opt,name=termination_address,json=terminationAddress,proto3" json:"termination_address,omitempty" yaml:"termination_address"` // staking_coin_weights specifies coin weights for the plan - StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,6,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` + StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,7,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` // start_time specifies the start time of the plan - StartTime time.Time `protobuf:"bytes,7,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + StartTime time.Time `protobuf:"bytes,8,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` // end_time specifies the end time of the plan - EndTime time.Time `protobuf:"bytes,8,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` + EndTime time.Time `protobuf:"bytes,9,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` } func (m *BasePlan) Reset() { *m = BasePlan{} } @@ -393,73 +395,74 @@ func init() { } var fileDescriptor_5b657e0809d9de86 = []byte{ - // 1049 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcf, 0x6b, 0x1b, 0x47, - 0x14, 0xd6, 0xc8, 0xbf, 0xa4, 0x51, 0x6b, 0xcb, 0x2b, 0xdb, 0xc8, 0x4a, 0xa2, 0x5d, 0xf6, 0x50, - 0x84, 0x8b, 0x57, 0xc4, 0xcd, 0xc9, 0x37, 0xaf, 0x64, 0x07, 0xd1, 0x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 0xda, 0x62, 0x0c, 0x6b, - 0x0e, 0xda, 0xae, 0xd3, 0x51, 0x36, 0xe0, 0x72, 0x02, 0x89, 0x1a, 0x9f, 0xef, 0xb4, 0x76, 0xf3, - 0xe9, 0x52, 0xe1, 0xe8, 0x58, 0x5b, 0x1a, 0x43, 0xc5, 0x1f, 0xa9, 0xd2, 0xec, 0xf3, 0x9f, 0xca, - 0x29, 0xf3, 0xee, 0xab, 0xb3, 0x32, 0x38, 0x3d, 0x2b, 0x83, 0x3f, 0xcf, 0xca, 0xe0, 0xc5, 0x79, - 0x39, 0x75, 0x7a, 0x5e, 0x4e, 0xfd, 0x7e, 0x5e, 0x4e, 0x7d, 0xb5, 0x99, 0xa8, 0x77, 0xc2, 0x1f, - 0xda, 0x67, 0xe3, 0x6f, 0xbc, 0xf4, 0xf6, 0x3c, 0x9f, 0xf9, 0x9f, 0xfc, 0x1b, 0x00, 0x00, 0xff, - 0xff, 0xeb, 0x31, 0xca, 0x7d, 0xfd, 0x0a, 0x00, 0x00, + // 1059 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xbf, 0x6f, 0xdb, 0x46, + 0x14, 0xd6, 0x39, 0xb2, 0x2d, 0x9d, 0x5a, 0x5b, 0x3a, 0xd9, 0x86, 0xac, 0x24, 0x22, 0xc1, 0xa1, + 0x10, 0x5c, 0x98, 0x42, 0xdc, 0x4c, 0xde, 0x2c, 0xc9, 0x0e, 0x84, 0x06, 0x8e, 0xca, 0x28, 0x4d, + 0xdb, 0x85, 0x38, 0x89, 0x67, 0x99, 0x08, 0xc9, 0x53, 0x49, 0x2a, 0x89, 0xfe, 0x80, 0x02, 0x81, + 0xa7, 0xa0, 0x53, 0x87, 0x1a, 0x0d, 0xda, 0x2d, 0x73, 0xe7, 0xce, 0x01, 0xba, 0x18, 0x05, 0x0a, + 0x14, 0x1d, 0x98, 0xc2, 0xde, 0x3a,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, 0xf8, 0x71, 0x55, 0x4e, 0x3f, 0xfb, 0xa1, 0x92, 0xaa, 0xdf, 0x79, 0x75, 0x5a, 0x01, + 0x27, 0xa7, 0x15, 0xf0, 0xc7, 0x69, 0x05, 0x3c, 0x3f, 0xab, 0xa4, 0x4e, 0xce, 0x2a, 0xa9, 0xdf, + 0xce, 0x2a, 0xa9, 0x2f, 0x36, 0x13, 0xfd, 0x4e, 0xf9, 0x91, 0xfb, 0x74, 0xf2, 0xc5, 0x5b, 0xef, + 0x2e, 0x70, 0xcf, 0xff, 0xe8, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x2d, 0x76, 0x98, 0x11, + 0x0b, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -552,7 +555,7 @@ func (m *BasePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintFarming(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) if err2 != nil { return 0, err2 @@ -560,7 +563,7 @@ func (m *BasePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n2 i = encodeVarintFarming(dAtA, i, uint64(n2)) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 if len(m.StakingCoinWeights) > 0 { for iNdEx := len(m.StakingCoinWeights) - 1; iNdEx >= 0; iNdEx-- { { @@ -572,7 +575,7 @@ func (m *BasePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintFarming(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } } if len(m.TerminationAddress) > 0 { @@ -580,26 +583,33 @@ func (m *BasePlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.TerminationAddress) i = encodeVarintFarming(dAtA, i, uint64(len(m.TerminationAddress))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.RewardPoolAddress) > 0 { i -= len(m.RewardPoolAddress) copy(dAtA[i:], m.RewardPoolAddress) i = encodeVarintFarming(dAtA, i, uint64(len(m.RewardPoolAddress))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.FarmingPoolAddress) > 0 { i -= len(m.FarmingPoolAddress) copy(dAtA[i:], m.FarmingPoolAddress) i = encodeVarintFarming(dAtA, i, uint64(len(m.FarmingPoolAddress))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if m.Type != 0 { i = encodeVarintFarming(dAtA, i, uint64(m.Type)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintFarming(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 } if m.Id != 0 { i = encodeVarintFarming(dAtA, i, uint64(m.Id)) @@ -902,6 +912,10 @@ func (m *BasePlan) Size() (n int) { if m.Id != 0 { n += 1 + sovFarming(uint64(m.Id)) } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovFarming(uint64(l)) + } if m.Type != 0 { n += 1 + sovFarming(uint64(m.Type)) } @@ -1254,6 +1268,38 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFarming + } + 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 ErrInvalidLengthFarming + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFarming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } @@ -1272,7 +1318,7 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FarmingPoolAddress", wireType) } @@ -1304,7 +1350,7 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { } m.FarmingPoolAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RewardPoolAddress", wireType) } @@ -1336,7 +1382,7 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { } m.RewardPoolAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TerminationAddress", wireType) } @@ -1368,7 +1414,7 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { } m.TerminationAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingCoinWeights", wireType) } @@ -1402,7 +1448,7 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) } @@ -1435,7 +1481,7 @@ func (m *BasePlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) } diff --git a/x/farming/types/genesis.go b/x/farming/types/genesis.go index 10a23470..b6034050 100644 --- a/x/farming/types/genesis.go +++ b/x/farming/types/genesis.go @@ -50,10 +50,6 @@ func ValidateGenesis(data GenesisState) error { // Validate validates PlanRecord. func (r PlanRecord) Validate() error { - _, err := UnpackPlan(&r.Plan) - if err != nil { - return err - } if err := r.FarmingPoolCoins.Validate(); err != nil { return err } diff --git a/x/farming/types/msgs.go b/x/farming/types/msgs.go index 7a0e7eb8..5ff5ffd9 100644 --- a/x/farming/types/msgs.go +++ b/x/farming/types/msgs.go @@ -27,6 +27,7 @@ const ( // NewMsgCreateFixedAmountPlan creates a new MsgCreateFixedAmountPlan. func NewMsgCreateFixedAmountPlan( + name string, farmingPoolAddr sdk.AccAddress, stakingCoinWeights sdk.DecCoins, startTime time.Time, @@ -34,6 +35,7 @@ func NewMsgCreateFixedAmountPlan( epochAmount sdk.Coins, ) *MsgCreateFixedAmountPlan { return &MsgCreateFixedAmountPlan{ + Name: name, FarmingPoolAddress: farmingPoolAddr.String(), StakingCoinWeights: stakingCoinWeights, StartTime: startTime, @@ -51,7 +53,7 @@ func (msg MsgCreateFixedAmountPlan) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farming pool address %q: %v", msg.FarmingPoolAddress, err) } if !msg.EndTime.After(msg.StartTime) { - return sdkerrors.Wrapf(ErrInvalidPlanEndTime, "end time %s must be greater than start time %s", msg.EndTime.Format(time.RFC3339Nano), msg.StartTime.Format(time.RFC3339Nano)) + return sdkerrors.Wrapf(ErrInvalidPlanEndTime, "end time %s must be greater than start time %s", msg.EndTime.Format(time.RFC3339), msg.StartTime.Format(time.RFC3339)) } if msg.StakingCoinWeights.Empty() { return ErrEmptyStakingCoinWeights @@ -90,6 +92,7 @@ func (msg MsgCreateFixedAmountPlan) GetCreator() sdk.AccAddress { // NewMsgCreateRatioPlan creates a new MsgCreateRatioPlan. func NewMsgCreateRatioPlan( + name string, farmingPoolAddr sdk.AccAddress, stakingCoinWeights sdk.DecCoins, startTime time.Time, @@ -97,6 +100,7 @@ func NewMsgCreateRatioPlan( epochRatio sdk.Dec, ) *MsgCreateRatioPlan { return &MsgCreateRatioPlan{ + Name: name, FarmingPoolAddress: farmingPoolAddr.String(), StakingCoinWeights: stakingCoinWeights, StartTime: startTime, @@ -114,7 +118,7 @@ func (msg MsgCreateRatioPlan) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farming pool address %q: %v", msg.FarmingPoolAddress, err) } if !msg.EndTime.After(msg.StartTime) { - return sdkerrors.Wrapf(ErrInvalidPlanEndTime, "end time %s must be greater than start time %s", msg.EndTime.Format(time.RFC3339Nano), msg.StartTime.Format(time.RFC3339Nano)) + return sdkerrors.Wrapf(ErrInvalidPlanEndTime, "end time %s must be greater than start time %s", msg.EndTime.Format(time.RFC3339), msg.StartTime.Format(time.RFC3339)) } if msg.StakingCoinWeights.Empty() { return ErrEmptyStakingCoinWeights @@ -125,6 +129,9 @@ func (msg MsgCreateRatioPlan) ValidateBasic() error { if !msg.EpochRatio.IsPositive() { return ErrInvalidPlanEpochRatio } + if msg.EpochRatio.GT(sdk.NewDec(1)) { + return ErrInvalidPlanEpochRatio + } return nil } diff --git a/x/farming/types/msgs_test.go b/x/farming/types/msgs_test.go index 7a11a4c9..3a146697 100644 --- a/x/farming/types/msgs_test.go +++ b/x/farming/types/msgs_test.go @@ -14,6 +14,7 @@ import ( ) func TestMsgCreateFixedAmountPlan(t *testing.T) { + name := "test" farmingPoolAddr := sdk.AccAddress(crypto.AddressHash([]byte("farmingPoolAddr"))) stakingCoinWeights := sdk.NewDecCoins( sdk.DecCoin{Denom: "testFarmStakingCoinDenom", Amount: sdk.MustNewDecFromStr("1.0")}, @@ -29,36 +30,36 @@ func TestMsgCreateFixedAmountPlan(t *testing.T) { { "", // empty means no error expected types.NewMsgCreateFixedAmountPlan( - farmingPoolAddr, stakingCoinWeights, startTime, - endTime, sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, + name, farmingPoolAddr, stakingCoinWeights, + startTime, endTime, sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, ), }, { "invalid farming pool address \"\": empty address string is not allowed: invalid address", types.NewMsgCreateFixedAmountPlan( - sdk.AccAddress{}, stakingCoinWeights, startTime, - endTime, sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, + name, sdk.AccAddress{}, stakingCoinWeights, + startTime, endTime, sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, ), }, { "end time 2020-11-01T22:08:41Z must be greater than start time 2021-11-01T22:08:41Z: invalid plan end time", types.NewMsgCreateFixedAmountPlan( - farmingPoolAddr, stakingCoinWeights, startTime, - startTime.AddDate(-1, 0, 0), sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, + name, farmingPoolAddr, stakingCoinWeights, + startTime, startTime.AddDate(-1, 0, 0), sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, ), }, { "staking coin weights must not be empty", types.NewMsgCreateFixedAmountPlan( - farmingPoolAddr, sdk.NewDecCoins(), startTime, - endTime, sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, + name, farmingPoolAddr, sdk.NewDecCoins(), + startTime, endTime, sdk.Coins{sdk.NewCoin("uatom", sdk.NewInt(1))}, ), }, { "epoch amount must not be empty", types.NewMsgCreateFixedAmountPlan( - farmingPoolAddr, stakingCoinWeights, startTime, - endTime, sdk.Coins{}, + name, farmingPoolAddr, stakingCoinWeights, + startTime, endTime, sdk.Coins{}, ), }, } @@ -82,6 +83,7 @@ func TestMsgCreateFixedAmountPlan(t *testing.T) { } func TestMsgCreateRatioPlan(t *testing.T) { + name := "test" farmingPoolAddr := sdk.AccAddress(crypto.AddressHash([]byte("farmingPoolAddr"))) stakingCoinWeights := sdk.NewDecCoins( sdk.DecCoin{Denom: "testFarmStakingCoinDenom", Amount: sdk.MustNewDecFromStr("1.0")}, @@ -97,36 +99,36 @@ func TestMsgCreateRatioPlan(t *testing.T) { { "", // empty means no error expected types.NewMsgCreateRatioPlan( - farmingPoolAddr, stakingCoinWeights, startTime, - endTime, sdk.NewDec(1), + name, farmingPoolAddr, stakingCoinWeights, + startTime, endTime, sdk.NewDec(1), ), }, { "invalid farming pool address \"\": empty address string is not allowed: invalid address", types.NewMsgCreateRatioPlan( - sdk.AccAddress{}, stakingCoinWeights, startTime, - endTime, sdk.NewDec(1), + name, sdk.AccAddress{}, stakingCoinWeights, + startTime, endTime, sdk.NewDec(1), ), }, { "end time 2020-11-01T22:08:41Z must be greater than start time 2021-11-01T22:08:41Z: invalid plan end time", types.NewMsgCreateRatioPlan( - farmingPoolAddr, stakingCoinWeights, startTime, - startTime.AddDate(-1, 0, 0), sdk.NewDec(1), + name, farmingPoolAddr, stakingCoinWeights, + startTime, startTime.AddDate(-1, 0, 0), sdk.NewDec(1), ), }, { "staking coin weights must not be empty", types.NewMsgCreateRatioPlan( - farmingPoolAddr, sdk.NewDecCoins(), startTime, - endTime, sdk.NewDec(1), + name, farmingPoolAddr, sdk.NewDecCoins(), + startTime, endTime, sdk.NewDec(1), ), }, { "invalid plan epoch ratio", types.NewMsgCreateRatioPlan( - farmingPoolAddr, stakingCoinWeights, startTime, - endTime, sdk.NewDec(-1), + name, farmingPoolAddr, stakingCoinWeights, + startTime, endTime, sdk.NewDec(-1), ), }, } diff --git a/x/farming/types/plan.go b/x/farming/types/plan.go index 9e5be82e..174af92c 100644 --- a/x/farming/types/plan.go +++ b/x/farming/types/plan.go @@ -14,6 +14,10 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +const ( + MaxNameLength int = 140 +) + var ( _ PlanI = (*FixedAmountPlan)(nil) _ PlanI = (*RatioPlan)(nil) @@ -21,13 +25,13 @@ var ( // NewBasePlan creates a new BasePlan object //nolint:interfacer -// TODO: accept sdk.AccAddress instead of string for addresses -func NewBasePlan(id uint64, typ PlanType, farmingPoolAddr, terminationAddr string, coinWeights sdk.DecCoins, startTime, endTime time.Time) *BasePlan { +func NewBasePlan(id uint64, name string, typ PlanType, farmingPoolAddr, terminationAddr string, coinWeights sdk.DecCoins, startTime, endTime time.Time) *BasePlan { basePlan := &BasePlan{ Id: id, + Name: name, Type: typ, FarmingPoolAddress: farmingPoolAddr, - RewardPoolAddress: GenerateRewardPoolAcc(PlanName(id, typ, farmingPoolAddr)).String(), + RewardPoolAddress: GenerateRewardPoolAcc(PlanUniqueKey(id, typ, farmingPoolAddr)).String(), TerminationAddress: terminationAddr, StakingCoinWeights: coinWeights, StartTime: startTime, @@ -125,6 +129,9 @@ func (plan BasePlan) Validate() error { if _, err := sdk.AccAddressFromBech32(plan.TerminationAddress); err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid termination address %q: %v", plan.TerminationAddress, err) } + if len(plan.Name) > MaxNameLength { + return sdkerrors.Wrapf(ErrInvalidNameLength, "plan name cannot be longer than max length of %d", MaxNameLength) + } if err := plan.StakingCoinWeights.Validate(); err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid staking coin weights: %v", err) } @@ -162,13 +169,8 @@ func NewRatioPlan(basePlan *BasePlan, epochRatio sdk.Dec) *RatioPlan { } } -// Name returns unique name of the plan -func (plan BasePlan) Name() string { - return PlanName(plan.Id, plan.Type, plan.FarmingPoolAddress) -} - -// PlanName returns unique name of the plan consists of given Id, Type and FarmingPoolAddress. -func PlanName(id uint64, typ PlanType, farmingPoolAddr string) string { +// PlanUniqueKey returns unique name of the plan consists of given Id, Type and FarmingPoolAddress. +func PlanUniqueKey(id uint64, typ PlanType, farmingPoolAddr string) string { poolNameObjects := make([]string, 3) poolNameObjects[0] = strconv.FormatUint(id, 10) poolNameObjects[1] = strconv.FormatInt(int64(typ), 10) @@ -210,3 +212,44 @@ type PlanI interface { String() string } + +// ValidateRatioPlans validates a farmer's total epoch ratio and plan name. +// A total epoch ratio cannot be higher than 1 and plan name must not be duplicate. +func ValidateRatioPlans(i interface{}) error { + plans, ok := i.([]PlanI) + if !ok { + return sdkerrors.Wrapf(ErrInvalidPlanType, "invalid plan type %T", i) + } + + totalEpochRatio := make(map[string]sdk.Dec) + names := make(map[string]bool) + + for _, plan := range plans { + farmingPoolAddr := plan.GetFarmingPoolAddress().String() + + if plan, ok := plan.(*RatioPlan); ok { + if err := plan.Validate(); err != nil { + return err + } + + if epochRatio, ok := totalEpochRatio[farmingPoolAddr]; ok { + totalEpochRatio[farmingPoolAddr] = epochRatio.Add(plan.EpochRatio) + } else { + totalEpochRatio[farmingPoolAddr] = plan.EpochRatio + } + + if _, ok := names[plan.Name]; ok { + return sdkerrors.Wrap(ErrDuplicatePlanName, plan.Name) + } + names[plan.Name] = true + } + } + + for _, farmerRatio := range totalEpochRatio { + if farmerRatio.GT(sdk.NewDec(1)) { + return sdkerrors.Wrap(ErrInvalidPlanEpochRatio, "total epoch ratio must be lower than 1") + } + } + + return nil +} diff --git a/x/farming/types/plan_test.go b/x/farming/types/plan_test.go index f40ed415..9e83aa93 100644 --- a/x/farming/types/plan_test.go +++ b/x/farming/types/plan_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/tendermint/farming/x/farming/types" ) @@ -21,6 +22,7 @@ func TestGetPoolInformation(t *testing.T) { testCases := []struct { planId uint64 + name string planType types.PlanType farmingPoolAddr string rewardPoolAddr string @@ -30,6 +32,7 @@ func TestGetPoolInformation(t *testing.T) { }{ { planId: uint64(1), + name: "", planType: types.PlanTypePublic, farmingPoolAddr: sdk.AccAddress("farmingPoolAddr1").String(), rewardPoolAddr: "cosmos1yqurgw7xa94psk95ctje76ferlddg8vykflaln6xsgarj5w6jkrsuvh9dj", @@ -38,9 +41,71 @@ func TestGetPoolInformation(t *testing.T) { } for _, tc := range testCases { - planName := types.PlanName(tc.planId, tc.planType, tc.farmingPoolAddr) - rewardPoolAcc := types.GenerateRewardPoolAcc(planName) - basePlan := types.NewBasePlan(tc.planId, tc.planType, tc.farmingPoolAddr, commonTerminationAcc.String(), commonCoinWeights, commonStartTime, commonEndTime) + uniqueKey := types.PlanUniqueKey(tc.planId, tc.planType, tc.farmingPoolAddr) + rewardPoolAcc := types.GenerateRewardPoolAcc(uniqueKey) + basePlan := types.NewBasePlan(tc.planId, tc.name, tc.planType, tc.farmingPoolAddr, commonTerminationAcc.String(), commonCoinWeights, commonStartTime, commonEndTime) require.Equal(t, basePlan.RewardPoolAddress, rewardPoolAcc.String()) } } + +func TestRatioPlans(t *testing.T) { + name1 := "testPlan1" + name2 := "testPlan2" + farmingPoolAddr1 := sdk.AccAddress("farmingPoolAddr1") + terminationAddr1 := sdk.AccAddress("terminationAddr1") + stakingCoinWeights := sdk.NewDecCoins( + sdk.DecCoin{Denom: "testFarmStakingCoinDenom", Amount: sdk.MustNewDecFromStr("1.0")}, + ) + startTime := time.Now().UTC() + endTime := startTime.AddDate(1, 0, 0) + + testCases := []struct { + plans []types.PlanI + expectedErr error + }{ + { + []types.PlanI{ + types.NewRatioPlan( + types.NewBasePlan(1, name1, 1, farmingPoolAddr1.String(), terminationAddr1.String(), stakingCoinWeights, startTime, endTime), + sdk.NewDec(1), + ), + }, + nil, + }, + { + []types.PlanI{ + types.NewRatioPlan( + types.NewBasePlan(1, name1, 1, farmingPoolAddr1.String(), terminationAddr1.String(), stakingCoinWeights, startTime, endTime), + sdk.NewDec(1), + ), + types.NewRatioPlan( + types.NewBasePlan(1, name1, 1, farmingPoolAddr1.String(), terminationAddr1.String(), stakingCoinWeights, startTime, endTime), + sdk.NewDec(1), + ), + }, + sdkerrors.Wrap(types.ErrDuplicatePlanName, name1), + }, + { + []types.PlanI{ + types.NewRatioPlan( + types.NewBasePlan(1, name1, 1, farmingPoolAddr1.String(), terminationAddr1.String(), stakingCoinWeights, startTime, endTime), + sdk.NewDec(1), + ), + types.NewRatioPlan( + types.NewBasePlan(1, name2, 1, farmingPoolAddr1.String(), terminationAddr1.String(), stakingCoinWeights, startTime, endTime), + sdk.NewDec(1), + ), + }, + sdkerrors.Wrap(types.ErrInvalidPlanEpochRatio, "total epoch ratio must be lower than 1"), + }, + } + + for _, tc := range testCases { + err := types.ValidateRatioPlans(tc.plans) + if tc.expectedErr == nil { + require.NoError(t, err) + } else { + require.Equal(t, tc.expectedErr.Error(), err.Error()) + } + } +} diff --git a/x/farming/types/proposal.go b/x/farming/types/proposal.go index 896134a3..b4706bbc 100644 --- a/x/farming/types/proposal.go +++ b/x/farming/types/proposal.go @@ -3,9 +3,8 @@ package types import ( "fmt" - "github.com/gogo/protobuf/proto" - - "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" gov "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -21,16 +20,14 @@ func init() { gov.RegisterProposalTypeCodec(&PublicPlanProposal{}, "cosmos-sdk/PublicPlanProposal") } -func NewPublicPlanProposal(title, description string, plans []PlanI) (gov.Content, error) { - plansAny, err := PackPlans(plans) - if err != nil { - panic(err) - } - +func NewPublicPlanProposal(title, description string, addReq []*AddRequestProposal, + updateReq []*UpdateRequestProposal, deleteReq []*DeleteRequestProposal) (gov.Content, error) { return &PublicPlanProposal{ - Title: title, - Description: description, - Plans: plansAny, + Title: title, + Description: description, + AddRequestProposals: addReq, + UpdateRequestProposals: updateReq, + DeleteRequestProposals: deleteReq, }, nil } @@ -43,65 +40,93 @@ func (p *PublicPlanProposal) ProposalRoute() string { return RouterKey } func (p *PublicPlanProposal) ProposalType() string { return ProposalTypePublicPlan } func (p *PublicPlanProposal) ValidateBasic() error { - for _, plan := range p.Plans { - _, ok := plan.GetCachedValue().(PlanI) - if !ok { - return fmt.Errorf("expected planI") + if p.AddRequestProposals == nil && p.UpdateRequestProposals == nil && p.DeleteRequestProposals == nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "proposal request must not be empty") + } + + for _, ap := range p.AddRequestProposals { + if err := ap.Validate(); err != nil { + return err + } + } + + for _, up := range p.UpdateRequestProposals { + if err := up.Validate(); err != nil { + return err + } + } + + for _, dp := range p.DeleteRequestProposals { + if err := dp.Validate(); err != nil { + return err } - // TODO: PlanI needs ValidateBasic()? - // if err := p.ValidateBasic(); err != nil { - // return err - // } } return gov.ValidateAbstract(p) } func (p PublicPlanProposal) String() string { - return fmt.Sprintf(`Create FixedAmountPlan Proposal: - Title: %s - Description: %s - Plans: %s -`, p.Title, p.Description, p.Plans) + return fmt.Sprintf(`Public Plan Proposal: + Title: %s + Description: %s + AddRequestProposals: %s + UpdateRequestProposals: %s + DeleteRequestProposals: %s +`, p.Title, p.Description, p.AddRequestProposals, p.UpdateRequestProposals, p.DeleteRequestProposals) } -// PackPlans converts PlanIs to Any slice. -func PackPlans(plans []PlanI) ([]*types.Any, error) { - plansAny := make([]*types.Any, len(plans)) - for i, plan := range plans { - msg, ok := plan.(proto.Message) - if !ok { - return nil, fmt.Errorf("cannot proto marshal %T", plan) - } - any, err := types.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - plansAny[i] = any +func (p *AddRequestProposal) Validate() error { + if len(p.Name) > MaxNameLength { + return sdkerrors.Wrapf(ErrInvalidNameLength, "plan name cannot be longer than max length of %d", MaxNameLength) } - - return plansAny, nil + if _, err := sdk.AccAddressFromBech32(p.FarmingPoolAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farming pool address %q: %v", p.FarmingPoolAddress, err) + } + if _, err := sdk.AccAddressFromBech32(p.TerminationAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid termination address %q: %v", p.TerminationAddress, err) + } + if err := p.StakingCoinWeights.Validate(); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid staking coin weights: %v", err) + } + if !p.EndTime.After(p.StartTime) { + return sdkerrors.Wrapf(ErrInvalidPlanEndTime, "end time %s must be greater than start time %s", p.EndTime, p.StartTime) + } + if !p.EpochAmount.IsZero() && !p.EpochRatio.IsZero() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "either epoch amount or epoch ratio should be provided") + } + if p.EpochAmount.IsZero() && p.EpochRatio.IsZero() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "either epoch amount or epoch ratio must not be zero") + } + return nil } -// UnpackPlans converts Any slice to PlanIs. -func UnpackPlans(plansAny []*types.Any) ([]PlanI, error) { - plans := make([]PlanI, len(plansAny)) - for i, any := range plansAny { - p, ok := any.GetCachedValue().(PlanI) - if !ok { - return nil, fmt.Errorf("expected planI") - } - plans[i] = p +func (p *UpdateRequestProposal) Validate() error { + if p.PlanId == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid plan id: %d", p.PlanId) } - - return plans, nil + if len(p.Name) > MaxNameLength { + return sdkerrors.Wrapf(ErrInvalidNameLength, "plan name cannot be longer than max length of %d", MaxNameLength) + } + if _, err := sdk.AccAddressFromBech32(p.FarmingPoolAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid farming pool address %q: %v", p.FarmingPoolAddress, err) + } + if _, err := sdk.AccAddressFromBech32(p.TerminationAddress); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid termination address %q: %v", p.TerminationAddress, err) + } + if err := p.StakingCoinWeights.Validate(); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid staking coin weights: %v", err) + } + if !p.EndTime.After(*p.StartTime) { + return sdkerrors.Wrapf(ErrInvalidPlanEndTime, "end time %s must be greater than start time %s", p.EndTime, p.StartTime) + } + if !p.EpochAmount.Empty() && !p.EpochRatio.IsZero() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "epoch amount or epoch ratio must be provided") + } + return nil } -// UnpackPlan converts Any slice to PlanI. -func UnpackPlan(any *types.Any) (PlanI, error) { - p, ok := any.GetCachedValue().(PlanI) - if !ok { - return nil, fmt.Errorf("expected planI") +func (p *DeleteRequestProposal) Validate() error { + if p.PlanId == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid plan id: %d", p.PlanId) } - - return p, nil + return nil } diff --git a/x/farming/types/proposal.pb.go b/x/farming/types/proposal.pb.go index 8e599db3..404ad278 100644 --- a/x/farming/types/proposal.pb.go +++ b/x/farming/types/proposal.pb.go @@ -5,19 +5,24 @@ package types import ( fmt "fmt" - types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/regen-network/cosmos-proto" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -25,13 +30,21 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// PublicPlanProposal details a proposal for creating a public plan. +// PublicPlanProposal defines a public farming plan governance proposal that receives one of the following requests: +// A request that creates a public farming plan, a request that updates the plan, and a request that deletes the plan. +// For public plan creation, depending on which field is passed, either epoch amount or epoch ratio, it creates a fixed +// amount plan or ratio plan. type PublicPlanProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // title specifies the title of the plan + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // description specifies the description of the plan Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - // plans specifies the plan interface(s); it can be FixedAmountPlan or - // RatioPlan - Plans []*types.Any `protobuf:"bytes,3,rep,name=plans,proto3" json:"plans,omitempty"` + // add_request_proposals specifies AddRequestProposal object + AddRequestProposals []*AddRequestProposal `protobuf:"bytes,3,rep,name=add_request_proposals,json=addRequestProposals,proto3" json:"add_request_proposals,omitempty" yaml:"add_request_proposals"` + // update_request_proposals specifies UpdateRequestProposal object + UpdateRequestProposals []*UpdateRequestProposal `protobuf:"bytes,4,rep,name=update_request_proposals,json=updateRequestProposals,proto3" json:"update_request_proposals,omitempty" yaml:"update_request_proposals"` + // delete_request_proposals specifies DeleteRequestProposal object + DeleteRequestProposals []*DeleteRequestProposal `protobuf:"bytes,5,rep,name=delete_request_proposals,json=deleteRequestProposals,proto3" json:"delete_request_proposals,omitempty" yaml:"delete_request_proposals"` } func (m *PublicPlanProposal) Reset() { *m = PublicPlanProposal{} } @@ -66,8 +79,274 @@ func (m *PublicPlanProposal) XXX_DiscardUnknown() { var xxx_messageInfo_PublicPlanProposal proto.InternalMessageInfo +// AddRequestProposal details a proposal for creating a public plan. +type AddRequestProposal struct { + // name specifies the plan name that describes what plan is for + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // farming_pool_address defines the bech32-encoded address of the farming pool + FarmingPoolAddress string `protobuf:"bytes,2,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` + // termination_address defines the bech32-encoded address that terminates plan + // when the plan ends after the end time, the balance of farming pool address + // is transferred to the termination address + TerminationAddress string `protobuf:"bytes,3,opt,name=termination_address,json=terminationAddress,proto3" json:"termination_address,omitempty" yaml:"termination_address"` + // staking_coin_weights specifies coin weights for the plan + StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,4,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` + // start_time specifies the start time of the plan + StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + // end_time specifies the end time of the plan + EndTime time.Time `protobuf:"bytes,6,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` + // epoch_amount specifies the distributing amount for each epoch + EpochAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=epoch_amount,json=epochAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"epoch_amount" yaml:"epoch_amount"` + // epoch_ratio specifies the distributing amount by ratio + EpochRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=epoch_ratio,json=epochRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"epoch_ratio" yaml:"epoch_ratio"` +} + +func (m *AddRequestProposal) Reset() { *m = AddRequestProposal{} } +func (m *AddRequestProposal) String() string { return proto.CompactTextString(m) } +func (*AddRequestProposal) ProtoMessage() {} +func (*AddRequestProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_4719b03c30c7910a, []int{1} +} +func (m *AddRequestProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddRequestProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddRequestProposal.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 *AddRequestProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddRequestProposal.Merge(m, src) +} +func (m *AddRequestProposal) XXX_Size() int { + return m.Size() +} +func (m *AddRequestProposal) XXX_DiscardUnknown() { + xxx_messageInfo_AddRequestProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_AddRequestProposal proto.InternalMessageInfo + +func (m *AddRequestProposal) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *AddRequestProposal) GetFarmingPoolAddress() string { + if m != nil { + return m.FarmingPoolAddress + } + return "" +} + +func (m *AddRequestProposal) GetTerminationAddress() string { + if m != nil { + return m.TerminationAddress + } + return "" +} + +func (m *AddRequestProposal) GetStakingCoinWeights() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.StakingCoinWeights + } + return nil +} + +func (m *AddRequestProposal) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +func (m *AddRequestProposal) GetEndTime() time.Time { + if m != nil { + return m.EndTime + } + return time.Time{} +} + +func (m *AddRequestProposal) GetEpochAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.EpochAmount + } + return nil +} + +// UpdateRequestProposal details a proposal for updating an existing public plan. +type UpdateRequestProposal struct { + // plan_id specifies index of the farming plan + PlanId uint64 `protobuf:"varint,1,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` + // name specifies the plan name that describes what plan is for + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // farming_pool_address defines the bech32-encoded address of the farming pool + FarmingPoolAddress string `protobuf:"bytes,3,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` + // termination_address defines the bech32-encoded address that terminates plan + // when the plan ends after the end time, the balance of farming pool address + // is transferred to the termination address + TerminationAddress string `protobuf:"bytes,4,opt,name=termination_address,json=terminationAddress,proto3" json:"termination_address,omitempty" yaml:"termination_address"` + // staking_coin_weights specifies coin weights for the plan + StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,5,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` + // start_time specifies the start time of the plan + StartTime *time.Time `protobuf:"bytes,6,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time,omitempty" yaml:"start_time"` + // end_time specifies the end time of the plan + EndTime *time.Time `protobuf:"bytes,7,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time,omitempty" yaml:"end_time"` + // epoch_amount specifies the distributing amount for each epoch + EpochAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=epoch_amount,json=epochAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"epoch_amount" yaml:"epoch_amount"` + // epoch_ratio specifies the distributing amount by ratio + EpochRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=epoch_ratio,json=epochRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"epoch_ratio" yaml:"epoch_ratio"` +} + +func (m *UpdateRequestProposal) Reset() { *m = UpdateRequestProposal{} } +func (m *UpdateRequestProposal) String() string { return proto.CompactTextString(m) } +func (*UpdateRequestProposal) ProtoMessage() {} +func (*UpdateRequestProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_4719b03c30c7910a, []int{2} +} +func (m *UpdateRequestProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpdateRequestProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpdateRequestProposal.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 *UpdateRequestProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateRequestProposal.Merge(m, src) +} +func (m *UpdateRequestProposal) XXX_Size() int { + return m.Size() +} +func (m *UpdateRequestProposal) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateRequestProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateRequestProposal proto.InternalMessageInfo + +func (m *UpdateRequestProposal) GetPlanId() uint64 { + if m != nil { + return m.PlanId + } + return 0 +} + +func (m *UpdateRequestProposal) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *UpdateRequestProposal) GetFarmingPoolAddress() string { + if m != nil { + return m.FarmingPoolAddress + } + return "" +} + +func (m *UpdateRequestProposal) GetTerminationAddress() string { + if m != nil { + return m.TerminationAddress + } + return "" +} + +func (m *UpdateRequestProposal) GetStakingCoinWeights() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.StakingCoinWeights + } + return nil +} + +func (m *UpdateRequestProposal) GetStartTime() *time.Time { + if m != nil { + return m.StartTime + } + return nil +} + +func (m *UpdateRequestProposal) GetEndTime() *time.Time { + if m != nil { + return m.EndTime + } + return nil +} + +func (m *UpdateRequestProposal) GetEpochAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.EpochAmount + } + return nil +} + +// DeleteRequestProposal details a proposal for deleting an existing public plan. +type DeleteRequestProposal struct { + // plan_id specifies index of the farming plan + PlanId uint64 `protobuf:"varint,1,opt,name=plan_id,json=planId,proto3" json:"plan_id,omitempty"` +} + +func (m *DeleteRequestProposal) Reset() { *m = DeleteRequestProposal{} } +func (m *DeleteRequestProposal) String() string { return proto.CompactTextString(m) } +func (*DeleteRequestProposal) ProtoMessage() {} +func (*DeleteRequestProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_4719b03c30c7910a, []int{3} +} +func (m *DeleteRequestProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteRequestProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteRequestProposal.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 *DeleteRequestProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteRequestProposal.Merge(m, src) +} +func (m *DeleteRequestProposal) XXX_Size() int { + return m.Size() +} +func (m *DeleteRequestProposal) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteRequestProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteRequestProposal proto.InternalMessageInfo + +func (m *DeleteRequestProposal) GetPlanId() uint64 { + if m != nil { + return m.PlanId + } + return 0 +} + func init() { proto.RegisterType((*PublicPlanProposal)(nil), "tendermint.farming.v1beta1.PublicPlanProposal") + proto.RegisterType((*AddRequestProposal)(nil), "tendermint.farming.v1beta1.AddRequestProposal") + proto.RegisterType((*UpdateRequestProposal)(nil), "tendermint.farming.v1beta1.UpdateRequestProposal") + proto.RegisterType((*DeleteRequestProposal)(nil), "tendermint.farming.v1beta1.DeleteRequestProposal") } func init() { @@ -75,25 +354,56 @@ func init() { } var fileDescriptor_4719b03c30c7910a = []byte{ - // 281 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2c, 0x49, 0xcd, 0x4b, - 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x4b, 0x04, 0xd1, 0xe9, 0xfa, 0x65, 0x86, 0x49, - 0xa9, 0x25, 0x89, 0x86, 0xfa, 0x05, 0x45, 0xf9, 0x05, 0xf9, 0xc5, 0x89, 0x39, 0x7a, 0x05, 0x45, - 0xf9, 0x25, 0xf9, 0x42, 0x52, 0x08, 0xa5, 0x7a, 0x50, 0xa5, 0x7a, 0x50, 0xa5, 0x52, 0x22, 0xe9, - 0xf9, 0xe9, 0xf9, 0x60, 0x65, 0xfa, 0x20, 0x16, 0x44, 0x87, 0x94, 0x64, 0x72, 0x7e, 0x71, 0x6e, - 0x7e, 0x71, 0x3c, 0x44, 0x02, 0xc2, 0x81, 0x4a, 0x69, 0xe0, 0xb1, 0x17, 0x66, 0x38, 0xd4, 0x90, - 0xf4, 0xfc, 0xfc, 0xf4, 0x9c, 0x54, 0x7d, 0x30, 0x2f, 0xa9, 0x34, 0x4d, 0x3f, 0x31, 0xaf, 0x12, - 0x22, 0xa5, 0xd4, 0xc4, 0xc8, 0x25, 0x14, 0x50, 0x9a, 0x94, 0x93, 0x99, 0x1c, 0x90, 0x93, 0x98, - 0x17, 0x00, 0x75, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x49, 0x66, 0x49, 0x4e, 0xaa, 0x04, 0xa3, 0x02, - 0xa3, 0x06, 0x67, 0x10, 0x84, 0x23, 0xa4, 0xc0, 0xc5, 0x9d, 0x92, 0x5a, 0x9c, 0x5c, 0x94, 0x59, - 0x50, 0x92, 0x99, 0x9f, 0x27, 0xc1, 0x04, 0x96, 0x43, 0x16, 0x12, 0xd2, 0xe2, 0x62, 0x2d, 0xc8, - 0x49, 0xcc, 0x2b, 0x96, 0x60, 0x56, 0x60, 0xd6, 0xe0, 0x36, 0x12, 0xd1, 0x83, 0xd8, 0xac, 0x07, - 0xb3, 0x59, 0xcf, 0x31, 0xaf, 0x32, 0x08, 0xa2, 0xc4, 0x8a, 0xa3, 0x63, 0x81, 0x3c, 0xc3, 0x8c, - 0x05, 0xf2, 0x0c, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, - 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, - 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0xc5, 0xbb, 0x15, 0x70, - 0x56, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x1e, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x17, 0x42, 0x58, 0x21, 0x93, 0x01, 0x00, 0x00, + // 773 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4f, 0x4f, 0xdb, 0x48, + 0x1c, 0x8d, 0xc9, 0x5f, 0x26, 0x2b, 0xad, 0x76, 0x08, 0x6c, 0x08, 0xac, 0x1d, 0x79, 0xa5, 0x55, + 0x56, 0x2b, 0xec, 0x85, 0xde, 0xb8, 0x91, 0x22, 0xa1, 0x9e, 0x9a, 0x5a, 0xad, 0x5a, 0xf5, 0x62, + 0x4d, 0x32, 0x43, 0xb0, 0xb0, 0x3d, 0xae, 0x67, 0xd2, 0x96, 0x73, 0x5b, 0xa9, 0xa7, 0x8a, 0x63, + 0x8f, 0xa8, 0x47, 0x3e, 0x09, 0x47, 0x8e, 0x55, 0x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a9, 0x4b, + 0xac, 0x9e, 0x6f, 0xe6, 0x5b, 0xd5, 0x0d, 0xcb, 0x9a, 0xee, 0x93, 0xb5, 0x85, 0xb1, 0x23, 0x71, + 0xa9, 0x8e, 0x76, 0x73, 0x34, 0x34, 0x56, 0x0f, 0x50, 0xe0, 0x6f, 0x9a, 0x99, 0xb4, 0xa6, 0xb3, + 0x80, 0xae, 0xa0, 0x18, 0x3c, 0xd4, 0x40, 0x7d, 0x10, 0x61, 0xc4, 0x49, 0x86, 0x92, 0x82, 0x50, + 0xb2, 0x7e, 0x9d, 0x92, 0x67, 0x02, 0xfb, 0xb3, 0x98, 0xbf, 0x47, 0x43, 0xc3, 0x90, 0x62, 0xa6, + 0x91, 0x9b, 0xce, 0xd2, 0x20, 0x0b, 0x2b, 0x25, 0x61, 0xe2, 0x93, 0x4c, 0x49, 0xc5, 0x9b, 0x25, + 0x6d, 0x0b, 0xec, 0x35, 0x92, 0xa6, 0x91, 0x9b, 0xce, 0x12, 0xce, 0xc2, 0xb2, 0xcd, 0xca, 0xc7, + 0x23, 0x23, 0xf7, 0xf9, 0xc8, 0xc8, 0x99, 0x9f, 0x4a, 0x00, 0x5e, 0x75, 0x1f, 0x42, 0x50, 0x08, + 0x51, 0x90, 0x3e, 0x02, 0x31, 0x86, 0x4f, 0x40, 0x4d, 0x49, 0x73, 0x23, 0x4a, 0x7d, 0x17, 0x61, + 0x1c, 0x13, 0xc6, 0xe4, 0x63, 0x68, 0x1b, 0xa3, 0xa1, 0xb1, 0x22, 0xf5, 0x64, 0x75, 0x99, 0x0e, + 0x54, 0xd3, 0x1d, 0x4a, 0xfd, 0x2d, 0x39, 0x09, 0x1f, 0x83, 0x05, 0x2e, 0x4e, 0x8d, 0x92, 0x37, + 0x34, 0x66, 0xcc, 0x0b, 0x46, 0x7d, 0x34, 0x34, 0x1a, 0x92, 0x31, 0xa3, 0xc9, 0x74, 0xe0, 0xc4, + 0x6c, 0x4a, 0xf8, 0x45, 0x03, 0x35, 0x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0x93, 0x1b, 0xaf, 0x57, + 0xc4, 0x1b, 0xd9, 0x4e, 0xb6, 0xfa, 0x36, 0x34, 0xfe, 0x99, 0xed, 0x4e, 0x46, 0x43, 0x03, 0x4e, + 0x8a, 0x12, 0x54, 0xa6, 0x03, 0x44, 0xe5, 0x88, 0xe2, 0xb8, 0x04, 0x16, 0x33, 0xff, 0x08, 0xc0, + 0x3f, 0x41, 0x39, 0xf2, 0x51, 0xe8, 0x7a, 0x58, 0xc4, 0xa2, 0xe0, 0x94, 0x92, 0xf2, 0x11, 0x1e, + 0x87, 0x65, 0x6e, 0x86, 0xb0, 0xe4, 0xef, 0x3c, 0x2c, 0x85, 0xbb, 0x0f, 0x4b, 0xf1, 0xde, 0x86, + 0xa5, 0x34, 0x53, 0x58, 0xb4, 0x5b, 0x87, 0xa5, 0x3c, 0x53, 0x58, 0xb4, 0xdb, 0x87, 0xa5, 0x72, + 0x2f, 0xc2, 0x32, 0xff, 0x8b, 0xc2, 0xf2, 0x3f, 0x58, 0xcc, 0xfc, 0xef, 0x34, 0x35, 0x2b, 0xed, + 0x9d, 0x93, 0x73, 0x5d, 0x3b, 0x3d, 0xd7, 0xb5, 0xef, 0xe7, 0xba, 0x76, 0x78, 0xa1, 0xe7, 0x4e, + 0x2f, 0xf4, 0xdc, 0xd7, 0x0b, 0x3d, 0xf7, 0x72, 0x6d, 0x42, 0x55, 0xc6, 0xaf, 0x9c, 0xb7, 0xe3, + 0x91, 0x10, 0xd8, 0x2d, 0x89, 0x3b, 0x7a, 0xf0, 0x23, 0x00, 0x00, 0xff, 0xff, 0x06, 0x3e, 0x94, + 0x84, 0xaa, 0x09, 0x00, 0x00, } func (m *PublicPlanProposal) Marshal() (dAtA []byte, err error) { @@ -116,10 +426,38 @@ func (m *PublicPlanProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Plans) > 0 { - for iNdEx := len(m.Plans) - 1; iNdEx >= 0; iNdEx-- { + if len(m.DeleteRequestProposals) > 0 { + for iNdEx := len(m.DeleteRequestProposals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DeleteRequestProposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.UpdateRequestProposals) > 0 { + for iNdEx := len(m.UpdateRequestProposals) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UpdateRequestProposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.AddRequestProposals) > 0 { + for iNdEx := len(m.AddRequestProposals) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Plans[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AddRequestProposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -147,47 +485,919 @@ func (m *PublicPlanProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { - offset -= sovProposal(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *AddRequestProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *PublicPlanProposal) Size() (n int) { - if m == nil { - return 0 + +func (m *AddRequestProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddRequestProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.EpochRatio.Size() + i -= size + if _, err := m.EpochRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if len(m.EpochAmount) > 0 { + for iNdEx := len(m.EpochAmount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EpochAmount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintProposal(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x32 + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintProposal(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x2a + if len(m.StakingCoinWeights) > 0 { + for iNdEx := len(m.StakingCoinWeights) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingCoinWeights[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.TerminationAddress) > 0 { + i -= len(m.TerminationAddress) + copy(dAtA[i:], m.TerminationAddress) + i = encodeVarintProposal(dAtA, i, uint64(len(m.TerminationAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.FarmingPoolAddress) > 0 { + i -= len(m.FarmingPoolAddress) + copy(dAtA[i:], m.FarmingPoolAddress) + i = encodeVarintProposal(dAtA, i, uint64(len(m.FarmingPoolAddress))) + i-- + dAtA[i] = 0x12 } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UpdateRequestProposal) 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 *UpdateRequestProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpdateRequestProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) + { + size := m.EpochRatio.Size() + i -= size + if _, err := m.EpochRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintProposal(dAtA, i, uint64(size)) } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovProposal(uint64(l)) + i-- + dAtA[i] = 0x4a + if len(m.EpochAmount) > 0 { + for iNdEx := len(m.EpochAmount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EpochAmount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } } - if len(m.Plans) > 0 { - for _, e := range m.Plans { - l = e.Size() - n += 1 + l + sovProposal(uint64(l)) + if m.EndTime != nil { + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.EndTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintProposal(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x3a + } + if m.StartTime != nil { + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.StartTime):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintProposal(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x32 + } + if len(m.StakingCoinWeights) > 0 { + for iNdEx := len(m.StakingCoinWeights) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingCoinWeights[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProposal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.TerminationAddress) > 0 { + i -= len(m.TerminationAddress) + copy(dAtA[i:], m.TerminationAddress) + i = encodeVarintProposal(dAtA, i, uint64(len(m.TerminationAddress))) + i-- + dAtA[i] = 0x22 + } + if len(m.FarmingPoolAddress) > 0 { + i -= len(m.FarmingPoolAddress) + copy(dAtA[i:], m.FarmingPoolAddress) + i = encodeVarintProposal(dAtA, i, uint64(len(m.FarmingPoolAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.PlanId != 0 { + i = encodeVarintProposal(dAtA, i, uint64(m.PlanId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DeleteRequestProposal) 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 *DeleteRequestProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteRequestProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PlanId != 0 { + i = encodeVarintProposal(dAtA, i, uint64(m.PlanId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { + offset -= sovProposal(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PublicPlanProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if len(m.AddRequestProposals) > 0 { + for _, e := range m.AddRequestProposals { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + if len(m.UpdateRequestProposals) > 0 { + for _, e := range m.UpdateRequestProposals { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + if len(m.DeleteRequestProposals) > 0 { + for _, e := range m.DeleteRequestProposals { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + return n +} + +func (m *AddRequestProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.FarmingPoolAddress) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.TerminationAddress) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if len(m.StakingCoinWeights) > 0 { + for _, e := range m.StakingCoinWeights { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovProposal(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime) + n += 1 + l + sovProposal(uint64(l)) + if len(m.EpochAmount) > 0 { + for _, e := range m.EpochAmount { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + l = m.EpochRatio.Size() + n += 1 + l + sovProposal(uint64(l)) + return n +} + +func (m *UpdateRequestProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PlanId != 0 { + n += 1 + sovProposal(uint64(m.PlanId)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.FarmingPoolAddress) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.TerminationAddress) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + if len(m.StakingCoinWeights) > 0 { + for _, e := range m.StakingCoinWeights { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + if m.StartTime != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.StartTime) + n += 1 + l + sovProposal(uint64(l)) + } + if m.EndTime != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.EndTime) + n += 1 + l + sovProposal(uint64(l)) + } + if len(m.EpochAmount) > 0 { + for _, e := range m.EpochAmount { + l = e.Size() + n += 1 + l + sovProposal(uint64(l)) + } + } + l = m.EpochRatio.Size() + n += 1 + l + sovProposal(uint64(l)) + return n +} + +func (m *DeleteRequestProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PlanId != 0 { + n += 1 + sovProposal(uint64(m.PlanId)) + } + return n +} + +func sovProposal(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProposal(x uint64) (n int) { + return sovProposal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PublicPlanProposal) 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 ErrIntOverflowProposal + } + 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: PublicPlanProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PublicPlanProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddRequestProposals", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AddRequestProposals = append(m.AddRequestProposals, &AddRequestProposal{}) + if err := m.AddRequestProposals[len(m.AddRequestProposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateRequestProposals", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UpdateRequestProposals = append(m.UpdateRequestProposals, &UpdateRequestProposal{}) + if err := m.UpdateRequestProposals[len(m.UpdateRequestProposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeleteRequestProposals", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DeleteRequestProposals = append(m.DeleteRequestProposals, &DeleteRequestProposal{}) + if err := m.DeleteRequestProposals[len(m.DeleteRequestProposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AddRequestProposal) 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 ErrIntOverflowProposal + } + 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: AddRequestProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddRequestProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FarmingPoolAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FarmingPoolAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TerminationAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TerminationAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingCoinWeights", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingCoinWeights = append(m.StakingCoinWeights, types.DecCoin{}) + if err := m.StakingCoinWeights[len(m.StakingCoinWeights)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EpochAmount = append(m.EpochAmount, types.Coin{}) + if err := m.EpochAmount[len(m.EpochAmount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EpochRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func sovProposal(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozProposal(x uint64) (n int) { - return sovProposal(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *PublicPlanProposal) Unmarshal(dAtA []byte) error { +func (m *UpdateRequestProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -210,15 +1420,34 @@ func (m *PublicPlanProposal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PublicPlanProposal: wiretype end group for non-group") + return fmt.Errorf("proto: UpdateRequestProposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PublicPlanProposal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UpdateRequestProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + 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 ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -246,11 +1475,11 @@ func (m *PublicPlanProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Title = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FarmingPoolAddress", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -278,11 +1507,149 @@ func (m *PublicPlanProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Description = string(dAtA[iNdEx:postIndex]) + m.FarmingPoolAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TerminationAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TerminationAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingCoinWeights", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingCoinWeights = append(m.StakingCoinWeights, types.DecCoin{}) + if err := m.StakingCoinWeights[len(m.StakingCoinWeights)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.StartTime == nil { + m.StartTime = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProposal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.EndTime == nil { + m.EndTime = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.EndTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Plans", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EpochAmount", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -309,8 +1676,42 @@ func (m *PublicPlanProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Plans = append(m.Plans, &types.Any{}) - if err := m.Plans[len(m.Plans)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.EpochAmount = append(m.EpochAmount, types.Coin{}) + if err := m.EpochAmount[len(m.EpochAmount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.EpochRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -335,6 +1736,75 @@ func (m *PublicPlanProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *DeleteRequestProposal) 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 ErrIntOverflowProposal + } + 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: DeleteRequestProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteRequestProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowProposal + } + 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 := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipProposal(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/farming/types/tx.pb.go b/x/farming/types/tx.pb.go index a7dd6699..81fe7c37 100644 --- a/x/farming/types/tx.pb.go +++ b/x/farming/types/tx.pb.go @@ -38,16 +38,18 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgCreateFixedAmountPlan defines a SDK message for creating a new fixed // amount farming plan. type MsgCreateFixedAmountPlan struct { + // name specifies the name for the plan + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // farming_pool_address defines the bech32-encoded address of the farming pool - FarmingPoolAddress string `protobuf:"bytes,1,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` + FarmingPoolAddress string `protobuf:"bytes,2,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` // staking_coin_weights specifies coins weight for the plan - StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` + StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` // start_time specifies the start time of the plan - StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + StartTime time.Time `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` // end_time specifies the end time of the plan - EndTime time.Time `protobuf:"bytes,4,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` + EndTime time.Time `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` // epoch_amount specifies the distributing amount for each epoch - EpochAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=epoch_amount,json=epochAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"epoch_amount" yaml:"epoch_amount"` + EpochAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,6,rep,name=epoch_amount,json=epochAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"epoch_amount" yaml:"epoch_amount"` } func (m *MsgCreateFixedAmountPlan) Reset() { *m = MsgCreateFixedAmountPlan{} } @@ -124,16 +126,18 @@ var xxx_messageInfo_MsgCreateFixedAmountPlanResponse proto.InternalMessageInfo // MsgCreateRatioPlan defines a SDK message for creating a new ratio farming // plan. type MsgCreateRatioPlan struct { + // name specifies the name for the plan + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // farming_pool_address defines the bech32-encoded address of the farming pool - FarmingPoolAddress string `protobuf:"bytes,1,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` + FarmingPoolAddress string `protobuf:"bytes,2,opt,name=farming_pool_address,json=farmingPoolAddress,proto3" json:"farming_pool_address,omitempty" yaml:"farming_pool_address"` // staking_coin_weights specifies coins weight for the plan - StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` + StakingCoinWeights github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=staking_coin_weights,json=stakingCoinWeights,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"staking_coin_weights" yaml:"staking_coin_weights"` // start_time specifies the start time of the plan - StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + StartTime time.Time `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` // end_time specifies the end time of the plan - EndTime time.Time `protobuf:"bytes,4,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` + EndTime time.Time `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` // epoch_ratio specifies the distributing amount by ratio - EpochRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=epoch_ratio,json=epochRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"epoch_ratio" yaml:"epoch_ratio"` + EpochRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=epoch_ratio,json=epochRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"epoch_ratio" yaml:"epoch_ratio"` } func (m *MsgCreateRatioPlan) Reset() { *m = MsgCreateRatioPlan{} } @@ -461,57 +465,58 @@ func init() { } var fileDescriptor_a33d9a3ff13f514a = []byte{ - // 794 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x4f, 0xd4, 0x4e, - 0x18, 0xde, 0xfe, 0x58, 0xfe, 0x0d, 0xfc, 0x44, 0xca, 0x4a, 0x96, 0x82, 0xed, 0xa6, 0x26, 0x66, - 0x83, 0xa1, 0x95, 0xf5, 0x62, 0xb8, 0xb1, 0x10, 0x21, 0x26, 0x6b, 0xb0, 0x68, 0xfc, 0x73, 0xd9, - 0xcc, 0x6e, 0x87, 0xd2, 0xb0, 0xed, 0xac, 0x9d, 0x59, 0x04, 0xaf, 0xc6, 0x04, 0x2f, 0x86, 0x8f, - 0x60, 0xbc, 0x98, 0x78, 0xf5, 0xe8, 0x17, 0xe0, 0x64, 0x38, 0x1a, 0x0f, 0x8b, 0x81, 0x6f, 0xc0, - 0x27, 0x30, 0x9d, 0x99, 0xd6, 0x02, 0x65, 0x97, 0x3d, 0x9a, 0x78, 0xda, 0xce, 0xf4, 0x79, 0x9f, - 0x79, 0xdf, 0xe7, 0x7d, 0xde, 0xe9, 0x82, 0x5b, 0x14, 0xf9, 0x36, 0x0a, 0x3c, 0xd7, 0xa7, 0xe6, - 0x06, 0x0c, 0x7f, 0x1d, 0x73, 0x7b, 0xbe, 0x86, 0x28, 0x9c, 0x37, 0xe9, 0x8e, 0xd1, 0x0c, 0x30, - 0xc5, 0xf2, 0x64, 0x1d, 0x13, 0x0f, 0x13, 0x43, 0x00, 0x0c, 0x01, 0x50, 0x72, 0x0e, 0x76, 0x30, - 0x83, 0x98, 0xe1, 0x13, 0x47, 0x2b, 0x53, 0x1c, 0x5d, 0xe5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xeb, 0xa0, 0x9f, 0x0f, 0x4b, - 0xa1, 0x43, 0x30, 0x43, 0x28, 0xc5, 0x6e, 0x88, 0x98, 0xf4, 0x05, 0x18, 0x8c, 0x7c, 0xab, 0x77, - 0x08, 0x12, 0x18, 0x65, 0xb6, 0x3b, 0x26, 0x49, 0x1d, 0xf9, 0xa7, 0x13, 0xb5, 0xc0, 0x74, 0xa4, - 0x3e, 0xe7, 0x85, 0xf2, 0xca, 0xc1, 0xb1, 0x2a, 0x1d, 0x1e, 0xab, 0xd2, 0xaf, 0x63, 0x55, 0xda, - 0x3f, 0x51, 0x33, 0x87, 0x27, 0x6a, 0xe6, 0xc7, 0x89, 0x9a, 0x79, 0x39, 0x97, 0x98, 0x86, 0x94, - 0x3f, 0x73, 0x3b, 0xf1, 0x13, 0x1b, 0x8c, 0xda, 0x00, 0xbb, 0x49, 0xef, 0xfd, 0x0e, 0x00, 0x00, - 0xff, 0xff, 0x8c, 0xa3, 0x43, 0xb8, 0xf9, 0x09, 0x00, 0x00, + // 801 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0x4f, 0x4f, 0x13, 0x41, + 0x1c, 0xed, 0x4a, 0x29, 0x30, 0xa0, 0xc8, 0x50, 0x49, 0x59, 0x70, 0xb7, 0x59, 0x13, 0xd3, 0x60, + 0xd8, 0x95, 0x7a, 0x31, 0xdc, 0x28, 0x44, 0x88, 0x49, 0x0d, 0x2e, 0x1a, 0xff, 0x5c, 0x9a, 0x6d, + 0x77, 0x58, 0x36, 0x74, 0x77, 0xea, 0xce, 0x14, 0xc1, 0xab, 0x31, 0xc1, 0x8b, 0xe1, 0x23, 0x18, + 0x8f, 0x5e, 0x3d, 0xfa, 0x05, 0x38, 0x72, 0x34, 0x1e, 0x8a, 0x29, 0xdf, 0x80, 0x4f, 0x60, 0x76, + 0x66, 0x76, 0x59, 0xa0, 0xb4, 0xf4, 0x68, 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, 0x55, 0x23, 0x25, 0xe5, 0xb4, + 0xa5, 0xca, 0x1d, 0xa6, 0x8f, 0x83, 0x34, 0x73, 0x22, 0xd1, 0xcc, 0x0a, 0xbb, 0x77, 0xae, 0x23, + 0xb1, 0x77, 0xd4, 0x51, 0xf1, 0x73, 0x1a, 0x0c, 0x94, 0x89, 0x03, 0x3f, 0x4a, 0xe0, 0x4e, 0xe7, + 0x2f, 0xe3, 0x43, 0xbd, 0xf3, 0x17, 0x5c, 0xbf, 0xea, 0x3d, 0x27, 0x3f, 0xee, 0xb7, 0x22, 0xea, + 0x06, 0xbe, 0x03, 0xe3, 0x17, 0xdf, 0x8a, 0x73, 0x3d, 0xc9, 0x62, 0xac, 0x5c, 0xbc, 0x3e, 0x36, + 0xde, 0x72, 0x03, 0x0c, 0xf2, 0x61, 0xc9, 0x77, 0x29, 0x66, 0x08, 0xb9, 0xd0, 0x0b, 0x11, 0x93, + 0xbe, 0x01, 0x43, 0x51, 0x6e, 0xb5, 0x2e, 0x45, 0x02, 0x23, 0xcf, 0xf5, 0xc6, 0x24, 0xa9, 0xa3, + 0xfc, 0x74, 0xa3, 0x16, 0x98, 0xae, 0xd4, 0x17, 0xb2, 0x50, 0x5a, 0x3d, 0x6c, 0x2b, 0xd2, 0x51, + 0x5b, 0x91, 0xfe, 0xb4, 0x15, 0xe9, 0xe0, 0x44, 0x49, 0x1d, 0x9d, 0x28, 0xa9, 0x5f, 0x27, 0x4a, + 0xea, 0xed, 0x7c, 0x62, 0x1a, 0x3a, 0xfc, 0xe9, 0xdb, 0x8d, 0xaf, 0xd8, 0x60, 0x54, 0x33, 0xec, + 0x4d, 0xfa, 0xe8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0xcb, 0xdb, 0xb7, 0x21, 0x0a, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -781,7 +786,7 @@ func (m *MsgCreateFixedAmountPlan) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } } n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime):]) @@ -791,7 +796,7 @@ func (m *MsgCreateFixedAmountPlan) MarshalToSizedBuffer(dAtA []byte) (int, error i -= n1 i = encodeVarintTx(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) if err2 != nil { return 0, err2 @@ -799,7 +804,7 @@ func (m *MsgCreateFixedAmountPlan) MarshalToSizedBuffer(dAtA []byte) (int, error i -= n2 i = encodeVarintTx(dAtA, i, uint64(n2)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 if len(m.StakingCoinWeights) > 0 { for iNdEx := len(m.StakingCoinWeights) - 1; iNdEx >= 0; iNdEx-- { { @@ -811,7 +816,7 @@ func (m *MsgCreateFixedAmountPlan) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } } if len(m.FarmingPoolAddress) > 0 { @@ -819,6 +824,13 @@ func (m *MsgCreateFixedAmountPlan) MarshalToSizedBuffer(dAtA []byte) (int, error copy(dAtA[i:], m.FarmingPoolAddress) i = encodeVarintTx(dAtA, i, uint64(len(m.FarmingPoolAddress))) i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -876,7 +888,7 @@ func (m *MsgCreateRatioPlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime):]) if err3 != nil { return 0, err3 @@ -884,7 +896,7 @@ func (m *MsgCreateRatioPlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n3 i = encodeVarintTx(dAtA, i, uint64(n3)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) if err4 != nil { return 0, err4 @@ -892,7 +904,7 @@ func (m *MsgCreateRatioPlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n4 i = encodeVarintTx(dAtA, i, uint64(n4)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 if len(m.StakingCoinWeights) > 0 { for iNdEx := len(m.StakingCoinWeights) - 1; iNdEx >= 0; iNdEx-- { { @@ -904,7 +916,7 @@ func (m *MsgCreateRatioPlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } } if len(m.FarmingPoolAddress) > 0 { @@ -912,6 +924,13 @@ func (m *MsgCreateRatioPlan) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.FarmingPoolAddress) i = encodeVarintTx(dAtA, i, uint64(len(m.FarmingPoolAddress))) i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -1153,6 +1172,10 @@ func (m *MsgCreateFixedAmountPlan) Size() (n int) { } var l int _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.FarmingPoolAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1191,6 +1214,10 @@ func (m *MsgCreateRatioPlan) Size() (n int) { } var l int _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.FarmingPoolAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1339,6 +1366,38 @@ func (m *MsgCreateFixedAmountPlan) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FarmingPoolAddress", wireType) } @@ -1370,7 +1429,7 @@ func (m *MsgCreateFixedAmountPlan) Unmarshal(dAtA []byte) error { } m.FarmingPoolAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingCoinWeights", wireType) } @@ -1404,7 +1463,7 @@ func (m *MsgCreateFixedAmountPlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) } @@ -1437,7 +1496,7 @@ func (m *MsgCreateFixedAmountPlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) } @@ -1470,7 +1529,7 @@ func (m *MsgCreateFixedAmountPlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EpochAmount", wireType) } @@ -1605,6 +1664,38 @@ func (m *MsgCreateRatioPlan) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FarmingPoolAddress", wireType) } @@ -1636,7 +1727,7 @@ func (m *MsgCreateRatioPlan) Unmarshal(dAtA []byte) error { } m.FarmingPoolAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingCoinWeights", wireType) } @@ -1670,7 +1761,7 @@ func (m *MsgCreateRatioPlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) } @@ -1703,7 +1794,7 @@ func (m *MsgCreateRatioPlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) } @@ -1736,7 +1827,7 @@ func (m *MsgCreateRatioPlan) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EpochRatio", wireType) }