Skip to content

Commit

Permalink
fix: use default String implementation for types
Browse files Browse the repository at this point in the history
Merge pull request #214 from hallazzang/207-stringer
  • Loading branch information
hallazzang authored Nov 8, 2021
2 parents fedca46 + 2691957 commit acfe280
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 144 deletions.
16 changes: 7 additions & 9 deletions proto/tendermint/farming/v1beta1/farming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ message Params {
// extend this type for additional functionality (for example, fixed amount plan, ratio
// plan).
message BasePlan {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;

option (cosmos_proto.implements_interface) = "PlanI";

Expand Down Expand Up @@ -100,8 +99,7 @@ message BasePlan {
// FixedAmountPlan defines a fixed amount plan that distributes a fixed amount
// of coins for every epoch.
message FixedAmountPlan {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;

BasePlan base_plan = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_plan\""];

Expand All @@ -116,8 +114,7 @@ message FixedAmountPlan {
// RatioPlan defines a plan that distributes to farmers by ratio
// distribution for every epoch day.
message RatioPlan {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;

BasePlan base_plan = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_plan\""];

Expand All @@ -143,8 +140,7 @@ enum PlanType {

// Staking defines a farmer's staking information.
message Staking {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;

string amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

Expand All @@ -165,7 +161,7 @@ message TotalStakings {
string amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
}

// HistoricalRewards defines the culative unit rewards for a given staking coin denom and an epoch number.
// HistoricalRewards defines the cumulative unit rewards for a given staking coin denom and an epoch number.
message HistoricalRewards {
option (gogoproto.goproto_getters) = false;

Expand All @@ -179,6 +175,8 @@ message HistoricalRewards {
// OutstandingRewards represents outstanding (un-withdrawn) rewards
// for a staking coin denom.
message OutstandingRewards {
option (gogoproto.goproto_getters) = false;

repeated cosmos.base.v1beta1.DecCoin rewards = 1
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}
2 changes: 1 addition & 1 deletion proto/tendermint/farming/v1beta1/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ message ModifyPlanRequest {
// plan_id specifies index of the farming plan
uint64 plan_id = 1;

// name specifies the plan name for diplay
// name specifies the plan name for display
string name = 2;

// farming_pool_address defines the bech32-encoded address of the farming pool
Expand Down
2 changes: 0 additions & 2 deletions x/farming/spec/02_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ type PlanI interface {

GetBasePlan() *BasePlan

String() string

Validate() error
}
```
Expand Down
181 changes: 89 additions & 92 deletions x/farming/types/farming.pb.go

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions x/farming/types/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"
"time"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
Expand Down Expand Up @@ -189,20 +188,6 @@ func (plan BasePlan) Validate() error {
return nil
}

func (plan BasePlan) String() string {
out, _ := plan.MarshalYAML()
return out.(string)
}

// MarshalYAML returns the YAML representation of a Plan.
func (plan BasePlan) MarshalYAML() (interface{}, error) {
bz, err := codec.MarshalYAML(codec.NewProtoCodec(codectypes.NewInterfaceRegistry()), &plan)
if err != nil {
return nil, err
}
return string(bz), err
}

// NewFixedAmountPlan returns a new fixed amount plan.
func NewFixedAmountPlan(basePlan *BasePlan, epochAmount sdk.Coins) *FixedAmountPlan {
return &FixedAmountPlan{
Expand Down Expand Up @@ -258,8 +243,6 @@ type PlanI interface {

GetBasePlan() *BasePlan

String() string

Validate() error
}

Expand Down
6 changes: 3 additions & 3 deletions x/farming/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func (p *PublicPlanProposal) ValidateBasic() error {

func (p PublicPlanProposal) String() string {
return fmt.Sprintf(`Public Plan Proposal:
Title: %s
Description: %s
AddPlanRequests: %s
Title: %s
Description: %s
AddPlanRequests: %s
UpdatePlanRequests: %s
DeletePlanRequests: %s
`, p.Title, p.Description, p.AddPlanRequests, p.ModifyPlanRequests, p.DeletePlanRequests)
Expand Down
2 changes: 1 addition & 1 deletion x/farming/types/proposal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions x/farming/types/staking.go

This file was deleted.

0 comments on commit acfe280

Please sign in to comment.