Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add public and private plan creation #11

Merged
merged 45 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
17fb505
add proposal proto for public proposal plan messages
jaybxyz Jul 19, 2021
fdc9b93
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 19, 2021
b694ba1
update proto files
jaybxyz Jul 19, 2021
f557438
temp
jaybxyz Jul 19, 2021
13fcc46
change method name to prevent from duplicate
jaybxyz Jul 19, 2021
b47f8e3
WIP: designing what args to accept for adding plan proposal...
jaybxyz Jul 19, 2021
b0a61c8
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 20, 2021
3d230f3
change binary name to farmingd
jaybxyz Jul 20, 2021
25e83e8
change proposal design
jaybxyz Jul 20, 2021
edd2090
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 21, 2021
7ad06bd
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 24, 2021
ddf5eec
add private plans and public plans are work in progress
jaybxyz Jul 24, 2021
1cd663c
update cli commands for private plans
jaybxyz Jul 26, 2021
a5bb036
add tests for private farming plan command line interfaces
jaybxyz Jul 26, 2021
ed0520f
add public plan proposal
jaybxyz Jul 26, 2021
2edf4f7
add nolint:errcheck for now
jaybxyz Jul 26, 2021
6dbf2bb
fix golint by adding return value for sdkerrors.Wrapf
jaybxyz Jul 26, 2021
2eafadd
add name filed in both create fixed amount plan and ratio plan messages
jaybxyz Jul 27, 2021
e26e4cc
apply feedback
jaybxyz Jul 27, 2021
ac0d515
add validation and fix public ratio plan creation logic
jaybxyz Jul 27, 2021
af70b8e
remove empty name field and use the one from the passed argument
jaybxyz Jul 27, 2021
5ad0c33
remove unused rest code
jaybxyz Jul 27, 2021
7c56ea7
move the name field inside the AddRequestProposal
jaybxyz Jul 27, 2021
195ae66
add description on PublicPlanProposal message
jaybxyz Jul 27, 2021
ce77054
fix typo and add 09_proposal.md
jaybxyz Jul 27, 2021
e8b2924
add name field in update plan proposal
jaybxyz Jul 28, 2021
c40d32f
make indentation consistent and change variable name
jaybxyz Jul 28, 2021
adf7f92
reformat json
jaybxyz Jul 28, 2021
1dea61b
fix broken app
jaybxyz Jul 28, 2021
132026e
use three ifs instead of switch case and use else if to prevent from …
jaybxyz Jul 28, 2021
154b903
add detailed validation logics for AddRequestProposal, UpdateRequestP…
jaybxyz Jul 28, 2021
672bb5a
re: add detailed validation logics for AddRequestProposal, UpdateRequ…
jaybxyz Jul 28, 2021
e6a004b
add skeleton for docs #21
jaybxyz Jul 28, 2021
e6aadfc
add How-To farming_plans.md
jaybxyz Jul 28, 2021
adc1b61
update comment
jaybxyz Jul 28, 2021
95044e1
add validation for duplicate plan name
jaybxyz Jul 28, 2021
dd77f21
update date time format to RFC3339
jaybxyz Jul 29, 2021
ee1cf1b
feat: update public plan proposal
jaybxyz Jul 29, 2021
0a48a98
feat: adding validation logic for an epoch ratio must not exceed 1 wi…
jaybxyz Jul 29, 2021
bfe2ece
feat: add validation logic for overflow epoch ratio
jaybxyz Jul 30, 2021
876f696
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 30, 2021
8c79779
fix: add another if statement to check when both epoch amount and rat…
jaybxyz Aug 2, 2021
1f57a89
Merge commit '639a96bb38ab9bda41ab15cc74534f520bf4302b' into kogisin/…
jaybxyz Aug 2, 2021
f3abdf7
chore: update public plan proposal logics
jaybxyz Aug 2, 2021
d707cfd
docs: add command-line interfaces and update context
jaybxyz Aug 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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{},
Expand Down
1 change: 0 additions & 1 deletion contrib/devtools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down
17 changes: 10 additions & 7 deletions proto/tendermint/farming/v1beta1/farming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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\""];
}

Expand Down
120 changes: 114 additions & 6 deletions proto/tendermint/farming/v1beta1/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,128 @@ 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 {
jaybxyz marked this conversation as resolved.
Show resolved Hide resolved
// 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
];
}
jaybxyz marked this conversation as resolved.
Show resolved Hide resolved

// 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\""];
jaybxyz marked this conversation as resolved.
Show resolved Hide resolved

// 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) = false, (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) = false, (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;
}
26 changes: 16 additions & 10 deletions proto/tendermint/farming/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading