Skip to content

Commit

Permalink
Use proto generated stringer methods
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 committed Nov 10, 2021
1 parent 0cf3384 commit 390c372
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 86 deletions.
8 changes: 0 additions & 8 deletions proto/kava/pricefeed/v1beta1/store.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ option (gogoproto.verbose_equal_all) = true;

// Params defines the parameters for the pricefeed module.
message Params {
option (gogoproto.goproto_stringer) = false;

repeated Market markets = 1 [(gogoproto.castrepeated) = "Markets", (gogoproto.nullable) = false];
}

// Market defines an asset in the pricefeed.
message Market {
option (gogoproto.goproto_stringer) = false;

string market_id = 1 [(gogoproto.customname) = "MarketID"];
string base_asset = 2;
string quote_asset = 3;
Expand All @@ -32,8 +28,6 @@ message Market {

// PostedPrice defines a price for market posted by a specific oracle.
message PostedPrice {
option (gogoproto.goproto_stringer) = false;

string market_id = 1 [(gogoproto.customname) = "MarketID"];
bytes oracle_address = 2 [
(cosmos_proto.scalar) = "cosmos.AddressBytes",
Expand All @@ -46,8 +40,6 @@ message PostedPrice {
// CurrentPrice defines a current price for a particular market in the pricefeed
// module.
message CurrentPrice {
option (gogoproto.goproto_stringer) = false;

string market_id = 1 [(gogoproto.customname) = "MarketID"];
string price = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}
1 change: 0 additions & 1 deletion x/pricefeed/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func (k QueryServer) Prices(c context.Context, req *types.QueryPricesRequest) (*
ctx := sdk.UnwrapSDKContext(c)

var currentPrices types.CurrentPriceResponses

for _, cp := range k.keeper.GetCurrentPrices(ctx) {
currentPrices = append(currentPrices, types.CurrentPriceResponse(cp))
}
Expand Down
25 changes: 0 additions & 25 deletions x/pricefeed/types/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ func NewMarket(id, base, quote string, oracles []sdk.AccAddress, active bool) Ma
}
}

// String implement fmt.Stringer
func (m Market) String() string {
return fmt.Sprintf(`Asset:
Market ID: %s
Base Asset: %s
Quote Asset: %s
Oracles: %s
Active: %t`,
m.MarketID, m.BaseAsset, m.QuoteAsset, m.Oracles, m.Active)
}

// Validate performs a basic validation of the market params
func (m Market) Validate() error {
if strings.TrimSpace(m.MarketID) == "" {
Expand Down Expand Up @@ -175,20 +164,6 @@ func NewPostedPriceResponse(marketID string, oracle sdk.AccAddress, price sdk.De
// PostedPriceResponses is a slice of PostedPriceResponse
type PostedPriceResponses []PostedPriceResponse

// String implements fmt.Stringer
func (cp CurrentPrice) String() string {
return strings.TrimSpace(fmt.Sprintf(`Market ID: %s
Price: %s`, cp.MarketID, cp.Price))
}

// String implements fmt.Stringer
func (pp PostedPrice) String() string {
return strings.TrimSpace(fmt.Sprintf(`Market ID: %s
Oracle Address: %s
Price: %s
Expiry: %s`, pp.MarketID, pp.OracleAddress, pp.Price, pp.Expiry))
}

// SortDecs provides the interface needed to sort sdk.Dec slices
type SortDecs []sdk.Dec

Expand Down
10 changes: 0 additions & 10 deletions x/pricefeed/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"fmt"
"strings"

paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
Expand Down Expand Up @@ -38,15 +37,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
}
}

// String implements fmt.stringer
func (p Params) String() string {
out := "Params:\n"
for _, a := range p.Markets {
out += fmt.Sprintf("%s\n", a.String())
}
return strings.TrimSpace(out)
}

// Validate ensure that params have valid values
func (p Params) Validate() error {
return validateMarketParams(p.Markets)
Expand Down
87 changes: 45 additions & 42 deletions x/pricefeed/types/store.pb.go

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

0 comments on commit 390c372

Please sign in to comment.